npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

asl-puml

v0.21.0

Published

Generates a plant uml file from a valid JSON ASL file

Downloads

38

Readme

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 Requirement | asl-puml | AWS Toolkit | AWS Workflow Studio | |-----------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------| | renders the step function as a state diagram | Diagram of the step function in the style of a PlantUML State Diagram with colors | shows state machine rendered by AWS Toolkit with generic rendering for every state | shows 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.