sfn-diagram 1.7.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
 
@@ -61,7 +63,7 @@ There's no shortage of ways to look at a state machine โ€” this is where sfn-dia
61
63
 
62
64
  | | **sfn-diagram** | AWS Console visualizer | Mermaid Live Editor |
63
65
  |---|---|---|---|
64
- | Input | ASL, CloudFormation/SAM/CDK templates, live AWS state machines | Deployed state machine only | Manual Mermaid you write by hand |
66
+ | Input | ASL, CloudFormation/SAM/CDK templates, Terraform configs, live AWS state machines | Deployed state machine only | Manual Mermaid you write by hand |
65
67
  | Output | SVG, Mermaid, PNG, interactive HTML | Static graph in-browser | Mermaid diagram only |
66
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 |
67
69
  | Execution overlays | Paints a real run's path/status/duration onto the diagram | Basic per-execution highlighting, console-only | Not applicable |
@@ -70,21 +72,62 @@ There's no shortage of ways to look at a state machine โ€” this is where sfn-dia
70
72
 
71
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.
72
74
 
75
+ ## Command line
76
+
77
+ Render what is actually deployed, with `--from-aws`:
78
+
79
+ ```bash
80
+ pnpm add @aws-sdk/client-sfn # optional peer, only needed for --from-aws
81
+ sfn-diagram --from-aws arn:aws:states:us-east-1:111122223333:stateMachine:Orders -o live.svg
82
+ ```
83
+
84
+ The region comes from the ARN and credentials from the AWS SDK's default chain, so
85
+ `AWS_PROFILE`, SSO and instance roles work as they do for the AWS CLI. The flag takes a
86
+ state machine, version or alias ARN โ€” not a bare name โ€” is repeatable with `--out-dir`,
87
+ and combines with `--diff` (whose baseline may itself be an ARN, for live-against-live
88
+ drift), `--execution` and `--check`. It needs the optional peer above, so it is
89
+ unavailable in the [standalone binary](https://sfn.yusufaf.dev/guides/cli/#standalone-binary).
90
+ See [Rendering a live state machine](https://sfn.yusufaf.dev/guides/cli/#rendering-a-live-state-machine).
91
+
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.
95
+
96
+ ```bash
97
+ sfn-diagram my-workflow.asl.json --format png --scale 2 -o diagram@2x.png
98
+ ```
99
+
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.
104
+
105
+ ```bash
106
+ sfn-diagram my-workflow.asl.json --format html --redact-fields Parameters,Arguments -o share.html
107
+ ```
108
+
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).
113
+
73
114
  ## Features
74
115
 
75
- - **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
76
117
  - **Automatic Layout**: Smart graph positioning using Dagre layout engine
77
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
78
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
79
120
  - **Visual Diffing**: Compare two definitions and highlight added / modified / removed states โ€” drives the PR-preview GitHub Action
80
- - **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
81
- - **Customizable Themes**: AWS light/dark themes plus custom theme support
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
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
82
124
  - **Flexible Layouts**: Top-bottom, left-right, right-left, bottom-top
83
125
  - **Type-Safe**: Full TypeScript support with comprehensive type definitions
84
- - **AWS SDK Integration**: Direct integration with AWS Step Functions API
126
+ - **AWS SDK Integration**: Direct integration with AWS Step Functions API, from the API (`generateFromAwsResponse`) or the CLI (`--from-aws <arn>`)
85
127
  - **Dual APIs**: Function-based and class-based interfaces
86
128
  - **Runs Anywhere**: SVG and Mermaid generation has zero platform dependencies โ€” works in Node, the browser, and edge runtimes
87
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).
88
131
 
89
132
  ## Supported state types
90
133
 
@@ -109,7 +152,7 @@ Full documentation lives at **[sfn.yusufaf.dev](https://sfn.yusufaf.dev)**.
109
152
 
110
153
  - [Introduction](https://sfn.yusufaf.dev/introduction/) โ€” what it does and how it compares
111
154
  - [Quick start](https://sfn.yusufaf.dev/quick-start/) โ€” your first diagram
112
- - [Command line](https://sfn.yusufaf.dev/guides/cli/) โ€” the `sfn-diagram` CLI, diffs, and execution overlays
155
+ - [Command line](https://sfn.yusufaf.dev/guides/cli/) โ€” the `sfn-diagram` CLI, flags, exit codes, diffs, and execution overlays
113
156
  - [Configuration](https://sfn.yusufaf.dev/guides/configuration/) โ€” themes, layouts, edge styles, service icons
114
157
  - [Examples](https://sfn.yusufaf.dev/guides/examples/) โ€” complete worked examples
115
158
  - [Use with your framework](https://sfn.yusufaf.dev/guides/frameworks/) โ€” Next.js, Remix, SvelteKit, Astro