diff --git a/package.json b/package.json index 1d3c761..8448d49 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@xtr-dev/payload-mailing", - "version": "0.1.18", + "version": "0.1.19", "description": "Template-based email system with scheduling and job processing for PayloadCMS", "type": "module", "main": "dist/index.js", diff --git a/src/payload-types.ts b/src/payload-types.ts index 08838c9..2f762f5 100644 --- a/src/payload-types.ts +++ b/src/payload-types.ts @@ -143,6 +143,10 @@ export interface Email { * Sender email address (optional, uses default if not provided) */ from?: string | null; + /** + * Sender display name (optional, e.g., "John Doe" for "John Doe ") + */ + fromName?: string | null; /** * Reply-to email address */ @@ -336,6 +340,7 @@ export interface EmailsSelect { cc?: T; bcc?: T; from?: T; + fromName?: T; replyTo?: T; subject?: T; html?: T; diff --git a/src/plugin.ts b/src/plugin.ts index a447526..89ce6b6 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -74,10 +74,15 @@ export const mailingPlugin = (pluginConfig: MailingPluginConfig) => (config: Con }), } satisfies CollectionConfig + // Filter out any existing collections with the same slugs to prevent duplicates + const existingCollections = (config.collections || []).filter( + (collection) => collection.slug !== templatesSlug && collection.slug !== emailsSlug + ) + return { ...config, collections: [ - ...(config.collections || []), + ...existingCollections, templatesCollection, emailsCollection, ],