update
This commit is contained in:
@ -1,111 +0,0 @@
|
||||
/**
|
||||
* SMTP Client - Legacy Compatibility Facade
|
||||
*
|
||||
* @deprecated This file provides backward compatibility for the legacy SmtpClient class.
|
||||
* New code should use the modular implementation from smtpclient/ directory.
|
||||
*
|
||||
* Migration Guide:
|
||||
* - Replace `new SmtpClient(options)` with `createSmtpClient(options)`
|
||||
* - Import from `'./smtpclient/index.js'` instead of `'./classes.smtp.client.js'`
|
||||
* - The new API is fully compatible with the legacy interface
|
||||
*/
|
||||
|
||||
import { createSmtpClient } from './smtpclient/index.js';
|
||||
import type {
|
||||
ISmtpClientOptions as ModularOptions,
|
||||
ISmtpSendResult,
|
||||
IConnectionPoolStatus
|
||||
} from './smtpclient/interfaces.js';
|
||||
import type { SmtpClient as ModularSmtpClient } from './smtpclient/smtp-client.js';
|
||||
import type { Email } from '../core/classes.email.js';
|
||||
|
||||
// Re-export the new interfaces for compatibility
|
||||
export type { ISmtpSendResult, IConnectionPoolStatus };
|
||||
|
||||
/**
|
||||
* Legacy SMTP client options interface
|
||||
* @deprecated Use ISmtpClientOptions from smtpclient/interfaces.js
|
||||
*/
|
||||
export type ISmtpClientOptions = ModularOptions;
|
||||
|
||||
/**
|
||||
* Legacy SMTP Client class - Compatibility Facade
|
||||
*
|
||||
* This class wraps the new modular implementation to maintain backward compatibility.
|
||||
* All method calls are delegated to the new implementation.
|
||||
*
|
||||
* @deprecated Use createSmtpClient() factory function instead
|
||||
*/
|
||||
export class SmtpClient {
|
||||
private client: ModularSmtpClient;
|
||||
|
||||
constructor(options: ISmtpClientOptions) {
|
||||
// Create the new modular client
|
||||
this.client = createSmtpClient(options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an email
|
||||
*/
|
||||
public async sendMail(email: Email): Promise<ISmtpSendResult> {
|
||||
return this.client.sendMail(email);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test connection to SMTP server
|
||||
*/
|
||||
public async verify(): Promise<boolean> {
|
||||
return this.client.verify();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if client is connected
|
||||
*/
|
||||
public isConnected(): boolean {
|
||||
return this.client.isConnected();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get connection pool status
|
||||
*/
|
||||
public getPoolStatus(): IConnectionPoolStatus {
|
||||
return this.client.getPoolStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update client options
|
||||
*/
|
||||
public updateOptions(newOptions: Partial<ISmtpClientOptions>): void {
|
||||
return this.client.updateOptions(newOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close all connections and shutdown client
|
||||
*/
|
||||
public async close(): Promise<void> {
|
||||
return this.client.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add event listener (delegate to internal client)
|
||||
*/
|
||||
public on(event: string, listener: (...args: any[]) => void): this {
|
||||
this.client.on(event, listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove event listener (delegate to internal client)
|
||||
*/
|
||||
public off(event: string, listener: (...args: any[]) => void): this {
|
||||
this.client.off(event, listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Emit event (delegate to internal client)
|
||||
*/
|
||||
public emit(event: string, ...args: any[]): boolean {
|
||||
return this.client.emit(event, ...args);
|
||||
}
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
// Email delivery components
|
||||
export * from './smtpserver/index.js';
|
||||
export * from './classes.emailsignjob.js';
|
||||
export * from './classes.delivery.queue.js';
|
||||
export * from './classes.delivery.system.js';
|
||||
@ -17,4 +16,9 @@ export * from './classes.unified.rate.limiter.js';
|
||||
|
||||
// SMTP client and configuration
|
||||
export * from './classes.mta.config.js';
|
||||
export * from './classes.smtp.client.js';
|
||||
|
||||
// Import and export SMTP modules as namespaces to avoid conflicts
|
||||
import * as smtpClientMod from './smtpclient/index.js';
|
||||
import * as smtpServerMod from './smtpserver/index.js';
|
||||
|
||||
export { smtpClientMod, smtpServerMod };
|
Reference in New Issue
Block a user