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