rokot-notification
Version:
Rokot - [Rocketmakers](http://www.rocketmakers.com/) TypeScript NodeJs Platform
45 lines (44 loc) • 2.75 kB
TypeScript
import * as nodemailer from 'nodemailer';
import * as Logger from "bunyan";
import { IRecipientResolver } from "../core/recipients";
import { INotification, NotificationRecipients, INotificationDispatchResult, INotificationHandler, INotificationTransport } from "../core/core";
import { NotificationDispatchHandler } from "../core/dispatchHandler";
declare module "../core/core" {
interface INotificationRecipient {
nodemailer?: string | string[];
email?: string | string[];
}
}
export declare class NodemailerNotificationDispatchHandler extends NotificationDispatchHandler<INodemailerNotificationTransport> {
constructor(logger: Logger, transport: INodemailerNotificationTransport);
}
export declare function nodemailerInitializer(logger: Logger, transporterProvider: NodemailerTransporterBase, defaultFromAddress: string, recipientResolver?: IRecipientResolver): Promise<NodemailerNotificationDispatchHandler>;
export interface INodemailerNotification extends INotification {
fromAddress?: string;
}
export interface INodemailerNotificationHandler<T extends INodemailerNotification> extends INotificationHandler<T> {
nodemailer(notification: T, transport: INodemailerNotificationTransport): Promise<any>;
}
export interface INodemailerNotificationTransport extends INotificationTransport<nodemailer.Transporter> {
send(recipients: NotificationRecipients, builder: (message: nodemailer.SendMailOptions) => void): Promise<INotificationDispatchResult>;
getFromAddress(notification: INodemailerNotification): string;
}
export declare abstract class NodemailerTransporterBase {
getTransporter(): Promise<nodemailer.Transporter>;
protected abstract validate(): any;
protected abstract createNodemailerTransport(): nodemailer.Transport;
private createTransport;
}
export declare class NodemailerNotificationTransport implements INodemailerNotificationTransport {
private logger;
native: nodemailer.Transporter;
private recipientResolver;
private defaultFromAddress;
static create(logger: Logger, transporter: NodemailerTransporterBase, recipientResolver: IRecipientResolver, defaultFromAddress: string): Promise<INodemailerNotificationTransport>;
constructor(logger: Logger, native: nodemailer.Transporter, recipientResolver: IRecipientResolver, defaultFromAddress: string);
getFromAddress(notification: INodemailerNotification): string;
shutdown(): void;
resolveTokens(recipients: NotificationRecipients): Promise<string[]>;
send(recipients: NotificationRecipients, builder: (message: nodemailer.SendMailOptions) => void): Promise<INotificationDispatchResult>;
sendMessage(mail: nodemailer.SendMailOptions): Promise<INotificationDispatchResult>;
}