sfn-diagram 0.2.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.
@@ -0,0 +1,1076 @@
1
+ //#region node_modules/.pnpm/@smithy+types@4.9.0/node_modules/@smithy/types/dist-types/response.d.ts
2
+ /**
3
+ * @public
4
+ */
5
+ interface ResponseMetadata {
6
+ /**
7
+ * The status code of the last HTTP response received for this operation.
8
+ */
9
+ httpStatusCode?: number;
10
+ /**
11
+ * A unique identifier for the last request sent for this operation. Often
12
+ * requested by AWS service teams to aid in debugging.
13
+ */
14
+ requestId?: string;
15
+ /**
16
+ * A secondary identifier for the last request sent. Used for debugging.
17
+ */
18
+ extendedRequestId?: string;
19
+ /**
20
+ * A tertiary identifier for the last request sent. Used for debugging.
21
+ */
22
+ cfId?: string;
23
+ /**
24
+ * The number of times this operation was attempted.
25
+ */
26
+ attempts?: number;
27
+ /**
28
+ * The total amount of time (in milliseconds) that was spent waiting between
29
+ * retry attempts.
30
+ */
31
+ totalRetryDelay?: number;
32
+ }
33
+ /**
34
+ * @public
35
+ */
36
+ interface MetadataBearer {
37
+ /**
38
+ * Metadata pertaining to this request.
39
+ */
40
+ $metadata: ResponseMetadata;
41
+ }
42
+ //#endregion
43
+ //#region node_modules/.pnpm/@smithy+types@4.9.0/node_modules/@smithy/types/dist-types/http/httpHandlerInitialization.d.ts
44
+
45
+ declare global {
46
+ /**
47
+ * interface merging stub.
48
+ */
49
+ interface RequestInit {}
50
+ }
51
+ //#endregion
52
+ //#region node_modules/.pnpm/@aws-sdk+types@3.936.0/node_modules/@aws-sdk/types/dist-types/serde.d.ts
53
+ /**
54
+ * @public
55
+ *
56
+ * Declare DOM interfaces in case dom.d.ts is not added to the tsconfig lib, causing
57
+ * interfaces to not be defined. For developers with dom.d.ts added, the interfaces will
58
+ * be merged correctly.
59
+ *
60
+ * This is also required for any clients with streaming interfaces where the corresponding
61
+ * types are also referred. The type is only declared here once since this `@aws-sdk/types`
62
+ * is depended by all `@aws-sdk` packages.
63
+ */
64
+ declare global {
65
+ /**
66
+ * @public
67
+ */
68
+ export interface ReadableStream {}
69
+ /**
70
+ * @public
71
+ */
72
+ export interface Blob {}
73
+ }
74
+ //#endregion
75
+ //#region node_modules/.pnpm/@aws-sdk+client-sfn@3.940.0/node_modules/@aws-sdk/client-sfn/dist-types/models/enums.d.ts
76
+ /**
77
+ * @public
78
+ * @enum
79
+ */
80
+ declare const EncryptionType: {
81
+ readonly AWS_OWNED_KEY: "AWS_OWNED_KEY";
82
+ readonly CUSTOMER_MANAGED_KMS_KEY: "CUSTOMER_MANAGED_KMS_KEY";
83
+ };
84
+ /**
85
+ * @public
86
+ */
87
+ type EncryptionType = (typeof EncryptionType)[keyof typeof EncryptionType];
88
+ /**
89
+ * @public
90
+ * @enum
91
+ */
92
+ declare const LogLevel: {
93
+ readonly ALL: "ALL";
94
+ readonly ERROR: "ERROR";
95
+ readonly FATAL: "FATAL";
96
+ readonly OFF: "OFF";
97
+ };
98
+ /**
99
+ * @public
100
+ */
101
+ type LogLevel = (typeof LogLevel)[keyof typeof LogLevel];
102
+ /**
103
+ * @public
104
+ * @enum
105
+ */
106
+ declare const StateMachineType: {
107
+ readonly EXPRESS: "EXPRESS";
108
+ readonly STANDARD: "STANDARD";
109
+ };
110
+ /**
111
+ * @public
112
+ */
113
+ type StateMachineType = (typeof StateMachineType)[keyof typeof StateMachineType];
114
+ /**
115
+ * @public
116
+ * @enum
117
+ */
118
+
119
+ /**
120
+ * @public
121
+ * @enum
122
+ */
123
+ declare const StateMachineStatus: {
124
+ readonly ACTIVE: "ACTIVE";
125
+ readonly DELETING: "DELETING";
126
+ };
127
+ /**
128
+ * @public
129
+ */
130
+ type StateMachineStatus = (typeof StateMachineStatus)[keyof typeof StateMachineStatus];
131
+ /**
132
+ * @public
133
+ * @enum
134
+ */
135
+
136
+ //#endregion
137
+ //#region node_modules/.pnpm/@aws-sdk+client-sfn@3.940.0/node_modules/@aws-sdk/client-sfn/dist-types/models/models_0.d.ts
138
+
139
+ /**
140
+ * <p>Settings to configure server-side encryption. </p>
141
+ * <p>
142
+ * For additional control over security, you can encrypt your data using a <b>customer-managed key</b> for Step Functions state machines and activities. You can configure a symmetric KMS key and data key reuse period when creating or updating a <b>State Machine</b>, and when creating an <b>Activity</b>. The execution history and state machine definition will be encrypted with the key applied to the State Machine. Activity inputs will be encrypted with the key applied to the Activity.
143
+ * </p>
144
+ * <note>
145
+ * <p> Step Functions automatically enables encryption at rest using Amazon Web Services owned keys at no charge. However, KMS charges apply when using a customer managed key. For more information about pricing, see <a href="https://aws.amazon.com/kms/pricing/">Key Management Service pricing</a>.</p>
146
+ * </note>
147
+ * <p>For more information on KMS, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/overview.html">What is Key Management Service?</a>
148
+ * </p>
149
+ * @public
150
+ */
151
+ interface EncryptionConfiguration {
152
+ /**
153
+ * <p>An alias, alias ARN, key ID, or key ARN of a symmetric encryption KMS key to encrypt data. To specify a KMS key in a different Amazon Web Services account, you must use the key ARN or alias ARN.</p>
154
+ * @public
155
+ */
156
+ kmsKeyId?: string | undefined;
157
+ /**
158
+ * <p>Maximum duration that Step Functions will reuse data keys. When the period expires, Step Functions will call <code>GenerateDataKey</code>. Only applies to customer managed keys.</p>
159
+ * @public
160
+ */
161
+ kmsDataKeyReusePeriodSeconds?: number | undefined;
162
+ /**
163
+ * <p>Encryption type</p>
164
+ * @public
165
+ */
166
+ type: EncryptionType | undefined;
167
+ }
168
+ /**
169
+ * <p>Tags are key-value pairs that can be associated with Step Functions state machines and
170
+ * activities.</p>
171
+ * <p>An array of key-value pairs. For more information, see <a href="https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/cost-alloc-tags.html">Using
172
+ * Cost Allocation Tags</a> in the <i>Amazon Web Services Billing and Cost Management User
173
+ * Guide</i>, and <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_iam-tags.html">Controlling Access Using IAM
174
+ * Tags</a>.</p>
175
+ * <p>Tags may only contain Unicode letters, digits, white space, or these symbols: <code>_ . : / = + - @</code>.</p>
176
+ * @public
177
+ */
178
+
179
+ /**
180
+ * <p></p>
181
+ * @public
182
+ */
183
+ interface CloudWatchLogsLogGroup {
184
+ /**
185
+ * <p>The ARN of the the CloudWatch log group to which you want your logs emitted to. The ARN
186
+ * must end with <code>:*</code>
187
+ * </p>
188
+ * @public
189
+ */
190
+ logGroupArn?: string | undefined;
191
+ }
192
+ /**
193
+ * <p></p>
194
+ * @public
195
+ */
196
+ interface LogDestination {
197
+ /**
198
+ * <p>An object describing a CloudWatch log group. For more information, see <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-loggroup.html">AWS::Logs::LogGroup</a> in the CloudFormation User Guide.</p>
199
+ * @public
200
+ */
201
+ cloudWatchLogsLogGroup?: CloudWatchLogsLogGroup | undefined;
202
+ }
203
+ /**
204
+ * <p>The <code>LoggingConfiguration</code> data type is used to set CloudWatch Logs
205
+ * options.</p>
206
+ * @public
207
+ */
208
+ interface LoggingConfiguration {
209
+ /**
210
+ * <p>Defines which category of execution history events are logged.</p>
211
+ * @public
212
+ */
213
+ level?: LogLevel | undefined;
214
+ /**
215
+ * <p>Determines whether execution data is included in your log. When set to <code>false</code>,
216
+ * data is excluded.</p>
217
+ * @public
218
+ */
219
+ includeExecutionData?: boolean | undefined;
220
+ /**
221
+ * <p>An array of objects that describes where your execution history events will be logged.
222
+ * Limited to size 1. Required, if your log level is not set to <code>OFF</code>.</p>
223
+ * @public
224
+ */
225
+ destinations?: LogDestination[] | undefined;
226
+ }
227
+ /**
228
+ * <p>Selects whether or not the state machine's X-Ray tracing is enabled. Default is
229
+ * <code>false</code>
230
+ * </p>
231
+ * @public
232
+ */
233
+ interface TracingConfiguration {
234
+ /**
235
+ * <p>When set to <code>true</code>, X-Ray tracing is enabled.</p>
236
+ * @public
237
+ */
238
+ enabled?: boolean | undefined;
239
+ }
240
+ /**
241
+ * @public
242
+ */
243
+
244
+ /**
245
+ * @public
246
+ */
247
+ interface DescribeStateMachineOutput {
248
+ /**
249
+ * <p>The Amazon Resource Name (ARN) that identifies the state machine.</p>
250
+ * <p>If you specified a state machine version ARN in your request, the API returns the version ARN. The version ARN is a combination of state machine ARN and the version number separated by a colon (:). For example, <code>stateMachineARN:1</code>.</p>
251
+ * @public
252
+ */
253
+ stateMachineArn: string | undefined;
254
+ /**
255
+ * <p>The name of the state machine.</p>
256
+ * <p>A name must <i>not</i> contain:</p>
257
+ * <ul>
258
+ * <li>
259
+ * <p>white space</p>
260
+ * </li>
261
+ * <li>
262
+ * <p>brackets <code>< > \{ \} [ ]</code>
263
+ * </p>
264
+ * </li>
265
+ * <li>
266
+ * <p>wildcard characters <code>? *</code>
267
+ * </p>
268
+ * </li>
269
+ * <li>
270
+ * <p>special characters <code>" # % \ ^ | ~ ` $ & , ; : /</code>
271
+ * </p>
272
+ * </li>
273
+ * <li>
274
+ * <p>control characters (<code>U+0000-001F</code>, <code>U+007F-009F</code>, <code>U+FFFE-FFFF</code>)</p>
275
+ * </li>
276
+ * <li>
277
+ * <p>surrogates (<code>U+D800-DFFF</code>)</p>
278
+ * </li>
279
+ * <li>
280
+ * <p>invalid characters (<code> U+10FFFF</code>)</p>
281
+ * </li>
282
+ * </ul>
283
+ * <p>To enable logging with CloudWatch Logs, the name should only contain 0-9, A-Z, a-z, - and _.</p>
284
+ * @public
285
+ */
286
+ name: string | undefined;
287
+ /**
288
+ * <p>The current status of the state machine.</p>
289
+ * @public
290
+ */
291
+ status?: StateMachineStatus | undefined;
292
+ /**
293
+ * <p>The Amazon States Language definition of the state machine. See <a href="https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html">Amazon States Language</a>.</p>
294
+ * <p>If called with <code>includedData = METADATA_ONLY</code>, the returned definition will be <code>\{\}</code>.</p>
295
+ * @public
296
+ */
297
+ definition: string | undefined;
298
+ /**
299
+ * <p>The Amazon Resource Name (ARN) of the IAM role used when creating this state machine. (The IAM role
300
+ * maintains security by granting Step Functions access to Amazon Web Services resources.)</p>
301
+ * @public
302
+ */
303
+ roleArn: string | undefined;
304
+ /**
305
+ * <p>The <code>type</code> of the state machine (<code>STANDARD</code> or
306
+ * <code>EXPRESS</code>).</p>
307
+ * @public
308
+ */
309
+ type: StateMachineType | undefined;
310
+ /**
311
+ * <p>The date the state machine is created.</p>
312
+ * <p>For a state machine version, <code>creationDate</code> is the date the version was created.</p>
313
+ * @public
314
+ */
315
+ creationDate: Date | undefined;
316
+ /**
317
+ * <p>The <code>LoggingConfiguration</code> data type is used to set CloudWatch Logs
318
+ * options.</p>
319
+ * @public
320
+ */
321
+ loggingConfiguration?: LoggingConfiguration | undefined;
322
+ /**
323
+ * <p>Selects whether X-Ray tracing is enabled.</p>
324
+ * @public
325
+ */
326
+ tracingConfiguration?: TracingConfiguration | undefined;
327
+ /**
328
+ * <p>A user-defined or an auto-generated string that identifies a <code>Map</code> state. This parameter is present only if the <code>stateMachineArn</code> specified in input is a qualified state machine ARN.</p>
329
+ * @public
330
+ */
331
+ label?: string | undefined;
332
+ /**
333
+ * <p>The revision identifier for the state machine.</p>
334
+ * <p>Use the <code>revisionId</code> parameter to compare between versions of a state machine
335
+ * configuration used for executions without performing a diff of the properties, such as
336
+ * <code>definition</code> and <code>roleArn</code>.</p>
337
+ * @public
338
+ */
339
+ revisionId?: string | undefined;
340
+ /**
341
+ * <p>The description of the state machine version.</p>
342
+ * @public
343
+ */
344
+ description?: string | undefined;
345
+ /**
346
+ * <p>Settings to configure server-side encryption. </p>
347
+ * @public
348
+ */
349
+ encryptionConfiguration?: EncryptionConfiguration | undefined;
350
+ /**
351
+ * <p>A map of <b>state name</b> to a list of variables referenced by that state. States that do not use variable references will not be shown in the response.</p>
352
+ * @public
353
+ */
354
+ variableReferences?: Record<string, string[]> | undefined;
355
+ }
356
+ /**
357
+ * @public
358
+ */
359
+ //#endregion
360
+ //#region node_modules/.pnpm/@aws-sdk+client-sfn@3.940.0/node_modules/@aws-sdk/client-sfn/dist-types/commands/DescribeStateMachineCommand.d.ts
361
+ /**
362
+ * @public
363
+ *
364
+ * The output of {@link DescribeStateMachineCommand}.
365
+ */
366
+ interface DescribeStateMachineCommandOutput extends DescribeStateMachineOutput, MetadataBearer {}
367
+ //#endregion
368
+ //#region src/types/index.d.ts
369
+ type StateType = 'Pass' | 'Task' | 'Choice' | 'Wait' | 'Succeed' | 'Fail' | 'Parallel' | 'Map';
370
+ interface CatchBlock {
371
+ ErrorEquals: string[];
372
+ Next?: string;
373
+ ResultPath?: string;
374
+ }
375
+ interface RetryBlock {
376
+ BackoffRate?: number;
377
+ ErrorEquals: string[];
378
+ IntervalSeconds?: number;
379
+ MaxAttempts?: number;
380
+ }
381
+ interface ChoiceRule {
382
+ BooleanEquals?: boolean;
383
+ Next: string;
384
+ NumericEquals?: number;
385
+ StringEquals?: string;
386
+ Variable?: string;
387
+ [key: string]: any;
388
+ }
389
+ interface AslState {
390
+ Assign?: Record<string, any>;
391
+ Branches?: AslDefinition[];
392
+ Catch?: CatchBlock[];
393
+ Cause?: string;
394
+ Choices?: ChoiceRule[];
395
+ Comment?: string;
396
+ Default?: string;
397
+ End?: boolean;
398
+ Error?: string;
399
+ Iterator?: AslDefinition;
400
+ Next?: string;
401
+ Output?: any;
402
+ Parameters?: Record<string, any>;
403
+ Resource?: string;
404
+ Result?: any;
405
+ ResultPath?: string;
406
+ Retry?: RetryBlock[];
407
+ Seconds?: number | string;
408
+ SecondsPath?: string;
409
+ Timestamp?: string;
410
+ TimestampPath?: string;
411
+ Type: StateType;
412
+ }
413
+ interface AslDefinition {
414
+ Comment?: string;
415
+ QueryLanguage?: 'JSONata' | 'JSONPath';
416
+ StartAt: string;
417
+ States: Record<string, AslState>;
418
+ TimeoutSeconds?: number;
419
+ Version?: string;
420
+ }
421
+ interface StateNode {
422
+ /** Child node IDs (for container nodes like Parallel/Map) */
423
+ children?: string[];
424
+ height?: number;
425
+ /** URL to AWS service icon (CDN path for Task states) */
426
+ iconUrl?: string;
427
+ id: string;
428
+ /** Whether this node is a container (Parallel or Map state) */
429
+ isContainer?: boolean;
430
+ label: string;
431
+ /** Parent node ID (for nodes inside Parallel/Map containers) */
432
+ parent?: string;
433
+ /** AWS service identifier for Task states (e.g., 'lambda', 's3') */
434
+ serviceType?: string;
435
+ style?: NodeStyle;
436
+ type: string;
437
+ width?: number;
438
+ x?: number;
439
+ y?: number;
440
+ }
441
+ /** Edge types for state transitions */
442
+ type EdgeType = 'normal' | 'error' | 'choice' | 'default';
443
+ interface GraphEdge {
444
+ condition?: string;
445
+ from: string;
446
+ label?: string;
447
+ to: string;
448
+ type?: EdgeType;
449
+ visualOnly?: boolean;
450
+ }
451
+ /** Node shape types for rendering state nodes */
452
+ type NodeShape = 'rect' | 'diamond' | 'circle';
453
+ interface NodeStyle {
454
+ fill: string;
455
+ stroke: string;
456
+ strokeWidth: number;
457
+ shape: NodeShape;
458
+ }
459
+ interface CustomTheme {
460
+ background: string;
461
+ edgeColors: {
462
+ choice: string;
463
+ default: string;
464
+ error: string;
465
+ normal: string;
466
+ };
467
+ fontFamily: string;
468
+ fontSize: number;
469
+ nodeColors: Record<StateType, {
470
+ fill: string;
471
+ stroke: string;
472
+ }>;
473
+ textColor: string;
474
+ }
475
+ /** Supported output formats for diagram generation */
476
+ type DiagramFormat = 'svg' | 'mermaid' | 'png';
477
+ /** Theme options: built-in themes or custom theme object */
478
+ type ThemeOption = 'light' | 'dark' | CustomTheme;
479
+ /** Graph layout direction */
480
+ type LayoutDirection = 'TB' | 'LR' | 'RL' | 'BT';
481
+ /** Edge path rendering style */
482
+ type EdgePathStyle = 'straight' | 'curved' | 'orthogonal';
483
+ /** Catch/Retry label display style */
484
+ type CatchLabelStyle = 'error-type' | 'catch-number';
485
+ /** Visual style preset for node shapes */
486
+ type StylePreset = 'aws-standard' | 'enhanced';
487
+ interface DiagramOptions {
488
+ /**
489
+ * Background color for PNG export
490
+ * @default 'transparent'
491
+ */
492
+ backgroundColor?: string | 'transparent';
493
+ /**
494
+ * Style for Catch block edge labels: 'error-type' shows error names, 'catch-number' shows "Catch #N"
495
+ * @default 'error-type'
496
+ */
497
+ catchLabelStyle?: CatchLabelStyle;
498
+ /** Custom styling overrides for specific state types */
499
+ customColors?: Partial<Record<StateType, NodeStyle>>;
500
+ /**
501
+ * Style of edge paths: straight, curved, or orthogonal
502
+ * @default 'curved'
503
+ */
504
+ edgeStyle?: EdgePathStyle;
505
+ /** Output format for the diagram */
506
+ format?: DiagramFormat;
507
+ /** Overall diagram height in pixels (auto-calculated if not specified) */
508
+ height?: number;
509
+ /**
510
+ * Position of AWS service icons relative to node label
511
+ * @default 'left'
512
+ */
513
+ iconPosition?: 'left' | 'top' | 'right';
514
+ /** Custom function to resolve icon URLs for services */
515
+ iconResolver?: (service: string) => string | null;
516
+ /**
517
+ * Size of AWS service icons in pixels
518
+ * @default 24
519
+ */
520
+ iconSize?: number;
521
+ /**
522
+ * Whether to use state comments as node labels
523
+ * @default true
524
+ */
525
+ includeComments?: boolean;
526
+ /** Graph layout direction: TB (top-bottom), LR (left-right), RL (right-left), BT (bottom-top) */
527
+ layout?: LayoutDirection;
528
+ /**
529
+ * Height of each state node in pixels
530
+ * @default 60
531
+ */
532
+ nodeHeight?: number;
533
+ /**
534
+ * Horizontal separation between nodes in pixels
535
+ * @default 50
536
+ */
537
+ nodeSeparation?: number;
538
+ /**
539
+ * Width of each state node in pixels
540
+ * @default 120
541
+ */
542
+ nodeWidth?: number;
543
+ /**
544
+ * Padding around the diagram in pixels
545
+ * @default 20
546
+ */
547
+ padding?: number;
548
+ /**
549
+ * PNG export quality from 1-100
550
+ * @default 90
551
+ */
552
+ pngQuality?: number;
553
+ /**
554
+ * Vertical separation between ranks in pixels
555
+ * @default 50
556
+ */
557
+ rankSeparation?: number;
558
+ /**
559
+ * Whether to display AWS service icons on Task state nodes
560
+ * @default false
561
+ */
562
+ showIcons?: boolean;
563
+ /**
564
+ * Whether to display state type labels on nodes
565
+ * @default false
566
+ */
567
+ showStateTypes?: boolean;
568
+ /**
569
+ * Visual style preset: 'aws-standard' uses rectangles (AWS parity), 'enhanced' uses shapes for visual distinction
570
+ * @default 'aws-standard'
571
+ */
572
+ stylePreset?: StylePreset;
573
+ /** Color theme: 'light', 'dark', or custom theme object */
574
+ theme?: ThemeOption;
575
+ /** Overall diagram width in pixels (auto-calculated if not specified) */
576
+ width?: number;
577
+ }
578
+ /** SVG diagram output */
579
+ interface SvgOutput {
580
+ /** Height of the diagram in pixels */
581
+ height: number;
582
+ /** Metadata about the generated diagram */
583
+ metadata: {
584
+ /** Number of edges (transitions) in the diagram */
585
+ edgeCount: number;
586
+ /** Number of state nodes in the diagram */
587
+ nodeCount: number;
588
+ };
589
+ /** Complete SVG markup as a string */
590
+ svg: string;
591
+ /** Width of the diagram in pixels */
592
+ width: number;
593
+ }
594
+ /** Mermaid diagram code output */
595
+ interface MermaidOutput {
596
+ /** Mermaid state diagram syntax */
597
+ code: string;
598
+ /** Metadata about the generated diagram */
599
+ metadata: {
600
+ /** Number of transitions in the diagram */
601
+ edgeCount: number;
602
+ /** Number of states in the diagram */
603
+ stateCount: number;
604
+ };
605
+ }
606
+ /** PNG image output */
607
+ interface PngOutput {
608
+ /** PNG image data as a Buffer */
609
+ buffer: Buffer;
610
+ /** Height of the image in pixels */
611
+ height: number;
612
+ /** Metadata about the generated image */
613
+ metadata: {
614
+ /** Image format (always 'png') */
615
+ format: 'png';
616
+ };
617
+ /** Width of the image in pixels */
618
+ width: number;
619
+ }
620
+ interface GenerateSvgParams extends DiagramOptions {
621
+ /** ASL definition as object or JSON string */
622
+ aslDefinition: AslDefinition | string;
623
+ }
624
+ interface GenerateMermaidParams extends DiagramOptions {
625
+ /** ASL definition as object or JSON string */
626
+ aslDefinition: AslDefinition | string;
627
+ }
628
+ interface GenerateDiagramParams extends DiagramOptions {
629
+ /** ASL definition as object or JSON string */
630
+ aslDefinition: AslDefinition | string;
631
+ }
632
+ interface ExportPngParams extends DiagramOptions {
633
+ /** ASL definition as object or JSON string */
634
+ aslDefinition: AslDefinition | string;
635
+ }
636
+ interface GenerateFromAwsParams extends DiagramOptions {
637
+ /** AWS SDK DescribeStateMachine command output */
638
+ response: DescribeStateMachineCommandOutput;
639
+ }
640
+ //#endregion
641
+ //#region src/config/themes.d.ts
642
+ /**
643
+ * AWS Light Theme - matches the AWS Step Functions console light mode
644
+ */
645
+ declare const AWS_LIGHT_THEME: CustomTheme;
646
+ /**
647
+ * AWS Dark Theme - matches the AWS Step Functions console dark mode
648
+ */
649
+ declare const AWS_DARK_THEME: CustomTheme;
650
+ /**
651
+ * Get theme object from theme name or custom theme
652
+ */
653
+ //#endregion
654
+ //#region src/utils/iconEmbedder.d.ts
655
+ interface EmbedIconsParams {
656
+ svg: string;
657
+ /** Timeout in milliseconds for each icon fetch (default: 5000) */
658
+ timeoutMs?: number;
659
+ }
660
+ /**
661
+ * Embed external icon URLs in SVG as base64 data URIs
662
+ *
663
+ * This function scans the SVG for external image references (href attributes)
664
+ * and replaces them with inline base64-encoded data URIs. This ensures icons
665
+ * display correctly in standalone SVG files, PNG exports, and contexts where
666
+ * external resources are blocked by security policies.
667
+ *
668
+ * @param params - Parameters for icon embedding
669
+ * @param params.svg - SVG string containing external icon URLs
670
+ * @returns Promise resolving to SVG string with embedded icons
671
+ *
672
+ * @example
673
+ * const svgWithExternalIcons = generateSvg({ aslDefinition, showIcons: true });
674
+ * const svgWithEmbeddedIcons = await embedIcons({ svg: svgWithExternalIcons.svg });
675
+ * writeFileSync('diagram.svg', svgWithEmbeddedIcons);
676
+ *
677
+ * @example
678
+ * // Chain with PNG export
679
+ * const { svg } = generateSvg({ aslDefinition, showIcons: true });
680
+ * const embeddedSvg = await embedIcons({ svg });
681
+ * const png = await exportPng({ svg: embeddedSvg });
682
+ */
683
+ declare function embedIcons(params: EmbedIconsParams): Promise<string>;
684
+ //#endregion
685
+ //#region src/exporters/PngExporter.d.ts
686
+ /** Parameters for converting SVG to PNG */
687
+ interface ConvertParams {
688
+ /** Height of the SVG in pixels */
689
+ height: number;
690
+ /** SVG markup string */
691
+ svg: string;
692
+ /** Width of the SVG in pixels */
693
+ width: number;
694
+ }
695
+ /**
696
+ * PngExporter - Converts SVG to PNG using headless rendering
697
+ */
698
+ declare class PngExporter {
699
+ private options;
700
+ constructor(options: DiagramOptions);
701
+ /**
702
+ * Convert SVG string to PNG buffer
703
+ *
704
+ * Note: External images (like AWS service icons from CDN) may not render in PNG export
705
+ * due to limitations with headless browser rendering. Use SVG output for best results
706
+ * when showIcons is enabled.
707
+ */
708
+ convert(params: ConvertParams): Promise<PngOutput>;
709
+ /**
710
+ * Wrap SVG in HTML for rendering
711
+ */
712
+ private wrapSvgInHtml;
713
+ }
714
+ //#endregion
715
+ //#region src/AslParser.d.ts
716
+ /**
717
+ * Error thrown when ASL validation fails
718
+ */
719
+ declare class AslValidationError extends Error {
720
+ constructor(message: string);
721
+ }
722
+ /**
723
+ * Result of parsing an ASL definition into a graph structure
724
+ */
725
+
726
+ interface ValidateAslParams {
727
+ /** The ASL definition to validate */
728
+ definition: unknown;
729
+ }
730
+ /**
731
+ * Validates an ASL definition and returns helpful error messages
732
+ *
733
+ * @param params - Validation parameters
734
+ * @throws {AslValidationError} When the ASL definition is invalid
735
+ */
736
+ declare function validateAsl(params: ValidateAslParams): void;
737
+ /**
738
+ * Parameters for parsing an ASL definition into a graph
739
+ */
740
+
741
+ //#endregion
742
+ //#region src/index.d.ts
743
+ /**
744
+ * Generate an SVG diagram from an AWS Step Functions ASL definition
745
+ *
746
+ * This function parses an ASL definition and renders it as an SVG diagram using D3.js
747
+ * with automatic graph layout via Dagre. The output is a complete SVG string that can
748
+ * be saved to a file or embedded in HTML.
749
+ *
750
+ * @param params - Configuration object
751
+ * @param params.aslDefinition - ASL definition as an object or JSON string
752
+ * @param params.theme - Color theme: 'light' (default), 'dark', or a CustomTheme object
753
+ * @param params.layout - Layout direction: 'TB' (top-bottom, default), 'LR' (left-right), 'RL', or 'BT'
754
+ * @param params.nodeWidth - Width of state nodes in pixels (default: 120)
755
+ * @param params.nodeHeight - Height of state nodes in pixels (default: 60)
756
+ * @param params.rankSeparation - Vertical separation between ranks in pixels (default: 50)
757
+ * @param params.nodeSeparation - Horizontal separation between nodes in pixels (default: 50)
758
+ * @param params.padding - Padding around the diagram in pixels (default: 20)
759
+ * @param params.edgeStyle - Edge path style: 'curved' (default), 'straight', or 'orthogonal'
760
+ * @param params.showStateTypes - Whether to display state types on nodes (default: false)
761
+ * @param params.includeComments - Whether to use state comments as labels (default: true)
762
+ * @param params.customColors - Override colors for specific state types
763
+ *
764
+ * @returns SVG output containing the diagram string, dimensions, and metadata
765
+ *
766
+ * @throws {SyntaxError} If params.asl is a string with invalid JSON
767
+ * @throws {Error} If the ASL definition structure is invalid
768
+ *
769
+ * @example
770
+ * ```typescript
771
+ * import { generateSvg } from 'sfn-diagram';
772
+ * import { writeFileSync } from 'fs';
773
+ *
774
+ * const asl = {
775
+ * StartAt: 'HelloWorld',
776
+ * States: {
777
+ * HelloWorld: { Type: 'Pass', Result: 'Hello!', End: true }
778
+ * }
779
+ * };
780
+ *
781
+ * const { svg, width, height } = generateSvg({ aslDefinition: asl, theme: 'dark', layout: 'LR' });
782
+ * writeFileSync('diagram.svg', svg);
783
+ * console.log(`Generated ${width}x${height} diagram`);
784
+ * ```
785
+ *
786
+ * @example
787
+ * ```typescript
788
+ * // From JSON string
789
+ * const aslJson = fs.readFileSync('state-machine.json', 'utf-8');
790
+ * const result = generateSvg({ asl: aslJson, theme: 'light' });
791
+ * ```
792
+ *
793
+ * @example
794
+ * ```typescript
795
+ * // With AWS service icons
796
+ * const { svg } = generateSvg({
797
+ * aslDefinition: asl,
798
+ * showIcons: true,
799
+ * iconPosition: 'left',
800
+ * nodeWidth: 150
801
+ * });
802
+ * ```
803
+ */
804
+ declare function generateSvg(params: GenerateSvgParams): SvgOutput;
805
+ /**
806
+ * Generate Mermaid diagram syntax from an AWS Step Functions ASL definition
807
+ *
808
+ * This function converts an ASL definition into Mermaid state diagram syntax,
809
+ * which can be rendered using the Mermaid library or included in Markdown documentation.
810
+ * The output includes CSS classes for styling different state types.
811
+ *
812
+ * @param params - Configuration object
813
+ * @param params.aslDefinition - ASL definition as an object or JSON string
814
+ *
815
+ * @returns Mermaid output containing the diagram code and metadata
816
+ *
817
+ * @throws {SyntaxError} If params.asl is a string with invalid JSON
818
+ * @throws {Error} If the ASL definition structure is invalid
819
+ *
820
+ * @example
821
+ * ```typescript
822
+ * import { generateMermaid } from 'sfn-diagram';
823
+ *
824
+ * const asl = {
825
+ * StartAt: 'Process',
826
+ * States: {
827
+ * Process: { Type: 'Task', Resource: 'arn:aws:...', Next: 'Done' },
828
+ * Done: { Type: 'Succeed' }
829
+ * }
830
+ * };
831
+ *
832
+ * const { code, metadata } = generateMermaid({ asl });
833
+ * console.log(code);
834
+ * // Output:
835
+ * // stateDiagram-v2
836
+ * // [*] --> Process
837
+ * // Process --> Done
838
+ * // Done --> [*]
839
+ * // ...
840
+ *
841
+ * console.log(`Generated diagram with ${metadata.stateCount} states`);
842
+ * ```
843
+ *
844
+ * @example
845
+ * ```typescript
846
+ * // Use in Markdown
847
+ * const { code } = generateMermaid({ asl: myStateMachine });
848
+ * const markdown = `\`\`\`mermaid\n${code}\n\`\`\``;
849
+ * fs.writeFileSync('diagram.md', markdown);
850
+ * ```
851
+ */
852
+ declare function generateMermaid(params: GenerateMermaidParams): MermaidOutput;
853
+ /**
854
+ * Generate a diagram from an ASL definition (auto-detects format from options)
855
+ *
856
+ * This is a convenience function that generates either an SVG or Mermaid diagram
857
+ * based on the `format` option. If no format is specified, defaults to SVG.
858
+ *
859
+ * @param params - Configuration object
860
+ * @param params.aslDefinition - ASL definition as an object or JSON string
861
+ * @param params.format - Output format: 'svg' (default) or 'mermaid'
862
+ * @param params.theme - Color theme (SVG only)
863
+ * @param params.layout - Layout direction (SVG only)
864
+ * @param ...params - Other options (see generateSvg or generateMermaid)
865
+ *
866
+ * @returns SVG output if format is 'svg', Mermaid output if format is 'mermaid'
867
+ *
868
+ * @throws {SyntaxError} If params.asl is a string with invalid JSON
869
+ * @throws {Error} If the ASL definition structure is invalid
870
+ *
871
+ * @example
872
+ * ```typescript
873
+ * import { generateDiagram } from 'sfn-diagram';
874
+ *
875
+ * // Generate SVG (default)
876
+ * const svgResult = generateDiagram({ asl: myAsl });
877
+ *
878
+ * // Generate Mermaid
879
+ * const mermaidResult = generateDiagram({ asl: myAsl, format: 'mermaid' });
880
+ * ```
881
+ */
882
+ declare function generateDiagram(params: GenerateDiagramParams): SvgOutput | MermaidOutput;
883
+ /**
884
+ * Export a diagram as PNG (asynchronous)
885
+ *
886
+ * This function generates an SVG diagram and converts it to PNG format using
887
+ * headless browser rendering. The output is a Buffer that can be written to a file.
888
+ *
889
+ * **Note:** This function is asynchronous and uses Puppeteer for rendering,
890
+ * which may take a moment on first run to download the browser binary.
891
+ *
892
+ * @param params - Configuration object
893
+ * @param params.aslDefinition - ASL definition as an object or JSON string
894
+ * @param params.pngQuality - PNG quality from 1-100 (default: 90)
895
+ * @param params.backgroundColor - Background color as CSS color or 'transparent' (default: 'transparent')
896
+ * @param ...params - Other SVG options (see generateSvg)
897
+ *
898
+ * @returns Promise resolving to PNG output with buffer and dimensions
899
+ *
900
+ * @throws {SyntaxError} If params.asl is a string with invalid JSON
901
+ * @throws {Error} If the ASL definition structure is invalid or PNG conversion fails
902
+ *
903
+ * @example
904
+ * ```typescript
905
+ * import { exportPng } from 'sfn-diagram';
906
+ * import { writeFileSync } from 'fs';
907
+ *
908
+ * const asl = { StartAt: 'Hello', States: { Hello: { Type: 'Pass', End: true } } };
909
+ *
910
+ * const { buffer, width, height } = await exportPng({
911
+ * asl,
912
+ * theme: 'dark',
913
+ * pngQuality: 95,
914
+ * backgroundColor: 'white'
915
+ * });
916
+ *
917
+ * writeFileSync('diagram.png', buffer);
918
+ * console.log(`Saved ${width}x${height} PNG`);
919
+ * ```
920
+ */
921
+ declare function exportPng(params: ExportPngParams): Promise<PngOutput>;
922
+ /**
923
+ * Generate a diagram from an AWS SDK DescribeStateMachine response
924
+ *
925
+ * This is a convenience function for integrating with the AWS SDK. It extracts
926
+ * the ASL definition from the response and generates a diagram.
927
+ *
928
+ * @param params - Configuration object
929
+ * @param params.response - AWS SDK DescribeStateMachine response object
930
+ * @param params.format - Output format: 'svg' (default) or 'mermaid'
931
+ * @param ...params - Other options (see generateSvg or generateMermaid)
932
+ *
933
+ * @returns SVG output if format is 'svg', Mermaid output if format is 'mermaid'
934
+ *
935
+ * @throws {Error} If response.definition is missing
936
+ * @throws {SyntaxError} If the definition contains invalid JSON
937
+ * @throws {Error} If the ASL definition structure is invalid
938
+ *
939
+ * @example
940
+ * ```typescript
941
+ * import { SFNClient, DescribeStateMachineCommand } from '@aws-sdk/client-sfn';
942
+ * import { generateFromAwsResponse } from 'sfn-diagram';
943
+ *
944
+ * const client = new SFNClient({ region: 'us-east-1' });
945
+ * const response = await client.send(
946
+ * new DescribeStateMachineCommand({
947
+ * stateMachineArn: 'arn:aws:states:...'
948
+ * })
949
+ * );
950
+ *
951
+ * const { svg } = generateFromAwsResponse({
952
+ * response,
953
+ * theme: 'light',
954
+ * layout: 'TB'
955
+ * });
956
+ * ```
957
+ */
958
+ declare function generateFromAwsResponse(params: GenerateFromAwsParams): SvgOutput | MermaidOutput;
959
+ /**
960
+ * Class-based API for advanced usage with fluent interface
961
+ *
962
+ * This class allows you to configure diagram options once and generate multiple
963
+ * diagrams with the same settings. Options can be updated using the fluent
964
+ * `setOptions()` method.
965
+ *
966
+ * @example
967
+ * ```typescript
968
+ * import { SfnDiagramGenerator } from 'sfn-diagram';
969
+ *
970
+ * const generator = new SfnDiagramGenerator({
971
+ * theme: 'dark',
972
+ * layout: 'LR',
973
+ * nodeWidth: 150
974
+ * });
975
+ *
976
+ * // Generate multiple diagrams with the same options
977
+ * const diagram1 = generator.generateSvg({ asl: stateMachine1 });
978
+ * const diagram2 = generator.generateSvg({ asl: stateMachine2 });
979
+ *
980
+ * // Update options and generate more
981
+ * generator.setOptions({ theme: 'light' });
982
+ * const diagram3 = generator.generateSvg({ asl: stateMachine3 });
983
+ * ```
984
+ */
985
+ declare class SfnDiagramGenerator {
986
+ private options;
987
+ /**
988
+ * Create a new diagram generator with default options
989
+ *
990
+ * @param options - Default diagram options for all subsequent generations
991
+ *
992
+ * @example
993
+ * ```typescript
994
+ * const generator = new SfnDiagramGenerator({ theme: 'dark', layout: 'LR' });
995
+ * ```
996
+ */
997
+ constructor(options?: DiagramOptions);
998
+ /**
999
+ * Generate a diagram (auto-detects format from options)
1000
+ *
1001
+ * @param params - Generation parameters
1002
+ * @param params.asl - ASL definition as an object or JSON string
1003
+ * @returns SVG or Mermaid output based on format option
1004
+ *
1005
+ * @example
1006
+ * ```typescript
1007
+ * const result = generator.generate({ asl: myStateMachine });
1008
+ * ```
1009
+ */
1010
+ generate(params: {
1011
+ aslDefinition: AslDefinition | string;
1012
+ }): SvgOutput | MermaidOutput;
1013
+ /**
1014
+ * Generate an SVG diagram
1015
+ *
1016
+ * @param params - Generation parameters
1017
+ * @param params.asl - ASL definition as an object or JSON string
1018
+ * @returns SVG output with diagram and metadata
1019
+ *
1020
+ * @example
1021
+ * ```typescript
1022
+ * const { svg } = generator.generateSvg({ asl: myStateMachine });
1023
+ * ```
1024
+ */
1025
+ generateSvg(params: {
1026
+ aslDefinition: AslDefinition | string;
1027
+ }): SvgOutput;
1028
+ /**
1029
+ * Generate Mermaid diagram syntax
1030
+ *
1031
+ * @param params - Generation parameters
1032
+ * @param params.asl - ASL definition as an object or JSON string
1033
+ * @returns Mermaid output with code and metadata
1034
+ *
1035
+ * @example
1036
+ * ```typescript
1037
+ * const { code } = generator.generateMermaid({ asl: myStateMachine });
1038
+ * ```
1039
+ */
1040
+ generateMermaid(params: {
1041
+ aslDefinition: AslDefinition | string;
1042
+ }): MermaidOutput;
1043
+ /**
1044
+ * Export diagram as PNG
1045
+ *
1046
+ * @param params - Generation parameters
1047
+ * @param params.asl - ASL definition as an object or JSON string
1048
+ * @returns Promise resolving to PNG output
1049
+ *
1050
+ * @example
1051
+ * ```typescript
1052
+ * const { buffer } = await generator.exportPng({ asl: myStateMachine });
1053
+ * ```
1054
+ */
1055
+ exportPng(params: {
1056
+ aslDefinition: AslDefinition | string;
1057
+ }): Promise<PngOutput>;
1058
+ /**
1059
+ * Update the generator's default options (fluent interface)
1060
+ *
1061
+ * @param options - Partial options to merge with existing options
1062
+ * @returns This generator instance for method chaining
1063
+ *
1064
+ * @example
1065
+ * ```typescript
1066
+ * generator
1067
+ * .setOptions({ theme: 'dark' })
1068
+ * .setOptions({ layout: 'LR' });
1069
+ *
1070
+ * const result = generator.generateSvg({ asl: myAsl });
1071
+ * ```
1072
+ */
1073
+ setOptions(options: Partial<DiagramOptions>): this;
1074
+ }
1075
+ //#endregion
1076
+ export { AWS_DARK_THEME, AWS_LIGHT_THEME, type AslDefinition, type AslState, AslValidationError, type CustomTheme, type DiagramFormat, type DiagramOptions, type EdgePathStyle, type EdgeType, type ExportPngParams, type GenerateDiagramParams, type GenerateFromAwsParams, type GenerateMermaidParams, type GenerateSvgParams, type GraphEdge, type LayoutDirection, type MermaidOutput, type NodeShape, type NodeStyle, PngExporter, type PngOutput, SfnDiagramGenerator, type StateNode, type StateType, type SvgOutput, type ThemeOption, embedIcons, exportPng, generateDiagram, generateFromAwsResponse, generateMermaid, generateSvg, validateAsl };