sfn-diagram 1.6.1 → 1.8.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
@@ -21,10 +21,10 @@ Generate diagrams from AWS Step Functions ASL (Amazon States Language) definitio
21
21
  npm install sfn-diagram
22
22
  ```
23
23
 
24
- The core package pulls in **no browser engine** — SVG and Mermaid generation stay lightweight. PNG export relies on a headless browser, provided by the optional peer dependency `node-html-to-image`. Install it only if you use `sfn-diagram/png`:
24
+ The core package pulls in **no browser engine or native rasterizer** — SVG and Mermaid generation stay lightweight. PNG export uses `@resvg/resvg-js`, a native, browser-free renderer, provided by an optional peer dependency. Install it only if you use `sfn-diagram/png`:
25
25
 
26
26
  ```bash
27
- npm install sfn-diagram node-html-to-image
27
+ npm install sfn-diagram @resvg/resvg-js
28
28
  ```
29
29
 
30
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/).
@@ -55,6 +55,26 @@ Prefer the command line:
55
55
  npx sfn-diagram my-workflow.asl.json --format svg -o diagram.svg
56
56
  ```
57
57
 
58
+ Or render what is actually deployed, with `--from-aws`:
59
+
60
+ ```bash
61
+ pnpm add @aws-sdk/client-sfn # optional peer, only needed for --from-aws
62
+ sfn-diagram --from-aws arn:aws:states:us-east-1:111122223333:stateMachine:Orders -o live.svg
63
+ ```
64
+
65
+ The region comes from the ARN and credentials from the AWS SDK's default chain, so
66
+ `AWS_PROFILE`, SSO and instance roles work as they do for the AWS CLI. The flag takes a
67
+ state machine, version or alias ARN — not a bare name — is repeatable with `--out-dir`,
68
+ and combines with `--diff` (whose baseline may itself be an ARN, for live-against-live
69
+ drift), `--execution` and `--check`. It needs the optional peer above, so it is
70
+ unavailable in the [standalone binary](https://sfn.yusufaf.dev/guides/cli/#standalone-binary).
71
+ See [Rendering a live state machine](https://sfn.yusufaf.dev/guides/cli/#rendering-a-live-state-machine).
72
+
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).
77
+
58
78
  ## Why sfn-diagram
59
79
 
60
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:
@@ -77,11 +97,12 @@ In short: reach for the AWS Console visualizer to eyeball a state machine you al
77
97
  - **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
98
  - **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
99
  - **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
100
+ - **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
81
102
  - **Customizable Themes**: AWS light/dark themes plus custom theme support
82
103
  - **Flexible Layouts**: Top-bottom, left-right, right-left, bottom-top
83
104
  - **Type-Safe**: Full TypeScript support with comprehensive type definitions
84
- - **AWS SDK Integration**: Direct integration with AWS Step Functions API
105
+ - **AWS SDK Integration**: Direct integration with AWS Step Functions API, from the API (`generateFromAwsResponse`) or the CLI (`--from-aws <arn>`)
85
106
  - **Dual APIs**: Function-based and class-based interfaces
86
107
  - **Runs Anywhere**: SVG and Mermaid generation has zero platform dependencies — works in Node, the browser, and edge runtimes
87
108
  - **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.
@@ -109,7 +130,7 @@ Full documentation lives at **[sfn.yusufaf.dev](https://sfn.yusufaf.dev)**.
109
130
 
110
131
  - [Introduction](https://sfn.yusufaf.dev/introduction/) — what it does and how it compares
111
132
  - [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
133
+ - [Command line](https://sfn.yusufaf.dev/guides/cli/) — the `sfn-diagram` CLI, flags, exit codes, diffs, and execution overlays
113
134
  - [Configuration](https://sfn.yusufaf.dev/guides/configuration/) — themes, layouts, edge styles, service icons
114
135
  - [Examples](https://sfn.yusufaf.dev/guides/examples/) — complete worked examples
115
136
  - [Use with your framework](https://sfn.yusufaf.dev/guides/frameworks/) — Next.js, Remix, SvelteKit, Astro
package/dist/aws.cjs CHANGED
@@ -1,4 +1,3 @@
1
- require("./ci.cjs");
2
1
  let _aws_sdk_client_sfn = require("@aws-sdk/client-sfn");
3
2
  //#region src/aws.ts
4
3
  /**
package/dist/aws.d.cts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { HistoryEvent, SFNClient } from "@aws-sdk/client-sfn";
2
-
3
2
  //#region src/aws.d.ts
4
- interface FetchExecutionHistoryParams {
3
+ export interface FetchExecutionHistoryParams {
5
4
  /** A caller-constructed SFN client (with the caller's credentials/region). */
6
5
  client: SFNClient;
7
6
  /** ARN of the execution whose history should be fetched. */
@@ -10,27 +9,26 @@ interface FetchExecutionHistoryParams {
10
9
  maxResults?: number;
11
10
  }
12
11
  /**
13
- * Fetches the complete history of a Step Functions execution, paginating through
14
- * every `GetExecutionHistory` page so callers don't have to hand-roll the
15
- * `nextToken` loop.
16
- *
17
- * The returned `HistoryEvent[]` can be passed straight to `parseExecutionHistory`,
18
- * `generateExecution`, or `generateMermaidExecution` from `sfn-diagram`.
19
- *
20
- * @param params - The SFN client, execution ARN, and optional page size.
21
- * @returns All history events for the execution, in chronological order.
22
- *
23
- * @example
24
- * ```ts
25
- * import { SFNClient } from '@aws-sdk/client-sfn';
26
- * import { fetchExecutionHistory } from 'sfn-diagram/aws';
27
- * import { generateExecution } from 'sfn-diagram';
28
- *
29
- * const client = new SFNClient({ region: 'us-east-1' });
30
- * const events = await fetchExecutionHistory({ client, executionArn });
31
- * const { svg } = generateExecution({ aslDefinition: asl, history: events });
32
- * ```
33
- */
34
- declare function fetchExecutionHistory(params: FetchExecutionHistoryParams): Promise<HistoryEvent[]>;
35
- //#endregion
36
- export { FetchExecutionHistoryParams, fetchExecutionHistory };
12
+ * Fetches the complete history of a Step Functions execution, paginating through
13
+ * every `GetExecutionHistory` page so callers don't have to hand-roll the
14
+ * `nextToken` loop.
15
+ *
16
+ * The returned `HistoryEvent[]` can be passed straight to `parseExecutionHistory`,
17
+ * `generateExecution`, or `generateMermaidExecution` from `sfn-diagram`.
18
+ *
19
+ * @param params - The SFN client, execution ARN, and optional page size.
20
+ * @returns All history events for the execution, in chronological order.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import { SFNClient } from '@aws-sdk/client-sfn';
25
+ * import { fetchExecutionHistory } from 'sfn-diagram/aws';
26
+ * import { generateExecution } from 'sfn-diagram';
27
+ *
28
+ * const client = new SFNClient({ region: 'us-east-1' });
29
+ * const events = await fetchExecutionHistory({ client, executionArn });
30
+ * const { svg } = generateExecution({ aslDefinition: asl, history: events });
31
+ * ```
32
+ */
33
+ export declare function fetchExecutionHistory(params: FetchExecutionHistoryParams): Promise<HistoryEvent[]>;
34
+ //#endregion
package/dist/aws.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { HistoryEvent, SFNClient } from "@aws-sdk/client-sfn";
2
-
3
2
  //#region src/aws.d.ts
4
- interface FetchExecutionHistoryParams {
3
+ export interface FetchExecutionHistoryParams {
5
4
  /** A caller-constructed SFN client (with the caller's credentials/region). */
6
5
  client: SFNClient;
7
6
  /** ARN of the execution whose history should be fetched. */
@@ -10,27 +9,26 @@ interface FetchExecutionHistoryParams {
10
9
  maxResults?: number;
11
10
  }
12
11
  /**
13
- * Fetches the complete history of a Step Functions execution, paginating through
14
- * every `GetExecutionHistory` page so callers don't have to hand-roll the
15
- * `nextToken` loop.
16
- *
17
- * The returned `HistoryEvent[]` can be passed straight to `parseExecutionHistory`,
18
- * `generateExecution`, or `generateMermaidExecution` from `sfn-diagram`.
19
- *
20
- * @param params - The SFN client, execution ARN, and optional page size.
21
- * @returns All history events for the execution, in chronological order.
22
- *
23
- * @example
24
- * ```ts
25
- * import { SFNClient } from '@aws-sdk/client-sfn';
26
- * import { fetchExecutionHistory } from 'sfn-diagram/aws';
27
- * import { generateExecution } from 'sfn-diagram';
28
- *
29
- * const client = new SFNClient({ region: 'us-east-1' });
30
- * const events = await fetchExecutionHistory({ client, executionArn });
31
- * const { svg } = generateExecution({ aslDefinition: asl, history: events });
32
- * ```
33
- */
34
- declare function fetchExecutionHistory(params: FetchExecutionHistoryParams): Promise<HistoryEvent[]>;
35
- //#endregion
36
- export { FetchExecutionHistoryParams, fetchExecutionHistory };
12
+ * Fetches the complete history of a Step Functions execution, paginating through
13
+ * every `GetExecutionHistory` page so callers don't have to hand-roll the
14
+ * `nextToken` loop.
15
+ *
16
+ * The returned `HistoryEvent[]` can be passed straight to `parseExecutionHistory`,
17
+ * `generateExecution`, or `generateMermaidExecution` from `sfn-diagram`.
18
+ *
19
+ * @param params - The SFN client, execution ARN, and optional page size.
20
+ * @returns All history events for the execution, in chronological order.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import { SFNClient } from '@aws-sdk/client-sfn';
25
+ * import { fetchExecutionHistory } from 'sfn-diagram/aws';
26
+ * import { generateExecution } from 'sfn-diagram';
27
+ *
28
+ * const client = new SFNClient({ region: 'us-east-1' });
29
+ * const events = await fetchExecutionHistory({ client, executionArn });
30
+ * const { svg } = generateExecution({ aslDefinition: asl, history: events });
31
+ * ```
32
+ */
33
+ export declare function fetchExecutionHistory(params: FetchExecutionHistoryParams): Promise<HistoryEvent[]>;
34
+ //#endregion