Update documentation for v0.0.39 Handlebars template system

- Replace JSONPath references with Handlebars syntax
- Add comprehensive template examples and type conversion docs
- Update CHANGELOG with v0.0.39 breaking changes and migration notes

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-11 21:37:55 +02:00
parent f29f08972b
commit 4c513aa730
2 changed files with 62 additions and 9 deletions

View File

@@ -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/), 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). 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 ## [0.0.38] - 2025-09-10
### Changed ### Changed

View File

@@ -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 -**Scheduled Workflows** - Use webhook triggers with external cron services
- 📊 **Execution Tracking** - Complete history and monitoring of workflow runs - 📊 **Execution Tracking** - Complete history and monitoring of workflow runs
- 🔧 **Extensible Steps** - HTTP requests, document CRUD, email notifications - 🔧 **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 ## Installation
@@ -74,7 +74,7 @@ Make external API calls with comprehensive error handling and retry logic.
- Support for GET, POST, PUT, DELETE, PATCH methods - Support for GET, POST, PUT, DELETE, PATCH methods
- Authentication: Bearer token, Basic auth, API key headers - Authentication: Bearer token, Basic auth, API key headers
- Configurable timeouts and retry logic - Configurable timeouts and retry logic
- JSONPath integration for dynamic URLs and request bodies - Handlebars templates for dynamic URLs and request bodies
**Error Handling:** **Error Handling:**
HTTP Request steps use a **response-based success model** rather than status-code-based failures: 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: // 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. 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: // Access in workflow conditions:
// "$.steps.httpStep.errorDetails.errorType == 'timeout'" // "{{steps.httpStep.errorDetails.errorType}} == 'timeout'"
// "$.steps.httpStep.errorDetails.duration > 5000" // "{{steps.httpStep.errorDetails.duration}} > 5000"
``` ```
### Document Operations ### Document Operations
@@ -147,11 +147,39 @@ For network failures (timeouts, DNS errors, connection failures), the plugin pro
## Data Resolution ## Data Resolution
Use JSONPath to access workflow data: Use Handlebars templates to access workflow data:
- `$.trigger.doc.id` - Access trigger document - `{{trigger.doc.id}}` - Access trigger document
- `$.steps.stepName.output` - Use previous step outputs - `{{steps.stepName.output}}` - Use previous step outputs
- `$.context` - Access workflow context - `{{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 ## Requirements