ECM-TL Overview
The ECM Transformation Language (ECM-TL) provides a declarative way to express context transformations, enabling portable transformation definitions across implementations.
Basic Transformations
Field Mapping
transform customer_context {
input: source.record
output: context
map {
context.id = source.customer_id
context.data.email = lower(source.email)
context.data.name = concat(source.first_name, " ", source.last_name)
context.metadata.created = now()
}
}
Built-in Functions
String functions: concat, lower, upper, trim, substring, replace. Numeric functions: round, abs, ceil, floor. Date functions: now, parse_date, format_date, date_diff. Null handling: coalesce, nullif, is_null.
Conditional Logic
Conditional Mapping
transform customer_tier {
map {
context.data.tier = case {
when source.total_spend > 10000 then "gold"
when source.total_spend > 1000 then "silver"
else "bronze"
}
}
}
Pattern Matching
transform contact_channel {
map {
context.data.preferred_channel = match source.contact_pref {
/^email/i => "email"
/^sms|text/i => "sms"
/^phone|call/i => "phone"
_ => "email" // default
}
}
}
Collection Operations
Array Transformations
transform order_history {
map {
context.data.orders = source.orders
| filter(o => o.status != "cancelled")
| map(o => {
order_id: o.id,
amount: o.total,
date: o.created_at
})
| sort_by(o => o.date, desc)
| take(10)
}
}
Aggregations
transform customer_metrics {
map {
context.data.metrics = {
total_orders: count(source.orders),
total_spend: sum(source.orders, o => o.total),
avg_order: avg(source.orders, o => o.total),
last_order: max(source.orders, o => o.created_at)
}
}
}
Composition
Transform Composition
transform full_customer_context {
compose {
customer_context,
customer_tier,
customer_metrics,
order_history
}
}
Type System
Type Annotations
transform typed_customer {
input: source.record as CustomerRecord
output: context as CustomerContext
types {
CustomerRecord = {customer_id: string, email: string, ...}
CustomerContext = {id: string, data: CustomerData, ...}
}
}
Conclusion
ECM-TL provides a portable, expressive language for context transformations. Learn the core mapping syntax, conditional logic, and collection operations to build complex transformations declaratively.