totherik / step

An Amazon States Language implementation in JS. (The beginnings of building out FaaS-agnostic Step Functions.)
53 stars 9 forks source link

step

An Amazon State Language based state machine.

It is probably worth pointing out that this design probably isn't terribly practical in reality. There are many ways to solve this problem but the current structure was chosen for ease of development, to better understand the problem space, and to get a feel for the Amazon State Language spec itself. One could imagine many different approaches, including:

See additional notes below.

Basic API

const json = {
    "StartAt": "Demo",
    "States": {
        "Demo": {
            "Type": "Pass",
            "Result": {
                "pass": {
                    "a": "b"
                }
            },
            "Next": "Done"
        },
        "Done": {
            "Type": "Succeed"
        }
    }
};

const input = {
    foo: {
        bar: true,
    },
};

const machine = Machine.create(json);
const result = await machine.run(input);
console.log(result);

Testing

$ npm test
Notes