Merge pull request #26 from xtr-dev/dev

Refactor `sendEmail` to improve type safety and align with `BaseEmail…
This commit is contained in:
Bas
2025-09-13 22:41:28 +02:00
committed by GitHub
2 changed files with 4 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@xtr-dev/payload-mailing",
"version": "0.1.9",
"version": "0.1.10",
"description": "Template-based email system with scheduling and job processing for PayloadCMS",
"type": "module",
"main": "dist/index.js",

View File

@@ -1,9 +1,10 @@
import { Payload } from 'payload'
import { getMailing, renderTemplate, parseAndValidateEmails } from './utils/helpers.js'
import {Email} from "./payload-types.js"
import {BaseEmail} from "./types/index.js"
// Options for sending emails
export interface SendEmailOptions<T extends Email = Email> {
export interface SendEmailOptions<T extends BaseEmail = BaseEmail> {
// Template-based email
template?: {
slug: string
@@ -35,7 +36,7 @@ export interface SendEmailOptions<T extends Email = Email> {
* })
* ```
*/
export const sendEmail = async <T extends Email = Email>(
export const sendEmail = async <T extends BaseEmail = BaseEmail>(
payload: Payload,
options: SendEmailOptions<T>
): Promise<T> => {