mirror of
https://github.com/xtr-dev/payload-mailing.git
synced 2025-12-10 08:13:23 +00:00
Fix critical type safety and validation issues
Issue 2 - Type Safety: - Remove dangerous 'as any' casts in sendEmail function - Use proper typing for payload.create() calls - Maintain type safety throughout email creation process Issue 3 - Email Validation: - Implement RFC 5322 compliant email regex - Add comprehensive validation for common invalid patterns - Check for consecutive dots, invalid domain formats - Prevent emails like 'test@.com' and 'test@domain.' Issue 4 - Error Message Logic: - Add contextual error messages for template vs direct email modes - Distinguish between template rendering failures and missing direct email content - Provide clearer guidance to developers on what went wrong Additional fixes: - Update imports to use generated Email type instead of BaseEmailData - Maintain compatibility with updated sendEmail interface 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { sendEmail, type BaseEmailData } from '../sendEmail.js'
|
||||
import { sendEmail } from '../sendEmail.js'
|
||||
import { Email } from '../payload-types.js'
|
||||
|
||||
export interface SendEmailTaskInput {
|
||||
// Template mode fields
|
||||
@@ -153,7 +154,7 @@ export const sendEmailJob = {
|
||||
})
|
||||
|
||||
// Use the sendEmail helper to create the email
|
||||
const email = await sendEmail<BaseEmailData>(payload, sendEmailOptions)
|
||||
const email = await sendEmail<Email>(payload, sendEmailOptions)
|
||||
|
||||
return {
|
||||
output: {
|
||||
|
||||
Reference in New Issue
Block a user