466e55a015
* fix: reconcile annual reports with final closing entries * test: cover annual report depreciation and VAT balances * Merge remote-tracking branch 'origin/main' into fix/usr-fdbck-ch * fix: show exact invoice delivery details * fix: use currency account in invoice emails * fix: address invoice delivery review feedback * fix: harden invoice delivery and payment accounts * test: assert RLS-denied zero-row updates * fix: close remaining invoice compliance gaps * fix: harden invoice archive authorization * fix: close invoice delivery review findings * fix: verify delivery finalization results * fix: cap combined invoice email recipients * fix: close final invoice compliance findings * fix: prevent stale payment account saves * test: prove invoice delivery isolation * fix: close invoice privacy review findings * test: normalize delivery retention dates
55 lines
1.2 KiB
TypeScript
55 lines
1.2 KiB
TypeScript
/**
|
|
* Email Service Interface
|
|
*
|
|
* Core defines the contract. The email extension registers a real
|
|
* implementation (Resend). Without the extension, a no-op service
|
|
* is used: email-dependent features degrade gracefully.
|
|
*/
|
|
|
|
export interface SendEmailOptions {
|
|
to: string | string[]
|
|
cc?: string | string[]
|
|
bcc?: string | string[]
|
|
subject: string
|
|
html: string
|
|
text?: string
|
|
replyTo?: string
|
|
fromName?: string
|
|
attachments?: Array<{
|
|
filename: string
|
|
content: Buffer | string
|
|
contentType?: string
|
|
}>
|
|
}
|
|
|
|
export interface SendEmailResult {
|
|
success: boolean
|
|
provider?: string
|
|
messageId?: string
|
|
error?: string
|
|
}
|
|
|
|
export interface EmailService {
|
|
sendEmail(options: SendEmailOptions): Promise<SendEmailResult>
|
|
isConfigured(): boolean
|
|
}
|
|
|
|
class NoopEmailService implements EmailService {
|
|
async sendEmail(): Promise<SendEmailResult> {
|
|
return { success: false, error: 'Email service not configured' }
|
|
}
|
|
isConfigured(): boolean {
|
|
return false
|
|
}
|
|
}
|
|
|
|
let emailService: EmailService = new NoopEmailService()
|
|
|
|
export function getEmailService(): EmailService {
|
|
return emailService
|
|
}
|
|
|
|
export function registerEmailService(svc: EmailService): void {
|
|
emailService = svc
|
|
}
|