0.21.0 • Published 4 months ago

asl-puml v0.21.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

asl-puml

license npm version

NPM

Install

# Use via the CLI
npm install -g asl-puml
# Use in your code
npm install asl-puml

CLI

$ asl-puml --help

  Usage: asl-puml [options]

  Amazon States Language to PUML

  Options:

Amazon States Language to PUML

Options:
  -i --input <input>    path to input file
  -o --output <output>  path to output dir
  -c --config <config>  path to config file
  -h, --help            display help for command

Return status:

  • 0 if diagram was generated
  • 1 if there was an error

In your code

const aslPuml = require('asl-puml');
const definition = require('./path/to/my/state/machine/json/definition');
const { isValid, puml, message } = aslPuml(definition);
if (isValid) {
  console.log(puml)
} else {
  console.error(message);
}

What does it do?

Generates a plantuml state diagram from a valid Amazon States Language file.

But why? There's already good tooling from AWS.

The existing tools are good, but I'm looking for a simpler rendering that encodes a little more info than the AWS Toolkit.

I also do all of my development in an IDE and don't want to switch to the browser based AWS Workflow Studio.

Example step function

See __tests__/Definitions/demo.asl.json for the step function used for these examples.

The diagrams below show the same step function rendered by:

  • asl-puml (this library)
  • AWS Toolkit
  • AWS Workflow Studio

Feature comparison

Feature or Style Requirementasl-pumlAWS ToolkitAWS Workflow Studio
renders the step function as a state diagramDiagram of the step function in the style of a PlantUML State Diagram with colorsshows state machine rendered by AWS Toolkit with generic rendering for every stateshows state machine in workflow studio with colors and icons
conveys the behavior for the state:white_check_mark:, via colors and some icons:x::white_check_mark:, very familiar AWS icons and colors.
matches the style for instance executions:x::white_check_mark::x:
renders within Webstorm/JetBrains products:white_check_mark:, via the existing plantuml plugin:x:, not in AWS Toolkit for Webstorm:x:
renders the step function within VS Code:white_check_mark:, via the existing plantuml plugin:white_check_mark:, available in AWS Toolkit for VS Code:x:
label the path from a catch:white_check_mark:, with line weight and color:x::white_check_mark:, path is labeled with a Catch
label the path to a Fail state:white_check_mark:, with line weight and color:x::x:
identify the compensation path:white_check_mark:, albeit hard coded by state name regex:x::x:
avoid drawing duplicate paths to reduce clutter (catches):white_check_mark::white_check_mark::x:, all paths are drawn

Compensation Path

The term "compensate" is borrowed from business processes where it refers to the undoing of work as part of handling a fault.

When reviewing a process, it's useful to identify which parts of the process are in service of the happy path versus those in the compensation path.

Currently, the library uses a regex to match on the state's name to decide if it's in the compensation path. This will be made configurable as part of the theme. There isn't a good way to determine the compensation path without hints from the config.

Configuration

A user supplied file that conforms to the config-schema.json type can be provided to control the diagram theme.

{
  "theme": {
    "skinparams": {
      "ArrowColor": "#black"
    },
    "states": {
      "Pass": {
        "BackgroundColor": "#whitesmoke"
      },
      "Map": {
        "BackgroundColor": "#whitesmoke"
      },
      "Choice": {
        "BackgroundColor": "#whitesmoke"
      },
      "Parallel": {
        "BackgroundColor": "#whitesmoke"
      },
      "Wait": {
        "BackgroundColor": "#whitesmoke"
      },
      "Task": {
        "BackgroundColor": "#lightblue"
      },
      "Fail": {
        "BackgroundColor": "#red"
      },
      "Succeed": {
        "BackgroundColor": "#green"
      }
    },
    "lines": {
      "fromCatch": {
        "bold": true,
        "color": "#orange"
      },
      "toFail": {
        "color": "#pink"
      }
    },
    "compensation": {
      "pattern": "^.*(compensate).*$",
      "color": "#orange"
    }
  }
}

See also

License

See LICENSE.

0.21.0

4 months ago

0.20.0

8 months ago

0.19.0

9 months ago

0.17.2

9 months ago

0.16.0

9 months ago

0.17.0

9 months ago

0.18.0

9 months ago

0.17.1

9 months ago

0.15.0

1 year ago

0.15.1

1 year ago

0.14.5

1 year ago

0.14.6

1 year ago

0.14.7

1 year ago

0.14.8

1 year ago

0.13.0

1 year ago

0.14.0

1 year ago

0.13.1

1 year ago

0.14.1

1 year ago

0.13.2

1 year ago

0.14.2

1 year ago

0.14.3

1 year ago

0.14.4

1 year ago

0.10.0

1 year ago

0.11.0

1 year ago

0.12.0

1 year ago

0.9.0

1 year ago

0.6.3

1 year ago

0.8.0

1 year ago

0.6.4

1 year ago

0.7.0

1 year ago

0.6.2

2 years ago

0.6.1

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago