Tools for working with Step Functions and States Language. This is not super robust, and certainly would never work in any serious production capacity. It should, however, be sufficient for most basic use-cases and local testing.
Alternatives:
- asl-types - TypeScript types module that makes it easier to create AWS Step Functions JSON.
- asl-validator - A simple Amazon States Language validator based on JSON schemas.
Built on top of:
- @rickosborne/foundation for data structures and general helpers
- @rickosborne/guard for TypeScript guards
- @rickosborne/typical for helper TypeScript type definitions
As a simple example, based on one from the spec, presume you have a Lambda function which adds two numbers. Its implementation might be:
export function add(numbers: { val1: number; val2: number }): number {
return numbers.val1 + numbers.val2;
}
That function could accept an input of:
{
"val1": 3,
"val2": 4
}
Aside: Function arguments always arrive as a single value. Even if you provide an array, it will just be an array as the first value.
Your State Machine definition around that function might look like:
{
"StartAt": "Add",
"States": {
"Add": {
"End": true,
"Resource": "arn:aws:lambda:us-east-1:123456789012:function:Add",
"Type": "Task"
}
}
}
Presumably, you already have unit tests for the add
function.
But what if you want to test your State Machine definition?
Enter the runStateMachine
function from this library:
// Import the State Machine runner.
import { runStateMachine } from "@rickosborne/skip";
// Import your implementation from its source.
import { add } from "../add.js";
// Import the State Machine definition as JSON. Or read it from a file. Or use a literal.
import addStateMachine from "../state-machines/add.json" with { type: "json" };
describe(add.name, () => {
test("valid inputs", async () => {
// The runner is always asynchronous. There is no synchronous API.
const result = await runStateMachine(addStateMachine, {
input: {
val1: 3,
val2: 4,
},
// As the State Machine definition uses Resource ARNs, you need
// to tell the runner how to resolve those ARNs to local functions.
// You can do this as a simple Record, or you could provide a
// resolver function.
fnForResource: {
[addStateMachine.States.Add.Resource]: add,
}
});
// Assert the correct result was returned.
expect(result, "result").eq(7);
});
});
That runStateMachine
function's configuration object has additional properties for things like:
-
nowProvider
— Inject a stable replacement forDate.now()
. (Note that this will not be injected into your implementation functions. If you need such a thing, you'll need to partially apply your function with the replacement.) -
onHeartbeatSeconds
— Simulate heartbeat failures and successes. -
onMaxInputBytesPerBatch
— Micromanage input batches based on input size. -
onRetry
— Observe and modify failure retries. -
onStateComplete
— Observe state transitions and their current context values, like inputs and outputs. -
onWait
— Simulate various wait conditions and asynchronous completion.
See the docs for RunStateMachineOptions
for details.
See the examples.test.ts unit tests for more extensive examples.
It's not a robust production-ready implementation, but it should be sufficient for most tasks.
- It uses the jsonata library, and wires up the
$states
bindings, so most/all JSONata expressions should work. - It uses the jsonpath library, and resolves all the
*Path
properties, so most/all JSONPath expressions should work. - All Data Test Expressions for JSONPath are implemented. (i.e.
StringMatches
,TimestampGreaterThan
, etc.) - All Intrinsic Functions are implemented. (i.e.
States.Hash
,States.JsonMerge
, etc.) -
Parallel
tasks are actually run in parallel via promises. (Not Web Workers, though, so you're still on a single thread.) -
Map
tasks are batched and also run in parallel according to theMaxConcurrency
configuration. -
Timeout
values are checked. (To support faster unit tests, this implementation allows decimal timeouts, not just integers as the spec dictates. So0.25
is a quarter-second timeout, for example.)
So ... what doesn't work?
- Any
Heartbeat
configuration does not actually use heartbeats. Instead, you can configure a callback to decide whether to simulate a heartbeat failure. - By default,
Wait
won't actually wait. You can, however, provide an async function which will beawait
-ed, if you really do want to sleep some amount of time. - Errors are dodgy. The spec isn't great at specifying where some/most of the
States.*
errors come into play. I've made my best guess, but yourRetry
andChoices
may need to include a few extraError
names (mostlySyntaxError
) which AWS's implementation will likely just ignore. - Some
Assign
versusOutput
handling may be busted. Again, the spec is super unclear on exactly how these should interact. If you have a working-in-the-cloud example of how they interact, let me know! - Try/
Catch
/Retry
may not match AWS cloud execution. It's been tested to handle "reasonable" cases, but nowhere near exhaustively.
Or, put simple: it mostly works, but there are likely to be sharp edges here and there.
Install via your favorite package manager.
Each package supports CommonJS require
, ESM import
, and TypeScript usage.
You also have a choice: barrel imports or direct imports.
Barrel imports mean you're going to require/import everything from the same package-level namespace:
// CommonJS
const { isPlainObject, isListOf } = require("@rickosborne/guard");
// ESM / TypeScript
import { isPlainObject, isListOf } from "@rickosborne/guard";
Implications:
- Nice and simple.
- Your build system needs to do tree-shaking well ... or you'll end up adding the entire package even if you only import two functions.
The other option is to use direct imports:
// CommonJS
const { isPlainObject } = require("@rickosborne/guard/is-object");
const { isListOf } = require("@rickosborne/guard/is-list-of");
// ESM / TypeScript
import { isPlainObject } from "@rickosborne/guard/is-object.js";
import { isListOf } from "@rickosborne/guard/is-list-of.js";
Implications:
- You (probably) don't have to worry about tree-shaking as your build (likely) ends up with only the functions you need.
If you're using a modern build system, there aren't any strong reasons to prefer one way over the other. It's really just down to your personal preference.
Do you need to use file extensions? And if so, which extensions?
Honestly ... this is a dumpster fire question. It really comes down to your own setup and configuration.
Within each package itself:
- The CommonJS files all have
.cjs
extensions. - The ESM files all have
.mjs
extensions. - Node subpath exports have been set up to send
.js
imports to the.cjs
(viarequire
) or.mjs
(viaimport
) files, depending on your setup.
So, in theory, the only extension which won't work would be .ts
because the source isn't included.
If you run into a problem with a particular configuration, file a GitHub issue with:
- Your
tsconfig.json
'smodule
,moduleResolution
, andtarget
settings. - Your
package.json
'stype
andimports
settings. - An example of another package which imports correctly for you.
This package is licensed as CC-BY-NC-SA-4.0 unless otherwise noted. That is, Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International.
class JSONPathError extends StatesError
Thrown when there's a problem trying to resolve or assign using a JSONPath expression. This implementation is super-duper basic, so it's not going to support anything beyond dotted-path expressions.
class QueryEvaluationError extends StatesError
Error thrown when a JSONata expression evaluation or parsing fails.
class StatesError extends Error
Generic error for "something went wrong while executing a State Machine". Its name
will always be one of the reserved States.*
errors.
arrayAssertion: (fieldName: string, stateName: StateIdentifier) => EvaluationAssertion<JSONArray>
Builder for an evaluation assertion for an array.
function assertExactlyOne<T extends object, K extends string>(name: string, value: T, ...keys: K[]): void;
Throw unless at most exactly one of the given keys is present in the given value. Used for "you can have A or B, but never both".
function assertLanguage<Q extends QueryLanguageIdentifier>(actual: QueryLanguageIdentifier, expected: Q, fieldName: string): asserts actual is Q;
Throw if the current actual language (in the context of the state) is not the expected language (based on the attempted operation).
function assertNullUndef(value: unknown, errorProvider: (type: string) => Error): asserts value is (null | undefined);
Throw if the given value is not null or undefined.
function assertNumber(value: unknown, errorProvider: (type: string) => Error): asserts value is number;
Throw if the given value is not a number.
function assertString(value: unknown, errorProvider: (type: string) => Error): asserts value is string;
Throw if the given value is not a string.
function assertValidStateName(name: string): asserts name is StateIdentifier;
Basic check to ensure the State identifier meets the spec restrictions.
assignJSONPath: (target: JSONSerializable, jsonPathExpression: string, value: JSONSerializable) => void
Given a target object, a JSONPath expression for navigating that object, and a value, try to traverse the object and assign the value at the given path. Will create "container" records and arrays to make the path work, if necessary. Does not support anything particularly tricky.
assignThenContinue: (context: {
error?: Error | undefined;
errorOutput: ErrorOutput | undefined;
evalOutput?: boolean | undefined;
evaluateOutput: (context: RunStateContext<State> & {
catcher?: Catcher;
output: JSONSerializable;
}) => Promise<JSONSerializable>;
input: JSONSerializable;
nextStateName?: StateIdentifier | undefined;
onNextState: (context: RunStateContext<State>) => Promise<JSONSerializable>;
options: RunStateMachineOptions;
output: JSONSerializable;
retryCount: number;
state: State;
stateMachine: StateMachine;
stateName: StateIdentifier;
stateStack: State[];
}) => Promise<JSONSerializable>
After the main part of a State has been evaluated, handle any Catch or Retry as applicable, and then transition to the next state.
definitionFromSource: (sourcePath: string, fnName?: string | undefined) => StateMachine
errorOutputFromError: (error: Error) => ErrorOutput
Format an ErrorOutput based on the information in an Error
. Tries to find the root cause, if present.
evaluateChoice: (choice: ChoiceRule, context: {
input: JSONSerializable;
language: QueryLanguageIdentifier;
options: RunStateMachineOptions;
state: ChoiceState;
stateName: StateIdentifier;
}) => Promise<boolean>
Evaluate whether a given Choice Rule matches the current State.
evaluateExpression: (expr: JSONSerializable, context: {
catcher?: JSONataCatcher | JSONPathCatcher | undefined;
contextObject?: JSONObject;
errorOutput?: ErrorOutput | undefined;
input: JSONSerializable;
language: QueryLanguageIdentifier;
options: RunStateMachineOptions;
state: State;
stateStack: State[];
}) => Promise<JSONSerializable>
Evaluate an expression, which may be a literal, JSONPath, or JSONata, in the context of the current State.
evaluateIntrinsicFunction: (expr: string | IntrinsicFunctionCall, input?: JSONSerializable, context?: JSONSerializable | undefined) => JSONSerializable
General entry point for an Intrinsic Function. Given an Intrinsic Function call expression, parse it, validate the given args against the params, and evaluate and return the result.
evaluateJSONata: <T extends JSONSerializable>(text: JSONataString, context: {
contextObject?: JSONObject;
input: JSONSerializable;
output?: JSONSerializable | undefined;
errorOutput?: ErrorOutput | undefined;
state: State;
}, assertion?: EvaluationAssertion<T>) => Promise<T>
Evaluate a JSONata expression in the context of a running State.
evaluateJSONPath: <T extends JSONSerializable>(expression: string, context: {
contextOverride?: JSONObject | undefined;
input: JSONSerializable;
options: RunStateMachineOptions;
}, assertion?: {
expected: string;
fieldName: string;
predicate: (value: JSONSerializable) => value is T;
stateName: StateIdentifier;
}) => T
Evaluate a JSONPath expression in the context of the current State.
evaluateJSONPathChoice: (choice: JSONPathChoiceRule, depth: number, context: {
input: JSONSerializable;
options: RunStateMachineOptions;
state: ChoiceState;
stateName: StateIdentifier;
}) => Promise<boolean>
Evaluate a Choice Rule in a JSONPath context.
evaluateOutput: (context: {
catcher?: JSONataCatcher | JSONPathCatcher | undefined;
errorOutput?: ErrorOutput | undefined;
evaluateOutput: (context: RunStateContext<State> & {
catcher?: Catcher;
output: JSONSerializable;
}) => Promise<JSONSerializable>;
input: JSONSerializable;
onNextState: (context: RunStateContext<State>) => Promise<JSONSerializable>;
options: RunStateMachineOptions;
output: JSONSerializable;
retryCount: number;
state: State;
stateMachine: StateMachine;
stateName: StateIdentifier;
stateStack: State[];
}) => Promise<JSONSerializable>
For the various ways a State can modify its output, go through each.
function expectJSONPath(value: JSONSerializable, name: string): JSONPathPath;
Assert that a value is a JSONPath expression, and return it.
expectState: (name: StateIdentifier, stateMachine: StateMachine) => State
Find the given State by its identifier in the given State Machine, throwing if it is not found.
getLanguage: (context: {
options: RunStateMachineOptions;
state: State;
stateMachine: StateMachine;
}) => QueryLanguageIdentifier
Figure out what the current query language is based on the current State, its parent State Machine, or the provided Run options.
getMaxConcurrency: (context: {
assertionBuilder: (fieldName: string, stateName: string) => EvaluationAssertion<number>;
input: JSONSerializable;
language: QueryLanguageIdentifier;
options: RunStateMachineOptions;
state: MapState;
stateName: StateIdentifier;
}) => Promise<number>
Try to figure out the configured maximum concurrency for a Map State.
getTimeouts: <T>(context: {
assertionBuilder: (fieldName: string, stateName: string) => EvaluationAssertion<number>;
input: JSONSerializable;
language: QueryLanguageIdentifier;
options: RunStateMachineOptions;
state: TaskState;
stateName: StateIdentifier;
}) => Promise<TimedWrapper<T> | undefined>
Try to figure out the timeout/heartbeat configuration for a State. Instead of returning a timeout, returns a wrapper which will throw/return based on that timeout or heartbeat.
getToleratedFailureCount: (context: {
assertionBuilder: (fieldName: string, stateName: StateIdentifier) => EvaluationAssertion<number>;
input: JSONSerializable;
itemCount: number;
language: QueryLanguageIdentifier;
options: RunStateMachineOptions;
state: MapState;
stateName: StateIdentifier;
}) => Promise<number>
Try to figure out the configured tolerated failure count of a Map State.
hasQueryLanguage: (value: unknown) => value is Required<CanQueryLanguage>
hasTimeouts: (value: unknown) => value is HasTimeoutsState
isAndExpression: (value: unknown) => value is AndExpression
isArgumentsState: (value: unknown) => value is ArgumentsState
isAssignedState: (state: unknown) => state is AssignedState
isCatchState: (state: unknown) => state is CatchState
isDataTestExpression: (value: unknown) => value is DataTestExpression
isDataTestLiteralExpressionKey: (key: keyof DataTestExpressions) => key is keyof DataTestLiteralExpressions
isEndState: <S extends State>(state: S) => state is S & EndState
isInputPathState: (value: unknown) => value is InputPathState
isIntString: (value: unknown) => value is `${number}`
Guard for whether the value is a stringified integer.
isIsoDate: (value: unknown) => value is SimpleIsoDate
Guard for whether the value is an ISO8601-formatted date.
isIsoDateTime: (value: unknown) => value is IsoDateTime
Guard for whether the value is an ISO8601-formatted date or datetime (timestamp).
isIsoTime: (value: unknown) => value is SimpleIsoTime
Guard for whether the value is an ISO8601-formatted time.
isIsoTimeZone: (value: unknown) => value is SimpleIsoTimeZone
Guard for whether the value is an ISO8601-formatted timezone.
isJSONataChoiceRule: (value: unknown) => value is JSONataChoiceRule
isJSONataItemBatcher: (value: unknown) => value is JSONataItemBatcher
isJSONataItemReader: (value: unknown) => value is JSONataItemReader
isJSONataString: (value: unknown) => value is JSONataString
isJSONPathInterpolated: (value: unknown) => value is JSONPathInterpolated
isJSONPathItemBatcher: (value: unknown) => value is JSONPathItemBatcher
isJSONPathItemReader: (value: unknown) => value is JSONPathItemReader
isJSONPathPath: (value: unknown) => value is JSONPathPath
isJSONPathPayloadTemplate: (value: unknown) => value is JSONPathPayloadTemplate
isNonTerminalState: (value: unknown) => value is NonTerminalState
isNotExpression: (value: unknown) => value is NotExpression
isOrExpression: (value: unknown) => value is OrExpression
isOutputPathState: (value: unknown) => value is OutputPathState
isOutputState: (state: unknown) => state is OutputState
isParametersState: (value: unknown) => value is ParametersState
isResultPathState: (value: unknown) => value is ResultPathState
isResultSelectorState: (value: unknown) => value is ResultSelectorState
isRetryState: (value: unknown) => value is RetryState
isSucceedState: <S extends State>(state: S) => state is S & SucceedState
parseIntrinsicFunctionExpression: (expr: string) => IntrinsicFunctionCall
Try to parse an Intrinsic Function call expression. This is a very basic pull parser. It's a little flaky, as the JSONPath expressions aren't quoted, and the jsonpath
library's parse
function can't handle trailing text like ,
or )
. And, of course, both ,
and )
are perfectly valid at places inside a JSONPath expression, so we can't just look for the first one of those, either.
positiveIntAssertion: (fieldName: string, stateName: StateIdentifier) => EvaluationAssertion<number>
Builder for an evaluation assertion for a positive integer.
processArgs: (context: {
input: JSONSerializable;
options: RunStateMachineOptions;
state: State;
stateMachine: StateMachine;
stateStack: State[];
}, targetOverride?: ResultWriter) => Promise<JSONSerializable>
Try to find the Arguments
, InputPath
, and Parameters
for the target, and evaluate them as necessary to modify the input for the current State.
resourceHandlerResolver: (options: RunStateMachineOptions) => ResourceHandlerResolver
Given some State Machine options, generate a function which can resolve Resource URIs to Lambda-like function implementations.
runAssign: (output: JSONSerializable, assigned: AssignedState, context: {
input: JSONSerializable;
options: RunStateMachineOptions;
state: State;
stateMachine: StateMachine;
stateStack: State[];
}) => Promise<JSONSerializable>
If the current State can use Assign
, evaluate that to modify the given output.
runChoice: (context: RunStateContext<ChoiceState>) => Promise<JSONSerializable>
Run the given Choice State.
runFail: (context: RunStateContext<FailState>) => Promise<JSONSerializable>
Run the given Fail State.
runMap: (context: RunStateContext<MapState>) => Promise<JSONSerializable>
Run the given Map State.
runParallel: (context: RunStateContext<ParallelState>) => Promise<JSONSerializable>
Run the given Parallel State.
runPass: (context: RunStateContext<PassState>) => Promise<JSONSerializable>
Run the given Pass State.
runState: <S extends State>(context: RunStateContext<S>) => Promise<JSONSerializable>
Run the given State.
runStateMachine: (stateMachine: StateMachine, options?: RunStateMachineOptions) => Promise<JSONSerializable>
runSucceed: (context: RunStateContext<SucceedState>) => Promise<JSONSerializable>
Run the given Succeed State.
runTask: (context: RunStateContext<TaskState>) => Promise<JSONSerializable>
Run the given Task state.
runWait: (context: RunStateContext<WaitState>) => Promise<JSONSerializable>
Run the given Wait State.
shouldRetry: (context: {
errorOutput: ErrorOutput;
options: RunStateMachineOptions;
retryCount: number;
state: State;
stateName: StateIdentifier;
}) => Promise<boolean>
Figure out whether a failed State should attempt a retry, based on its configuration and the current retry count.
statesArray: (...values: JSONSerializable[]) => JSONArray
statesArrayContains: (haystack: JSONArray, needle: JSONSerializable) => boolean
statesArrayGetItem: (array: JSONArray, index: number) => JSONSerializable
statesArrayLength: (array: JSONArray) => number
statesArrayPartition: (array: JSONArray, size: number) => JSONArray
statesArrayRange: (first: number, last: number, step: number) => number[]
statesArrayUnique: (array: JSONArray) => JSONArray
statesBase64Decode: (encoded: string) => string
statesBase64Encode: (text: string) => string
statesFormat: (text: string, ...values: JSONSerializable[]) => string
statesHash: (data: JSONSerializable, algorithm: string) => string
statesJsonMerge: (left: JSONObject, right: JSONObject, deep: boolean) => JSONObject
statesJsonToString: (value: JSONSerializable) => string
statesMathAdd: (a: number, b: number) => number
statesMathRandom: (start: number, end: number, seed?: number) => number
statesStringSplit: (text: string, delimiter: string) => string[]
statesStringToJson: (text: string) => JSONSerializable
statesUUID: () => string
stringAssertion: (fieldName: string, stateName: StateIdentifier) => EvaluationAssertion<string>
Builder for an evaluation assertion for a string.
toDataTestLiteralExpressionKey: (key: Exclude<keyof DataTestExpressions, keyof DataTestLiteralExpressions>) => keyof DataTestLiteralExpressions
tryHandleCatch: (context: {
input: JSONSerializable;
error?: Error | undefined;
errorOutput: ErrorOutput;
evaluateOutput: (context: RunStateContext<State> & {
catcher?: Catcher;
output: JSONSerializable;
}) => Promise<JSONSerializable>;
options: RunStateMachineOptions;
onNextState: (context: RunStateContext<State>) => Promise<JSONSerializable>;
retryCount: number;
state: State;
stateMachine: StateMachine;
stateName: StateIdentifier;
stateStack: State[];
}) => Promise<JSONSerializable>
If the current State has a Catch expression, try to evaluate it to see what to do next.
export interface AndExpression
export interface ArgumentsState
export interface AssignedState
export interface CanArguments extends Partial<ArgumentsState>
Included in: Task, Parallel.
export interface CanAssign extends Partial<AssignedState>
Included in: Choice Rule, Catcher, Map, Parallel.
export interface CanCatchOf<Q extends QueryLanguageIdentifier> extends Partial<CatchStateOf<Q>>
Included in: Task, Parallel, Map
export interface CanComment extends Partial<CommentState>
export interface CanEnd
Excluded from: Choice State, Succeed State, Fail State.
export interface CanInputOutputPath extends Partial<InputPathState>, Partial<OutputPathState>
Excluded from: Succeed, Fail
export interface CanOutput extends Partial<OutputState>
Excluded from: Fail.
export interface CanParameters extends Partial<ParametersState>
Included in: Task, Parallel, Map, Pass
export interface CanQueryLanguage
export interface CanResultPath extends Partial<ResultPathState>
Included in: Task, Parallel, Map, Pass
export interface CanResultSelector extends Partial<ResultSelectorState>
Included in: Task, Parallel, Map
export interface CanRetry extends Partial<RetryState>
Included in: Task, Parallel, Map
export interface Catcher extends CanAssign, NonTerminalState
export interface CatcherOf
export interface CatchState
export interface CatchStateOf<Q extends QueryLanguageIdentifier>
export interface ChoiceStateCommon extends CanAssign
export interface CommentState
export interface DataTestExpressions extends DataTestLiteralExpressions
export interface DataTestLiteralExpressions
export interface EndState
export interface ErrorOutput
export interface EvaluationAssertion<T extends JSONSerializable>
A value type guard/assertion which should happen after evaluating a JSONata or JSONPath expression.
export interface FailStateCommon
export interface HasTimeoutsState
export interface InputPathState
export interface IntrinsicFunctionCall
export interface ItemProcessor
export interface ItemReader
export interface JSONataCatcher extends Catcher, CanOutput
export interface JSONataChoiceRule extends CanAssign, CanOutput, NonTerminalState
export interface JSONataChoiceState extends StateOf<ChoiceType, QueryLanguageJSONata>, ChoiceStateCommon, CanOutput, CanComment
export interface JSONataFailState extends StateOf<FailType, QueryLanguageJSONata>, JSONataFailStateCommon, CanOutput, CanComment
export interface JSONataFailStateCommon extends FailStateCommon
export interface JSONataItemBatcher
export interface JSONataItemProcessor extends ItemProcessor
export interface JSONataItemReader extends ItemReader
export interface JSONataMapStateCommon extends MapStateCommon, CanCatchOf<QueryLanguageJSONata>
export interface JSONataMapStateWithoutEndOrNext extends StateOf<MapType, QueryLanguageJSONata>, JSONataMapStateCommon, CanOutput, CanArguments
export interface JSONataParallelStateWithoutEndOrNext extends StateOf<ParallelType, QueryLanguageJSONata>, ParallelStateCommon, CanOutput, CanArguments, CanCatchOf<QueryLanguageJSONata>
export interface JSONataPassStateWithoutEndOrNext extends StateOf<PassType, QueryLanguageJSONata>, PassStateCommon, CanOutput
export interface JSONataResultWriter extends ResultWriter
export interface JSONataSucceedState extends StateOf<SucceedType, QueryLanguageJSONata>, SucceedStateCommon, CanOutput, CanComment
export interface JSONataTaskStateWithoutEndOrNext extends StateOf<TaskType, QueryLanguageJSONata>, TaskStateCommon, CanOutput, CanArguments, CanCatchOf<QueryLanguageJSONata>
export interface JSONataTaskTimeout
export interface JSONataWaitStateWithoutEndOrNext extends StateOf<WaitType, QueryLanguageJSONata>, WaitStateCommon, CanOutput
export interface JSONataWaitTimes
export interface JSONPathCatcher extends Catcher, CanResultPath
export interface JSONPathChoiceState extends StateOf<ChoiceType, QueryLanguageJSONPath>, ChoiceStateCommon, CanInputOutputPath, CanComment
export interface JSONPathErrorOptions extends ErrorOptions
export interface JSONPathFailStateCauses
export interface JSONPathFailStateErrors
export interface JSONPathItemReader extends ItemReader
export interface JSONPathMapStateCommon extends MapStateCommon, CanCatchOf<QueryLanguageJSONPath>
export interface JSONPathMapStateWithoutEndOrNext extends StateOf<MapType, QueryLanguageJSONPath>, JSONPathMapStateCommon, CanInputOutputPath, CanResultPath, CanParameters, CanResultSelector
export interface JSONPathParallelStateWithoutEndOrNext extends StateOf<ParallelType, QueryLanguageJSONPath>, ParallelStateCommon, CanInputOutputPath, CanResultPath, CanParameters, CanResultSelector, CanCatchOf<QueryLanguageJSONPath>
export interface JSONPathPassStateWithoutEndOrNext extends StateOf<PassType, QueryLanguageJSONPath>, PassStateCommon, CanInputOutputPath, CanResultPath, CanParameters
export interface JSONPathResultWriter extends ResultWriter
export interface JSONPathSucceedState extends StateOf<SucceedType, QueryLanguageJSONPath>, SucceedStateCommon, CanInputOutputPath, CanComment
export interface JSONPathTaskHeartbeatNumber
export interface JSONPathTaskHeartbeatPath
export interface JSONPathTaskStateWithoutEndOrNext extends StateOf<TaskType, QueryLanguageJSONPath>, TaskStateCommon, CanInputOutputPath, CanResultPath, CanParameters, CanCatchOf<QueryLanguageJSONPath>
export interface JSONPathTaskTimeoutNumber
export interface JSONPathTaskTimeoutPath
export interface JSONPathWaitFields
export interface JSONPathWaitStateWithoutEndOrNext extends StateOf<WaitType, QueryLanguageJSONPath>, WaitStateCommon, CanInputOutputPath
export interface MapStateCommon extends CanRetry, CanAssign
export interface NonTerminalState
export interface NonTerminalStateOf<S extends StateIdentifier>
export interface NotExpression
export interface OrExpression
export interface OutputPathState
export interface OutputState
export interface ParallelBranch
export interface ParallelBranchOf<S extends StateIdentifier>
export interface ParallelStateCommon extends CanRetry, CanAssign
export interface ParametersState
export interface PassStateCommon extends CanAssign
export interface QueryEvaluationErrorOptions extends ErrorOptions
export interface QueryLanguageJSONataState
export interface QueryLanguageJSONPathState
export interface ResultPathState
export interface ResultSelectorState
export interface ResultWriter
export interface Retrier
export interface RetryState
export interface RunStateContext<StateT extends State>
Shared context needed for running any State.
export interface RunStateMachineOptions
Initial options for running a State Machine.
export interface StateForType
export interface StateMachine extends CanComment
export interface StateMachineOf<S extends StateIdentifier, Q extends QueryLanguageIdentifier = QueryLanguageJSONPath> extends StateMachine
export interface StateOf<T extends StateType, Q extends QueryLanguageIdentifier>
export interface SucceedStateCommon
export interface TaskStateCommon extends CanRetry, CanAssign
export interface WaitSeconds
export interface WaitStateCommon extends CanAssign, NonTerminalState
export interface WaitTimestamp
type ARN = `arn:aws:${string}`;
type ChoiceRule = JSONataChoiceRule | (JSONPathChoiceRule & NonTerminalState);
type ChoiceState = JSONataChoiceState | JSONPathChoiceState;
type ChoiceType = typeof TYPE_CHOICE;
type DataTestExpression = ExactlyOneOf<DataTestExpressions> & {
Variable: JSONPathPath;
};
type EndOrNext = EndState | NonTerminalState;
type EndOrNextOf<S extends StateIdentifier> = EndState | NonTerminalStateOf<S>;
type ErrorName = string;
type FailState = JSONataFailState | JSONPathFailState;
type FailType = typeof TYPE_FAIL;
type IntrinsicFunctionArg = IntrinsicFunctionLiteralArg | IntrinsicFunctionPathArg | IntrinsicFunctionCall;
type IntrinsicFunctionExpression = `${IntrinsicFunctionName}(${string})`;
type IntrinsicFunctionName = typeof STATES_ARRAY | typeof STATES_ARRAY_CONTAINS | typeof STATES_ARRAY_GET_ITEM | typeof STATES_ARRAY_LENGTH | typeof STATES_ARRAY_PARTITION | typeof STATES_ARRAY_RANGE | typeof STATES_ARRAY_UNIQUE | typeof STATES_BASE64_DECODE | typeof STATES_BASE64_ENCODE | typeof STATES_FORMAT | typeof STATES_HASH | typeof STATES_JSON_MERGE | typeof STATES_JSON_TO_STRING | typeof STATES_MATH_ADD | typeof STATES_MATH_RANDOM | typeof STATES_STRING_SPLIT | typeof STATES_STRING_TO_JSON | typeof STATES_UUID;
type IsoDateTime = `${SimpleIsoDate}T${SimpleIsoTime}${SimpleIsoTimeZone}`;
type JSONataMapState = JSONataMapStateWithoutEndOrNext & EndOrNext & CanComment;
type JSONataMapStateOf<S extends StateIdentifier> = JSONataMapStateWithoutEndOrNext & EndOrNextOf<S>;
type JSONataParallelState = JSONataParallelStateWithoutEndOrNext & EndOrNext & CanComment;
type JSONataParallelStateOf<S extends StateIdentifier> = JSONataParallelStateWithoutEndOrNext & EndOrNextOf<S>;
type JSONataPassState = JSONataPassStateWithoutEndOrNext & EndOrNext & CanComment;
type JSONataPassStateOf<S extends StateIdentifier> = JSONataPassStateWithoutEndOrNext & EndOrNextOf<S>;
type JSONataString = `{%${string}%}`;
type JSONataTaskState = JSONataTaskStateWithoutEndOrNext & JSONataTaskTimeout & EndOrNext & CanComment;
type JSONataTaskStateOf<S extends StateIdentifier> = JSONataTaskStateWithoutEndOrNext & JSONataTaskTimeout & EndOrNextOf<S>;
type JSONataWaitState = JSONataWaitStateWithoutEndOrNext & JSONataWaitTime & EndOrNext & CanComment;
type JSONataWaitStateOf<S extends StateIdentifier> = JSONataWaitStateWithoutEndOrNext & JSONataWaitTime & EndOrNextOf<S>;
type JSONataWaitTime = ExactlyOneOf<JSONataWaitTimes>;
type JSONPathChoiceRule = AndExpression | OrExpression | NotExpression | DataTestExpression;
type JSONPathFailState = StateOf<FailType, QueryLanguageJSONPath> & JSONPathFailStateCommon & CanInputOutputPath & CanComment;
type JSONPathFailStateCommon = {
Next?: never;
} & Partial<ExactlyOneOf<JSONPathFailStateCauses>> & Partial<ExactlyOneOf<JSONPathFailStateErrors>>;
type JSONPathInterpolated = `${string}.$`;
type JSONPathItemBatcher = {
BatchInput?: JSONPathPayloadTemplate;
} & Partial<ExactlyOneOf<{
MaxItemsPerBatch: number;
MaxItemsPerBatchPath: JSONPathPath;
}>> & Partial<ExactlyOneOf<{
MaxInputBytesPerBatch: number;
MaxInputBytesPerBatchPath: JSONPathPath;
}>>;
type JSONPathItemProcessor = ItemProcessor & Partial<ExactlyOneOf<{
ToleratedFailureCount: number;
ToleratedFailureCountPath: JSONPathPath;
}>> & Partial<ExactlyOneOf<{
ToleratedFailurePercentage: number;
ToleratedFailurePercentagePath: JSONPathPath;
}>>;
type JSONPathMapMaxConcurrency = Partial<ExactlyOneOf<{
MaxConcurrency: number;
MaxConcurrencyPath: JSONPathPath;
}>>;
type JSONPathMapState = JSONPathMapStateWithoutEndOrNext & JSONPathMapMaxConcurrency & EndOrNext & CanComment;
type JSONPathMapStateOf<S extends StateIdentifier> = JSONPathMapStateWithoutEndOrNext & JSONPathMapMaxConcurrency & EndOrNextOf<S>;
type JSONPathParallelState = JSONPathParallelStateWithoutEndOrNext & EndOrNext & CanComment;
type JSONPathParallelStateOf<S extends StateIdentifier> = JSONPathParallelStateWithoutEndOrNext & EndOrNextOf<S>;
type JSONPathPassState = JSONPathPassStateWithoutEndOrNext & EndOrNext & CanComment;
type JSONPathPassStateOf<S extends StateIdentifier> = JSONPathPassStateWithoutEndOrNext & EndOrNextOf<S>;
type JSONPathPath = `$${string}`;
type JSONPathTaskState = JSONPathTaskStateWithoutEndOrNext & JSONPathTaskTimeout & EndOrNext & CanComment;
type JSONPathTaskStateOf<S extends StateIdentifier> = JSONPathTaskStateWithoutEndOrNext & JSONPathTaskTimeout & EndOrNextOf<S>;
type JSONPathTaskTimeout = (JSONPathTaskTimeoutNumber | JSONPathTaskHeartbeatNumber) & (JSONPathTaskTimeoutPath | JSONPathTaskHeartbeatPath);
type JSONPathWaitState = JSONPathWaitStateWithoutEndOrNext & JSONPathWaitTime & EndOrNext & CanComment;
type JSONPathWaitStateOf<S extends StateIdentifier> = JSONPathWaitStateWithoutEndOrNext & JSONPathWaitTime & EndOrNextOf<S>;
type JSONPathWaitTime = ExactlyOneOf<JSONPathWaitFields>;
type MapState = JSONataMapState | JSONPathMapState;
type MapStateOf<S extends StateIdentifier> = JSONataMapStateOf<S> | JSONPathMapStateOf<S>;
type MapType = typeof TYPE_MAP;
type ParallelState = JSONataParallelState | JSONPathParallelState;
type ParallelStateOf<S extends StateIdentifier> = JSONataParallelStateOf<S> | JSONPathParallelStateOf<S>;
type ParallelType = typeof TYPE_PARALLEL;
type PassState = JSONataPassState | JSONPathPassState;
type PassStateOf<S extends StateIdentifier> = JSONataPassStateOf<S> | JSONPathPassStateOf<S>;
type PassType = typeof TYPE_PASS;
type QueryLanguageIdentifier = QueryLanguageJSONata | QueryLanguageJSONPath;
type QueryLanguageJSONata = typeof JSONATA;
type QueryLanguageJSONPath = typeof JSONPATH;
type ResourceHandlerResolver = (resourceUri: ResourceURI) => StepFunctionLambdaLike;
Resolve a resource URI to a local runnable function.
type ResourceURI = string;
type SimpleIsoDate = `${number}${number}${number}${number}-${number}${number}-${number}${number}`;
type SimpleIsoTime = `${number}${number}:${number}${number}:${number}${number}${"" | `.${number}`}`;
type SimpleIsoTimeZone = "Z" | `${"+" | "-"}${number}${number}:${number}${number}`;
type State = ChoiceState | FailState | MapState | ParallelState | PassState | SucceedState | TaskState | WaitState;
type StateIdentifier = string;
type StatesAll = typeof STATES_ALL;
type StatesHashAlgorithm = ItemType<typeof STATES_HASH_ALGORITHMS>;
type StateType = TaskType | SucceedType | FailType | ParallelType | MapType | ChoiceType | PassType | WaitType;
type StepFunctionLambdaLike = (...args: any) => (JSONSerializable | undefined | Promise<JSONSerializable | undefined> | void);
A (local) function which accepts only JSON-serializable params and returns only JSON-serializable results, if any, or a promise for the same.
type SucceedState = JSONataSucceedState | JSONPathSucceedState;
type SucceedType = typeof TYPE_SUCCEED;
type TaskState = JSONataTaskState | JSONPathTaskState;
type TaskStateOf<S extends StateIdentifier> = JSONataTaskStateOf<S> | JSONPathTaskStateOf<S>;
type TaskType = typeof TYPE_TASK;
type TerminalState = EndState | SucceedState | FailState;
type VariableName = string;
type WaitState = JSONataWaitState | JSONPathWaitState;
type WaitStateOf<S extends StateIdentifier> = JSONataWaitStateOf<S> | JSONPathWaitStateOf<S>;
type WaitTime = WaitSeconds | WaitTimestamp;
type WaitType = typeof TYPE_WAIT;
JSONATA = "JSONata"
JSONPATH = "JSONPath"
STATES_ALL = "States.ALL"
STATES_ARRAY = "States.Array"
STATES_ARRAY_CONTAINS = "States.ArrayContains"
STATES_ARRAY_GET_ITEM = "States.ArrayGetItem"
STATES_ARRAY_LENGTH = "States.ArrayLength"
STATES_ARRAY_PARTITION = "States.ArrayPartition"
STATES_ARRAY_RANGE = "States.ArrayRange"
STATES_ARRAY_UNIQUE = "States.ArrayUnique"
STATES_BASE64_DECODE = "States.Base64Decode"
STATES_BASE64_ENCODE = "States.Base64Encode"
STATES_BRANCH_FAILED = "States.BranchFailed"
STATES_EXCEED_TOLERATED_FAILURE_THRESHOLD = "States.ExceedToleratedFailureThreshold"
STATES_FORMAT = "States.Format"
STATES_HASH = "States.Hash"
STATES_HASH_ALGORITHMS: readonly ["MD5", "SHA-1", "SHA-256", "SHA-384", "SHA-512"]
STATES_HASH_MD5 = "MD5"
STATES_HASH_SHA1 = "SHA-1"
STATES_HASH_SHA256 = "SHA-256"
STATES_HASH_SHA384 = "SHA-384"
STATES_HASH_SHA512 = "SHA-512"
STATES_HEARTBEAT_TIMEOUT = "States.HeartbeatTimeout"
STATES_INTRINSIC_FAILURE = "States.IntrinsicFailure"
STATES_ITEM_READER_FAILED = "States.ItemReaderFailed"
STATES_JSON_MERGE = "States.JsonMerge"
STATES_JSON_TO_STRING = "States.JsonToString"
STATES_MATH_ADD = "States.MathAdd"
STATES_MATH_RANDOM = "States.MathRandom"
STATES_NO_CHOICE_MATCHED = "States.NoChoiceMatched"
STATES_PARAMETER_PATH_FAILURE = "States.ParameterPathFailure"
STATES_PERMISSIONS = "States.Permissions"
STATES_QUERY_EVALUATION_ERROR = "States.QueryEvaluationError"
STATES_RESULT_PATH_MATCH_FAILURE = "States.ResultPathMatchFailure"
STATES_RESULT_WRITER_FAILED = "States.ResultWriterFailed"
STATES_STRING_SPLIT = "States.StringSplit"
STATES_STRING_TO_JSON = "States.StringToJson"
STATES_TASK_FAILED = "States.TaskFailed"
STATES_TIMEOUT = "States.Timeout"
STATES_UUID = "States.UUID"
TYPE_CHOICE = "Choice"
TYPE_FAIL = "Fail"
TYPE_MAP = "Map"
TYPE_PARALLEL = "Parallel"
TYPE_PASS = "Pass"
TYPE_SUCCEED = "Succeed"
TYPE_TASK = "Task"
TYPE_WAIT = "Wait"
VERSION_1 = "1.0"