3.0.4 • Published 6 months ago

@types/preview-email v3.0.4

Weekly downloads
1,028
License
MIT
Repository
github
Last release
6 months ago

Installation

npm install --save @types/preview-email

Summary

This package contains type definitions for preview-email (https://github.com/niftylettuce/preview-email).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/preview-email.

index.d.ts

// Type definitions for preview-email 2.0
// Project: https://github.com/niftylettuce/preview-email
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.3

import { Options as NodeMailerOptions } from 'nodemailer/lib/mailer';

/**
 * Automatically opens your browser to preview Node.js email messages sent with Nodemailer. Made for Lad!
 *
 * The function `previewEmail` returns a `Promise` which resolves with a URL.
 * We automatically open the browser to this URL unless you specify options.open as false
 */
declare function previewEmail(message: NodeMailerOptions, options?: previewEmail.Options): Promise<string>;

declare namespace previewEmail {
    interface Options {
        /**
         * a unique ID for the file name created for the preview in dir (defaults to `uuid.v4()` from `uuid`)
         */
        id?: string | undefined;
        /**
         *  a path to a directory for saving the generated email previews (defaults to `os.tmpdir()`)
         */
        dir?: string | undefined;
        /**
         * an options object that is passed to open (defaults to `{ wait: false }`).
         * If set to `false` then it will not open the email automatically in the browser using open,
         * and if set to true then it will default to `{ wait: false }`
         * @default { wait: false }
         */
        open?: OpenOptions | boolean | undefined;
        /**
         *  file path to a pug template file (defaults to preview-email's `template.pug` by default)
         * - this is where you can pass a custom template for rendering email previews, e.g. your own stylesheet
         */
        template?: string | undefined;
        /**
         * a function to build preview url from file path
         * - this is where you can customize the opened path to handle WSL to Windows transformation or build a http url if dir is served.
         * @default (path) => 'file://[file path]'
         */
        urlTransform?: UrlTransform | undefined;
    }

    interface OpenOptions {
        /** @default false */
        wait?: boolean | undefined;
    }

    /**
     * a function to build preview url from file path
     */
    interface UrlTransform {
        (path: string): string;
    }
}

export = previewEmail;

Additional Details

  • Last updated: Thu, 08 Jul 2021 20:19:50 GMT
  • Dependencies: @types/nodemailer
  • Global values: none

Credits

These definitions were written by Piotr Błażejewicz.

3.0.4

6 months ago

3.0.3

7 months ago

3.0.2

8 months ago

3.0.1

11 months ago

3.0.0

1 year ago

2.0.1

3 years ago

2.0.0

4 years ago