mailgun.js 9.1.2 → 9.2.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,30 @@
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.1](https://github.com/mailgun/mailgun.js/compare/v9.2.0...v9.2.1) (2023-08-16)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * Node.js native FormData issue ([f00dd57](https://github.com/mailgun/mailgun.js/commits/f00dd57137334e663b01dc833deefad2f36b23f6))
11
+
12
+
13
+ ### Other changes
14
+
15
+ * Update readme for events ([83996c9](https://github.com/mailgun/mailgun.js/commits/83996c95fce7d8ecc3f2c5b8fcd0241500a7b1a5))
16
+
17
+ ## [9.2.0](https://github.com/mailgun/mailgun.js/compare/v9.1.2...v9.2.0) (2023-07-07)
18
+
19
+
20
+ ### Features
21
+
22
+ * Add skiped domain update method ([cef4e3b](https://github.com/mailgun/mailgun.js/commits/cef4e3ba97e0003f27a5ef9a5d905b942838cb9d))
23
+
24
+
25
+ ### Other changes
26
+
27
+ * Move type from class file ([24c6002](https://github.com/mailgun/mailgun.js/commits/24c6002b64e0377fef8cdaf49591f3fb925a5821))
28
+
5
29
  ### [9.1.2](https://github.com/mailgun/mailgun.js/compare/v9.1.1...v9.1.2) (2023-06-30)
6
30
 
7
31
 
@@ -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>;
@@ -4,7 +4,7 @@ declare class FormDataBuilder {
4
4
  private FormDataConstructor;
5
5
  constructor(FormDataConstructor: InputFormData);
6
6
  createFormData(data: any): NodeFormData | FormData;
7
- private isNodeFormData;
7
+ private isFormDataPackage;
8
8
  private getAttachmentOptions;
9
9
  private addMimeDataToFD;
10
10
  private addFilesToFD;
@@ -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
@@ -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)
@@ -96,6 +97,7 @@ The following service methods are available to instantiated clients. The example
96
97
  - [assignIp](#assignip)
97
98
  - [events](#events)
98
99
  - [get](#get-1)
100
+ - [Example with Date and *Filter field*](#example-with-date-and-filter-field)
99
101
  - [stats](#stats)
100
102
  - [getDomain](#getdomain)
101
103
  - [getAccount](#getaccount)
@@ -122,13 +124,13 @@ The following service methods are available to instantiated clients. The example
122
124
  - [list](#list-2)
123
125
  - [get](#get-3)
124
126
  - [create](#create-3)
125
- - [update](#update)
127
+ - [update](#update-1)
126
128
  - [destroy](#destroy-2)
127
129
  - [routes](#routes)
128
130
  - [list](#list-3)
129
131
  - [get](#get-4)
130
132
  - [create](#create-4)
131
- - [update](#update-1)
133
+ - [update](#update-2)
132
134
  - [destroy](#destroy-3)
133
135
  - [validate](#validate)
134
136
  - [get](#get-5)
@@ -141,7 +143,7 @@ The following service methods are available to instantiated clients. The example
141
143
  - [list](#list-5)
142
144
  - [get](#get-6)
143
145
  - [create](#create-6)
144
- - [update](#update-2)
146
+ - [update](#update-3)
145
147
  - [destroy](#destroy-5)
146
148
  - [mailing list members](#mailing-list-members)
147
149
  - [listMembers](#listmember)
@@ -485,13 +487,13 @@ Method naming conventions:
485
487
 
486
488
  - #### get
487
489
 
488
- `mg.domains.get()`
490
+ `mg.domains.get(domain)`
489
491
 
490
492
  Example:
491
493
 
492
494
  ```JS
493
- mg.domains.get()
494
- .then(domains => console.log(domains)) // logs array of domains
495
+ mg.domains.get('testing.example.com')
496
+ .then(domains => console.log(domains)) // logs domain object
495
497
  .catch(err => console.error(err)); // logs any error
496
498
  ```
497
499
 
@@ -538,7 +540,11 @@ Method naming conventions:
538
540
  spam_action: 'disabled',
539
541
  state: 'unverified',
540
542
  type: 'custom',
541
- wildcard: true
543
+ wildcard: true,
544
+ id: '64a4291ebbe4ec7e1d78bc80',
545
+ is_disabled: false,
546
+ web_prefix: 'email',
547
+ web_scheme: 'http'
542
548
  }
543
549
  ```
544
550
 
@@ -556,59 +562,149 @@ Method naming conventions:
556
562
 
557
563
  Create method accepts data object with next properties:
558
564
 
565
+ | Parameter | Description |
566
+ |--- |--- |
567
+ | name | Name of the domain (ex. domain.com) |
568
+ | smtp_password | Password for SMTP authentication |
569
+ | 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`. |
570
+ | 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`. |
571
+ | 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`. |
572
+ | dkim_key_size | **1024** or **2048**<br>Set the length of your domain’s generated DKIM key<br>The default is **1024** |
573
+ | 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. |
574
+ | 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) |
575
+ | 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` |
576
+
577
+ Promise returns:
578
+
579
+ ```JS
580
+ name: 'foobar.example.com',
581
+ require_tls: false,
582
+ skip_verification: false,
583
+ state: 'unverified',
584
+ wildcard: false,
585
+ spam_action: 'disabled',
586
+ created_at: 'Tue, 04 Jul 2023 14:09:18 GMT',
587
+ smtp_password: undefined,
588
+ smtp_login: 'postmaster@foobar.example.com',
589
+ type: 'custom',
590
+ receiving_dns_records: [{
591
+ "name": "foobar.example.com",
592
+ "record_type": "TXT",
593
+ "valid": "unknown",
594
+ "value": "v=spf1 include:mailgun.org ~all"
595
+ },
596
+ {
597
+ "name": "k1._domainkey.foobar.example.com",
598
+ "record_type": "TXT",
599
+ "valid": "unknown",
600
+ "value": "k=rsa; 123456"
601
+ },
602
+ {
603
+ "name": "email.foobar.example.com",
604
+ "record_type": "CNAME",
605
+ "valid": "unknown",
606
+ "value": "mailgun.org"
607
+ }
608
+ ],
609
+ sending_dns_records: [{
610
+ "priority": "10",
611
+ "record_type": "MX",
612
+ "valid": "unknown",
613
+ "value": "mxa.mailgun.org"
614
+ },
615
+ {
616
+ "priority": "10",
617
+ "record_type": "MX",
618
+ "valid": "unknown",
619
+ "value": "mxb.mailgun.org"
620
+ }],
621
+ id: '64a4291ebbe4ec7e1d78bc80',
622
+ is_disabled: false,
623
+ web_prefix: 'email',
624
+ web_scheme: 'http'
625
+ ```
626
+
627
+ - #### update
628
+
629
+ `mg.domains.update(domain, options)`
630
+
631
+ Example:
632
+
633
+ ```js
634
+ mg.domains.update('foobar.example.com',{
635
+ wildcard: 'true',
636
+ web_scheme: 'http',
637
+ spam_action: 'disabled',
638
+ })
639
+ .then(msg => console.log(msg)) // logs response data
640
+ .catch(err => console.error(err)); // logs any error
641
+ ```
642
+
643
+ Update method accepts data object with next properties:
644
+
559
645
  | Property | Description |
560
646
  |:--------------|:----------------------------------------------------------------------------------------------------------------------------------------------|
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. |
647
+ | 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).|
648
+ | 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`|
649
+ | wildcard | Can be string `'true'` or `'false'` or `boolean`. Determines whether the domain will accept email for sub-domains. The default is `false`.|
565
650
 
566
651
  Promise returns:
567
652
 
568
653
  ```JS
569
654
  {
570
- created_at: 'Sun, 19 Oct 2014 18:49:36 GMT',
571
655
  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
- },
656
+ require_tls: false,
657
+ skip_verification: false,
658
+ state: 'unverified',
659
+ wildcard: true,
660
+ spam_action: 'disabled',
661
+ created_at: 'Tue, 04 Jul 2023 14:09:18 GMT',
662
+ smtp_password: undefined,
663
+ smtp_login: 'postmaster@foobar.example.com',
664
+ type: 'custom',
665
+ receiving_dns_records: [
578
666
  {
579
- "name": "k1._domainkey.foobar.example.com",
580
- "record_type": "TXT",
581
- "valid": "unknown",
582
- "value": "k=rsa; 123456"
667
+ is_active: true,
668
+ cached: [],
669
+ priority: '10',
670
+ record_type: 'MX',
671
+ valid: 'unknown',
672
+ value: 'mxa.mailgun.org'
583
673
  },
584
674
  {
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"
675
+ is_active: true,
676
+ cached: [],
677
+ priority: '10',
678
+ record_type: 'MX',
679
+ valid: 'unknown',
680
+ value: 'mxb.mailgun.org'
681
+ }
682
+ ],
683
+ sending_dns_records: [
684
+ {
685
+ is_active: true,
686
+ cached: [],
687
+ name: 'foobar.example.com',
688
+ record_type: 'TXT',
689
+ valid: 'unknown',
690
+ value: 'v=spf1 include:mailgun.org ~all'
596
691
  },
597
692
  {
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
693
+ is_active: true,
694
+ cached: [],
695
+ name: 'email.foobar.example.com',
696
+ record_type: 'CNAME',
697
+ valid: 'unknown',
698
+ value: 'mailgun.org'
699
+ }
700
+ ],
701
+ id: '64a5880eere4eg7e1d85bc69',
702
+ is_disabled: false,
703
+ web_prefix: 'email',
704
+ web_scheme: 'http'
610
705
  }
611
706
  ```
707
+
612
708
  - #### destroy
613
709
 
614
710
  `mg.domains.destroy(domainAddress)`
@@ -803,13 +899,15 @@ Method naming conventions:
803
899
 
804
900
  - #### get
805
901
 
806
- `mg.events.get(domain, query)`
902
+ `mg.events.get(domain, data)`
807
903
 
808
904
  Example:
809
905
 
810
906
  ```js
811
- mg.events.get('foobar.example.com', { page: 'mypageid' })
812
- .then(data => console.log(data.items)) // logs array of event objects
907
+ mg.events.get('foobar.example.com', {
908
+ page: 'mypageid',
909
+ event: 'opened'
910
+ }).then(data => console.log(data.items)) // logs array of event objects
813
911
  .catch(err => console.error(err)); // logs any error
814
912
  ```
815
913
 
@@ -823,8 +921,17 @@ Method naming conventions:
823
921
  | end | The end of the search time range. It can be specified as a string (see Date Format) or linux epoch seconds. Refer to Time Range for details. |
824
922
  | ascending | Defines the direction of the search time range if the range end time is not specified. Can be either yes or no. Refer to Time Range for details. |
825
923
  | limit | Number of entries to return. (300 max) |
826
- | <field> | <field> is the name of the Filter Field. The value of the parameter should be a valid Filter Expression. Several field filters can be specified in one request. If the same field is mentioned, more then once, then all its filter expressions are combined with AND operator. |
827
-
924
+ | **field** | **field** is the name of the *[Filter Field](https://documentation.mailgun.com/en/latest/api-events.html#filter-field)*. The value of the parameter should be a valid Filter Expression. Several field filters can be specified in one request. If the same field is mentioned, more then once, then all its filter expressions are combined with AND operator. |
925
+ - #### Example with Date and *Filter field*
926
+ ```js
927
+ const date = new Date(2023, 7, 2, 0, 0, 0, 0); // Wed Aug 02 2023 00:00:00 GMT+0300
928
+ const events = await mg.events.get('foobar.example.com', {
929
+ begin: date.toUTCString(), // 'Tue, 01 Aug 2023 21:00:00 GMT'
930
+ ascending: 'yes',
931
+ limit: 5,
932
+ event: 'delivered'
933
+ });
934
+ ```
828
935
  Promise returns: items (array of event objects), pages (paging keys grouped by id)
829
936
 
830
937
  ```JS
@@ -1382,7 +1489,7 @@ Method naming conventions:
1382
1489
 
1383
1490
  Promise returns: response body
1384
1491
 
1385
- ```JS
1492
+ ```js
1386
1493
  {
1387
1494
  actions: [ 'forward("http://myhost.com/messages/")', 'stop()' ],
1388
1495
  created_at: 'Mon, 26 Oct 2015 03:56:51 GMT',
@@ -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;
@@ -133,4 +145,8 @@ export type TDomain = {
133
145
  type: string;
134
146
  receiving_dns_records: DNSRecord[] | null;
135
147
  sending_dns_records: DNSRecord[] | null;
148
+ id?: string;
149
+ is_disabled?: boolean;
150
+ web_prefix?: string;
151
+ web_scheme?: string;
136
152
  };