mirror of
https://github.com/eleith/emailjs.git
synced 2024-07-02 11:08:51 +00:00
chore: move type imports from inline statements
This commit is contained in:
parent
1322ba2f2b
commit
93f23cdc11
|
@ -1,12 +1,14 @@
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import addressparser from 'addressparser';
|
import addressparser from 'addressparser';
|
||||||
import { Message } from './message';
|
import { Message } from './message';
|
||||||
|
import type { MessageAttachment, MessageHeaders } from './message'; // eslint-disable-line no-unused-vars
|
||||||
import { SMTP, SMTPState } from './smtp';
|
import { SMTP, SMTPState } from './smtp';
|
||||||
|
import type { SMTPOptions } from './smtp'; // eslint-disable-line no-unused-vars
|
||||||
|
|
||||||
export interface MessageStack {
|
export interface MessageStack {
|
||||||
callback: (error: Error | null, message: Message) => void;
|
callback: (error: Error | null, message: Message) => void;
|
||||||
message: Message;
|
message: Message;
|
||||||
attachment: import('./message').MessageAttachment;
|
attachment: MessageAttachment;
|
||||||
text: string;
|
text: string;
|
||||||
returnPath: string;
|
returnPath: string;
|
||||||
from: string;
|
from: string;
|
||||||
|
@ -25,7 +27,7 @@ export class Client {
|
||||||
/**
|
/**
|
||||||
* @param {*} server smtp options
|
* @param {*} server smtp options
|
||||||
*/
|
*/
|
||||||
constructor(server: Partial<import('./smtp').SMTPOptions>) {
|
constructor(server: Partial<SMTPOptions>) {
|
||||||
this.smtp = new SMTP(server);
|
this.smtp = new SMTP(server);
|
||||||
//this.smtp.debug(1);
|
//this.smtp.debug(1);
|
||||||
}
|
}
|
||||||
|
@ -152,7 +154,7 @@ export class Client {
|
||||||
* @param {MessageStack} msg message stack
|
* @param {MessageStack} msg message stack
|
||||||
* @returns {boolean} can make message
|
* @returns {boolean} can make message
|
||||||
*/
|
*/
|
||||||
_canMakeMessage(msg: import('./message').MessageHeaders) {
|
_canMakeMessage(msg: MessageHeaders) {
|
||||||
return (
|
return (
|
||||||
msg.from &&
|
msg.from &&
|
||||||
(msg.to || msg.cc || msg.bcc) &&
|
(msg.to || msg.cc || msg.bcc) &&
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { hostname } from 'os';
|
import { hostname } from 'os';
|
||||||
import { Stream } from 'stream';
|
import { Stream } from 'stream';
|
||||||
|
import type { Duplex } from 'stream'; // eslint-disable-line no-unused-vars
|
||||||
|
import type { Indexed } from '@ledge/types'; // eslint-disable-line no-unused-vars
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import addressparser from 'addressparser';
|
import addressparser from 'addressparser';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
@ -8,8 +10,6 @@ import { mimeWordEncode } from 'emailjs-mime-codec';
|
||||||
|
|
||||||
import { getRFC2822Date } from './date';
|
import { getRFC2822Date } from './date';
|
||||||
|
|
||||||
type Indexed = import('@ledge/types').Indexed;
|
|
||||||
|
|
||||||
const CRLF = '\r\n' as const;
|
const CRLF = '\r\n' as const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,7 +48,7 @@ export interface MessageAttachment extends AlternateMessageAttachment {
|
||||||
charset: string;
|
charset: string;
|
||||||
method: string;
|
method: string;
|
||||||
path: string;
|
path: string;
|
||||||
stream: import('stream').Duplex;
|
stream: Duplex;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MessageHeaders extends Indexed {
|
export interface MessageHeaders extends Indexed {
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
import { makeSMTPError, SMTPErrorStates } from './error';
|
import { makeSMTPError, SMTPErrorStates } from './error';
|
||||||
|
import type { Socket } from 'net'; // eslint-disable-line no-unused-vars
|
||||||
|
import type { TLSSocket } from 'tls'; // eslint-disable-line no-unused-vars
|
||||||
|
|
||||||
type Socket = import('net').Socket | import('tls').TLSSocket;
|
|
||||||
export class SMTPResponse {
|
export class SMTPResponse {
|
||||||
public stop: (err?: Error) => void;
|
public stop: (err?: Error) => void;
|
||||||
|
|
||||||
constructor(stream: Socket, timeout: number, onerror: (err: Error) => void) {
|
constructor(
|
||||||
|
stream: Socket | TLSSocket,
|
||||||
|
timeout: number,
|
||||||
|
onerror: (err: Error) => void
|
||||||
|
) {
|
||||||
let buffer = '';
|
let buffer = '';
|
||||||
|
|
||||||
const notify = () => {
|
const notify = () => {
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { createHmac } from 'crypto';
|
||||||
import { hostname } from 'os';
|
import { hostname } from 'os';
|
||||||
import { connect, createSecureContext, TLSSocket } from 'tls';
|
import { connect, createSecureContext, TLSSocket } from 'tls';
|
||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
|
import type { Indexed } from '@ledge/types'; // eslint-disable-line no-unused-vars
|
||||||
|
|
||||||
import { SMTPResponse } from './response';
|
import { SMTPResponse } from './response';
|
||||||
import { makeSMTPError, SMTPErrorStates } from './error';
|
import { makeSMTPError, SMTPErrorStates } from './error';
|
||||||
|
@ -94,9 +95,7 @@ export class SMTP extends EventEmitter {
|
||||||
private _secure = false;
|
private _secure = false;
|
||||||
|
|
||||||
protected sock: Socket | TLSSocket | null = null;
|
protected sock: Socket | TLSSocket | null = null;
|
||||||
protected features:
|
protected features: Indexed<string | boolean> | null = null;
|
||||||
| import('@ledge/types').Indexed<string | boolean>
|
|
||||||
| null = null;
|
|
||||||
protected monitor: SMTPResponse | null = null;
|
protected monitor: SMTPResponse | null = null;
|
||||||
protected authentication: (keyof typeof AUTH_METHODS)[];
|
protected authentication: (keyof typeof AUTH_METHODS)[];
|
||||||
protected domain = hostname();
|
protected domain = hostname();
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import type { Readable } from 'stream'; // eslint-disable-line no-unused-vars
|
||||||
import test from 'ava';
|
import test from 'ava';
|
||||||
import mailparser from 'mailparser';
|
import mailparser from 'mailparser';
|
||||||
import smtp from 'smtp-server';
|
import smtp from 'smtp-server';
|
||||||
|
@ -22,11 +23,7 @@ const send = (
|
||||||
) => void,
|
) => void,
|
||||||
done: () => void
|
done: () => void
|
||||||
) => {
|
) => {
|
||||||
server.onData = (
|
server.onData = (stream: Readable, _session, callback: () => void) => {
|
||||||
stream: import('stream').Readable,
|
|
||||||
_session,
|
|
||||||
callback: () => void
|
|
||||||
) => {
|
|
||||||
mailparser.simpleParser(stream).then(verify).then(done).catch(done);
|
mailparser.simpleParser(stream).then(verify).then(done).catch(done);
|
||||||
stream.on('end', callback);
|
stream.on('end', callback);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import type { Readable } from 'stream'; // eslint-disable-line no-unused-vars
|
||||||
import test from 'ava';
|
import test from 'ava';
|
||||||
import mailparser from 'mailparser';
|
import mailparser from 'mailparser';
|
||||||
import smtp from 'smtp-server';
|
import smtp from 'smtp-server';
|
||||||
|
@ -22,11 +23,7 @@ const send = (
|
||||||
) => void,
|
) => void,
|
||||||
done: () => void
|
done: () => void
|
||||||
) => {
|
) => {
|
||||||
server.onData = (
|
server.onData = (stream: Readable, _session, callback: () => void) => {
|
||||||
stream: import('stream').Readable,
|
|
||||||
_session,
|
|
||||||
callback: () => void
|
|
||||||
) => {
|
|
||||||
mailparser.simpleParser(stream).then(verify).then(done).catch(done);
|
mailparser.simpleParser(stream).then(verify).then(done).catch(done);
|
||||||
stream.on('end', callback);
|
stream.on('end', callback);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import type { Readable } from 'stream'; // eslint-disable-line no-unused-vars
|
||||||
import { readFileSync, createReadStream } from 'fs';
|
import { readFileSync, createReadStream } from 'fs';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
|
||||||
|
@ -24,11 +25,7 @@ const send = (
|
||||||
) => void,
|
) => void,
|
||||||
done: () => void
|
done: () => void
|
||||||
) => {
|
) => {
|
||||||
server.onData = (
|
server.onData = (stream: Readable, _session, callback: () => void) => {
|
||||||
stream: import('stream').Readable,
|
|
||||||
_session,
|
|
||||||
callback: () => void
|
|
||||||
) => {
|
|
||||||
mailparser.simpleParser(stream).then(verify).then(done).catch(done);
|
mailparser.simpleParser(stream).then(verify).then(done).catch(done);
|
||||||
stream.on('end', callback);
|
stream.on('end', callback);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user