Spec Version:
Transformation YAML Reference Beta
- free
- growth
- enterprise
7 minute read
This guide provides a complete YAML reference for managing transformation resources using Rudder CLI.
Overview
You can define transformation resources in YAML files anywhere inside your CLI project directory. Rudder CLI scans the project recursively and processes valid resource files.
Supported resource kinds for this workflow:
transformationtransformation-library
Transformation resource
Use kind: transformation to define a transformation.
spec properties
tests properties
| Property | Type | Description |
|---|---|---|
nameRequired | String | Test suite name. Must be non-empty and can contain only letters, numbers, spaces, _, -, and /. |
input | String | Directory with JSON input payload files. Relative paths resolve from the spec directory. If omitted, default is ./input. |
output | String | Directory with expected output JSON files. Relative paths resolve from the spec directory. If omitted, default is ./output. |
Rudder CLI tests the transformation using default RudderStack events if:
spec.testsis not configured, or- No input JSON files are found in the specified
inputpath
Validation rules
Transformation imports must resolve to existing transformation libraries
Rule ID: transformations/transformation/semantic-valid
Examples
Transformation spec syntax must be valid
Rule ID: transformations/transformation/spec-syntax-valid
Examples
Transformation library resource
Use kind: transformation-library to define a reusable transformation library.
spec properties
| Property | Type | Description |
|---|---|---|
idRequired | String | Unique project ID for the library. |
nameRequired | String | Human-readable name — must be non-empty. |
description | String | Optional description. |
languageRequired | String | Library language. Allowed values are javascript and python. |
code | String | Inline library code containing valid syntax for the selected language. Mutually exclusive with file. |
file | String | Path to library code file. Note that:
|
import_nameRequired | String | Handle used when importing the library in transformation code — must be camelCase of name.
|
Library validation rules
Transformation library must be semantically valid
Rule ID: transformations/transformation-library/semantic-valid
Examples
Transformation library spec syntax must be valid
Rule ID: transformations/transformation-library/spec-syntax-valid
Examples
Testing framework
Rudder CLI includes a rich built-in testing framework for validating transformations and transformation libraries locally.
Structure
The testing framework uses input and output directories to run test cases:
- All files in the
inputdirectory are treated as test inputs - Corresponding files in the
outputdirectory are used as expected outputs for comparison against the actual transformation results
Input and output file names must match for accurate testing and comparison.
For each test case, the framework sends the input event through the transformation and compares the actual output against the expected output.
Test modes
The testing framework supports two modes:
| Mode | Description |
|---|---|
| Default | Displays minimal details about test results. |
--verbose | Displays more context around differences, including three lines above and below each code diff. |
Test result classification
Each input file represents a separate test case. Rudder CLI classifies transformation test results into the following categories:
Transformation library tests focus specifically on syntax validation.
See more
- See Manage Transformations Using Rudder CLI for feature overview
- See Transformations Quickstart for a complete end-to-end example
