š Transformation System
The transformation system enables flexible content processing through a pipeline of transformer plugins. Each transformer can modify, enhance, or restructure content as it flows through the system.
šļø Architectureā
Transform Pipelineā
Content flows through three possible transformation stages:
- Global Stream Transforms: Applied to all content in a feed's stream
- Per-Distributor Transforms: Applied to content for specific distributors
- Recap Transforms: Applied to content in scheduled recaps
Each stage can have multiple transforms that are applied in sequence, with the output of one transform becoming the input for the next.
Configuration Placementā
Transforms can be configured in three locations in your curate.config.json
:
{
"feeds": [{
"outputs": {
"stream": {
"transform": [
// Global stream transforms
// Applied to all content in this feed's stream
],
"distribute": [{
"transform": [
// Per-distributor transforms
// Applied only to content going to this distributor
]
}]
},
"recap": {
"transform": [
// Recap transforms
// Applied to content in scheduled recaps
]
}
}
}]
}
š Available Transformersā
- Simple Transform - String-based formatting using templates
- Object Transform - Object-to-object mapping using templates
- AI Transform - Content enhancement using AI
š Type Safetyā
Transformers use TypeScript generics to ensure type safety between transforms:
interface TransformerPlugin<TInput, TOutput, TConfig> {
transform(args: { input: TInput, config: TConfig }): Promise<TOutput>;
}
When chaining transforms, ensure the output type of one transform matches the input type expected by the next transform in the chain.
š Best Practicesā
- Use Global Transforms for standardizing data structure across all distributors
- Use Per-Distributor Transforms for format-specific requirements
- Chain Transforms to break down complex transformations into manageable steps
- Consider Type Safety when designing transform chains
- Document Input/Output Types for custom transformers
Start with a global transform to create a consistent data structure, then use per-distributor transforms to format that data for specific outputs.
š Transform Flowā
The transformation process follows a sequential flow:
- Content Input: The original content enters the transformation system
- Global Transform: Content passes through global transforms that apply to all content in a feed
- Per-Distributor Transform: Content is then processed by distributor-specific transforms
- Final Output: The fully transformed content is ready for distribution
This sequential approach allows for both general standardization and platform-specific formatting.
š Example Transform Chainā
Here's an example of chaining transforms to process content:
- First, use Object Transform to standardize the data structure:
{
"plugin": "@curatedotfun/object-transform",
"config": {
"mappings": {
"title": "{{content|truncate:100}}",
"text": "{{content}}",
"author": "{{firstName}} {{lastName}}",
"source": "https://x.com/{{username}}/status/{{submissionId}}"
}
}
}
- Then, use AI Transform to enhance the content:
{
"plugin": "@curatedotfun/ai-transform",
"config": {
"prompt": "Analyze and enhance the content...",
"schema": {
"title": {
"type": "string",
"description": "An engaging title"
},
"summary": {
"type": "string",
"description": "A concise summary"
}
}
}
}
- Finally, use Simple Transform to format for distribution:
{
"plugin": "@curatedotfun/simple-transform",
"config": {
"template": "š¢ {{title}}\n\n{{summary}}\n\nš¤ {{author}}\nš {{source}}"
}
}
This chain:
- Standardizes the data structure
- Enhances the content with AI
- Formats it for final distribution