mirror of
https://github.com/xtr-dev/payload-automation.git
synced 2025-12-11 09:13:24 +00:00
Major Features: • Add persistent error tracking for timeout/network failures that bypasses PayloadCMS output limitations • Implement smart error classification (timeout, DNS, connection, network) with duration-based detection • Add comprehensive test infrastructure with MongoDB in-memory testing and enhanced mocking • Fix HTTP request handler error preservation with detailed context storage • Add independent execution tracking with success/failure status and duration metrics Technical Improvements: • Update JSONPath documentation to use correct $.trigger.doc syntax across all step types • Fix PayloadCMS job execution to use runByID instead of run() for reliable task processing • Add enhanced HTTP error handling that preserves outputs for 4xx/5xx status codes • Implement proper nock configuration with undici for Node.js 22 fetch interception • Add comprehensive unit tests for WorkflowExecutor with mocked PayloadCMS instances Developer Experience: • Add detailed error information in workflow context with URL, method, timeout, attempts • Update README with HTTP error handling patterns and enhanced error tracking examples • Add test helpers and setup infrastructure for reliable integration testing • Fix workflow step validation and JSONPath field descriptions Breaking Changes: None - fully backward compatible 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
79 lines
1.9 KiB
TypeScript
79 lines
1.9 KiB
TypeScript
import type { TaskConfig } from "payload"
|
|
|
|
import { sendEmailHandler } from "./send-email-handler.js"
|
|
|
|
export const SendEmailStepTask = {
|
|
slug: 'send-email',
|
|
handler: sendEmailHandler,
|
|
inputSchema: [
|
|
{
|
|
name: 'to',
|
|
type: 'text',
|
|
admin: {
|
|
description: 'Recipient email address. Use JSONPath for dynamic values (e.g., "$.trigger.doc.email" or "$.trigger.user.email")'
|
|
},
|
|
required: true
|
|
},
|
|
{
|
|
name: 'from',
|
|
type: 'text',
|
|
admin: {
|
|
description: 'Sender email address. Use JSONPath if needed (e.g., "$.trigger.doc.senderEmail"). Uses default if not provided.'
|
|
}
|
|
},
|
|
{
|
|
name: 'subject',
|
|
type: 'text',
|
|
admin: {
|
|
description: 'Email subject line. Can include JSONPath references (e.g., "Order #$.trigger.doc.orderNumber received")'
|
|
},
|
|
required: true
|
|
},
|
|
{
|
|
name: 'text',
|
|
type: 'textarea',
|
|
admin: {
|
|
description: 'Plain text email content. Use JSONPath to include dynamic content (e.g., "Dear $.trigger.doc.customerName, your order #$.trigger.doc.id has been received.")'
|
|
}
|
|
},
|
|
{
|
|
name: 'html',
|
|
type: 'textarea',
|
|
admin: {
|
|
description: 'HTML email content. Use JSONPath for dynamic values (e.g., "<h1>Order #$.trigger.doc.orderNumber</h1>")'
|
|
}
|
|
},
|
|
{
|
|
name: 'cc',
|
|
type: 'text',
|
|
admin: {
|
|
description: 'CC recipients'
|
|
},
|
|
hasMany: true
|
|
},
|
|
{
|
|
name: 'bcc',
|
|
type: 'text',
|
|
admin: {
|
|
description: 'BCC recipients'
|
|
},
|
|
hasMany: true
|
|
}
|
|
],
|
|
outputSchema: [
|
|
{
|
|
name: 'messageId',
|
|
type: 'text',
|
|
admin: {
|
|
description: 'Email message ID from the mail server'
|
|
}
|
|
},
|
|
{
|
|
name: 'response',
|
|
type: 'text',
|
|
admin: {
|
|
description: 'Response from the mail server'
|
|
}
|
|
}
|
|
]
|
|
} satisfies TaskConfig<'send-email'> |