mailgun.js 4.0.1 → 4.1.3

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/.eslintrc CHANGED
@@ -30,6 +30,7 @@
30
30
  "class-methods-use-this": 0,
31
31
  "prefer-destructuring": 0,
32
32
  "import/extensions": 0,
33
+ "no-shadow": "off",
33
34
  "lines-between-class-members": ["error", "always", { "exceptAfterSingleLine": true }],
34
35
  "import/no-extraneous-dependencies" :["error", {"devDependencies": true, "optionalDependencies": false, "peerDependencies": false}]
35
36
  },
@@ -42,7 +43,8 @@
42
43
  ],
43
44
  "parser": "@typescript-eslint/parser",
44
45
  "rules": {
45
- "import/extensions": 0
46
+ "import/extensions": 0,
47
+ "@typescript-eslint/no-shadow": ["error"]
46
48
  // "import/no-extraneous-dependencies" :["error", {"devDependencies": true, "optionalDependencies": false, "peerDependencies": false}]
47
49
  },
48
50
  "plugins": [
package/CHANGELOG.md CHANGED
@@ -2,6 +2,29 @@
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
+ ### [4.1.3](https://github.com/mailgun/mailgun.js/compare/v4.1.2...v4.1.3) (2021-12-23)
6
+
7
+ ### [4.1.2](https://github.com/mailgun/mailgun.js/compare/v4.1.1...v4.1.2) (2021-12-14)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * Update stats methods to allow an array of events ([#216](https://github.com/mailgun/mailgun.js/issues/216)) ([3b0fc41](https://github.com/mailgun/mailgun.js/commits/3b0fc411a4fa34a27cfd255a914adb17499f3af6))
13
+
14
+ ### [4.1.1](https://github.com/mailgun/mailgun.js/compare/v4.1.0...v4.1.1) (2021-12-13)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * Ip_pools create and update methods fix ([#215](https://github.com/mailgun/mailgun.js/issues/215)) ([eb1830d](https://github.com/mailgun/mailgun.js/commits/eb1830de472737c0b3dc6a4cb8856f73b52d20c2))
20
+
21
+ ## [4.1.0](https://github.com/mailgun/mailgun.js/compare/v4.0.1...v4.1.0) (2021-11-30)
22
+
23
+
24
+ ### Features
25
+
26
+ * Add support of whitelists into suppressions client ([#214](https://github.com/mailgun/mailgun.js/issues/214)) ([1e4fb84](https://github.com/mailgun/mailgun.js/commits/1e4fb84d2528751a9c2dddd1599d2bc0e12b1fdd))
27
+
5
28
  ### [4.0.1](https://github.com/mailgun/mailgun.js/compare/v4.0.0...v4.0.1) (2021-11-25)
6
29
 
7
30
 
@@ -2,7 +2,10 @@ import { DomainsQuery, DomainInfo, DomainShortData, DNSRecord, ConnectionSetting
2
2
  import APIResponse from './interfaces/ApiResponse';
3
3
  import Request from './request';
4
4
  import { DomainTrackingData, OpenTrackingInfo, ClickTrackingInfo, UnsubscribeTrackingInfo, UpdatedOpenTracking } from './interfaces/DomainTracking';
5
+ import { IDomainCredentials } from './interfaces/DomainCredentials';
6
+ import { IDomainTemplatesClient } from './interfaces/DomainTemplates';
5
7
  import DomainCredentialsClient from './domainsCredentials';
8
+ import DomainTemplatesClient from './domainsTemplates';
6
9
  export declare class Domain {
7
10
  name: string;
8
11
  require_tls: boolean;
@@ -20,8 +23,9 @@ export declare class Domain {
20
23
  }
21
24
  export default class DomainClient {
22
25
  request: Request;
23
- domainCredentials: DomainCredentialsClient;
24
- constructor(request: Request, domainCredentialsClient: DomainCredentialsClient);
26
+ domainCredentials: IDomainCredentials;
27
+ domainTemplates: IDomainTemplatesClient;
28
+ constructor(request: Request, domainCredentialsClient: DomainCredentialsClient, domainTemplatesClient: DomainTemplatesClient);
25
29
  private _parseMessage;
26
30
  private _parseDomainList;
27
31
  private _parseDomain;
@@ -0,0 +1,35 @@
1
+ import Request from './request';
2
+ import { CreateDomainTemplateVersionResult, DomainTemplate, DomainTemplateData, DomainTemplatesQuery, DomainTemplateUpdateData, DomainTemplateUpdateVersionData, DomainTemplateVersionData, IDomainTemplatesClient, ListDomainTemplatesResult, ListDomainTemplateVersionsResult, MutateDomainTemplateVersionResult, NotificationResult, ShortTemplateVersion, TemplateVersion, UpdateOrDeleteDomainTemplateResult } from './interfaces/DomainTemplates';
3
+ export declare class DomainTemplateItem implements DomainTemplate {
4
+ name: string;
5
+ description: string;
6
+ createdAt: Date | '';
7
+ createdBy: string;
8
+ id: string;
9
+ version?: TemplateVersion;
10
+ versions?: ShortTemplateVersion[];
11
+ constructor(domainTemplateFromAPI: DomainTemplate);
12
+ }
13
+ export default class DomainTemplatesClient implements IDomainTemplatesClient {
14
+ baseRoute: string;
15
+ request: Request;
16
+ constructor(request: Request);
17
+ private parseCreationResponse;
18
+ private parseCreationVersionResponse;
19
+ private parseMutationResponse;
20
+ private parseNotificationResponse;
21
+ private parseMutateTemplateVersionResponse;
22
+ private parseList;
23
+ private parseListTemplateVersions;
24
+ list(domain: string, query?: DomainTemplatesQuery): Promise<ListDomainTemplatesResult>;
25
+ get(domain: string, templateName: string): Promise<DomainTemplateItem>;
26
+ create(domain: string, data: DomainTemplateData): Promise<DomainTemplateItem>;
27
+ update(domain: string, templateName: string, data: DomainTemplateUpdateData): Promise<UpdateOrDeleteDomainTemplateResult>;
28
+ destroy(domain: string, templateName: string): Promise<UpdateOrDeleteDomainTemplateResult>;
29
+ destroyAll(domain: string): Promise<NotificationResult>;
30
+ createVersion(domain: string, templateName: string, data: DomainTemplateVersionData): Promise<CreateDomainTemplateVersionResult>;
31
+ getVersion(domain: string, templateName: string, tag: string): Promise<DomainTemplateItem>;
32
+ updateVersion(domain: string, templateName: string, tag: string, data: DomainTemplateUpdateVersionData): Promise<MutateDomainTemplateVersionResult>;
33
+ destroyVersion(domain: string, templateName: string, tag: string): Promise<MutateDomainTemplateVersionResult>;
34
+ listVersions(domain: string, templateName: string, query?: DomainTemplatesQuery): Promise<ListDomainTemplateVersionsResult>;
35
+ }
@@ -0,0 +1,191 @@
1
+ import { DomainTemplateItem } from '../domainsTemplates';
2
+ export declare enum YesNo {
3
+ YES = "yes",
4
+ NO = "no"
5
+ }
6
+ export declare enum Pages {
7
+ FIRST = "first",
8
+ LAST = "last",
9
+ NEXT = "next",
10
+ PREV = "prev"
11
+ }
12
+ export interface DomainTemplateData {
13
+ name: string;
14
+ description: string;
15
+ template: string;
16
+ tag?: string;
17
+ engine?: string;
18
+ comment?: string;
19
+ }
20
+ export interface DomainTemplateVersionData {
21
+ template: string;
22
+ tag: string;
23
+ engine?: string;
24
+ comment?: string;
25
+ active?: YesNo;
26
+ }
27
+ export interface DomainTemplateUpdateData {
28
+ description: string;
29
+ }
30
+ export interface DomainTemplateUpdateVersionData {
31
+ template?: string;
32
+ comment?: string;
33
+ active?: YesNo;
34
+ }
35
+ export interface DomainTemplatesQuery {
36
+ page: Pages;
37
+ limit: number;
38
+ p: string;
39
+ }
40
+ export interface ShortTemplateVersion {
41
+ tag: string;
42
+ engine: string;
43
+ mjml: string;
44
+ createdAt: string | Date;
45
+ comment: string;
46
+ active: boolean;
47
+ id: string;
48
+ }
49
+ export interface TemplateVersion extends ShortTemplateVersion {
50
+ template: string;
51
+ }
52
+ export interface DomainTemplate {
53
+ name: string;
54
+ description: string;
55
+ createdAt: string | Date;
56
+ createdBy: string;
57
+ id: string;
58
+ version?: TemplateVersion;
59
+ versions?: ShortTemplateVersion[];
60
+ }
61
+ export interface CreateDomainTemplateAPIResponse {
62
+ status: number;
63
+ body: {
64
+ message: string;
65
+ template: DomainTemplate;
66
+ };
67
+ }
68
+ export interface ListDomainTemplatesAPIResponse {
69
+ status: number;
70
+ body: {
71
+ items: DomainTemplate[];
72
+ paging: {
73
+ first: string;
74
+ last: string;
75
+ next: string;
76
+ previous: string;
77
+ };
78
+ };
79
+ }
80
+ export interface ListDomainTemplatesResult {
81
+ items: DomainTemplate[];
82
+ pages: {
83
+ first: string;
84
+ last: string;
85
+ next: string;
86
+ previous: string;
87
+ };
88
+ }
89
+ export interface GetDomainTemplateAPIResponse {
90
+ status: number;
91
+ body: {
92
+ template: DomainTemplate;
93
+ };
94
+ }
95
+ export interface UpdateOrDeleteDomainTemplateAPIResponse {
96
+ status: number;
97
+ body: {
98
+ message: string;
99
+ template: {
100
+ name: string;
101
+ };
102
+ };
103
+ }
104
+ export interface UpdateOrDeleteDomainTemplateResult {
105
+ status: number;
106
+ message: string;
107
+ templateName?: string;
108
+ }
109
+ export interface NotificationAPIResponse {
110
+ status: number;
111
+ body: {
112
+ message: string;
113
+ };
114
+ }
115
+ export interface NotificationResult {
116
+ status: number;
117
+ message: string;
118
+ }
119
+ export interface CreateDomainTemplateVersionAPIResponse {
120
+ status: number;
121
+ body: {
122
+ message: string;
123
+ template: DomainTemplate;
124
+ };
125
+ }
126
+ export interface CreateDomainTemplateVersionResult {
127
+ status: number;
128
+ message: string;
129
+ template: DomainTemplate;
130
+ }
131
+ export interface MutateDomainTemplateVersionAPIResponse {
132
+ status: number;
133
+ body: {
134
+ message: string;
135
+ template: {
136
+ name: string;
137
+ version: {
138
+ tag: string;
139
+ };
140
+ };
141
+ };
142
+ }
143
+ export interface MutateDomainTemplateVersionResult {
144
+ status: number;
145
+ message: string;
146
+ templateName: string;
147
+ templateVersion: {
148
+ tag: string;
149
+ };
150
+ }
151
+ export interface ListDomainTemplateVersionsAPIResponse {
152
+ status: number;
153
+ body: {
154
+ template: {
155
+ name: string;
156
+ description: string;
157
+ createdAt: string;
158
+ createdBy: string;
159
+ id: string;
160
+ versions: ShortTemplateVersion[];
161
+ };
162
+ paging: {
163
+ first: string;
164
+ last: string;
165
+ next: string;
166
+ previous: string;
167
+ };
168
+ };
169
+ }
170
+ export interface ListDomainTemplateVersionsResult {
171
+ template: DomainTemplateItem;
172
+ pages: {
173
+ first: string;
174
+ last: string;
175
+ next: string;
176
+ previous: string;
177
+ };
178
+ }
179
+ export interface IDomainTemplatesClient {
180
+ list(domain: string, query?: DomainTemplatesQuery): Promise<ListDomainTemplatesResult>;
181
+ get(domain: string, templateName: string): Promise<DomainTemplateItem>;
182
+ create(domain: string, data: DomainTemplateData): Promise<DomainTemplateItem>;
183
+ update(domain: string, templateName: string, data: DomainTemplateUpdateData): Promise<UpdateOrDeleteDomainTemplateResult>;
184
+ destroy(domain: string, templateName: string): Promise<UpdateOrDeleteDomainTemplateResult>;
185
+ destroyAll(domain: string): Promise<NotificationResult>;
186
+ createVersion(domain: string, templateName: string, data: DomainTemplateVersionData): Promise<CreateDomainTemplateVersionResult>;
187
+ getVersion(domain: string, templateName: string, tag: string): Promise<DomainTemplateItem>;
188
+ updateVersion(domain: string, templateName: string, tag: string, data: DomainTemplateUpdateVersionData): Promise<MutateDomainTemplateVersionResult>;
189
+ destroyVersion(domain: string, templateName: string, tag: string): Promise<MutateDomainTemplateVersionResult>;
190
+ listVersions(domain: string, templateName: string, query?: DomainTemplatesQuery): Promise<ListDomainTemplateVersionsResult>;
191
+ }
@@ -1,14 +1,21 @@
1
- interface StatsOptions {
1
+ export interface Stat {
2
+ time: string | Date;
3
+ delivered: {
4
+ smtp: number;
5
+ http: number;
6
+ total: number;
7
+ };
8
+ }
9
+ export interface StatsOptions {
2
10
  start: string | Date;
3
11
  end: string | Date;
4
12
  resolution: string;
5
- stats: {
6
- time: string | Date;
7
- delivered: {
8
- smtp: number;
9
- http: number;
10
- total: number;
11
- };
12
- }[];
13
+ stats: Stat[];
14
+ }
15
+ export interface StatsQuery {
16
+ event: string | string[];
17
+ start: string | Date;
18
+ end: string | Date;
19
+ resolution: 'hour' | 'day' | 'month';
20
+ duration: string;
13
21
  }
14
- export default StatsOptions;
@@ -13,3 +13,9 @@ export interface UnsubscribeData {
13
13
  tags: any;
14
14
  created_at: string | Date;
15
15
  }
16
+ export interface WhiteListData {
17
+ type: string;
18
+ value: string;
19
+ reason: string;
20
+ createdAt: string | Date;
21
+ }
@@ -19,6 +19,7 @@ declare class Request {
19
19
  post(url: string, data: any, options?: any): Promise<APIResponse>;
20
20
  postWithFD(url: string, data: any): Promise<APIResponse>;
21
21
  putWithFD(url: string, data: any): Promise<APIResponse>;
22
+ patchWithFD(url: string, data: any): Promise<APIResponse>;
22
23
  createFormData(data: any): NodeFormData | FormData;
23
24
  private addMimeDataToFD;
24
25
  private addFilesToFD;
@@ -1,19 +1,20 @@
1
1
  import Request from './request';
2
- import StatsOptions from './interfaces/StatsOptions';
2
+ import { StatsQuery, StatsOptions, Stat } from './interfaces/StatsOptions';
3
3
  declare class Stats {
4
4
  start: Date;
5
5
  end: Date;
6
6
  resolution: string;
7
- stats: any;
7
+ stats: Stat[];
8
8
  constructor(data: StatsOptions);
9
9
  }
10
10
  export default class StatsClient {
11
11
  request: Request;
12
12
  constructor(request: Request);
13
+ private prepareSearchParams;
13
14
  _parseStats(response: {
14
15
  body: StatsOptions;
15
16
  }): Stats;
16
- getDomain(domain: string, query: any): Promise<Stats>;
17
- getAccount(query: any): Promise<Stats>;
17
+ getDomain(domain: string, query?: StatsQuery): Promise<Stats>;
18
+ getAccount(query?: StatsQuery): Promise<Stats>;
18
19
  }
19
20
  export {};
@@ -1,5 +1,5 @@
1
1
  import Request from './request';
2
- import { BounceData, ComplaintData, UnsubscribeData } from './interfaces/Supressions';
2
+ import { BounceData, ComplaintData, UnsubscribeData, WhiteListData } from './interfaces/Supressions';
3
3
  declare class Bounce {
4
4
  type: string;
5
5
  address: string;
@@ -21,13 +21,21 @@ declare class Unsubscribe {
21
21
  created_at: Date;
22
22
  constructor(data: UnsubscribeData);
23
23
  }
24
- declare type TModel = typeof Bounce | typeof Complaint | typeof Unsubscribe;
24
+ declare class WhiteList {
25
+ type: string;
26
+ value: string;
27
+ reason: string;
28
+ createdAt: Date;
29
+ constructor(data: WhiteListData);
30
+ }
31
+ declare type TModel = typeof Bounce | typeof Complaint | typeof Unsubscribe | typeof WhiteList;
25
32
  export default class SuppressionClient {
26
33
  request: any;
27
34
  models: {
28
35
  bounces: typeof Bounce;
29
36
  complaints: typeof Complaint;
30
37
  unsubscribes: typeof Unsubscribe;
38
+ whitelists: typeof WhiteList;
31
39
  };
32
40
  constructor(request: Request);
33
41
  _parsePage(id: string, pageUrl: string): {
@@ -49,7 +57,8 @@ export default class SuppressionClient {
49
57
  }, Model: TModel): any;
50
58
  _parseItem(response: {
51
59
  body: any;
52
- }, Model: TModel): Bounce | Complaint | Unsubscribe;
60
+ }, Model: TModel): Bounce | Complaint | Unsubscribe | WhiteList;
61
+ private createWhiteList;
53
62
  list(domain: string, type: string, query: any): any;
54
63
  get(domain: string, type: string, address: string): any;
55
64
  create(domain: string, type: string, data: any): any;