mailgun.js 5.0.0 → 5.0.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
@@ -19,7 +19,7 @@
19
19
  }
20
20
  }
21
21
  },
22
- "ignorePatterns": ["docs/assets/js/*", "dist/**"],
22
+ "ignorePatterns": ["docs/assets/js/*", "dist/**", "docs/**"],
23
23
  "rules": {
24
24
  "tsdoc/syntax": "warn",
25
25
  "comma-dangle": 0,
package/CHANGELOG.md CHANGED
@@ -2,6 +2,35 @@
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
+ ### [5.0.3](https://github.com/mailgun/mailgun.js/compare/v5.0.2...v5.0.3) (2022-03-23)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * Remove deprecated url package ([406eb56](https://github.com/mailgun/mailgun.js/commits/406eb56916bd52ca8e3d9b1ffacf419d42db5a86))
11
+ * TypeError -> mailgun_js_1.default is not a constructor ([ff91333](https://github.com/mailgun/mailgun.js/commits/ff91333c3f34434c54e993da62a61dc38d6196f4))
12
+ * Update DomainsQuery interface for mg.domains.list ([b55eb52](https://github.com/mailgun/mailgun.js/commits/b55eb52c18eb6d81dd3e6fcb991a8b7b5a75a4ab))
13
+ * Update get method in Domain templates client interface to have an optional parameter ([12868a8](https://github.com/mailgun/mailgun.js/commits/12868a88e5465d4f3dcb3e3797522c7b4fc552a0))
14
+
15
+
16
+ ### Other changes
17
+
18
+ * Update webpack release config ([240038a](https://github.com/mailgun/mailgun.js/commits/240038a180eb0ad6a704bf24ed01e3c241bef5d5))
19
+
20
+ ### [5.0.2](https://github.com/mailgun/mailgun.js/compare/v5.0.1...v5.0.2) (2022-03-14)
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * Make `StatsQuery` interface properties optional, add `StatsEvent` type ([91a2d6a](https://github.com/mailgun/mailgun.js/commits/91a2d6ae22f2c9cb86ee64ccab636d23926bb6d1))
26
+
27
+ ### [5.0.1](https://github.com/mailgun/mailgun.js/compare/v5.0.0...v5.0.1) (2022-02-23)
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * Resolve ts strict mode issues ([473f6a2](https://github.com/mailgun/mailgun.js/commits/473f6a2909bfa72e9d779d1233485767eac6f323))
33
+
5
34
  ## [5.0.0](https://github.com/mailgun/mailgun.js/compare/v4.2.2...v5.0.0) (2022-02-23)
6
35
 
7
36
 
@@ -6,11 +6,11 @@ declare module 'mailgun.js' {
6
6
  import Client from 'mailgun.js/client';
7
7
  import { InputFormData } from 'mailgun.js/interfaces/IFormData';
8
8
  import Options from 'mailgun.js/interfaces/Options';
9
- class Mailgun {
9
+ export default class Mailgun {
10
+ static get default(): typeof Mailgun;
10
11
  constructor(FormData: InputFormData);
11
12
  client(options: Options): Client;
12
13
  }
13
- export = Mailgun;
14
14
  }
15
15
 
16
16
  declare module 'mailgun.js/client' {
@@ -44,7 +44,7 @@ declare module 'mailgun.js/client' {
44
44
  }
45
45
 
46
46
  declare module 'mailgun.js/interfaces/IFormData' {
47
- import NodeFormData from 'form-data';
47
+ import * as NodeFormData from 'form-data';
48
48
  export interface IFormDataOptions {
49
49
  [key: string]: any;
50
50
  }
@@ -155,80 +155,61 @@ declare module 'mailgun.js/stats' {
155
155
 
156
156
  declare module 'mailgun.js/suppressions' {
157
157
  import Request from 'mailgun.js/request';
158
- import { BounceData, ComplaintData, UnsubscribeData, WhiteListData } from 'mailgun.js/interfaces/Supressions';
159
- class Bounce {
158
+ import { BounceData, ComplaintData, ParsedPage, ParsedPagesList, SuppressionCreationData, SuppressionCreationResult, SuppressionDestroyResult, SuppressionList, SuppressionListQuery, SuppressionListResponse, SuppressionModels, UnsubscribeData, WhiteListData } from 'mailgun.js/interfaces/Supressions';
159
+ export class Suppression {
160
160
  type: string;
161
+ constructor(type: SuppressionModels);
162
+ }
163
+ export class Bounce extends Suppression {
161
164
  address: string;
162
165
  code: number;
163
166
  error: string;
164
167
  created_at: Date;
165
168
  constructor(data: BounceData);
166
169
  }
167
- class Complaint {
168
- type: string;
169
- address: any;
170
+ export class Complaint extends Suppression {
171
+ address: string | undefined;
170
172
  created_at: Date;
171
173
  constructor(data: ComplaintData);
172
174
  }
173
- class Unsubscribe {
174
- type: string;
175
+ export class Unsubscribe extends Suppression {
175
176
  address: string;
176
- tags: any;
177
+ tags: string[];
177
178
  created_at: Date;
178
179
  constructor(data: UnsubscribeData);
179
180
  }
180
- class WhiteList {
181
- type: string;
181
+ export class WhiteList extends Suppression {
182
182
  value: string;
183
183
  reason: string;
184
184
  createdAt: Date;
185
185
  constructor(data: WhiteListData);
186
186
  }
187
- type TModel = typeof Bounce | typeof Complaint | typeof Unsubscribe | typeof WhiteList;
188
187
  export default class SuppressionClient {
189
- request: any;
190
- models: {
191
- bounces: typeof Bounce;
192
- complaints: typeof Complaint;
193
- unsubscribes: typeof Unsubscribe;
194
- whitelists: typeof WhiteList;
195
- };
188
+ request: Request;
189
+ models: Map<string, any>;
196
190
  constructor(request: Request);
197
- _parsePage(id: string, pageUrl: string): {
198
- id: string;
199
- page: string | string[];
200
- address: string | string[];
201
- url: string;
202
- };
203
- _parsePageLinks(response: {
204
- body: {
205
- paging: any;
206
- };
207
- }): any;
208
- _parseList(response: {
209
- body: {
210
- items: any;
211
- paging: any;
212
- };
213
- }, Model: TModel): any;
214
- _parseItem(response: {
215
- body: any;
216
- }, Model: TModel): Bounce | Complaint | Unsubscribe | WhiteList;
217
- list(domain: string, type: string, query: any): any;
218
- get(domain: string, type: string, address: string): any;
219
- create(domain: string, type: string, data: any): any;
220
- destroy(domain: string, type: string, address: string): any;
191
+ _parsePage(id: string, pageUrl: string): ParsedPage;
192
+ _parsePageLinks(response: SuppressionListResponse): ParsedPagesList;
193
+ _parseList(response: SuppressionListResponse, Model: {
194
+ new (data: BounceData | ComplaintData | UnsubscribeData | WhiteListData): Bounce | Complaint | Unsubscribe | WhiteList;
195
+ }): SuppressionList;
196
+ _parseItem<T extends Suppression>(data: BounceData | ComplaintData | UnsubscribeData | WhiteListData, Model: {
197
+ new (data: BounceData | ComplaintData | UnsubscribeData | WhiteListData): T;
198
+ }): T;
199
+ list(domain: string, type: string, query?: SuppressionListQuery): Promise<SuppressionList>;
200
+ get(domain: string, type: string, address: string): Promise<Bounce | Complaint | Unsubscribe | WhiteList>;
201
+ create(domain: string, type: string, data: SuppressionCreationData | SuppressionCreationData[]): Promise<SuppressionCreationResult>;
202
+ destroy(domain: string, type: string, address: string): Promise<SuppressionDestroyResult>;
221
203
  }
222
- export {};
223
204
  }
224
205
 
225
206
  declare module 'mailgun.js/webhooks' {
226
- import { ValidationResponse, WebhookList, WebhookResponse, WebhooksQuery } from 'mailgun.js/interfaces/Webhooks';
207
+ import { ValidationResponse, WebhookList, WebhookResponse, WebhooksIds, WebhooksQuery } from 'mailgun.js/interfaces/Webhooks';
227
208
  import Request from 'mailgun.js/request';
228
209
  class Webhook {
229
210
  id: string;
230
- url: string;
231
- constructor(id: string, url: string);
211
+ url: string | undefined;
212
+ constructor(id: string, url: string | undefined);
232
213
  }
233
214
  export default class WebhookClient {
234
215
  request: Request;
@@ -249,7 +230,7 @@ declare module 'mailgun.js/webhooks' {
249
230
  message: string;
250
231
  };
251
232
  list(domain: string, query: WebhooksQuery): Promise<WebhookList>;
252
- get(domain: string, id: string): Promise<Webhook>;
233
+ get(domain: string, id: WebhooksIds): Promise<Webhook>;
253
234
  create(domain: string, id: string, url: string, test?: boolean): Promise<Webhook | ValidationResponse>;
254
235
  update(domain: string, id: string, url: string): Promise<Webhook>;
255
236
  destroy(domain: string, id: string): Promise<Webhook>;
@@ -348,10 +329,10 @@ declare module 'mailgun.js/lists' {
348
329
 
349
330
  declare module 'mailgun.js/interfaces/Domains' {
350
331
  export interface DomainsQuery {
351
- authority: string;
352
- state: 'active' | 'unverified' | 'disabled';
353
- limit: number;
354
- skip: number;
332
+ authority?: string;
333
+ state?: 'active' | 'unverified' | 'disabled';
334
+ limit?: number;
335
+ skip?: number;
355
336
  }
356
337
  export interface DomainInfo {
357
338
  name: string;
@@ -479,7 +460,7 @@ declare module 'mailgun.js/interfaces/ApiResponse' {
479
460
  }
480
461
 
481
462
  declare module 'mailgun.js/request' {
482
- import NodeFormData from 'form-data';
463
+ import * as NodeFormData from 'form-data';
483
464
  import RequestOptions from 'mailgun.js/interfaces/RequestOptions';
484
465
  import { InputFormData } from 'mailgun.js/interfaces/IFormData';
485
466
  import APIResponse from 'mailgun.js/interfaces/ApiResponse';
@@ -793,7 +774,7 @@ declare module 'mailgun.js/interfaces/DomainTemplates' {
793
774
  }
794
775
  export interface IDomainTemplatesClient {
795
776
  list(domain: string, query?: DomainTemplatesQuery): Promise<ListDomainTemplatesResult>;
796
- get(domain: string, templateName: string, query: TemplateQuery): Promise<DomainTemplateItem>;
777
+ get(domain: string, templateName: string, query?: TemplateQuery): Promise<DomainTemplateItem>;
797
778
  create(domain: string, data: DomainTemplateData): Promise<DomainTemplateItem>;
798
779
  update(domain: string, templateName: string, data: DomainTemplateUpdateData): Promise<UpdateOrDeleteDomainTemplateResult>;
799
780
  destroy(domain: string, templateName: string): Promise<UpdateOrDeleteDomainTemplateResult>;
@@ -1222,16 +1203,18 @@ declare module 'mailgun.js/interfaces/StatsOptions' {
1222
1203
  resolution: string;
1223
1204
  stats: Stat[];
1224
1205
  }
1206
+ export type StatsEvent = 'accepted' | 'delivered' | 'opened' | 'clicked' | 'unsubscribed' | 'stored' | 'rejected' | 'complained' | 'failed-temporary' | 'failed-permanent';
1225
1207
  export interface StatsQuery {
1226
- event: string | string[];
1227
- start: string | Date;
1228
- end: string | Date;
1229
- resolution: 'hour' | 'day' | 'month';
1230
- duration: string;
1208
+ event: StatsEvent | StatsEvent[];
1209
+ start?: string | Date;
1210
+ end?: string | Date;
1211
+ resolution?: 'hour' | 'day' | 'month';
1212
+ duration?: string;
1231
1213
  }
1232
1214
  }
1233
1215
 
1234
1216
  declare module 'mailgun.js/interfaces/Supressions' {
1217
+ import { Bounce, Complaint, Unsubscribe, WhiteList } from 'mailgun.js/suppressions';
1235
1218
  export interface BounceData {
1236
1219
  address: string;
1237
1220
  code: number;
@@ -1253,6 +1236,87 @@ declare module 'mailgun.js/interfaces/Supressions' {
1253
1236
  reason: string;
1254
1237
  createdAt: string | Date;
1255
1238
  }
1239
+ export interface ParsedPage {
1240
+ id: string;
1241
+ page: string | null | undefined;
1242
+ address: string | null | undefined;
1243
+ url: string;
1244
+ }
1245
+ export interface ParsedPagesList {
1246
+ previous: ParsedPage;
1247
+ first: ParsedPage;
1248
+ last: ParsedPage;
1249
+ next: ParsedPage;
1250
+ }
1251
+ export interface SuppressionList {
1252
+ items: (Bounce | Complaint | Unsubscribe | WhiteList)[];
1253
+ pages: ParsedPagesList;
1254
+ }
1255
+ export interface PagesList {
1256
+ previous: string;
1257
+ first: string;
1258
+ last: string;
1259
+ next: string;
1260
+ }
1261
+ export enum SuppressionModels {
1262
+ BOUNCES = "bounces",
1263
+ COMPLAINTS = "complaints",
1264
+ UNSUBSCRIBES = "unsubscribes",
1265
+ WHITELISTS = "whitelists"
1266
+ }
1267
+ export interface PagesListAccumulator {
1268
+ [index: string]: ParsedPage;
1269
+ }
1270
+ export interface SuppressionListQuery {
1271
+ limit?: number;
1272
+ }
1273
+ export interface SuppressionListResponse {
1274
+ body: {
1275
+ items: BounceData[] | ComplaintData[] | UnsubscribeData[] | WhiteListData[];
1276
+ paging: PagesList;
1277
+ };
1278
+ status: number;
1279
+ }
1280
+ export interface SuppressionResponse {
1281
+ body: BounceData | ComplaintData | UnsubscribeData | WhiteListData;
1282
+ status: number;
1283
+ }
1284
+ export interface SuppressionDestroyResponse {
1285
+ body: {
1286
+ message: string;
1287
+ value?: string;
1288
+ address?: string;
1289
+ };
1290
+ status: number;
1291
+ }
1292
+ export interface SuppressionDestroyResult {
1293
+ message: string;
1294
+ value: string;
1295
+ address: string;
1296
+ status: number;
1297
+ }
1298
+ export interface SuppressionCreationData {
1299
+ address: string;
1300
+ code?: number;
1301
+ error?: string;
1302
+ domain?: string;
1303
+ tag?: string;
1304
+ created_at?: string;
1305
+ }
1306
+ export interface SuppressionCreationResponse {
1307
+ body: {
1308
+ message: string;
1309
+ type?: string;
1310
+ value?: string;
1311
+ };
1312
+ status: number;
1313
+ }
1314
+ export interface SuppressionCreationResult {
1315
+ message: string;
1316
+ type: string;
1317
+ value: string;
1318
+ status: number;
1319
+ }
1256
1320
  }
1257
1321
 
1258
1322
  declare module 'mailgun.js/interfaces/Webhooks' {
@@ -1281,6 +1345,15 @@ declare module 'mailgun.js/interfaces/Webhooks' {
1281
1345
  code: number;
1282
1346
  message: string;
1283
1347
  }
1348
+ export enum WebhooksIds {
1349
+ CLICKED = "clicked",
1350
+ COMPLAINED = "complained",
1351
+ DELIVERED = "delivered",
1352
+ OPENED = "opened",
1353
+ PERMANENT_FAIL = "permanent_fail",
1354
+ TEMPORARY_FAIL = "temporary_fail",
1355
+ UNSUBSCRIBED = "unsubscribe"
1356
+ }
1284
1357
  }
1285
1358
 
1286
1359
  declare module 'mailgun.js/interfaces/routes' {