generateFromAwsResponse
function generateFromAwsResponse(params): | SvgOutput | HtmlOutput | MermaidOutput;Defined in: src/index.ts:277
Generate a diagram from an AWS SDK DescribeStateMachine response
This is a convenience function for integrating with the AWS SDK. It extracts the ASL definition from the response and generates a diagram.
Parameters
Section titled “Parameters”params
Section titled “params”Configuration object
Returns
Section titled “Returns”| SvgOutput
| HtmlOutput
| MermaidOutput
SVG output if format is ‘svg’, Mermaid output if format is ‘mermaid’
Throws
Section titled “Throws”If response.definition is missing
Throws
Section titled “Throws”If the definition contains invalid JSON (also an instanceof SyntaxError and AslValidationError)
Throws
Section titled “Throws”If the ASL definition structure is invalid
Example
Section titled “Example”import { SFNClient, DescribeStateMachineCommand } from '@aws-sdk/client-sfn';import { generateFromAwsResponse } from 'sfn-diagram';
const client = new SFNClient({ region: 'us-east-1' });const response = await client.send( new DescribeStateMachineCommand({ stateMachineArn: 'arn:aws:states:...' }));
const { svg } = generateFromAwsResponse({ response, theme: 'light', layout: 'TB'});