mailgun.js 9.1.1 → 9.2.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/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [9.2.0](https://github.com/mailgun/mailgun.js/compare/v9.1.2...v9.2.0) (2023-07-07)
6
+
7
+
8
+ ### Features
9
+
10
+ * Add skiped domain update method ([cef4e3b](https://github.com/mailgun/mailgun.js/commits/cef4e3ba97e0003f27a5ef9a5d905b942838cb9d))
11
+
12
+
13
+ ### Other changes
14
+
15
+ * Move type from class file ([24c6002](https://github.com/mailgun/mailgun.js/commits/24c6002b64e0377fef8cdaf49591f3fb925a5821))
16
+
17
+ ### [9.1.2](https://github.com/mailgun/mailgun.js/compare/v9.1.1...v9.1.2) (2023-06-30)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * Added priority? to DNSRecord type ([65a9d02](https://github.com/mailgun/mailgun.js/commits/65a9d02e81dc2c78a64095c073ab69530081577d))
23
+ * Dependencies update ([60478d0](https://github.com/mailgun/mailgun.js/commits/60478d0b5075defaf032ac91dd6e21ea9dba3b1b))
24
+
25
+
26
+ ### Other changes
27
+
28
+ * Update build ([bdc3dc5](https://github.com/mailgun/mailgun.js/commits/bdc3dc5afe7cca544e02238aa31d5e07e10ad5d8))
29
+
5
30
  ### [9.1.1](https://github.com/mailgun/mailgun.js/compare/v9.1.0...v9.1.1) (2023-06-23)
6
31
 
7
32
 
@@ -1,4 +1,4 @@
1
- import { DNSRecord, DomainShortData, TDomain } from '../../Types/Domains';
1
+ import { DNSRecord, DomainData, DomainShortData, TDomain } from '../../Types/Domains';
2
2
  export default class Domain implements TDomain {
3
3
  name: string;
4
4
  require_tls: boolean;
@@ -12,5 +12,9 @@ export default class Domain implements TDomain {
12
12
  type: string;
13
13
  receiving_dns_records: DNSRecord[] | null;
14
14
  sending_dns_records: DNSRecord[] | null;
15
- constructor(data: DomainShortData, receiving?: DNSRecord[] | null, sending?: DNSRecord[] | null);
15
+ id?: string;
16
+ is_disabled?: boolean;
17
+ web_prefix?: string;
18
+ web_scheme?: string;
19
+ constructor(data: DomainShortData | DomainData, receiving?: DNSRecord[] | null, sending?: DNSRecord[] | null);
16
20
  }
@@ -4,13 +4,14 @@ import Request from '../common/Request';
4
4
  import DomainCredentialsClient from './domainsCredentials';
5
5
  import DomainTemplatesClient from './domainsTemplates';
6
6
  import DomainTagsClient from './domainsTags';
7
- import { MessageResponse, DomainTrackingData, UpdatedOpenTracking, DomainsQuery, DomainInfo, ConnectionSettings, UpdatedConnectionSettings, OpenTrackingInfo, ClickTrackingInfo, UnsubscribeTrackingInfo, ReplacementForPool, DKIMAuthorityInfo, UpdatedDKIMAuthority, DKIMSelectorInfo, UpdatedDKIMSelectorResponse, WebPrefixInfo, UpdatedWebPrefixResponse, TDomain } from '../../Types/Domains';
7
+ import { MessageResponse, DomainTrackingData, UpdatedOpenTracking, DomainsQuery, DomainInfo, ConnectionSettings, UpdatedConnectionSettings, OpenTrackingInfo, ClickTrackingInfo, UnsubscribeTrackingInfo, ReplacementForPool, DKIMAuthorityInfo, UpdatedDKIMAuthority, DKIMSelectorInfo, UpdatedDKIMSelectorResponse, WebPrefixInfo, UpdatedWebPrefixResponse, TDomain, DomainUpdateInfo } from '../../Types/Domains';
8
8
  export default class DomainsClient implements IDomainsClient {
9
9
  request: Request;
10
10
  domainCredentials: IDomainCredentials;
11
11
  domainTemplates: IDomainTemplatesClient;
12
12
  domainTags: IDomainTagsClient;
13
13
  constructor(request: Request, domainCredentialsClient: DomainCredentialsClient, domainTemplatesClient: DomainTemplatesClient, domainTagsClient: DomainTagsClient);
14
+ private _handleBoolValues;
14
15
  private _parseMessage;
15
16
  private parseDomainList;
16
17
  private _parseDomain;
@@ -19,6 +20,7 @@ export default class DomainsClient implements IDomainsClient {
19
20
  list(query?: DomainsQuery): Promise<TDomain[]>;
20
21
  get(domain: string): Promise<TDomain>;
21
22
  create(data: DomainInfo): Promise<TDomain>;
23
+ update(domain: string, data: DomainUpdateInfo): Promise<TDomain>;
22
24
  verify(domain: string): Promise<TDomain>;
23
25
  destroy(domain: string): Promise<MessageResponse>;
24
26
  getConnection(domain: string): Promise<ConnectionSettings>;
@@ -1,5 +1,5 @@
1
1
  import { APIResponse } from '../../Types/Common';
2
- import { ClickTrackingInfo, ConnectionSettings, DKIMAuthorityInfo, DKIMSelectorInfo, DomainInfo, DomainsQuery, DomainTrackingData, MessageResponse, OpenTrackingInfo, ReplacementForPool, TDomain, UnsubscribeTrackingInfo, UpdatedConnectionSettings, UpdatedDKIMAuthority, UpdatedDKIMSelectorResponse, UpdatedOpenTracking, UpdatedWebPrefixResponse, WebPrefixInfo } from '../../Types/Domains';
2
+ import { ClickTrackingInfo, ConnectionSettings, DKIMAuthorityInfo, DKIMSelectorInfo, DomainInfo, DomainsQuery, DomainTrackingData, DomainUpdateInfo, MessageResponse, OpenTrackingInfo, ReplacementForPool, TDomain, UnsubscribeTrackingInfo, UpdatedConnectionSettings, UpdatedDKIMAuthority, UpdatedDKIMSelectorResponse, UpdatedOpenTracking, UpdatedWebPrefixResponse, WebPrefixInfo } from '../../Types/Domains';
3
3
  import { IDomainCredentials } from './DomainCredentials';
4
4
  import { IDomainTagsClient } from './DomainTags';
5
5
  import { IDomainTemplatesClient } from './DomainTemplates';
@@ -10,6 +10,7 @@ export interface IDomainsClient {
10
10
  list(query?: DomainsQuery): Promise<TDomain[]>;
11
11
  get(domain: string): Promise<TDomain>;
12
12
  create(data: DomainInfo): Promise<TDomain>;
13
+ update(domain: string, data: DomainUpdateInfo): Promise<TDomain>;
13
14
  verify(domain: string): Promise<TDomain>;
14
15
  destroy(domain: string): Promise<MessageResponse>;
15
16
  getConnection(domain: string): Promise<ConnectionSettings>;
package/README.md CHANGED
@@ -53,7 +53,7 @@ Once the package is installed, you can import the library using `import` or `req
53
53
  ```js
54
54
  import * as FormData from 'form-data';
55
55
  import Mailgun from 'mailgun.js';
56
- const mailgun = new Mailgun(formData);
56
+ const mailgun = new Mailgun(FormData);
57
57
  const mg = mailgun.client({username: 'api', key: process.env.MAILGUN_API_KEY || 'key-yourkeyhere'});
58
58
  ```
59
59
  ### Types imports
@@ -89,6 +89,7 @@ The following service methods are available to instantiated clients. The example
89
89
  - [list](#list)
90
90
  - [get](#get)
91
91
  - [create](#create-1)
92
+ - [update](#update)
92
93
  - [destroy](#destroy)
93
94
  - [getTracking](#gettracking)
94
95
  - [updateTracking](#updatetracking)
@@ -122,13 +123,13 @@ The following service methods are available to instantiated clients. The example
122
123
  - [list](#list-2)
123
124
  - [get](#get-3)
124
125
  - [create](#create-3)
125
- - [update](#update)
126
+ - [update](#update-1)
126
127
  - [destroy](#destroy-2)
127
128
  - [routes](#routes)
128
129
  - [list](#list-3)
129
130
  - [get](#get-4)
130
131
  - [create](#create-4)
131
- - [update](#update-1)
132
+ - [update](#update-2)
132
133
  - [destroy](#destroy-3)
133
134
  - [validate](#validate)
134
135
  - [get](#get-5)
@@ -141,7 +142,7 @@ The following service methods are available to instantiated clients. The example
141
142
  - [list](#list-5)
142
143
  - [get](#get-6)
143
144
  - [create](#create-6)
144
- - [update](#update-2)
145
+ - [update](#update-3)
145
146
  - [destroy](#destroy-5)
146
147
  - [mailing list members](#mailing-list-members)
147
148
  - [listMembers](#listmember)
@@ -485,13 +486,13 @@ Method naming conventions:
485
486
 
486
487
  - #### get
487
488
 
488
- `mg.domains.get()`
489
+ `mg.domains.get(domain)`
489
490
 
490
491
  Example:
491
492
 
492
493
  ```JS
493
- mg.domains.get()
494
- .then(domains => console.log(domains)) // logs array of domains
494
+ mg.domains.get('testing.example.com')
495
+ .then(domains => console.log(domains)) // logs domain object
495
496
  .catch(err => console.error(err)); // logs any error
496
497
  ```
497
498
 
@@ -538,7 +539,11 @@ Method naming conventions:
538
539
  spam_action: 'disabled',
539
540
  state: 'unverified',
540
541
  type: 'custom',
541
- wildcard: true
542
+ wildcard: true,
543
+ id: '64a4291ebbe4ec7e1d78bc80',
544
+ is_disabled: false,
545
+ web_prefix: 'email',
546
+ web_scheme: 'http'
542
547
  }
543
548
  ```
544
549
 
@@ -556,59 +561,149 @@ Method naming conventions:
556
561
 
557
562
  Create method accepts data object with next properties:
558
563
 
564
+ | Parameter | Description |
565
+ |--- |--- |
566
+ | name | Name of the domain (ex. domain.com) |
567
+ | smtp_password | Password for SMTP authentication |
568
+ | spam_action | `disabled`, `block`, or `tag`<br>If `disabled`, no spam filtering will occur for inbound messages.<br>If `block`, inbound spam messages will not be delivered.<br>If `tag`, inbound messages will be tagged with a spam header. [Spam Filter](https://documentation.mailgun.com/en/latest/user_manual.html#um-spam-filter)<br>The default is `disabled`. |
569
+ | wildcard | Can be string `'true'` or `'false'` or `boolean`<br>Determines whether the domain will accept email for sub-domains when sending messages.<br>The default is `false`. |
570
+ | force_dkim_authority | Can be string `'true'` or `'false'` or `boolean`<br>If set to `true`, the domain will be the DKIM authority for itself even if the root domain is registered on the same mailgun account<br>If set to `false`, the domain will have the same DKIM authority as the root domain registered on the same mailgun account<br>The default is `false`. |
571
+ | dkim_key_size | **1024** or **2048**<br>Set the length of your domain’s generated DKIM key<br>The default is **1024** |
572
+ | ips | An optional, comma-separated list of IP addresses to be assigned to this domain. If not specified, all dedicated IP addresses on the account will be assigned. If the request cannot be fulfilled (e.g. a requested IP is not assigned to the account, etc), a 400 will be returned. |
573
+ | pool_id | The id of the IP Pool that you wish to assign to the domain. The pool must contain at least 1 IP. (Note: IP Pools are only available on certain plans; see http://mailgun.com/pricing) |
574
+ | web_scheme | String with `http` or `https`<br>Set your **open**, **click** and **unsubscribe** URLs to use `http` or `https`<br>The default is `http` |
575
+
576
+ Promise returns:
577
+
578
+ ```JS
579
+ name: 'foobar.example.com',
580
+ require_tls: false,
581
+ skip_verification: false,
582
+ state: 'unverified',
583
+ wildcard: false,
584
+ spam_action: 'disabled',
585
+ created_at: 'Tue, 04 Jul 2023 14:09:18 GMT',
586
+ smtp_password: undefined,
587
+ smtp_login: 'postmaster@foobar.example.com',
588
+ type: 'custom',
589
+ receiving_dns_records: [{
590
+ "name": "foobar.example.com",
591
+ "record_type": "TXT",
592
+ "valid": "unknown",
593
+ "value": "v=spf1 include:mailgun.org ~all"
594
+ },
595
+ {
596
+ "name": "k1._domainkey.foobar.example.com",
597
+ "record_type": "TXT",
598
+ "valid": "unknown",
599
+ "value": "k=rsa; 123456"
600
+ },
601
+ {
602
+ "name": "email.foobar.example.com",
603
+ "record_type": "CNAME",
604
+ "valid": "unknown",
605
+ "value": "mailgun.org"
606
+ }
607
+ ],
608
+ sending_dns_records: [{
609
+ "priority": "10",
610
+ "record_type": "MX",
611
+ "valid": "unknown",
612
+ "value": "mxa.mailgun.org"
613
+ },
614
+ {
615
+ "priority": "10",
616
+ "record_type": "MX",
617
+ "valid": "unknown",
618
+ "value": "mxb.mailgun.org"
619
+ }],
620
+ id: '64a4291ebbe4ec7e1d78bc80',
621
+ is_disabled: false,
622
+ web_prefix: 'email',
623
+ web_scheme: 'http'
624
+ ```
625
+
626
+ - #### update
627
+
628
+ `mg.domains.update(domain, options)`
629
+
630
+ Example:
631
+
632
+ ```js
633
+ mg.domains.update('foobar.example.com',{
634
+ wildcard: 'true',
635
+ web_scheme: 'http',
636
+ spam_action: 'disabled',
637
+ })
638
+ .then(msg => console.log(msg)) // logs response data
639
+ .catch(err => console.error(err)); // logs any error
640
+ ```
641
+
642
+ Update method accepts data object with next properties:
643
+
559
644
  | Property | Description |
560
645
  |:--------------|:----------------------------------------------------------------------------------------------------------------------------------------------|
561
- | name | Name of the domain (ex. domain.com) |
562
- | smtp_password | Password for SMTP authentication |
563
- | spam_action | disabled or tag Disable, no spam filtering will occur for inbound messages. Tag, messages will be tagged wtih a spam header. See Spam Filter. |
564
- | wildcard | true or false Determines whether the domain will accept email for sub-domains. |
646
+ | spam_action | Can be string with value `disabled`, `block`, or `tag`. If *disabled*, no spam filtering will occur for inbound messages. If `block`, inbound spam messages will not be delivered. If `tag`, inbound messages will be tagged with a spam header. See [Spam Filter](https://documentation.mailgun.com/en/latest/user_manual.html#um-spam-filter).|
647
+ | web_scheme | Can be string with value `http` or `https`. Set your **open**, **click** and **unsubscribe** URLs to use `http` or `https`. The default is `http`|
648
+ | wildcard | Can be string `'true'` or `'false'` or `boolean`. Determines whether the domain will accept email for sub-domains. The default is `false`.|
565
649
 
566
650
  Promise returns:
567
651
 
568
652
  ```JS
569
653
  {
570
- created_at: 'Sun, 19 Oct 2014 18:49:36 GMT',
571
654
  name: 'foobar.example.com',
572
- receiving_dns_records: [{
573
- "name": "foobar.example.com",
574
- "record_type": "TXT",
575
- "valid": "unknown",
576
- "value": "v=spf1 include:mailgun.org ~all"
577
- },
655
+ require_tls: false,
656
+ skip_verification: false,
657
+ state: 'unverified',
658
+ wildcard: true,
659
+ spam_action: 'disabled',
660
+ created_at: 'Tue, 04 Jul 2023 14:09:18 GMT',
661
+ smtp_password: undefined,
662
+ smtp_login: 'postmaster@foobar.example.com',
663
+ type: 'custom',
664
+ receiving_dns_records: [
578
665
  {
579
- "name": "k1._domainkey.foobar.example.com",
580
- "record_type": "TXT",
581
- "valid": "unknown",
582
- "value": "k=rsa; 123456"
666
+ is_active: true,
667
+ cached: [],
668
+ priority: '10',
669
+ record_type: 'MX',
670
+ valid: 'unknown',
671
+ value: 'mxa.mailgun.org'
583
672
  },
584
673
  {
585
- "name": "email.foobar.example.com",
586
- "record_type": "CNAME",
587
- "valid": "unknown",
588
- "value": "mailgun.org"
589
- }],
590
- require_tls: true,
591
- sending_dns_records: [{
592
- "priority": "10",
593
- "record_type": "MX",
594
- "valid": "unknown",
595
- "value": "mxa.mailgun.org"
674
+ is_active: true,
675
+ cached: [],
676
+ priority: '10',
677
+ record_type: 'MX',
678
+ valid: 'unknown',
679
+ value: 'mxb.mailgun.org'
680
+ }
681
+ ],
682
+ sending_dns_records: [
683
+ {
684
+ is_active: true,
685
+ cached: [],
686
+ name: 'foobar.example.com',
687
+ record_type: 'TXT',
688
+ valid: 'unknown',
689
+ value: 'v=spf1 include:mailgun.org ~all'
596
690
  },
597
691
  {
598
- "priority": "10",
599
- "record_type": "MX",
600
- "valid": "unknown",
601
- "value": "mxb.mailgun.org"
602
- }],
603
- skip_verification: true,
604
- smtp_login: 'postmaster@foobar.example.com',
605
- smtp_password: 'password',
606
- spam_action: 'disabled',
607
- state: 'unverified',
608
- type: 'custom',
609
- wildcard: false
692
+ is_active: true,
693
+ cached: [],
694
+ name: 'email.foobar.example.com',
695
+ record_type: 'CNAME',
696
+ valid: 'unknown',
697
+ value: 'mailgun.org'
698
+ }
699
+ ],
700
+ id: '64a5880eere4eg7e1d85bc69',
701
+ is_disabled: false,
702
+ web_prefix: 'email',
703
+ web_scheme: 'http'
610
704
  }
611
705
  ```
706
+
612
707
  - #### destroy
613
708
 
614
709
  `mg.domains.destroy(domainAddress)`
@@ -4,16 +4,28 @@ export type DomainsQuery = {
4
4
  limit?: number;
5
5
  skip?: number;
6
6
  };
7
- export type DomainInfo = {
7
+ export type DomainUpdateInfo = {
8
+ spam_action?: 'disabled' | 'block' | 'tag';
9
+ web_scheme?: 'http' | 'https';
10
+ wildcard?: boolean | 'true' | 'false';
11
+ };
12
+ export type DomainUpdateInfoReq = DomainUpdateInfo & {
13
+ wildcard?: 'true' | 'false';
14
+ };
15
+ export type DomainInfo = DomainUpdateInfo & {
8
16
  name: string;
9
17
  smtp_password: string;
10
- spam_action?: 'disabled' | 'block' | 'tag';
11
- wildcard?: boolean;
12
18
  force_dkim_authority?: boolean | 'true' | 'false';
13
19
  dkim_key_size?: 1024 | 2048;
14
20
  ips?: '';
15
21
  pool_id?: '';
16
- web_scheme: 'http' | 'https';
22
+ };
23
+ export type DomainInfoReq = DomainInfo & {
24
+ force_dkim_authority?: 'true' | 'false';
25
+ };
26
+ export type BoolToString = {
27
+ force_dkim_authority?: DomainInfo['force_dkim_authority'];
28
+ wildcard?: DomainUpdateInfo['wildcard'];
17
29
  };
18
30
  export type DomainShortData = {
19
31
  name: string;
@@ -43,6 +55,7 @@ export interface DNSRecord {
43
55
  record_type: string;
44
56
  valid: string;
45
57
  value: string;
58
+ priority?: string;
46
59
  }
47
60
  export type DomainResponseData = {
48
61
  status: number;
@@ -132,4 +145,8 @@ export type TDomain = {
132
145
  type: string;
133
146
  receiving_dns_records: DNSRecord[] | null;
134
147
  sending_dns_records: DNSRecord[] | null;
148
+ id?: string;
149
+ is_disabled?: boolean;
150
+ web_prefix?: string;
151
+ web_scheme?: string;
135
152
  };