Skip to content

Commit

Permalink
Add types
Browse files Browse the repository at this point in the history
  • Loading branch information
xanderberkein committed Feb 9, 2023
1 parent 849a521 commit 7296aca
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.13",
"description": "Email parser for browser environments",
"main": "dist/postal-mime.js",
"types": "postal-mime.d.ts",
"scripts": {
"test": "eslint",
"build": "webpack",
Expand Down
45 changes: 45 additions & 0 deletions postal-mime.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
declare namespace postalMime {
type RawEmail = string | ArrayBuffer | Blob | Buffer;

type Header = Record<string, string>;

type Address = {
address: string;
name: string;
};

type Attachment = {
filename: string;
mimeType: string;
disposition: 'attachment' | 'inline' | null;
related?: boolean;
contentId?: string;
content: string;
};

type Email = {
headers: Header[];
from: Address;
sender?: Address;
replyTo?: Address[];
deliveredTo?: string;
returnPath?: string;
to: Address[];
cc?: Address[];
bcc?: Address[];
subject?: string;
messageId: string;
inReplyTo?: string;
references?: string;
date?: string;
html?: string;
text?: string;
attachments: Attachment[];
};
}

declare class PostalMime {
parse(email: postalMime.RawEmail): Promise<postalMime.Email>;
}

export default PostalMime;

0 comments on commit 7296aca

Please sign in to comment.