UNPKG

@454creative/easy-email

Version:

A framework-agnostic email service library for Node.js with observability and monitoring

260 lines 6.56 kB
/** * SendGrid-specific TypeScript types and constants */ import { SendGridConfig } from '../interfaces/email-options.interface'; export type { SendGridConfig }; /** * SendGrid Error Types */ export type SendGridErrorType = 'Unauthorized' | 'Forbidden' | 'BadRequest' | 'NotFound' | 'TooManyRequests' | 'InternalServerError' | 'ServiceUnavailable' | 'GatewayTimeout' | 'InvalidEmail' | 'InvalidSender' | 'InvalidRecipient' | 'InvalidTemplate' | 'InvalidAttachment' | 'RateLimitExceeded' | 'QuotaExceeded' | 'NetworkError' | 'TimeoutError'; /** * SendGrid Error Types Array */ export declare const SENDGRID_ERROR_TYPES: SendGridErrorType[]; /** * SendGrid Metrics Interface */ export interface SendGridMetrics { quotaUsage: number; deliveryRate: number; bounceRate: number; spamReportRate: number; lastQuotaCheck?: string; } /** * SendGrid Quota Data Interface */ export interface SendGridQuotaData { dailyQuota: number; dailyUsed: number; monthlyQuota: number; monthlyUsed: number; remainingQuota: number; } /** * SendGrid Statistics Data Interface */ export interface SendGridStatisticsData { delivered: number; bounces: number; spamReports: number; opens: number; clicks: number; unsubscribes: number; } /** * SendGrid Email Event Interface */ export interface SendGridEmailEvent { id: string; timestamp: string; type: 'email_sent' | 'email_failed'; provider: 'sendgrid'; recipient?: string; subject?: string; messageId?: string; duration?: number; error?: { message: string; code: SendGridErrorType; details?: { sendgridErrorType: SendGridErrorType; originalError: any; statusCode?: number; }; }; metadata?: Record<string, any>; } /** * SendGrid Connection Event Interface */ export interface SendGridConnectionEvent { id: string; timestamp: string; type: 'connection_verified' | 'connection_failed'; provider: 'sendgrid'; duration?: number; error?: { message: string; code: string; }; } /** * SendGrid Quota Event Interface */ export interface SendGridQuotaEvent { id: string; timestamp: string; type: 'connection_verified'; provider: 'sendgrid'; metadata: { quotaUsage: number; dailyQuota: number; dailyUsed: number; monthlyQuota: number; monthlyUsed: number; remainingQuota: number; }; } /** * SendGrid Statistics Event Interface */ export interface SendGridStatisticsEvent { id: string; timestamp: string; type: 'connection_verified'; provider: 'sendgrid'; metadata: { deliveryRate: number; bounceRate: number; spamReportRate: number; openRate: number; clickRate: number; unsubscribeRate: number; delivered: number; bounces: number; spamReports: number; opens: number; clicks: number; unsubscribes: number; }; } /** * SendGrid Error Event Interface */ export interface SendGridErrorEvent { id: string; timestamp: string; type: 'email_failed'; provider: 'sendgrid'; duration: number; error: { message: string; code: SendGridErrorType; details: { sendgridErrorType: SendGridErrorType; originalError: any; statusCode?: number; }; }; metadata: { errorType: SendGridErrorType; duration: number; statusCode?: number; }; } /** * SendGrid Error Codes */ export declare const SENDGRID_ERROR_CODES: { readonly UNAUTHORIZED: "Unauthorized"; readonly FORBIDDEN: "Forbidden"; readonly BAD_REQUEST: "BadRequest"; readonly NOT_FOUND: "NotFound"; readonly TOO_MANY_REQUESTS: "TooManyRequests"; readonly INTERNAL_SERVER_ERROR: "InternalServerError"; readonly SERVICE_UNAVAILABLE: "ServiceUnavailable"; readonly GATEWAY_TIMEOUT: "GatewayTimeout"; readonly INVALID_EMAIL: "InvalidEmail"; readonly INVALID_SENDER: "InvalidSender"; readonly INVALID_RECIPIENT: "InvalidRecipient"; readonly INVALID_TEMPLATE: "InvalidTemplate"; readonly INVALID_ATTACHMENT: "InvalidAttachment"; readonly RATE_LIMIT_EXCEEDED: "RateLimitExceeded"; readonly QUOTA_EXCEEDED: "QuotaExceeded"; readonly NETWORK_ERROR: "NetworkError"; readonly TIMEOUT_ERROR: "TimeoutError"; }; /** * SendGrid Default Configuration */ export declare const SENDGRID_DEFAULT_CONFIG: SendGridConfig; /** * SendGrid API Response Interface */ export interface SendGridApiResponse { messageId: string; statusCode: number; headers: Record<string, string>; body?: any; } /** * SendGrid Email Content Interface */ export interface SendGridEmailContent { type: 'text/plain' | 'text/html'; value: string; } /** * SendGrid Personalization Interface */ export interface SendGridPersonalization { to: Array<{ email: string; name?: string; }>; cc?: Array<{ email: string; name?: string; }>; bcc?: Array<{ email: string; name?: string; }>; subject?: string; headers?: Record<string, string>; substitutions?: Record<string, string>; dynamicTemplateData?: Record<string, any>; customArgs?: Record<string, string>; sendAt?: number; } /** * SendGrid Mail Settings Interface */ export interface SendGridMailSettings { bypassListManagement?: boolean; bypassSpamManagement?: boolean; bypassBounceManagement?: boolean; bypassUnsubscribeManagement?: boolean; footer?: { enable?: boolean; text?: string; html?: string; }; sandboxMode?: { enable?: boolean; }; spamCheck?: { enable?: boolean; threshold?: number; postToUrl?: string; }; } /** * SendGrid Tracking Settings Interface */ export interface SendGridTrackingSettings { clickTracking?: { enable?: boolean; enableText?: boolean; }; openTracking?: { enable?: boolean; substitutionTag?: string; }; subscriptionTracking?: { enable?: boolean; text?: string; html?: string; substitutionTag?: string; }; ganalytics?: { enable?: boolean; utmSource?: string; utmMedium?: string; utmTerm?: string; utmContent?: string; utmCampaign?: string; }; } //# sourceMappingURL=sendgrid.types.d.ts.map