feat: Add support for custom email recipients in workflow steps
This commit is contained in:
@@ -208,6 +208,27 @@ export const WorkflowSchemas = {
|
||||
};
|
||||
|
||||
export const WorkflowStepConfigSchemas = {
|
||||
sendEmail: z.object({
|
||||
templateId: uuid,
|
||||
recipient: z
|
||||
.object({
|
||||
type: z.enum(['CONTACT', 'CUSTOM']),
|
||||
customEmail: email.optional(),
|
||||
})
|
||||
.refine(
|
||||
data => {
|
||||
// If type is CUSTOM, customEmail must be provided
|
||||
if (data.type === 'CUSTOM') {
|
||||
return !!data.customEmail;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
{
|
||||
message: 'Custom email is required when recipient type is CUSTOM',
|
||||
},
|
||||
)
|
||||
.optional(),
|
||||
}),
|
||||
delay: z
|
||||
.object({
|
||||
amount: z.number().positive(),
|
||||
|
||||
@@ -26,3 +26,6 @@ export * from './segments/index.js';
|
||||
|
||||
// Security types
|
||||
export * from './security/index.js';
|
||||
|
||||
// Workflow types
|
||||
export * from './workflows/index.js';
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Workflow-specific type definitions
|
||||
*/
|
||||
|
||||
/**
|
||||
* Recipient type for workflow email steps
|
||||
*/
|
||||
export enum EmailRecipientType {
|
||||
/** Send to the contact that triggered the workflow */
|
||||
CONTACT = 'CONTACT',
|
||||
/** Send to a custom email address */
|
||||
CUSTOM = 'CUSTOM',
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for email recipient in SEND_EMAIL workflow step
|
||||
*/
|
||||
export interface EmailRecipientConfig {
|
||||
/** Type of recipient */
|
||||
type: EmailRecipientType;
|
||||
/** Custom email address (required when type is CUSTOM) */
|
||||
customEmail?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for SEND_EMAIL workflow step
|
||||
*/
|
||||
export interface SendEmailStepConfig {
|
||||
/** Template ID to use for the email */
|
||||
templateId: string;
|
||||
/** Recipient configuration */
|
||||
recipient?: EmailRecipientConfig;
|
||||
}
|
||||
Reference in New Issue
Block a user