mailgun.js 3.7.1 → 4.0.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +335 -1
  3. package/dist/lib/client.d.ts +0 -4
  4. package/dist/lib/domains.d.ts +19 -13
  5. package/dist/lib/domainsCredentials.d.ts +14 -0
  6. package/dist/lib/events.d.ts +3 -3
  7. package/dist/lib/interfaces/DomainCredentials.d.ts +52 -0
  8. package/dist/lib/interfaces/DomainTracking.d.ts +4 -4
  9. package/dist/lib/interfaces/Domains.d.ts +53 -3
  10. package/dist/lib/interfaces/Events.d.ts +66 -2
  11. package/dist/lib/interfaces/MultipleValidation.d.ts +55 -0
  12. package/dist/lib/interfaces/Validate.d.ts +12 -0
  13. package/dist/lib/interfaces/Webhooks.d.ts +5 -1
  14. package/dist/lib/interfaces/lists.d.ts +1 -1
  15. package/dist/lib/multipleValidation.d.ts +10 -0
  16. package/dist/lib/parse.d.ts +0 -6
  17. package/dist/lib/request.d.ts +4 -1
  18. package/dist/lib/validate.d.ts +5 -2
  19. package/dist/lib/webhooks.d.ts +3 -3
  20. package/dist/mailgun.node.js +2 -2
  21. package/dist/mailgun.node.js.LICENSE.txt +1 -1
  22. package/dist/mailgun.web.js +2 -2
  23. package/dist/mailgun.web.js.LICENSE.txt +1 -1
  24. package/lib/client.ts +6 -12
  25. package/lib/domains.ts +82 -26
  26. package/lib/domainsCredentials.ts +88 -0
  27. package/lib/events.ts +6 -6
  28. package/lib/interfaces/DomainCredentials.ts +68 -0
  29. package/lib/interfaces/DomainTracking.ts +4 -4
  30. package/lib/interfaces/Domains.ts +65 -4
  31. package/lib/interfaces/Events.ts +66 -2
  32. package/lib/interfaces/MultipleValidation.ts +62 -0
  33. package/lib/interfaces/Validate.ts +15 -0
  34. package/lib/interfaces/Webhooks.ts +6 -1
  35. package/lib/interfaces/lists.ts +1 -1
  36. package/lib/multipleValidation.ts +37 -0
  37. package/lib/request.ts +75 -34
  38. package/lib/validate.ts +10 -4
  39. package/lib/webhooks.ts +19 -10
  40. package/package.json +6 -6
  41. package/test/client.test.ts +21 -5
  42. package/test/data/emailsValidation1.csv +3 -0
  43. package/test/domains.test.ts +118 -15
  44. package/test/domainsCredentials.test.ts +97 -0
  45. package/test/events.test.ts +15 -24
  46. package/test/multipleValidation.test.ts +159 -0
  47. package/test/validate.test.ts +7 -4
  48. package/test/webhooks.test.ts +6 -6
  49. package/webpack/webpack.dev.config.js +10 -0
  50. package/lib/parse.ts +0 -27
  51. package/test/parse.test.ts +0 -75
@@ -15,9 +15,73 @@ export interface EventsResponse {
15
15
  paging: PagesList;
16
16
  };
17
17
  }
18
+ export interface DomainEvent {
19
+ severity: string;
20
+ tags: string[];
21
+ storage: {
22
+ url: string;
23
+ key: string;
24
+ };
25
+ 'delivery-status': {
26
+ tls: boolean;
27
+ 'mx-host': string;
28
+ code: number;
29
+ description: string;
30
+ 'session-seconds': number;
31
+ utf8: boolean;
32
+ 'attempt-no': number;
33
+ message: string;
34
+ 'certificate-verified': boolean;
35
+ };
36
+ 'recipient-domain': string;
37
+ id: string;
38
+ campaigns: [];
39
+ reason: string;
40
+ 'user-variables': {
41
+ [key: string]: any;
42
+ };
43
+ flags: {
44
+ 'is-routed': boolean;
45
+ 'is-authenticated': boolean;
46
+ 'is-system-test': boolean;
47
+ 'is-test-mode': boolean;
48
+ };
49
+ 'log-level': string;
50
+ template?: any;
51
+ timestamp: number;
52
+ envelope: {
53
+ transport: string;
54
+ sender: string;
55
+ 'sending-ip': string;
56
+ targets: string;
57
+ };
58
+ message: {
59
+ headers: {
60
+ to: string;
61
+ 'message-id': string;
62
+ from: string;
63
+ subject: string;
64
+ };
65
+ attachments: [];
66
+ size: 308;
67
+ };
68
+ recipient: string;
69
+ event: string;
70
+ }
71
+ export interface ParsedPage {
72
+ id: string;
73
+ number: string;
74
+ url: string;
75
+ }
76
+ export interface ParsedPagesList {
77
+ previous: ParsedPage;
78
+ first: ParsedPage;
79
+ last: ParsedPage;
80
+ next: ParsedPage;
81
+ }
18
82
  export interface EventsList {
19
- items: [];
20
- pages: PagesList;
83
+ items: DomainEvent[];
84
+ pages: ParsedPagesList;
21
85
  }
22
86
  export interface PagesListAccumulator {
23
87
  [index: string]: EventsPage;
@@ -0,0 +1,55 @@
1
+ export interface MultipleValidationJob {
2
+ created_at: number;
3
+ download_url: {
4
+ csv: string;
5
+ json: string;
6
+ };
7
+ id: string;
8
+ quantity: number;
9
+ records_processed: number;
10
+ status: string;
11
+ summary: {
12
+ result: {
13
+ catch_all: number;
14
+ deliverable: number;
15
+ do_not_send: number;
16
+ undeliverable: number;
17
+ unknown: number;
18
+ };
19
+ risk: {
20
+ high: number;
21
+ low: number;
22
+ medium: number;
23
+ unknown: number;
24
+ };
25
+ };
26
+ }
27
+ export interface CreatedMultipleValidationJob {
28
+ id: string;
29
+ message: string;
30
+ }
31
+ export interface PagesList {
32
+ prev: string;
33
+ first: string;
34
+ last: string;
35
+ next: string;
36
+ }
37
+ export interface MultipleValidationJobsListResult {
38
+ jobs: MultipleValidationJob[];
39
+ paging: PagesList;
40
+ total: number;
41
+ }
42
+ export interface MultipleValidationJobsListResponse {
43
+ status: 200;
44
+ body: MultipleValidationJobsListResult;
45
+ }
46
+ export interface CanceledMultipleValidationJob {
47
+ body: string;
48
+ status: number;
49
+ }
50
+ export interface IMultipleValidationClient {
51
+ list(): Promise<MultipleValidationJobsListResult>;
52
+ get(listId: string): Promise<MultipleValidationJob>;
53
+ create(listId: string, file: any): Promise<CreatedMultipleValidationJob>;
54
+ destroy(listId: string): Promise<CanceledMultipleValidationJob>;
55
+ }
@@ -0,0 +1,12 @@
1
+ export interface ValidationResult {
2
+ address: string;
3
+ is_disposable_address: boolean;
4
+ is_role_address: boolean;
5
+ reason: string[];
6
+ result: string;
7
+ risk: string;
8
+ }
9
+ export interface ValidationResponse {
10
+ status: number;
11
+ body: ValidationResult;
12
+ }
@@ -7,7 +7,7 @@ export interface WebhookResponseBody {
7
7
  webhook: APIWebhook;
8
8
  }
9
9
  export interface WebhookResponse {
10
- status: string;
10
+ status: number;
11
11
  body: WebhookResponseBody;
12
12
  }
13
13
  export interface WebhookList {
@@ -19,3 +19,7 @@ export interface WebhooksQuery {
19
19
  limit?: number;
20
20
  skip?: number;
21
21
  }
22
+ export interface ValidationResponse {
23
+ code: number;
24
+ message: string;
25
+ }
@@ -7,7 +7,7 @@ export interface CreateUpdateList {
7
7
  address: string;
8
8
  name?: string;
9
9
  description?: string;
10
- access_level?: 'read-only' | 'members' | 'everyone';
10
+ access_level?: 'readonly' | 'members' | 'everyone';
11
11
  reply_preference?: 'list' | 'sender';
12
12
  }
13
13
  export interface DestroyedList {
@@ -0,0 +1,10 @@
1
+ import { CanceledMultipleValidationJob, CreatedMultipleValidationJob, IMultipleValidationClient, MultipleValidationJob, MultipleValidationJobsListResult } from './interfaces/MultipleValidation';
2
+ import Request from './request';
3
+ export default class MultipleValidationClient implements IMultipleValidationClient {
4
+ request: Request;
5
+ constructor(request: Request);
6
+ list(): Promise<MultipleValidationJobsListResult>;
7
+ get(listId: string): Promise<MultipleValidationJob>;
8
+ create(listId: string, file: any): Promise<CreatedMultipleValidationJob>;
9
+ destroy(listId: string): Promise<CanceledMultipleValidationJob>;
10
+ }
@@ -1,6 +0,0 @@
1
- import Request from './request';
2
- export default class ParseClient {
3
- request: Request;
4
- constructor(request: Request);
5
- get(addresses: string[] | string, enableDnsEspChecks: boolean): Promise<any>;
6
- }
@@ -8,7 +8,7 @@ declare class Request {
8
8
  private url;
9
9
  private timeout;
10
10
  private headers;
11
- private formData;
11
+ private FormDataConstructor;
12
12
  constructor(options: RequestOptions, formData: InputFormData);
13
13
  request(method: string, url: string, inputOptions?: any): Promise<APIResponse>;
14
14
  query(method: string, url: string, query: any, options?: any): Promise<APIResponse>;
@@ -20,6 +20,9 @@ declare class Request {
20
20
  postWithFD(url: string, data: any): Promise<APIResponse>;
21
21
  putWithFD(url: string, data: any): Promise<APIResponse>;
22
22
  createFormData(data: any): NodeFormData | FormData;
23
+ private addMimeDataToFD;
24
+ private addFilesToFD;
25
+ private addCommonPropertyToFD;
23
26
  put(url: string, data: any, options?: any): Promise<APIResponse>;
24
27
  patch(url: string, data: any, options?: any): Promise<APIResponse>;
25
28
  delete(url: string, data?: any, options?: any): Promise<APIResponse>;
@@ -1,6 +1,9 @@
1
+ import { IMultipleValidationClient } from './interfaces/MultipleValidation';
2
+ import { ValidationResult } from './interfaces/Validate';
1
3
  import Request from './request';
2
4
  export default class ValidateClient {
5
+ multipleValidation: IMultipleValidationClient;
3
6
  request: Request;
4
- constructor(request: Request);
5
- get(address: string): Promise<any>;
7
+ constructor(request: Request, multipleValidationClient: IMultipleValidationClient);
8
+ get(address: string): Promise<ValidationResult>;
6
9
  }
@@ -1,4 +1,4 @@
1
- import { WebhookList, WebhookResponse, WebhooksQuery } from './interfaces/Webhooks';
1
+ import { ValidationResponse, WebhookList, WebhookResponse, WebhooksQuery } from './interfaces/Webhooks';
2
2
  import Request from './request';
3
3
  declare class Webhook {
4
4
  id: string;
@@ -6,7 +6,7 @@ declare class Webhook {
6
6
  constructor(id: string, url: string);
7
7
  }
8
8
  export default class WebhookClient {
9
- request: any;
9
+ request: Request;
10
10
  constructor(request: Request);
11
11
  _parseWebhookList(response: {
12
12
  body: {
@@ -25,7 +25,7 @@ export default class WebhookClient {
25
25
  };
26
26
  list(domain: string, query: WebhooksQuery): Promise<WebhookList>;
27
27
  get(domain: string, id: string): Promise<Webhook>;
28
- create(domain: string, id: string, url: string, test?: boolean): Promise<Webhook>;
28
+ create(domain: string, id: string, url: string, test?: boolean): Promise<Webhook | ValidationResponse>;
29
29
  update(domain: string, id: string, url: string): Promise<Webhook>;
30
30
  destroy(domain: string, id: string): Promise<Webhook>;
31
31
  }