Files
payload-automation/src/steps/read-document.ts
Bas van den Aakster 74217d532d Implement independent error storage system and comprehensive improvements
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>
2025-09-04 18:03:30 +02:00

76 lines
1.8 KiB
TypeScript

import type { TaskConfig } from "payload"
import { readDocumentHandler } from "./read-document-handler.js"
export const ReadDocumentStepTask = {
slug: 'read-document',
handler: readDocumentHandler,
inputSchema: [
{
name: 'collectionSlug',
type: 'text',
admin: {
description: 'The collection slug to read from'
},
required: true
},
{
name: 'id',
type: 'text',
admin: {
description: 'The ID of a specific document to read. Use JSONPath (e.g., "$.trigger.doc.relatedId"). Leave empty to find multiple.'
}
},
{
name: 'where',
type: 'json',
admin: {
description: 'Query conditions to find documents when ID is not provided. Use JSONPath in values (e.g., {"category": "$.trigger.doc.category", "status": "published"})'
}
},
{
name: 'limit',
type: 'number',
admin: {
description: 'Maximum number of documents to return (default: 10)'
}
},
{
name: 'sort',
type: 'text',
admin: {
description: 'Field to sort by (prefix with - for descending order)'
}
},
{
name: 'locale',
type: 'text',
admin: {
description: 'Locale for the document (if localization is enabled)'
}
},
{
name: 'depth',
type: 'number',
admin: {
description: 'Depth of relationships to populate (0-10)'
}
}
],
outputSchema: [
{
name: 'doc',
type: 'json',
admin: {
description: 'The document(s) found'
}
},
{
name: 'totalDocs',
type: 'number',
admin: {
description: 'Total number of documents matching the query'
}
}
]
} satisfies TaskConfig<'read-document'>