From 965569be0665bd968710de21279ea71f71670788 Mon Sep 17 00:00:00 2001 From: Bas van den Aakster Date: Sat, 13 Sep 2025 23:44:57 +0200 Subject: [PATCH] Add Date type support for timestamp fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update scheduledAt, sentAt, lastAttemptAt, createdAt, updatedAt fields to support Date | string | null - Support both Date objects and ISO string formats for all timestamp fields - Update BaseEmailDocument, BaseEmailTemplateDocument, and QueuedEmail interfaces consistently - Update documentation to reflect Date object compatibility Fixes type constraint error where customer timestamp fields use Date objects but plugin interfaces only supported string formats. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- CUSTOM-TYPES.md | 16 +++++++++------- src/types/index.ts | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/CUSTOM-TYPES.md b/CUSTOM-TYPES.md index fefd8f9..602deea 100644 --- a/CUSTOM-TYPES.md +++ b/CUSTOM-TYPES.md @@ -44,6 +44,8 @@ The plugin works with: - **String IDs**: `id: string` - **Number IDs**: `id: number` - **Nullable fields**: Fields can be `null`, `undefined`, or have values +- **Date fields**: Timestamp fields support both `Date` objects and `string` (ISO) formats +- **JSON variables**: Variables field supports any JSON-compatible value type - **Generated types**: Works with `payload generate:types` output Your Payload configuration determines which types are used. The plugin automatically adapts to your setup. @@ -68,15 +70,15 @@ interface BaseEmailDocument { html: string text?: string | null variables?: JSONValue // Supports any JSON-compatible value - scheduledAt?: string | null - sentAt?: string | null + scheduledAt?: string | Date | null + sentAt?: string | Date | null status?: 'pending' | 'processing' | 'sent' | 'failed' | null attempts?: number | null - lastAttemptAt?: string | null + lastAttemptAt?: string | Date | null error?: string | null priority?: number | null - createdAt?: string | null - updatedAt?: string | null + createdAt?: string | Date | null + updatedAt?: string | Date | null } interface BaseEmailTemplateDocument { @@ -85,8 +87,8 @@ interface BaseEmailTemplateDocument { slug: string subject?: string | null content?: any - createdAt?: string | null - updatedAt?: string | null + createdAt?: string | Date | null + updatedAt?: string | Date | null } ``` diff --git a/src/types/index.ts b/src/types/index.ts index bf8d462..bcd947f 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -18,15 +18,15 @@ export interface BaseEmailDocument { html: string text?: string | null variables?: JSONValue - scheduledAt?: string | null - sentAt?: string | null + scheduledAt?: string | Date | null + sentAt?: string | Date | null status?: 'pending' | 'processing' | 'sent' | 'failed' | null attempts?: number | null - lastAttemptAt?: string | null + lastAttemptAt?: string | Date | null error?: string | null priority?: number | null - createdAt?: string | null - updatedAt?: string | null + createdAt?: string | Date | null + updatedAt?: string | Date | null } export interface BaseEmailTemplateDocument { @@ -35,8 +35,8 @@ export interface BaseEmailTemplateDocument { slug: string subject?: string | null content?: any - createdAt?: string | null - updatedAt?: string | null + createdAt?: string | Date | null + updatedAt?: string | Date | null } export type BaseEmail = Omit & {template: Omit | TEmailTemplate['id'] | undefined | null} @@ -88,11 +88,11 @@ export interface QueuedEmail { html: string text?: string | null variables?: JSONValue - scheduledAt?: string | null - sentAt?: string | null + scheduledAt?: string | Date | null + sentAt?: string | Date | null status: 'pending' | 'processing' | 'sent' | 'failed' attempts: number - lastAttemptAt?: string | null + lastAttemptAt?: string | Date | null error?: string | null priority?: number | null createdAt: string