Fix critical issues and enhance PayloadCMS automation plugin

## Critical Fixes Implemented:

### 1. Hook Execution Reliability (src/plugin/index.ts)
- Replaced fragile global variable pattern with proper dependency injection
- Added structured executor registry with initialization tracking
- Implemented proper logging using PayloadCMS logger instead of console
- Added graceful handling for executor unavailability scenarios

### 2. Error Handling & Workflow Run Tracking
- Fixed error swallowing in hook execution
- Added createFailedWorkflowRun() to track hook execution failures
- Improved error categorization and user-friendly error messages
- Enhanced workflow run status tracking with detailed context

### 3. Enhanced HTTP Step (src/steps/)
- Complete rewrite of HTTP request handler with enterprise features:
  - Multiple authentication methods (Bearer, Basic Auth, API Key)
  - Configurable timeouts and retry logic with exponential backoff
  - Comprehensive error handling for different failure scenarios
  - Support for all HTTP methods with proper request/response parsing
  - Request duration tracking and detailed logging

### 4. User Experience Improvements
- Added StatusCell component with visual status indicators
- Created ErrorDisplay component with user-friendly error explanations
- Added WorkflowExecutionStatus component for real-time execution monitoring
- Enhanced collections with better error display and conditional fields

### 5. Comprehensive Testing Suite
- Added hook-reliability.spec.ts: Tests executor availability and concurrent execution
- Added error-scenarios.spec.ts: Tests timeout, network, validation, and HTTP errors
- Added webhook-triggers.spec.ts: Tests webhook endpoints, conditions, and concurrent requests
- Fixed existing test to work with enhanced HTTP step schema

## Technical Improvements:
- Proper TypeScript interfaces for all new components
- Safe serialization handling for circular references
- Comprehensive logging with structured data
- Modular component architecture with proper exports
- Enhanced collection schemas with conditional field visibility

## Impact:
- Eliminates silent workflow execution failures
- Provides clear error visibility for users
- Makes HTTP requests production-ready with auth and retry capabilities
- Significantly improves debugging and monitoring experience
- Adds comprehensive test coverage for reliability

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-04 11:42:45 +02:00
parent 253de9b8b0
commit 04100787d7
13 changed files with 2574 additions and 74 deletions

View File

@@ -39,27 +39,30 @@ export const WorkflowRunsCollection: CollectionConfig = {
type: 'select',
admin: {
description: 'Current execution status',
components: {
Cell: '@/components/StatusCell'
}
},
defaultValue: 'pending',
options: [
{
label: 'Pending',
label: 'Pending',
value: 'pending',
},
{
label: 'Running',
label: '🔄 Running',
value: 'running',
},
{
label: 'Completed',
label: 'Completed',
value: 'completed',
},
{
label: 'Failed',
label: 'Failed',
value: 'failed',
},
{
label: 'Cancelled',
label: '⏹️ Cancelled',
value: 'cancelled',
},
],
@@ -136,6 +139,10 @@ export const WorkflowRunsCollection: CollectionConfig = {
type: 'textarea',
admin: {
description: 'Error message if workflow execution failed',
condition: (_, siblingData) => siblingData?.status === 'failed',
components: {
Field: '@/components/ErrorDisplay'
}
},
},
{