Intrinsic functions¶
Intrinsic functions transform payload values inside a state definition, without
calling out to a task. They are available in JSONPath query-language mode,
in fields whose name ends with .$:
In JSONata mode you use JSONata expressions instead of intrinsic functions. See JSONata.
Referencing data¶
In JSONPath mode, a string value references runtime data by its prefix:
$/$.path- The state input.
$is the whole input;$.order.idselects a path within it. $$.path- The context object, for example
$$.Execution.Id,$$.State.Nameor$$.State.EnteredTime. $name- A variable set earlier with
Assign, for example$customeror$customer.email.
An intrinsic function's arguments may be literals, input paths ($, $.…)
or context paths ($$.…). Assigned variables ($name) can be used in ordinary
JSONPath fields, but are not resolved inside intrinsic-function arguments.
This differs from AWS and is a known limitation.
Available functions¶
Stegflow implements the 18 standard Amazon States Language intrinsics.
States.Array(value, ...)- Builds an array from the given values.
States.ArrayContains(array, value)- Returns
trueifarraycontainsvalue. States.ArrayGetItem(array, index)- Returns the element at zero-based
index. States.ArrayLength(array)- Returns the number of elements in
array. States.ArrayPartition(array, chunkSize)- Splits
arrayinto chunks ofchunkSize. States.ArrayRange(start, end, step)- Builds an array of numbers from
starttoendbystep. States.ArrayUnique(array)- Removes duplicate elements from
array. States.Base64Encode(string)- Encodes
stringto Base64. States.Base64Decode(base64)- Decodes a Base64 string.
States.Format(template, value, ...)- Replaces each
{}placeholder intemplatewith the given values. States.Hash(data, algorithm)- Hashes
data.algorithmis one ofMD5,SHA-1,SHA-256,SHA-384,SHA-512. States.JsonMerge(json1, json2, isDeep)- Merges two objects.
isDeepis a boolean:falsefor a shallow merge,truefor a deep merge. States.JsonToString(path)- Serializes the value at
pathto a JSON string. States.MathAdd(num1, num2)- Returns
num1 + num2. States.MathRandom(start, end)- Returns a random integer between
startandend. An optional third argument seeds the generator for reproducible values. States.StringSplit(string, delimiter)- Splits
stringondelimiterinto an array. States.StringToJson(string)- Parses a JSON string into a value.
States.UUID()- Returns a version 4 UUID.
Examples¶
{
"chunks.$": "States.ArrayPartition($.items, 10)",
"checksum.$": "States.Hash($.payload, 'SHA-256')",
"merged.$": "States.JsonMerge($.defaults, $.overrides, false)",
"roll.$": "States.MathRandom(1, 6)",
"parts.$": "States.StringSplit('a,b,c', ',')"
}
Functions can be nested, and their arguments may be literals or JSONPath references into the state input.