113 lines
3.1 KiB
TypeScript
113 lines
3.1 KiB
TypeScript
import * as plugins from '../plugins.js';
|
|
import * as authInterfaces from '../data/auth.js';
|
|
|
|
// ============================================================================
|
|
// Catalog-compatible email types (matches @serve.zone/catalog IEmail/IEmailDetail)
|
|
// ============================================================================
|
|
export type TEmailStatus = 'delivered' | 'bounced' | 'rejected' | 'deferred' | 'pending';
|
|
export type TEmailDirection = 'inbound' | 'outbound';
|
|
|
|
export interface IEmail {
|
|
id: string;
|
|
direction: TEmailDirection;
|
|
status: TEmailStatus;
|
|
from: string;
|
|
to: string;
|
|
subject: string;
|
|
timestamp: string;
|
|
messageId: string;
|
|
size: string;
|
|
}
|
|
|
|
export interface ISmtpLogEntry {
|
|
timestamp: string;
|
|
direction: 'client' | 'server';
|
|
command: string;
|
|
responseCode?: number;
|
|
}
|
|
|
|
export interface IConnectionInfo {
|
|
sourceIp: string;
|
|
sourceHostname: string;
|
|
destinationIp: string;
|
|
destinationPort: number;
|
|
tlsVersion: string;
|
|
tlsCipher: string;
|
|
authenticated: boolean;
|
|
authMethod: string;
|
|
authUser: string;
|
|
}
|
|
|
|
export interface IAuthenticationResults {
|
|
spf: 'pass' | 'fail' | 'softfail' | 'neutral' | 'none';
|
|
spfDomain: string;
|
|
dkim: 'pass' | 'fail' | 'none';
|
|
dkimDomain: string;
|
|
dmarc: 'pass' | 'fail' | 'none';
|
|
dmarcPolicy: string;
|
|
}
|
|
|
|
export interface IEmailDetail extends IEmail {
|
|
toList: string[];
|
|
cc?: string[];
|
|
smtpLog: ISmtpLogEntry[];
|
|
connectionInfo: IConnectionInfo;
|
|
authenticationResults: IAuthenticationResults;
|
|
rejectionReason?: string;
|
|
bounceMessage?: string;
|
|
headers: Record<string, string>;
|
|
body: string;
|
|
}
|
|
|
|
// ============================================================================
|
|
// Get All Emails Request
|
|
// ============================================================================
|
|
export interface IReq_GetAllEmails extends plugins.typedrequestInterfaces.implementsTR<
|
|
plugins.typedrequestInterfaces.ITypedRequest,
|
|
IReq_GetAllEmails
|
|
> {
|
|
method: 'getAllEmails';
|
|
request: {
|
|
identity?: authInterfaces.IIdentity;
|
|
};
|
|
response: {
|
|
emails: IEmail[];
|
|
};
|
|
}
|
|
|
|
// ============================================================================
|
|
// Get Email Detail Request
|
|
// ============================================================================
|
|
export interface IReq_GetEmailDetail extends plugins.typedrequestInterfaces.implementsTR<
|
|
plugins.typedrequestInterfaces.ITypedRequest,
|
|
IReq_GetEmailDetail
|
|
> {
|
|
method: 'getEmailDetail';
|
|
request: {
|
|
identity?: authInterfaces.IIdentity;
|
|
emailId: string;
|
|
};
|
|
response: {
|
|
email: IEmailDetail | null;
|
|
};
|
|
}
|
|
|
|
// ============================================================================
|
|
// Resend Failed Email Request
|
|
// ============================================================================
|
|
export interface IReq_ResendEmail extends plugins.typedrequestInterfaces.implementsTR<
|
|
plugins.typedrequestInterfaces.ITypedRequest,
|
|
IReq_ResendEmail
|
|
> {
|
|
method: 'resendEmail';
|
|
request: {
|
|
identity?: authInterfaces.IIdentity;
|
|
emailId: string;
|
|
};
|
|
response: {
|
|
success: boolean;
|
|
newQueueId?: string;
|
|
error?: string;
|
|
};
|
|
}
|