Skip to content

Commit

Permalink
fix: Remove deprecated url package
Browse files Browse the repository at this point in the history
  • Loading branch information
Omazepa committed Mar 18, 2022
1 parent b55eb52 commit 406eb56
Show file tree
Hide file tree
Showing 11 changed files with 14,174 additions and 198 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
}
},
"ignorePatterns": ["docs/assets/js/*", "dist/**"],
"ignorePatterns": ["docs/assets/js/*", "dist/**", "docs/**"],
"rules": {
"tsdoc/syntax": "warn",
"comma-dangle": 0,
Expand Down
151 changes: 82 additions & 69 deletions dist/mailgun.js.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,66 +155,52 @@ declare module 'mailgun.js/stats' {

declare module 'mailgun.js/suppressions' {
import Request from 'mailgun.js/request';
import { BounceData, ComplaintData, IBounce, IComplaint, IUnsubscribe, IWhiteList, ParsedPage, ParsedPagesList, SuppressionList, SuppressionModels, UnsubscribeData, WhiteListData } from 'mailgun.js/interfaces/Supressions';
class Bounce implements IBounce {
import { BounceData, ComplaintData, ParsedPage, ParsedPagesList, SuppressionCreationData, SuppressionCreationResult, SuppressionDestroyResult, SuppressionList, SuppressionListQuery, SuppressionListResponse, SuppressionModels, UnsubscribeData, WhiteListData } from 'mailgun.js/interfaces/Supressions';
export class Suppression {
type: string;
constructor(type: SuppressionModels);
}
export class Bounce extends Suppression {
address: string;
code: number;
error: string;
created_at: Date;
constructor(data: BounceData);
}
class Complaint implements IComplaint {
type: string;
address: any;
export class Complaint extends Suppression {
address: string | undefined;
created_at: Date;
constructor(data: ComplaintData);
}
class Unsubscribe implements IUnsubscribe {
type: string;
export class Unsubscribe extends Suppression {
address: string;
tags: any;
tags: string[];
created_at: Date;
constructor(data: UnsubscribeData);
}
class WhiteList implements IWhiteList {
type: string;
export class WhiteList extends Suppression {
value: string;
reason: string;
createdAt: Date;
constructor(data: WhiteListData);
}
type TModel = typeof Bounce | typeof Complaint | typeof Unsubscribe | typeof WhiteList;
export default class SuppressionClient {
request: any;
models: {
bounces: typeof Bounce;
complaints: typeof Complaint;
unsubscribes: typeof Unsubscribe;
whitelists: typeof WhiteList;
};
request: Request;
models: Map<string, any>;
constructor(request: Request);
_parsePage(id: string, pageUrl: string): ParsedPage;
_parsePageLinks(response: {
body: {
paging: any;
};
}): ParsedPagesList;
_parseList(response: {
body: {
items: any;
paging: any;
};
}, Model: TModel): SuppressionList;
_parseItem(response: {
body: any;
}, Model: TModel): IBounce | IComplaint | IUnsubscribe | IWhiteList;
list(domain: string, type: SuppressionModels, query: any): Promise<SuppressionList>;
get(domain: string, type: SuppressionModels, address: string): Promise<IBounce | IComplaint | IUnsubscribe | IWhiteList>;
create(domain: string, type: string, data: any): any;
destroy(domain: string, type: string, address: string): any;
_parsePageLinks(response: SuppressionListResponse): ParsedPagesList;
_parseList(response: SuppressionListResponse, Model: {
new (data: BounceData | ComplaintData | UnsubscribeData | WhiteListData): Bounce | Complaint | Unsubscribe | WhiteList;
}): SuppressionList;
_parseItem<T extends Suppression>(data: BounceData | ComplaintData | UnsubscribeData | WhiteListData, Model: {
new (data: BounceData | ComplaintData | UnsubscribeData | WhiteListData): T;
}): T;
list(domain: string, type: SuppressionModels, query: SuppressionListQuery): Promise<SuppressionList>;
get(domain: string, type: SuppressionModels, address: string): Promise<Bounce | Complaint | Unsubscribe | WhiteList>;
create(domain: string, type: SuppressionModels, data: SuppressionCreationData | SuppressionCreationData[]): Promise<SuppressionCreationResult>;
destroy(domain: string, type: SuppressionModels, address: string): Promise<SuppressionDestroyResult>;
}
export {};
}

declare module 'mailgun.js/webhooks' {
Expand Down Expand Up @@ -343,10 +329,10 @@ declare module 'mailgun.js/lists' {

declare module 'mailgun.js/interfaces/Domains' {
export interface DomainsQuery {
authority: string;
state: 'active' | 'unverified' | 'disabled';
limit: number;
skip: number;
authority?: string;
state?: 'active' | 'unverified' | 'disabled';
limit?: number;
skip?: number;
}
export interface DomainInfo {
name: string;
Expand Down Expand Up @@ -788,7 +774,7 @@ declare module 'mailgun.js/interfaces/DomainTemplates' {
}
export interface IDomainTemplatesClient {
list(domain: string, query?: DomainTemplatesQuery): Promise<ListDomainTemplatesResult>;
get(domain: string, templateName: string, query: TemplateQuery): Promise<DomainTemplateItem>;
get(domain: string, templateName: string, query?: TemplateQuery): Promise<DomainTemplateItem>;
create(domain: string, data: DomainTemplateData): Promise<DomainTemplateItem>;
update(domain: string, templateName: string, data: DomainTemplateUpdateData): Promise<UpdateOrDeleteDomainTemplateResult>;
destroy(domain: string, templateName: string): Promise<UpdateOrDeleteDomainTemplateResult>;
Expand Down Expand Up @@ -1228,6 +1214,7 @@ declare module 'mailgun.js/interfaces/StatsOptions' {
}

declare module 'mailgun.js/interfaces/Supressions' {
import { Bounce, Complaint, Unsubscribe, WhiteList } from 'mailgun.js/suppressions';
export interface BounceData {
address: string;
code: number;
Expand All @@ -1249,34 +1236,10 @@ declare module 'mailgun.js/interfaces/Supressions' {
reason: string;
createdAt: string | Date;
}
export interface IBounce {
type: string;
address: string;
code: number;
error: string;
created_at: Date;
}
export interface IComplaint {
type: string;
address: any;
created_at: Date;
}
export interface IUnsubscribe {
type: string;
address: string;
tags: any;
created_at: Date;
}
export interface IWhiteList {
type: string;
value: string;
reason: string;
createdAt: Date;
}
export interface ParsedPage {
id: string;
page: string | undefined;
address: string | undefined;
page: string | null | undefined;
address: string | null | undefined;
url: string;
}
export interface ParsedPagesList {
Expand All @@ -1286,7 +1249,7 @@ declare module 'mailgun.js/interfaces/Supressions' {
next: ParsedPage;
}
export interface SuppressionList {
items: IBounce[] | IComplaint[] | IUnsubscribe[] | IWhiteList[];
items: (Bounce | Complaint | Unsubscribe | WhiteList)[];
pages: ParsedPagesList;
}
export interface PagesList {
Expand All @@ -1304,6 +1267,56 @@ declare module 'mailgun.js/interfaces/Supressions' {
export interface PagesListAccumulator {
[index: string]: ParsedPage;
}
export interface SuppressionListQuery {
limit?: number;
}
export interface SuppressionListResponse {
body: {
items: BounceData[] | ComplaintData[] | UnsubscribeData[] | WhiteListData[];
paging: PagesList;
};
status: number;
}
export interface SuppressionResponse {
body: BounceData | ComplaintData | UnsubscribeData | WhiteListData;
status: number;
}
export interface SuppressionDestroyResponse {
body: {
message: string;
value?: string;
address?: string;
};
status: number;
}
export interface SuppressionDestroyResult {
message: string;
value: string;
address: string;
status: number;
}
export interface SuppressionCreationData {
address: string;
code?: number;
error?: string;
domain?: string;
tag?: string;
created_at?: string;
}
export interface SuppressionCreationResponse {
body: {
message: string;
type?: string;
value?: string;
};
status: number;
}
export interface SuppressionCreationResult {
message: string;
type: string;
value: string;
status: number;
}
}

declare module 'mailgun.js/interfaces/Webhooks' {
Expand Down
10,423 changes: 10,420 additions & 3 deletions dist/mailgun.node.js

Large diffs are not rendered by default.

3,397 changes: 3,394 additions & 3 deletions dist/mailgun.web.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/send-email.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
const fs = require('fs');
const mailgun = require('../index');
const mailgun = require('../lib/index');

const mg = mailgun.client({ username: 'api', key: process.env.MAILGUN_API_KEY || '', timeout: 60000 });

Expand Down
1 change: 0 additions & 1 deletion lib/interfaces/DomainTags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ export interface DomainTagDevicesAggregation {
device: DevicesTypes;
}


export interface IDomainTagsClient {
list(domain: string): Promise<DomainTagsList>
get(domain: string, tag: string): Promise<DomainTagsItem>
Expand Down
93 changes: 65 additions & 28 deletions lib/interfaces/Supressions.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import {
Bounce, Complaint, Unsubscribe, WhiteList
} from '../suppressions';

/* eslint-disable camelcase */
export interface BounceData {
address: string;
Expand All @@ -24,35 +28,10 @@ export interface WhiteListData {
createdAt: string | Date;
}

export interface IBounce {
type: string;
address: string;
code: number;
error: string;
created_at: Date;
}
export interface IComplaint {
type: string;
address: any;
created_at: Date;
}
export interface IUnsubscribe {
type: string;
address: string;
tags: any;
created_at: Date;
}
export interface IWhiteList {
type: string;
value: string;
reason: string;
createdAt: Date;
}

export interface ParsedPage {
id: string;
page: string | undefined;
address: string | undefined;
page: string | null | undefined;
address: string | null | undefined;
url: string
}
export interface ParsedPagesList {
Expand All @@ -63,7 +42,7 @@ export interface ParsedPagesList {
}

export interface SuppressionList {
items: IBounce[] | IComplaint[] | IUnsubscribe[] | IWhiteList[];
items: (Bounce | Complaint | Unsubscribe | WhiteList)[];
pages: ParsedPagesList;
}

Expand All @@ -84,3 +63,61 @@ export enum SuppressionModels {
export interface PagesListAccumulator {
[index: string]: ParsedPage;
}

export interface SuppressionListQuery {
limit?: number;
}

export interface SuppressionListResponse {
body: {
items: BounceData[] | ComplaintData[] | UnsubscribeData[] | WhiteListData[];
paging: PagesList;
}
status: number;
}

export interface SuppressionResponse {
body: BounceData | ComplaintData | UnsubscribeData | WhiteListData;
status: number;
}

export interface SuppressionDestroyResponse {
body: {
message: string;
value?: string;
address?: string;
}
status: number;
}

export interface SuppressionDestroyResult {
message: string;
value: string;
address: string;
status: number;
}

export interface SuppressionCreationData {
address: string;
code?: number;
error?: string;
domain?: string;
tag?: string;
created_at?: string ;
}

export interface SuppressionCreationResponse {
body:{
message:string;
type?: string;
value?: string;
}
status: number;
}

export interface SuppressionCreationResult {
message:string;
type: string;
value: string;
status: number;
}
Loading

0 comments on commit 406eb56

Please sign in to comment.