mirror of
https://github.com/xtr-dev/payload-mailing.git
synced 2025-12-10 16:23:23 +00:00
Add null value support to BaseEmailDocument interface
- Update BaseEmailDocument to support `| null` for optional fields (cc, bcc, from, replyTo, text, etc.) - Update BaseEmailTemplateDocument to support `| null` for optional fields - Add explicit null checks in sendEmail processing to handle null values properly - Update CUSTOM-TYPES.md documentation to reflect null value compatibility Fixes type constraint error where customer Email types had `cc?: string[] | null` but BaseEmailDocument only supported `cc?: string[]`. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -38,13 +38,15 @@ const customEmail = await sendEmail<MyEmail>(payload, {
|
||||
})
|
||||
```
|
||||
|
||||
## ID Type Compatibility
|
||||
## Compatibility
|
||||
|
||||
The plugin works with both:
|
||||
The plugin works with:
|
||||
- **String IDs**: `id: string`
|
||||
- **Number IDs**: `id: number`
|
||||
- **Nullable fields**: Fields can be `null`, `undefined`, or have values
|
||||
- **Generated types**: Works with `payload generate:types` output
|
||||
|
||||
Your Payload configuration determines which type is used. The plugin automatically adapts to your setup.
|
||||
Your Payload configuration determines which types are used. The plugin automatically adapts to your setup.
|
||||
|
||||
## Type Definitions
|
||||
|
||||
@@ -55,33 +57,33 @@ interface BaseEmailDocument {
|
||||
id: string | number
|
||||
template?: any
|
||||
to: string[]
|
||||
cc?: string[]
|
||||
bcc?: string[]
|
||||
from?: string
|
||||
replyTo?: string
|
||||
cc?: string[] | null
|
||||
bcc?: string[] | null
|
||||
from?: string | null
|
||||
replyTo?: string | null
|
||||
subject: string
|
||||
html: string
|
||||
text?: string
|
||||
variables?: Record<string, any>
|
||||
scheduledAt?: string
|
||||
sentAt?: string
|
||||
status?: 'pending' | 'processing' | 'sent' | 'failed'
|
||||
attempts?: number
|
||||
lastAttemptAt?: string
|
||||
error?: string
|
||||
priority?: number
|
||||
createdAt?: string
|
||||
updatedAt?: string
|
||||
text?: string | null
|
||||
variables?: Record<string, any> | null
|
||||
scheduledAt?: string | null
|
||||
sentAt?: string | null
|
||||
status?: 'pending' | 'processing' | 'sent' | 'failed' | null
|
||||
attempts?: number | null
|
||||
lastAttemptAt?: string | null
|
||||
error?: string | null
|
||||
priority?: number | null
|
||||
createdAt?: string | null
|
||||
updatedAt?: string | null
|
||||
}
|
||||
|
||||
interface BaseEmailTemplateDocument {
|
||||
id: string | number
|
||||
name: string
|
||||
slug: string
|
||||
subject?: string
|
||||
subject?: string | null
|
||||
content?: any
|
||||
createdAt?: string
|
||||
updatedAt?: string
|
||||
createdAt?: string | null
|
||||
updatedAt?: string | null
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user