Comparing version 3.7.0 to 3.8.0
{ | ||
"name": "emailjs", | ||
"description": "send text/html emails and attachments (files, streams and strings) from node.js to any smtp server", | ||
"version": "3.7.0", | ||
"version": "3.8.0", | ||
"author": "eleith", | ||
@@ -20,22 +20,22 @@ "contributors": [ | ||
"@ledge/configs": "23.3.23322", | ||
"@rollup/plugin-typescript": "8.3.0", | ||
"@rollup/plugin-typescript": "8.3.1", | ||
"@types/mailparser": "3.4.0", | ||
"@types/node": "16.11.9", | ||
"@types/node": "17.0.21", | ||
"@types/smtp-server": "3.5.7", | ||
"@typescript-eslint/eslint-plugin": "5.4.0", | ||
"@typescript-eslint/parser": "5.4.0", | ||
"@typescript-eslint/eslint-plugin": "5.15.0", | ||
"@typescript-eslint/parser": "5.15.0", | ||
"ava": "3.15.0", | ||
"eslint": "7.32.0", | ||
"eslint-config-prettier": "8.3.0", | ||
"eslint-config-prettier": "8.5.0", | ||
"eslint-plugin-prettier": "4.0.0", | ||
"mailparser": "3.4.0", | ||
"prettier": "2.4.1", | ||
"rollup": "2.60.0", | ||
"smtp-server": "3.9.0", | ||
"ts-node": "10.4.0", | ||
"prettier": "2.6.0", | ||
"rollup": "2.70.1", | ||
"smtp-server": "3.10.0", | ||
"ts-node": "10.7.0", | ||
"tslib": "2.3.1", | ||
"typescript": "4.5.2" | ||
"typescript": "4.6.2" | ||
}, | ||
"resolutions": { | ||
"nodemailer": "6.7.1" | ||
"nodemailer": "6.7.2" | ||
}, | ||
@@ -42,0 +42,0 @@ "engines": { |
@@ -5,4 +5,12 @@ import { addressparser } from './address'; | ||
export type MessageCallback<T = Message | MessageHeaders> = < | ||
U extends Error | null, | ||
V extends U extends Error ? T : Message | ||
>( | ||
err: U, | ||
msg: V | ||
) => void; | ||
export interface MessageStack { | ||
callback: (error: Error | null, message: Message) => void; | ||
callback: MessageCallback; | ||
message: Message; | ||
@@ -40,10 +48,10 @@ attachment: MessageAttachment; | ||
* @param {Message} msg the message to send | ||
* @param {function(err: Error, msg: Message): void} callback . | ||
* @param {MessageCallback} callback . | ||
* @returns {void} | ||
*/ | ||
public send( | ||
msg: Message, | ||
callback: (err: Error | null, msg: Message) => void | ||
public send<T extends Message | MessageHeaders>( | ||
msg: T, | ||
callback: MessageCallback<T> | ||
) { | ||
const message: Message | null = | ||
const message = | ||
msg instanceof Message | ||
@@ -79,9 +87,11 @@ ? msg | ||
*/ | ||
public sendAsync(msg: Message) { | ||
public sendAsync(msg: Message | MessageHeaders) { | ||
return new Promise<Message>((resolve, reject) => { | ||
this.send(msg, (err, msg) => { | ||
this.send(msg, (err, message) => { | ||
if (err != null) { | ||
reject(err); | ||
} else { | ||
resolve(msg); | ||
// unfortunately, the conditional type doesn't reach here | ||
// fortunately, we only return a `Message` when err is null, so this is safe | ||
resolve(message as Message); | ||
} | ||
@@ -96,3 +106,3 @@ }); | ||
* @param {Message} message message to convert | ||
* @param {function(err: Error, msg: Message): void} callback errback | ||
* @param {MessageCallback} callback errback | ||
* @returns {MessageStack} raw message object | ||
@@ -102,3 +112,3 @@ */ | ||
message: Message, | ||
callback: (err: Error | null, msg: Message) => void = function () { | ||
callback: MessageCallback = function () { | ||
/* ø */ | ||
@@ -239,3 +249,3 @@ } | ||
protected _containsInlinedHtml( | ||
attachment: MessageAttachment | MessageAttachment[] | ||
attachment?: MessageAttachment | MessageAttachment[] | ||
) { | ||
@@ -256,3 +266,3 @@ if (Array.isArray(attachment)) { | ||
*/ | ||
protected _isAttachmentInlinedHtml(attachment: MessageAttachment) { | ||
protected _isAttachmentInlinedHtml(attachment?: MessageAttachment) { | ||
return ( | ||
@@ -259,0 +269,0 @@ attachment && |
@@ -71,15 +71,16 @@ import { | ||
| null | ||
| undefined | ||
| MessageAttachment | ||
| MessageAttachment[]; | ||
'content-type': string; | ||
'message-id': string; | ||
'return-path': string | null; | ||
date: string; | ||
'content-type'?: string; | ||
'message-id'?: string; | ||
'return-path'?: string | null; | ||
date?: string; | ||
from: string | string[]; | ||
to: string | string[]; | ||
cc: string | string[]; | ||
bcc: string | string[]; | ||
cc?: string | string[]; | ||
bcc?: string | string[]; | ||
subject: string; | ||
text: string | null; | ||
attachment: MessageAttachment | MessageAttachment[]; | ||
attachment?: MessageAttachment | MessageAttachment[]; | ||
} | ||
@@ -86,0 +87,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6750
340969
16