sfn-diagram 1.8.0 โ†’ 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,10 +6,12 @@
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
7
  [![Docs](https://img.shields.io/badge/docs-sfn.yusufaf.dev-brightgreen)](https://sfn.yusufaf.dev)
8
8
 
9
- Generate diagrams from AWS Step Functions ASL (Amazon States Language) definitions, CloudFormation/SAM/CDK templates, or live AWS state machines. Outputs SVG, Mermaid, standalone HTML, and PNG.
9
+ Generate diagrams from AWS Step Functions ASL (Amazon States Language) definitions, CloudFormation/SAM/CDK templates, Terraform configs, or live AWS state machines. Outputs SVG, Mermaid, standalone HTML, and PNG.
10
10
 
11
11
  **๐Ÿ“– [Documentation](https://sfn.yusufaf.dev)** ยท **โ–ถ [Live playground](https://sfn.yusufaf.dev/playground/)** โ€” paste any ASL definition and preview the diagram instantly, no install required.
12
12
 
13
+ **Use it as:** [CLI & Node library](https://www.npmjs.com/package/sfn-diagram) ยท VS Code extension ([Marketplace](https://marketplace.visualstudio.com/items?itemName=yusufaf.vscode-sfn-diagram) ยท [Open VSX](https://open-vsx.org/extension/yusufaf/vscode-sfn-diagram)) ยท [GitHub Action](https://github.com/marketplace/actions/step-functions-diagram-preview) ยท [React component](https://www.npmjs.com/package/sfn-diagram-react)
14
+
13
15
  <picture>
14
16
  <source media="(prefers-color-scheme: dark)" srcset="docs/images/parallel-dark.svg">
15
17
  <img src="docs/images/parallel-light.svg" alt="Example diagram of a Parallel state Step Functions workflow generated by sfn-diagram" width="410">
@@ -27,7 +29,7 @@ The core package pulls in **no browser engine or native rasterizer** โ€” SVG and
27
29
  npm install sfn-diagram @resvg/resvg-js
28
30
  ```
29
31
 
30
- Not a Node project? The CLI also ships as standalone binaries for Linux, macOS, and Windows on every [release](https://github.com/yusufaf/sfn-diagram/releases), or via Homebrew (`brew install yusufaf/tap/sfn-diagram`), and as a [Docker image](https://sfn.yusufaf.dev/guides/cli/#docker). See [using sfn-diagram from other languages](https://sfn.yusufaf.dev/guides/other-languages/).
32
+ Not a Node project? The CLI also ships as standalone binaries for Linux, macOS, and Windows, attached to every core release from v1.6.0 on ([download](https://sfn.yusufaf.dev/installation/#cli-without-node)), or via Homebrew (`brew install yusufaf/tap/sfn-diagram`), and as a [Docker image](https://sfn.yusufaf.dev/guides/cli/#docker). See [using sfn-diagram from other languages](https://sfn.yusufaf.dev/guides/other-languages/).
31
33
 
32
34
  ## Quick start
33
35
 
@@ -55,7 +57,24 @@ Prefer the command line:
55
57
  npx sfn-diagram my-workflow.asl.json --format svg -o diagram.svg
56
58
  ```
57
59
 
58
- Or render what is actually deployed, with `--from-aws`:
60
+ ## Why sfn-diagram
61
+
62
+ There's no shortage of ways to look at a state machine โ€” this is where sfn-diagram fits versus the other two most common options:
63
+
64
+ | | **sfn-diagram** | AWS Console visualizer | Mermaid Live Editor |
65
+ |---|---|---|---|
66
+ | Input | ASL, CloudFormation/SAM/CDK templates, Terraform configs, live AWS state machines | Deployed state machine only | Manual Mermaid you write by hand |
67
+ | Output | SVG, Mermaid, PNG, interactive HTML | Static graph in-browser | Mermaid diagram only |
68
+ | CI / PR integration | [GitHub Action](https://sfn.yusufaf.dev/ecosystem/github-action/) or [GitLab CI](https://sfn.yusufaf.dev/ecosystem/gitlab/) posts a diff overlay on every PR/MR that touches ASL | None | None |
69
+ | Execution overlays | Paints a real run's path/status/duration onto the diagram | Basic per-execution highlighting, console-only | Not applicable |
70
+ | Runs where | CLI, Node, browser, edge runtimes | AWS Console only | Web app only |
71
+ | Automation | Full programmatic API (`generateSvg`, `generateMermaid`, etc.) | None โ€” UI only | None โ€” UI only |
72
+
73
+ In short: reach for the AWS Console visualizer to eyeball a state machine you already deployed, reach for Mermaid Live if you're hand-drawing a diagram from scratch โ€” reach for sfn-diagram when you want diagrams generated automatically from your actual definition, checked into CI, and diffed on every pull request.
74
+
75
+ ## Command line
76
+
77
+ Render what is actually deployed, with `--from-aws`:
59
78
 
60
79
  ```bash
61
80
  pnpm add @aws-sdk/client-sfn # optional peer, only needed for --from-aws
@@ -70,42 +89,45 @@ drift), `--execution` and `--check`. It needs the optional peer above, so it is
70
89
  unavailable in the [standalone binary](https://sfn.yusufaf.dev/guides/cli/#standalone-binary).
71
90
  See [Rendering a live state machine](https://sfn.yusufaf.dev/guides/cli/#rendering-a-live-state-machine).
72
91
 
73
- It exits `0` on success, `1` when something goes wrong while running โ€” including a failed
74
- AWS call โ€” and `2` when the invocation itself was wrong, so a CI job can tell a bad flag
75
- from a bad definition. See
76
- [Exit codes](https://sfn.yusufaf.dev/guides/cli/#exit-codes).
92
+ `--scale` raises PNG resolution without changing the layout; see
93
+ [PNG resolution and fonts](https://sfn.yusufaf.dev/guides/cli/#png-resolution-and-fonts)
94
+ for the font options.
77
95
 
78
- ## Why sfn-diagram
96
+ ```bash
97
+ sfn-diagram my-workflow.asl.json --format png --scale 2 -o diagram@2x.png
98
+ ```
79
99
 
80
- There's no shortage of ways to look at a state machine โ€” this is where sfn-diagram fits versus the other two most common options:
100
+ An HTML document inlines every state's raw ASL for its detail panel. `--redact-fields`
101
+ replaces the named fields with `[redacted]`, and `--no-raw-state` replaces every state's;
102
+ see [Redacting the HTML document](https://sfn.yusufaf.dev/guides/cli/#redacting-the-html-document)
103
+ for what they don't cover.
81
104
 
82
- | | **sfn-diagram** | AWS Console visualizer | Mermaid Live Editor |
83
- |---|---|---|---|
84
- | Input | ASL, CloudFormation/SAM/CDK templates, live AWS state machines | Deployed state machine only | Manual Mermaid you write by hand |
85
- | Output | SVG, Mermaid, PNG, interactive HTML | Static graph in-browser | Mermaid diagram only |
86
- | CI / PR integration | [GitHub Action](https://sfn.yusufaf.dev/ecosystem/github-action/) or [GitLab CI](https://sfn.yusufaf.dev/ecosystem/gitlab/) posts a diff overlay on every PR/MR that touches ASL | None | None |
87
- | Execution overlays | Paints a real run's path/status/duration onto the diagram | Basic per-execution highlighting, console-only | Not applicable |
88
- | Runs where | CLI, Node, browser, edge runtimes | AWS Console only | Web app only |
89
- | Automation | Full programmatic API (`generateSvg`, `generateMermaid`, etc.) | None โ€” UI only | None โ€” UI only |
105
+ ```bash
106
+ sfn-diagram my-workflow.asl.json --format html --redact-fields Parameters,Arguments -o share.html
107
+ ```
90
108
 
91
- In short: reach for the AWS Console visualizer to eyeball a state machine you already deployed, reach for Mermaid Live if you're hand-drawing a diagram from scratch โ€” reach for sfn-diagram when you want diagrams generated automatically from your actual definition, checked into CI, and diffed on every pull request.
109
+ The CLI exits `0` on success, `1` when something goes wrong while running โ€” including a failed
110
+ AWS call โ€” and `2` when the invocation itself was wrong, so a CI job can tell a bad flag
111
+ from a bad definition. See
112
+ [Exit codes](https://sfn.yusufaf.dev/guides/cli/#exit-codes).
92
113
 
93
114
  ## Features
94
115
 
95
- - **Multiple Output Formats**: SVG (D3.js), Mermaid syntax, and PNG
116
+ - **Multiple Output Formats**: SVG, Mermaid syntax, a self-contained interactive HTML viewer, and PNG
96
117
  - **Automatic Layout**: Smart graph positioning using Dagre layout engine
97
118
  - **Full ASL Support**: All state types (Pass, Task, Choice, Wait, Succeed, Fail, Parallel, Map), both JSONPath and JSONata query languages, plus `Catch`/`Retry` rendering
98
119
  - **Modern ASL**: Variables (`Assign`) shown per state, and Distributed Map rendered distinctly from an inline Map โ€” including its `MaxConcurrency`, `ItemReader` source, and `ResultWriter` sink
99
120
  - **Visual Diffing**: Compare two definitions and highlight added / modified / removed states โ€” drives the PR-preview GitHub Action
100
121
  - **Linting**: `lintAsl()` returns every structural and semantic finding at once (unreachable states, dangling transitions, `End` with `Next`, JSONPath/JSONata field mixing, โ€ฆ); `sfn-diagram --check` fails CI on errors
101
- - **Execution Overlays**: Paint a real execution's history onto the diagram โ€” succeeded/failed/caught/not-reached states, the taken path, and per-state duration & retry counts. From a saved history file or live from an execution ARN, and `--follow` keeps re-rendering until the run finishes
102
- - **Customizable Themes**: AWS light/dark themes plus custom theme support
122
+ - **Execution Overlays**: Paint a real execution's history onto the diagram โ€” succeeded/failed/caught/not-reached states, the taken path, and per-state duration & retry counts. From a saved history file or live from an execution ARN, and `--follow` keeps re-rendering until the run finishes; with `--format html` it can be painted onto a `--diff` in the same viewer
123
+ - **Customizable Themes**: AWS light/dark themes, an `auto` theme that follows the system colour scheme, plus custom theme support
103
124
  - **Flexible Layouts**: Top-bottom, left-right, right-left, bottom-top
104
125
  - **Type-Safe**: Full TypeScript support with comprehensive type definitions
105
126
  - **AWS SDK Integration**: Direct integration with AWS Step Functions API, from the API (`generateFromAwsResponse`) or the CLI (`--from-aws <arn>`)
106
127
  - **Dual APIs**: Function-based and class-based interfaces
107
128
  - **Runs Anywhere**: SVG and Mermaid generation has zero platform dependencies โ€” works in Node, the browser, and edge runtimes
108
129
  - **Collapse Large Diagrams**: Replace Parallel/Map containers with placeholder nodes before layout so huge diagrams stay readable, with a live toggle in the interactive HTML viewer. See the [configuration guide](https://sfn.yusufaf.dev/guides/configuration/) for `collapse` and every other option.
130
+ - **Layout Cache**: `createLayoutCache()` keeps dagre layouts between renders that don't change geometry, such as a light/dark theme switch, so a long-lived host re-renders a large diagram without laying it out again. Opt-in and bounded; see [Reusing layouts across renders](https://sfn.yusufaf.dev/guides/configuration/#reusing-layouts-across-renders).
109
131
 
110
132
  ## Supported state types
111
133