generateFromAwsResponse
Call Signature
Section titled “Call Signature”function generateFromAwsResponse(params): SvgOutput;Defined in: src/index.ts:323
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.
Pass format as a literal ('svg' or 'mermaid') to get the matching output type;
omitted or non-literal, the return type is the union (SVG at runtime when omitted).
For HTML, pass response.definition to generateHtml from sfn-diagram/html.
Parameters
Section titled “Parameters”params
Section titled “params”GenerateFromAwsParams & object
Configuration object
Returns
Section titled “Returns”SVG output if format is ‘svg’, Mermaid output if format is ‘mermaid’
Throws
Section titled “Throws”If response.definition is missing, or if format is ‘html’ or ‘png’
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, format: 'svg', theme: 'light', layout: 'TB'});Call Signature
Section titled “Call Signature”function generateFromAwsResponse(params): MermaidOutput;Defined in: src/index.ts:335
Generate a Mermaid diagram from an AWS SDK DescribeStateMachine response.
Parameters
Section titled “Parameters”params
Section titled “params”GenerateFromAwsParams & object
Configuration object with format: 'mermaid'
Returns
Section titled “Returns”Mermaid output
Throws
Section titled “Throws”If response.definition is missing, or the ASL definition is invalid
Example
Section titled “Example”const { code } = generateFromAwsResponse({ response, format: 'mermaid' });Call Signature
Section titled “Call Signature”function generateFromAwsResponse(params): | SvgOutput | MermaidOutput;Defined in: src/index.ts:349
Generate a diagram from an AWS SDK response whose format is omitted or not known at compile time.
Parameters
Section titled “Parameters”params
Section titled “params”Configuration object
Returns
Section titled “Returns”The union; SVG at runtime when format is omitted
Throws
Section titled “Throws”If response.definition is missing, the ASL definition is invalid, or format is ‘html’ or ‘png’
Example
Section titled “Example”const result = generateFromAwsResponse({ response });if ('svg' in result) { console.log(result.svg); }