CEL scripting
CEL Script is used to perform data transformation and run validations in the Tailor Platform.
Here are some places you can utilize CEL:
authorization,preScript,postScript,preValidation,postValidationblocks on Pipeline resolverscreate_expr,update_exprhooks in TailorDB Hooksexprvalidation in TailorDB Validations
Standard operators and functions as well as String extensions can be used.
Example:
// filter and extract the IDs of a list
preScript: """
{
"objectIDs": args.edges.filter(r, r.node.lang.contains("en-US")).map(r, r.node.id)
}
""""Tailor Platform extensions
In addition, the Tailor platform provides useful extensions and supports optional types.
compact
Accepts a map and returns a new one that excludes the entries that have null values.
compact({ a: 1, b: null });
// → { "a": 1 }get
Provides safe navigation. Accepts an object/array, a path, and fallback value.
// args is { "input": { "query": { "some": "thing" } } }
get(args.input.query.date);
// → null
// args is { "input": { "query": { "date": "2023-01-01" } } }
get(args.input.query.date);
// → "2023-01-01"
// args is { "input": { "query": { "some": "thing" } } }
get(args.input.query.date, "1996-10-03");
// → "1996-10-03"intersect
Accepts two arrays and returns an array which contains the elements found in both. Drops null values.
intersect([1, 2, 3, null], [null, 3, 4, 5]);
// → [3]
intersect(["a", "b", "c"], ["c", "z", "b"]);
// → ["b", "c"]makeMap
Accepts an array and generates a map from it.
makeMap(["a", 1, "b", 2]);
// → { "a": 1, "b": 2 }uuidgen
Generates a UUID v4 string.
uuidgen();
// → 4f88b002-859f-4f59-b6fd-521c75041b13ifThen
Returns a specific value based on evaluation.
Accepts a condition, a true value and false value. If the condition evaluates to true, the true value is returned. Otherwise, the false value is returned.
// args is 'x = 5, y = 7'
ifThen(x < y, x, y);
// → 5
// args is 'x = 5, y = 7'
ifThen(x > y, x, y);
// → 7
// args is 'x = 5, y = 7'
ifThen(x > y, x);
// → nullisNull
Evaluates whether input is null and returns true or false.
// args is { "input": { "query": { "some": "thing" } } }
isNull(args.input.query.some);
// → false
// args is { "input": { "query": { "some": null } } }
isNull(args.input.query.some);
// → trueOptional types
With optional types, you can safely handle missing values in your scripts. This is especially useful for scenarios like:
- Checking if a value exists before performing an operation
- Providing default values for missing data
- Writing cleaner and more predictable expressions
// args is { "field": { "array_field": ["value1", "value2"] } }
args.?field.?array_field[?0].orValue("default_value")
// → "value1"