Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript Definitions #30

Open
DanielMcAssey opened this issue Jan 18, 2022 · 1 comment
Open

TypeScript Definitions #30

DanielMcAssey opened this issue Jan 18, 2022 · 1 comment

Comments

@DanielMcAssey
Copy link

Hi love this library.

Are there any plans for TypeScript definitions?

@ZhuBoao
Copy link

ZhuBoao commented Jun 29, 2023

Just used ChatGPT to generate one, seems perfect for me:

declare module 'emlformat' {
  interface Headers {
    [key: string]: string | string[];
  }

  interface Part {
    headers: Headers;
    body: string | Part[] | Body[];
  }

  interface Body {
    boundary: string;
    part: Part;
  }

  interface ParsedEml {
    headers: Headers;
    body: string | Body[];
  }

  interface Attachment {
    id?: string;
    name?: string;
    contentType?: string;
    inline?: boolean;
    data: string | Buffer;
  }

  interface EmailAddress {
    name?: string;
    email: string;
  }

  interface ReadEml {
    date?: Date;
    subject?: string;
    from?: EmailAddress | EmailAddress[];
    to?: EmailAddress | EmailAddress[];
    cc?: EmailAddress | EmailAddress[];
    headers: Headers;
    text?: string;
    html?: string;
    attachments?: Attachment[];
  }

  interface BuildOptions {
    headersOnly?: boolean;
  }

  interface UnpackOptions {
    parsedJsonFile?: string;
    readJsonFile?: string;
    simulate?: boolean;
  }

  function parse(eml: string, options: BuildOptions, callback: (error: Error | null, data: ParsedEml) => void): void;
  function read(eml: string | ParsedEml, options: BuildOptions, callback: (error: Error | null, data: ReadEml) => void): void;
  function build(data: ReadEml, options: BuildOptions, callback: (error: Error | null, eml: string) => void): void;
  function unpack(eml: string | ParsedEml, directory: string, options: UnpackOptions, callback: (error: Error | null, result: { files: string[] }) => void): void;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants