diff --git a/CHANGELOG.md b/CHANGELOG.md index ea966af..7e00003 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,31 @@ All notable changes to the PayloadCMS Automation Plugin will be documented in th The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.0.39] - 2025-09-11 + +### Changed +- **Breaking Change**: Replaced JSONPath with Handlebars template system for better string interpolation +- Automatic type conversion for numeric and boolean fields based on field names +- Enhanced condition evaluation with Handlebars template support +- Simplified data resolution syntax: `{{steps.stepName.output.field}}` instead of `$.steps.stepName.output.field` + +### Removed +- **Breaking Change**: Removed JSONPath dependency (`jsonpath-plus`) and all backward compatibility +- Removed `resolveJSONPathValue` and `parseConditionValue` methods + +### Added +- Handlebars template engine for dynamic data interpolation +- Smart type conversion: strings to numbers/booleans based on field patterns +- Enhanced template examples and documentation +- Support for complex string building: `"Post {{trigger.doc.title}} was updated"` + +### Migration Notes +- Update all workflow configurations to use Handlebars syntax: + - `$.steps.stepName.output.id` → `{{steps.stepName.output.id}}` + - `$.trigger.doc.status == 'published'` → `{{trigger.doc.status}} == 'published'` +- String interpolation now works naturally: `"Message: {{steps.step1.output.result}}"` +- Numeric fields (`timeout`, `retries`, etc.) are automatically converted from strings to numbers + ## [0.0.38] - 2025-09-10 ### Changed diff --git a/README.md b/README.md index e73396c..3c3a3b2 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ A comprehensive workflow automation plugin for PayloadCMS 3.x that enables visua - ⏰ **Scheduled Workflows** - Use webhook triggers with external cron services - 📊 **Execution Tracking** - Complete history and monitoring of workflow runs - 🔧 **Extensible Steps** - HTTP requests, document CRUD, email notifications -- 🔍 **JSONPath Integration** - Dynamic data interpolation and transformation +- 🔧 **Handlebars Templates** - Dynamic data interpolation with automatic type conversion ## Installation @@ -74,7 +74,7 @@ Make external API calls with comprehensive error handling and retry logic. - Support for GET, POST, PUT, DELETE, PATCH methods - Authentication: Bearer token, Basic auth, API key headers - Configurable timeouts and retry logic -- JSONPath integration for dynamic URLs and request bodies +- Handlebars templates for dynamic URLs and request bodies **Error Handling:** HTTP Request steps use a **response-based success model** rather than status-code-based failures: @@ -95,7 +95,7 @@ HTTP Request steps use a **response-based success model** rather than status-cod } // Use in workflow conditions: -// "$.steps.apiRequest.output.status >= 400" to handle errors +// "{{steps.apiRequest.output.status}} >= 400" to handle errors ``` This design allows workflows to handle HTTP errors gracefully rather than failing completely, enabling robust error handling and retry logic. @@ -132,8 +132,8 @@ For network failures (timeouts, DNS errors, connection failures), the plugin pro } // Access in workflow conditions: -// "$.steps.httpStep.errorDetails.errorType == 'timeout'" -// "$.steps.httpStep.errorDetails.duration > 5000" +// "{{steps.httpStep.errorDetails.errorType}} == 'timeout'" +// "{{steps.httpStep.errorDetails.duration}} > 5000" ``` ### Document Operations @@ -147,11 +147,39 @@ For network failures (timeouts, DNS errors, connection failures), the plugin pro ## Data Resolution -Use JSONPath to access workflow data: +Use Handlebars templates to access workflow data: -- `$.trigger.doc.id` - Access trigger document -- `$.steps.stepName.output` - Use previous step outputs -- `$.context` - Access workflow context +- `{{trigger.doc.id}}` - Access trigger document +- `{{steps.stepName.output}}` - Use previous step outputs +- `{{context}}` - Access workflow context + +### Template Examples + +```json +{ + "url": "https://api.example.com/posts/{{steps.createPost.output.id}}", + "message": "Post {{trigger.doc.title}} was updated by {{trigger.req.user.email}}", + "timeout": "{{steps.configStep.output.timeoutMs}}" +} +``` + +### Automatic Type Conversion + +Handlebars templates automatically convert string results to appropriate types based on field names: + +- **Numbers**: `timeout`, `retries`, `delay`, `port`, `count`, etc. → converted to numbers +- **Booleans**: `enabled`, `active`, `success`, `complete`, etc. → converted to booleans +- **Numeric strings**: `"5000"` → `5000`, `"3.14"` → `3.14` + +### Conditions + +Conditions support Handlebars templates with comparison operators: + +```json +{ + "condition": "{{trigger.doc.status}} == 'published'" +} +``` ## Requirements