mailgun.js 3.6.1 → 3.7.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.
Files changed (59) hide show
  1. package/.eslintrc +8 -6
  2. package/CHANGELOG.md +7 -0
  3. package/dist/index.d.ts +1 -1
  4. package/dist/lib/client.d.ts +1 -1
  5. package/dist/lib/events.d.ts +9 -25
  6. package/dist/lib/interfaces/APIErrorOptions.d.ts +2 -1
  7. package/dist/lib/interfaces/ApiResponse.d.ts +2 -1
  8. package/dist/lib/interfaces/Events.d.ts +24 -0
  9. package/dist/lib/interfaces/IpPools.d.ts +12 -0
  10. package/dist/lib/interfaces/Options.d.ts +2 -1
  11. package/dist/lib/interfaces/RequestOptions.d.ts +2 -1
  12. package/dist/lib/interfaces/StatsOptions.d.ts +2 -1
  13. package/dist/lib/interfaces/mailListMembers.d.ts +6 -6
  14. package/dist/lib/ip-pools.d.ts +11 -14
  15. package/dist/lib/ips.d.ts +6 -6
  16. package/dist/lib/messages.d.ts +1 -1
  17. package/dist/lib/suppressions.d.ts +1 -1
  18. package/dist/mailgun.node.js +2 -2
  19. package/dist/mailgun.node.js.LICENSE.txt +1 -1
  20. package/dist/mailgun.web.js +2 -2
  21. package/dist/mailgun.web.js.LICENSE.txt +1 -1
  22. package/examples/addresses.js +1 -0
  23. package/examples/list-domains.js +1 -0
  24. package/examples/send-email.js +1 -0
  25. package/index.ts +1 -1
  26. package/lib/client.ts +3 -2
  27. package/lib/events.ts +21 -19
  28. package/lib/interfaces/APIErrorOptions.ts +3 -1
  29. package/lib/interfaces/ApiResponse.ts +3 -1
  30. package/lib/interfaces/Events.ts +25 -0
  31. package/lib/interfaces/IFormData.ts +4 -3
  32. package/lib/interfaces/IpPools.ts +16 -1
  33. package/lib/interfaces/Ips.ts +1 -0
  34. package/lib/interfaces/Options.ts +5 -2
  35. package/lib/interfaces/RequestOptions.ts +4 -2
  36. package/lib/interfaces/StatsOptions.ts +4 -2
  37. package/lib/interfaces/Supressions.ts +1 -1
  38. package/lib/interfaces/lists.ts +1 -0
  39. package/lib/interfaces/mailListMembers.ts +18 -12
  40. package/lib/interfaces/routes.ts +1 -0
  41. package/lib/ip-pools.ts +8 -7
  42. package/lib/ips.ts +3 -3
  43. package/lib/lists.ts +1 -1
  44. package/lib/messages.ts +1 -1
  45. package/lib/parse.ts +4 -3
  46. package/lib/stats.ts +3 -2
  47. package/lib/suppressions.ts +16 -11
  48. package/lib/validate.ts +0 -1
  49. package/package.json +1 -1
  50. package/test/client.test.ts +7 -2
  51. package/test/events.test.ts +1 -1
  52. package/test/ips.test.ts +1 -1
  53. package/test/lists.test.ts +5 -6
  54. package/test/mailListMembers.test.ts +47 -42
  55. package/test/messageAttachment.test.ts +3 -3
  56. package/test/messages.test.ts +1 -1
  57. package/test/parse.test.ts +1 -1
  58. package/test/routes.test.ts +1 -0
  59. package/test/suppressions.test.ts +4 -3
package/.eslintrc CHANGED
@@ -9,10 +9,6 @@
9
9
  "extends": [
10
10
  "airbnb-base"
11
11
  ],
12
- "plugins": [
13
- "eslint-plugin-tsdoc",
14
- "@typescript-eslint"
15
- ],
16
12
  "parserOptions": {
17
13
  "ecmaVersion": 12
18
14
  },
@@ -34,7 +30,8 @@
34
30
  "class-methods-use-this": 0,
35
31
  "prefer-destructuring": 0,
36
32
  "import/extensions": 0,
37
- "lines-between-class-members": ["error", "always", { "exceptAfterSingleLine": true }]
33
+ "lines-between-class-members": ["error", "always", { "exceptAfterSingleLine": true }],
34
+ "import/no-extraneous-dependencies" :["error", {"devDependencies": true, "optionalDependencies": false, "peerDependencies": false}]
38
35
  },
39
36
  "overrides": [
40
37
  {
@@ -46,7 +43,12 @@
46
43
  "parser": "@typescript-eslint/parser",
47
44
  "rules": {
48
45
  "import/extensions": 0
49
- }
46
+ // "import/no-extraneous-dependencies" :["error", {"devDependencies": true, "optionalDependencies": false, "peerDependencies": false}]
47
+ },
48
+ "plugins": [
49
+ "eslint-plugin-tsdoc",
50
+ "@typescript-eslint"
51
+ ]
50
52
  }
51
53
  ]
52
54
  }
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
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
+ ## [3.7.0](https://github.com/mailgun/mailgun-js/compare/v3.6.1...v3.7.0) (2021-10-20)
6
+
7
+
8
+ ### Features
9
+
10
+ * Fix linter errors ([126ba03](https://github.com/mailgun/mailgun-js/commits/126ba039bccfbdb257ddde7d17a58790e4cd30a3))
11
+
5
12
  ### [3.6.1](https://github.com/mailgun/mailgun-js/compare/v3.6.0...v3.6.1) (2021-10-18)
6
13
 
7
14
 
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import Options from './lib/interfaces/Options';
3
3
  import IFormData from './lib/interfaces/IFormData';
4
4
  declare class Mailgun {
5
5
  private formData;
6
- constructor(FormData: new (...args: any[]) => IFormData);
6
+ constructor(FormData: new (...args: unknown[]) => IFormData);
7
7
  client(options: Options): Client;
8
8
  }
9
9
  export = Mailgun;
@@ -28,5 +28,5 @@ export default class Client {
28
28
  ips: IpsClient;
29
29
  ip_pools: IpPoolsClient;
30
30
  lists: ListsClient;
31
- constructor(options: Options, formData: new (...args: any[]) => IFormData);
31
+ constructor(options: Options, formData: new (...args: unknown[]) => IFormData);
32
32
  }
@@ -1,29 +1,13 @@
1
- declare const MgRequest: any;
1
+ import { EventsList, EventsPage, EventsResponse, PagesList } from './interfaces/Events';
2
+ import Request from './request';
2
3
  export default class EventClient {
3
- request: typeof MgRequest;
4
- constructor(request: typeof MgRequest);
4
+ request: Request;
5
+ constructor(request: Request);
5
6
  _parsePageNumber(url: string): string;
6
- _parsePage(id: string, url: string): {
7
- id: string;
8
- number: string;
9
- url: string;
10
- };
11
- _parsePageLinks(response: {
12
- body: {
13
- paging: any;
14
- };
15
- }): any;
16
- _parseEventList(response: {
17
- body: {
18
- items: any;
19
- paging: any;
20
- };
21
- }): {
22
- items: any;
23
- pages: any;
24
- };
7
+ _parsePage(id: string, url: string): EventsPage;
8
+ _parsePageLinks(response: EventsResponse): PagesList;
9
+ _parseEventList(response: EventsResponse): EventsList;
25
10
  get(domain: string, query: {
26
- page: any;
27
- }): any;
11
+ page: string;
12
+ }): Promise<EventsList>;
28
13
  }
29
- export {};
@@ -1,4 +1,4 @@
1
- export default interface APIErrorOptions {
1
+ interface APIErrorOptions {
2
2
  headers: {
3
3
  [key: string]: any;
4
4
  };
@@ -8,3 +8,4 @@ export default interface APIErrorOptions {
8
8
  url: string;
9
9
  statusText: string;
10
10
  }
11
+ export default APIErrorOptions;
@@ -1,4 +1,5 @@
1
- export default interface APIResponse {
1
+ interface APIResponse {
2
2
  status: number;
3
3
  body: any;
4
4
  }
5
+ export default APIResponse;
@@ -0,0 +1,24 @@
1
+ export interface EventsPage {
2
+ id: string;
3
+ number: string;
4
+ url: string;
5
+ }
6
+ export interface PagesList {
7
+ previous: string;
8
+ first: string;
9
+ last: string;
10
+ next: string;
11
+ }
12
+ export interface EventsResponse {
13
+ body: {
14
+ items: [];
15
+ paging: PagesList;
16
+ };
17
+ }
18
+ export interface EventsList {
19
+ items: [];
20
+ pages: PagesList;
21
+ }
22
+ export interface PagesListAccumulator {
23
+ [index: string]: EventsPage;
24
+ }
@@ -5,3 +5,15 @@ export interface IpPool {
5
5
  name: string;
6
6
  pool_id: string;
7
7
  }
8
+ export interface IpPoolListResponse {
9
+ body: {
10
+ ip_pools: IpPool;
11
+ message: string;
12
+ };
13
+ }
14
+ export interface IpPoolUpdateData {
15
+ name: string;
16
+ description: string;
17
+ add_ip: string;
18
+ remove_ip: string;
19
+ }
@@ -1,7 +1,8 @@
1
- export default interface Options {
1
+ interface Options {
2
2
  username: string;
3
3
  key: string;
4
4
  url?: string;
5
5
  public_key?: string;
6
6
  timeout?: number;
7
7
  }
8
+ export default Options;
@@ -1,5 +1,6 @@
1
1
  import Options from './Options';
2
- export default interface RequestOptions extends Options {
2
+ interface RequestOptions extends Options {
3
3
  headers: any;
4
4
  timeout: number;
5
5
  }
6
+ export default RequestOptions;
@@ -1,4 +1,4 @@
1
- export default interface StatsOptions {
1
+ interface StatsOptions {
2
2
  start: string | Date;
3
3
  end: string | Date;
4
4
  resolution: string;
@@ -11,3 +11,4 @@ export default interface StatsOptions {
11
11
  };
12
12
  }[];
13
13
  }
14
+ export default StatsOptions;
@@ -1,4 +1,10 @@
1
1
  import { MailingList } from './lists';
2
+ export interface MailListMember {
3
+ address: string;
4
+ name: string;
5
+ subscribed: boolean;
6
+ vars: string | any;
7
+ }
2
8
  export interface MailListMembersQuery {
3
9
  subscribed?: 'yes' | 'no';
4
10
  limit?: number;
@@ -25,12 +31,6 @@ export interface CreateUpdateMailListMembersReq {
25
31
  subscribed?: 'yes' | 'no' | boolean;
26
32
  upsert?: 'yes' | 'no';
27
33
  }
28
- export interface MailListMember {
29
- address: string;
30
- name: string;
31
- subscribed: boolean;
32
- vars: string | any;
33
- }
34
34
  export interface DeletedMember {
35
35
  member: {
36
36
  address: string;
@@ -1,24 +1,21 @@
1
- declare const MgRequest: any;
2
- import { IpPool } from "./interfaces/IpPools";
1
+ import Request from './request';
2
+ import { IpPool, IpPoolUpdateData } from './interfaces/IpPools';
3
3
  export default class IpPoolsClient {
4
- request: typeof MgRequest;
5
- constructor(request: typeof MgRequest);
6
- list(query: any): IpPool[];
4
+ request: Request;
5
+ constructor(request: Request);
6
+ list(query: any): Promise<IpPool[]>;
7
7
  create(data: {
8
8
  name: string;
9
9
  description?: string;
10
10
  ips?: string[];
11
- }): any;
12
- update(poolId: string, data: {
13
- name: string;
14
- description: string;
15
- add_ip: string;
16
- remove_ip: string;
17
- }): any;
11
+ }): Promise<{
12
+ message: string;
13
+ pool_id: string;
14
+ }>;
15
+ update(poolId: string, data: IpPoolUpdateData): Promise<any>;
18
16
  delete(poolId: string, data: {
19
17
  id: string;
20
18
  pool_id: string;
21
- }): any;
19
+ }): Promise<any>;
22
20
  private parseIpPoolsResponse;
23
21
  }
24
- export {};
package/dist/lib/ips.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- declare const MgRequest: any;
1
+ import MgRequest from './request';
2
+ import { IpData, IpsListResponseBody } from './interfaces/Ips';
2
3
  export default class IpsClient {
3
- request: typeof MgRequest;
4
- constructor(request: typeof MgRequest);
5
- list(query: any): any;
6
- get(ip: string): any;
4
+ request: MgRequest;
5
+ constructor(request: MgRequest);
6
+ list(query: any): Promise<IpsListResponseBody | IpData>;
7
+ get(ip: string): Promise<IpsListResponseBody | IpData>;
7
8
  private parseIpsResponse;
8
9
  }
9
- export {};
@@ -1,4 +1,4 @@
1
- import Request from "./request";
1
+ import Request from './request';
2
2
  export default class MessagesClient {
3
3
  request: Request;
4
4
  constructor(request: Request);
@@ -1,6 +1,5 @@
1
1
  import Request from './request';
2
2
  import { BounceData, ComplaintData, UnsubscribeData } from './interfaces/Supressions';
3
- declare type TModel = typeof Bounce | typeof Complaint | typeof Unsubscribe;
4
3
  declare class Bounce {
5
4
  type: string;
6
5
  address: string;
@@ -22,6 +21,7 @@ declare class Unsubscribe {
22
21
  created_at: Date;
23
22
  constructor(data: UnsubscribeData);
24
23
  }
24
+ declare type TModel = typeof Bounce | typeof Complaint | typeof Unsubscribe;
25
25
  export default class SuppressionClient {
26
26
  request: any;
27
27
  models: {