forked from didoo/figma-api
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ast-types.ts
1177 lines (1057 loc) · 44.3 KB
/
ast-types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/** An RGBA color */
export type Color = {
/** Red channel value, between 0 and 1 */
r: number;
/** Green channel value, between 0 and 1 */
g: number;
/** Blue channel value, between 0 and 1 */
b: number;
/** Alpha channel value, between 0 and 1 */
a: number;
};
/** A string enum with value, describing the end caps of vector paths. */
export enum StrokeCap {
NONE = 'NONE',
ROUND = 'ROUND',
SQUARE = 'SQUARE',
LINE_ARROW = 'LINE_ARROW',
TRIANGLE_ARROW = 'TRIANGLE_ARROW',
}
/** Where stroke is drawn relative to the vector outline as a string enum */
export enum StrokeAlign {
INSIDE = 'INSIDE',
OUTSIDE = 'OUTSIDE',
CENTER = 'CENTER',
}
/** A string enum with value, describing how corners in vector paths are rendered. */
export enum StrokeJoin {
MITER = 'MITER',
BEVEL = 'BEVEL',
ROUND = 'ROUND',
}
export enum ImageType {
JPG = 'JPG',
PNG = 'PNG',
SVG = 'SVG',
PDF = 'PDF',
}
/** A string enum with value, indicating the type of boolean operation applied */
export enum BooleanOperationType {
UNION = 'UNION',
INTERSECT = 'INTERSECT',
SUBTRACT = 'SUBTRACT',
EXCLUDE = 'EXCLUDE',
}
/** Text casing applied to the node, default is the original casing */
export enum TextCase {
ORIGINAL = 'ORIGINAL',
UPPER = 'UPPER',
LOWER = 'LOWER',
TITLE = 'TITLE',
SMALL_CAPS = 'SMALL_CAPS',
SMALL_CAPS_FORCED = 'SMALL_CAPS_FORCED',
}
/** Text decoration applied to the node */
export enum TextDecoration {
NONE = 'NONE',
STRIKETHROUGH = 'STRIKETHROUGH',
UNDERLINE = 'UNDERLINE',
}
/** Dimensions along which text will auto resize, default is that the text does not auto-resize. */
export enum TextAutoResize {
NONE = 'NONE',
HEIGHT = 'HEIGHT',
WIDTH_AND_HEIGHT = 'WIDTH_AND_HEIGHT',
TRUNCATE = 'TRUNCATE',
}
/** The unit of the line height value specified by the user. */
export enum LineHeightUnit {
PIXELS = 'PIXELS',
'FONT_SIZE_%' = 'FONT_SIZE_%',
'INTRINSIC_%' = 'INTRINSIC_%',
}
/**
* Record<StyleType, String>
* A mapping of a StyleType to style ID (see Style) of styles present on this node. The style ID can be used to look up more information about the style in the top-level styles field.
*/
export type StylesMap = { [styleType in StyleType]: string };
/** Format and size to export an asset at */
export type ExportSetting = {
/** File suffix to append to all filenames */
suffix: string;
/** Image type, string enum that supports values "JPG", "PNG", "SVG" and "PDF" */
format: ImageType;
/** Constraint that determines sizing of exported asset */
constraint: Constrain;
};
export enum ConstrainType {
/** Scale by value */
SCALE = 'SCALE',
/** Scale proportionally and set width to value */
WIDTH = 'WIDTH',
/** Scale proportionally and set width to value */
HEIGHT = 'HEIGHT',
}
/** Sizing constraint for exports */
export type Constrain = {
/**
* Type of constraint to apply; string enum with potential values below
* "SCALE": Scale by value
* "WIDTH": Scale proportionally and set width to value
* "HEIGHT": Scale proportionally and set height to value
*/
type: ConstrainType;
/** See type property for effect of this field */
value: number;
};
/** A rectangle that expresses a bounding box in absolute coordinates */
export type Rectangle = {
/** X coordinate of top left corner of the rectangle */
x: number;
/** Y coordinate of top left corner of the rectangle */
y: number;
/** Width of the rectangle */
width: number;
/** Height of the rectangle */
height: number;
};
/** Information about the arc properties of an ellipse. 0° is the x axis and increasing angles rotate clockwise * */
export type ArcData = {
/** Start of the sweep in radians * */
startingAngle: number;
/** End of the sweep in radians * */
endingAngle: number;
/** Inner radius value between 0 and 1 * */
innerRadius: number;
};
/**
* This type is a string enum with the following possible values
* Normal blends:
* "PASS_THROUGH" (Only applicable to objects with children)
* "NORMAL"
*
* Darken:
* "DARKEN"
* "MULTIPLY"
* "LINEAR_BURN"
* "COLOR_BURN"
*
* Lighten:
* "LIGHTEN"
* "SCREEN"
* "LINEAR_DODGE"
* "COLOR_DODGE"
*
* Contrast:
* "OVERLAY"
* "SOFT_LIGHT"
* "HARD_LIGHT"
*
* Inversion:
* "DIFFERENCE"
* "EXCLUSION"
*
* Component:
* "HUE"
* "SATURATION"
* "COLOR"
* "LUMINOSITY"
*/
export enum BlendMode {
// Normal blends:
/** (Only applicable to objects with children) */
PASS_THROUGH = 'PASS_THROUGH',
/** (Only applicable to objects with children) */
NORMAL = 'NORMAL',
/** Darken */
DARKEN = 'DARKEN',
MULTIPLY = 'MULTIPLY',
LINEAR_BURN = 'LINEAR_BURN',
COLOR_BURN = 'COLOR_BURN',
/** Lighten */
LIGHTEN = 'LIGHTEN',
SCREEN = 'SCREEN',
LINEAR_DODGE = 'LINEAR_DODGE',
COLOR_DODGE = 'COLOR_DODGE',
/** Contrast */
OVERLAY = 'OVERLAY',
SOFT_LIGHT = 'SOFT_LIGHT',
HARD_LIGHT = 'HARD_LIGHT',
/** Inversion */
DIFFERENCE = 'DIFFERENCE',
EXCLUSION = 'EXCLUSION',
/** Component */
HUE = 'HUE',
SATURATION = 'SATURATION',
COLOR = 'COLOR',
LUMINOSITY = 'LUMINOSITY',
}
/**
* Enum describing animation easing curves
* This type is a string enum with the following possible values
* "EASE_IN": Ease in with an animation curve similar to CSS ease-in.
* "EASE_OUT": Ease out with an animation curve similar to CSS ease-out.
* "EASE_IN_AND_OUT": Ease in and then out with an animation curve similar to CSS ease-in-out.
* "LINEAR": No easing, similar to CSS linear.
*/
export enum EasingType {
/** Ease in with an animation curve similar to CSS ease-in. */
EASE_IN = 'EASE_IN',
/** Ease out with an animation curve similar to CSS ease-out. */
EASE_OUT = 'EASE_OUT',
/** Ease in and then out with an animation curve similar to CSS ease-in-out. */
EASE_IN_AND_OUT = 'EASE_IN_AND_OUT',
/** No easing, similar to CSS linear. */
LINEAR = 'LINEAR',
/** Gentle spring animation similar to react-spring. * */
GENTLE_SPRING = 'GENTLE_SPRING',
}
export enum LayoutConstraintVertical {
TOP = 'TOP',
BOTTOM = 'BOTTOM',
CENTER = 'CENTER',
TOP_BOTTOM = 'TOP_BOTTOM',
SCALE = 'SCALE',
}
export enum LayoutConstraintHorizontal {
LEFT = 'LEFT',
RIGHT = 'RIGHT',
CENTER = 'CENTER',
LEFT_RIGHT = 'LEFT_RIGHT',
SCALE = 'SCALE',
}
/** A flow starting point used when launching a prototype to enter Presentation view. * */
export type FlowStartingPoint = {
/** Unique identifier specifying the frame * */
nodeId: string;
/** Name of flow * */
name: string;
};
/** Layout constraint relative to containing Frame */
export type LayoutConstraint = {
/**
* Vertical constraint as an enum
* "TOP": Node is laid out relative to top of the containing frame
* "BOTTOM": Node is laid out relative to bottom of the containing frame
* "CENTER": Node is vertically centered relative to containing frame
* "TOP_BOTTOM": Both top and bottom of node are constrained relative to containing frame (node stretches with frame)
* "SCALE": Node scales vertically with containing frame
*/
vertical: LayoutConstraintVertical;
/**
* Horizontal constraint as an enum
* "LEFT": Node is laid out relative to left of the containing frame
* "RIGHT": Node is laid out relative to right of the containing frame
* "CENTER": Node is horizontally centered relative to containing frame
* "LEFT_RIGHT": Both left and right of node are constrained relative to containing frame (node stretches with frame)
* "SCALE": Node scales horizontally with containing frame
*/
horizontal: LayoutConstraintHorizontal;
};
export enum LayoutAlign {
/** Determines if the layer should stretch along the parent’s counter axis. This property is only provided for direct children of auto-layout frames. */
INHERIT = 'INHERIT',
STRETCH = 'STRETCH',
/** In horizontal auto-layout frames, "MIN" and "MAX" correspond to "TOP" and "BOTTOM". In vertical auto-layout frames, "MIN" and "MAX" correspond to "LEFT" and "RIGHT". */
MIN = 'MIN',
CENTER = 'CENTER',
MAX = 'MAX',
}
export enum LayoutGridPattern {
COLUMNS = 'COLUMNS',
ROWS = 'ROWS',
GRID = 'GRID',
}
export enum LayoutGridAlignment {
MIN = 'MIN',
MAX = 'MAX',
CENTER = 'CENTER',
}
/** Guides to align and place objects within a frame */
export type LayoutGrid = {
/**
* Orientation of the grid as a string enum
* "COLUMNS": Vertical grid
* "ROWS": Horizontal grid
* "GRID": Square grid
*/
pattern: LayoutGridPattern;
/** Width of column grid or height of row grid or square grid spacing */
sectionSize: number;
/** Is the grid currently visible? */
visible: boolean;
/** Color of the grid */
color: Color;
// The following properties are only meaningful for directional grids (COLUMNS or ROWS)
/**
* Positioning of grid as a string enum
* "MIN": Grid starts at the left or top of the frame
* "MAX": Grid starts at the right or bottom of the frame
* "CENTER": Grid is center aligned
*/
alignment: LayoutGridAlignment;
/** Spacing in between columns and rows */
gutterSize: number;
/** Spacing before the first column or row */
offset: number;
/** Number of columns or rows */
count: number;
};
export enum AxisSizingMode {
FIXED = 'FIXED',
AUTO = 'AUTO',
}
export enum EffectType {
INNER_SHADOW = 'INNER_SHADOW',
DROP_SHADOW = 'DROP_SHADOW',
LAYER_BLUR = 'LAYER_BLUR',
BACKGROUND_BLUR = 'BACKGROUND_BLUR',
}
type Effect_ = {
/** Is the effect active? */
visible: boolean;
/** Radius of the blur effect (applies to shadows as well) */
radius: number;
};
type EffectShadow_ = {
/** The color of the shadow */
color: Color;
/** Blend mode of the shadow */
blendMode: BlendMode;
/** How far the shadow is projected in the x and y directions */
offset: Vector;
/** How far the shadow spreads */
spread: number;
};
export type EffectShadow = {
type: EffectType.DROP_SHADOW | EffectType.INNER_SHADOW;
} & Effect_ &
EffectShadow_;
export type EffectBlur = {
type: EffectType.BACKGROUND_BLUR | EffectType.LAYER_BLUR;
} & Effect_;
/** A visual effect such as a shadow or blur */
export type Effect = { type: EffectType } & Effect_ & Partial<EffectShadow_>;
export function isEffectShadow(effect: Effect): effect is EffectShadow {
return (
effect.type === EffectType.DROP_SHADOW ||
effect.type === EffectType.INNER_SHADOW
);
}
export function isEffectBlur(effect: Effect): effect is EffectBlur {
return (
effect.type === EffectType.BACKGROUND_BLUR ||
effect.type === EffectType.LAYER_BLUR
);
}
export type Hyperlink = {
/** Type of hyperlink */
type: 'URL' | 'NODE';
/** URL being linked to, if URL type */
url: string;
/** ID of frame hyperlink points to, if NODE type */
nodeID: string;
};
export enum PaintType {
SOLID = 'SOLID',
GRADIENT_LINEAR = 'GRADIENT_LINEAR',
GRADIENT_RADIAL = 'GRADIENT_RADIAL',
GRADIENT_ANGULAR = 'GRADIENT_ANGULAR',
GRADIENT_DIAMOND = 'GRADIENT_DIAMOND',
IMAGE = 'IMAGE',
EMOJI = 'EMOJI',
}
export enum PaintSolidScaleMode {
FILL = 'FILL',
FIT = 'FIT',
TILE = 'TILE',
STRETCH = 'STRETCH',
}
export type Paint_ = {
/** `default: true` Is the paint enabled? */
visible?: boolean;
/** `default: 1` Overall opacity of paint (colors within the paint can also have opacity values which would blend with this) */
opacity?: number;
};
type PaintSolid_ = {
/** Solid color of the paint */
color: Color;
};
type PaintGradient_ = {
/**
* How this node blends with nodes behind it in the scene (see blend mode section for more details)
*/
blendMode: BlendMode;
/**
* This field contains three vectors, each of which are a position in normalized object space (normalized object space is if the top left corner of the bounding box of the object is (0, 0) and the bottom right is (1,1)). The first position corresponds to the start of the gradient (value 0 for the purposes of calculating gradient stops), the second position is the end of the gradient (value 1), and the third handle position determines the width of the gradient (only relevant for non-linear gradients).
*/
gradientHandlePositions: Vector[];
/**
* Positions of key points along the gradient axis with the colors anchored there. Colors along the gradient are interpolated smoothly between neighboring gradient stops.
*/
gradientStops: ColorStop[];
};
type PaintImage_ = {
/** Image scaling mode */
scaleMode: PaintSolidScaleMode;
/** Image reference, get it with `Api.getImage` */
imageRef: string;
/** Affine transform applied to the image, only present if scaleMode is STRETCH */
imageTransform?: Transform;
/** Amount image is scaled by in tiling, only present if scaleMode is TILE */
scalingFactor?: number;
/** Image rotation, in degrees. */
rotation: number;
/** A reference to the GIF embedded in this node, if the image is a GIF. To download the image using this reference, use the GET file images endpoint to retrieve the mapping from image references to image URLs */
gifRef: string;
/** default: {}. Defines what image filters have been applied to this paint, if any. If this property is not defined, no filters have been applied. * */
filters: ImageFilters;
};
export type PaintSolid = {
type: PaintType.SOLID;
} & PaintSolid_ &
Paint_;
export type PaintGradient = {
type:
| PaintType.GRADIENT_ANGULAR
| PaintType.GRADIENT_DIAMOND
| PaintType.GRADIENT_LINEAR
| PaintType.GRADIENT_RADIAL;
} & PaintGradient_ &
Paint_;
export type PaintImage = {
type: PaintType.IMAGE;
} & PaintImage_ &
Paint_;
/** A solid color, gradient, or image texture that can be applied as fills or strokes */
export type Paint = { type: PaintType } & Paint_ &
Partial<PaintSolid_> &
Partial<PaintGradient_> &
Partial<PaintImage_>;
export function isPaintSolid(paint: Paint): paint is PaintSolid {
return paint.type === PaintType.SOLID;
}
export function isPaintGradient(paint: Paint): paint is PaintGradient {
return (
paint.type === PaintType.GRADIENT_ANGULAR ||
paint.type === PaintType.GRADIENT_DIAMOND ||
paint.type === PaintType.GRADIENT_LINEAR ||
paint.type === PaintType.GRADIENT_RADIAL
);
}
export function isPaintImage(paint: Paint): paint is PaintImage {
return paint.type === PaintType.IMAGE;
}
/** A 2d vector */
export type Vector = {
/** X coordinate of the vector */
x: number;
/** Y coordinate of the vector */
y: number;
};
/** A 2x3 2D affine transformation matrix */
export type Transform = [[number, number, number], [number, number, number]];
export enum PathWindingRule {
EVENODD = 'EVENODD',
NONZERO = 'NONZERO',
}
/** A vector svg path */
export type Path = {
/** A sequence of path commands in SVG notation */
path: string;
/** Winding rule for the path, either "EVENODD" or "NONZERO" */
windingRule: PathWindingRule;
};
/** Defines the image filters applied to an image paint. All values are from -1 to 1. * */
export type ImageFilters = {
/** default: 0 * */
exposure: number;
/** default: 0 * */
contrast: number;
/** default: 0 * */
saturation: number;
/** default: 0 * */
temperature: number;
/** default: 0 * */
tint: number;
/** default: 0 * */
highlights: number;
/** default: 0 * */
shadows: number;
};
/** A relative offset within a frame */
export type FrameOffset = {
/** Unique id specifying the frame */
node_id: string;
/** 2d vector offset within the frame */
node_offset: Vector;
};
/** Position of a region comment on the canvas * */
export type Region = {
/** X coordinate of the position * */
x: number;
/** Y coordinate of the position * */
y: number;
/** The height of the comment region. Must be greater than 0 * */
region_height: number;
/** The width of the comment region. Must be greater than 0 * */
region_width: number;
/** default: bottom-right, The corner of the comment region to pin to the node's corner as a string enum * */
comment_pin_corner: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
};
/** A relative offset region within a frame * */
export type FrameOffsetRegion = {
/** Unique id specifying the frame. * */
node_id: string;
/** 2D vector offset within the frame. * */
node_offset: Vector;
/** The height of the comment region * */
region_height: number;
/** The width of the comment region * */
region_width: number;
/** default: bottom-right, The corner of the comment region to pin to the node's corner as a string enum * */
comment_pin_corner: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
};
/** A position color pair representing a gradient stop */
export type ColorStop = {
/** Value between 0 and 1 representing position along gradient axis */
position: number;
/** Color attached to corresponding position */
color: Color;
};
/** Paint metadata to override default paints * */
export type PaintOverride = {
/** Paints applied to characters * */
fills: Paint[];
/** ID of style node, if any, that this inherits fill data from * */
inheritFillStyleId: string;
};
/** Metadata for character formatting */
export type TypeStyle = {
/** Font family of text (standard name) */
fontFamily: string;
/** PostScript font name */
fontPostScriptName: string;
/** Space between paragraphs in px, 0 if not present */
paragraphSpacing?: number;
/** Paragraph indentation in px, 0 if not present */
paragraphIndent?: number;
/** default: 0 Space between list items in px, 0 if not present * */
listSpacing: number;
/** Is text italicized? */
italic: boolean;
/** Numeric font weight */
fontWeight: number;
/** Font size in px */
fontSize: number;
/** Text casing applied to the node, default is the `ORIGINAL` casing */
textCase?: TextCase;
/** Text decoration applied to the node, default is `NONE` */
textDecoration?: TextDecoration;
/** Dimensions along which text will auto resize, default is that the text does not auto-resize. Default is `NONE` */
textAutoResize?: TextAutoResize;
/** Horizontal text alignment as string enum */
textAlignHorizontal: 'LEFT' | 'RIGHT' | 'CENTER' | 'JUSTIFIED';
/** Vertical text alignment as string enum */
textAlignVertical: 'TOP' | 'CENTER' | 'BOTTOM';
/** Space between characters in px */
letterSpacing: number;
/** Paints applied to characters */
fills: Paint[];
/** Link to a URL or frame */
hyperlink: Hyperlink;
/** A map of OpenType feature flags to 1 or 0, 1 if it is enabled and 0 if it is disabled. Note that some flags aren't reflected here. For example, SMCP (small caps) is still represented by the textCase field. */
opentypeFlags: { [flag: string]: number };
/** Line height in px */
lineHeightPx: number;
/** @deprecated Line height as a percentage of normal line height. This is deprecated; in a future version of the API only lineHeightPx and lineHeightPercentFontSize will be returned. */
lineHeightPercent?: number;
/** Line height as a percentage of the font size. Only returned when lineHeightPercent is not 100 */
lineHeightPercentFontSize?: number;
/** The unit of the line height value specified by the user. */
lineHeightUnit: LineHeightUnit;
};
export type StyleType = 'FILL' | 'TEXT' | 'EFFECT' | 'GRID';
/** Data on the frame a component resides in */
export interface FrameInfo {
/** Id of the frame node within the figma file */
nodeId: string;
/** Name of the frame */
name: string;
/** Background color of the frame */
backgroundColor: string;
/** Id of the frame's residing page */
pageId: string;
/** Name of the frame's residing page */
pageName: string;
}
/** Data on the "containingStateGroup" a component resides in */
/** Notice: at the moment is not documented in the REST API documentation. I have raised the issue
* (https://forum.figma.com/t/missing-containingstategroup-parameter-in-documentation-for-frameinfo/2558)
* and filed a bug with the support, but no one replied. From what I understand, this extra parameters are
* added when a component is a variant within a component_set (the name/nodeId are of the parent component_set)
*/
export interface ContainingStateGroup {
/** Name of the element's residing "state group" (likely, a component_set) */
name: string;
/** Id of the element's residing "state group" (likely, a component_set) */
nodeId: string;
}
/**
* NOT DOCUMENTED
*
* Data on component's containing page, if component resides in a multi-page file
*/
export interface PageInfo {}
/** An arrangement of published UI elements that can be instantiated across figma files */
export interface Component {
/** The key of the component */
key: string;
/** The name of the component */
name: string;
/** The description of the component as entered in the editor */
description: string;
/** The ID of the component set if the component belongs to one */
componentSetId: string | null;
/** The documentation links for this component */
documentationLinks: DocumentationLinks[];
}
export interface ComponentSet {
/** The key of the component */
key: string;
/** The name of the component */
name: string;
/** The description of the component as entered in the editor */
description: string;
/** The documentation links for this component */
documentationLinks: DocumentationLinks[];
}
/** Represents a link to documentation for a component. */
export interface DocumentationLinks {
/** Should be a valid URI (e.g. https://www.figma.com). */
uri: string;
}
/** A set of properties that can be applied to nodes and published. Styles for a property can be created in the corresponding property's panel while editing a file */
export interface Style {
/** The key of the style */
key: string;
/** The name of the style */
name: string;
/** The description of the style */
description: string;
/** Whether this style is a remote style that doesn't live in this file * */
remote: boolean;
/** The type of style */
styleType: StyleType;
}
/** Component property definition */
export interface ComponentPropertyDefinition {
/** Type of this component property */
type: ComponentPropertyType;
/** Initial value of this property for instances */
defaultValue: boolean | string;
/** All possible values for this property. Only exists on VARIANT properties */
variantOptions?: string[];
/** List of user-defined preferred values for this property. Only exists on INSTANCE_SWAP properties */
preferredValues?: InstanceSwapPreferredValue[];
}
/** Component property */
export interface ComponentProperty {
/** Type of this component property */
type: ComponentPropertyType;
/** Value of this property set on this instance */
value: boolean | string;
/** List of user-defined preferred values for this property. Only exists on INSTANCE_SWAP properties */
preferredValues?: InstanceSwapPreferredValue[];
/** A mapping of field to the VariableAlias of the bound variable. */
boundVariables?: Record<string, VariableAlias | VariableAlias[]>;
}
/** Component Property Type */
export type ComponentPropertyType =
| 'BOOLEAN'
| 'TEXT'
| 'INSTANCE_SWAP'
| 'VARIANT';
/** Instance swap preferred value */
export interface InstanceSwapPreferredValue {
/** Type of node for this preferred value */
type: 'COMPONENT' | 'COMPONENT_SET';
/** Key of this component or component set */
key: string;
}
/** Contains a variable alias. */
export interface VariableAlias {
/** Value is always VARIABLE_ALIAS. */
type: 'VARIABLE_ALIAS';
/** The id of the variable that the current variable is aliased to. This variable can be a local or remote variable, and both can be retrieved via the GET /v1/files/:file_key/variables/local endpoint. */
id: string;
}
/** Fields directly overridden on an instance. Inherited overrides are not included. */
export interface Overrides {
/** A unique ID for a node */
id: string;
/** An array of properties */
overriddenFields: string[];
}
/** The root node */
export interface DOCUMENT {
/** An array of canvases attached to the document */
children: Node[];
}
/** Represents a single page */
export interface CANVAS {
/** An array of top level layers on the canvas */
children: Node[];
/** Background color of the canvas */
backgroundColor: Color;
/** A array of flow starting points sorted by its position in the prototype settings panel. * */
flowStartingPoints: FlowStartingPoint[];
/** default: [] An array of export settings representing images to export from the canvas */
exportSettings: ExportSetting[];
/** Node ID that corresponds to the start frame for prototypes */
prototypeStartNodeID?: string | null;
}
/** A node of fixed size containing other nodes */
export interface FRAME {
/** An array of nodes that are direct children of this node */
children: Node[];
/** If true, layer is locked and cannot be edited, default `false` */
locked?: boolean;
/** @deprecated Background of the node. This is deprecated, as backgrounds for frames are now in the fills field. */
background: Paint[];
/** @deprecated Background color of the node. This is deprecated, as frames now support more than a solid color as a background. Please use the background field instead. */
backgroundColor?: Color;
/** An array of fill paints applied to the node */
fills: Paint[];
/** An array of stroke paints applied to the node */
strokes: Paint[];
/** The weight of strokes on the node */
strokeWeight: number;
/** The weight of strokes on different side of the node */
individualStrokeWeights?: {
top: number;
right: number;
left: number;
bottom: number;
};
/** Position of stroke relative to vector outline, as a string enum */
strokeAlign: StrokeAlign;
/** Radius of each corner of the frame if a single radius is set for all corners */
cornerRadius: number;
/** Array of length 4 of the radius of each corner of the rectangle, starting in the top left and proceeding clockwise */
rectangleCornerRadii: [number, number, number, number];
/** default: [] An array of export settings representing images to export from node */
exportSettings: ExportSetting[];
/** How this node blends with nodes behind it in the scene (see blend mode section for more details) */
blendMode: BlendMode;
/** default: false Keep height and width constrained to same ratio */
preserveRatio: boolean;
/** Horizontal and vertical layout constraints for node */
constraints: LayoutConstraint;
/** Determines if the layer should stretch along the parent’s counter axis. This property is only provided for direct children of auto-layout frames. */
layoutAlign: LayoutAlign;
/** default: 0. This property is applicable only for direct children of auto-layout frames, ignored otherwise. Determines whether a layer should stretch along the parent’s primary axis. A 0 corresponds to a fixed size and 1 corresponds to stretch. */
layoutGrow?: number;
/** default: null Node ID of node to transition to in prototyping */
transitionNodeID?: string | null;
/** default: null The duration of the prototyping transition on this node (in milliseconds). */
transitionDuration?: number | null;
/** default: null The easing curve used in the prototyping transition on this node. */
transitionEasing?: EasingType | null;
/** default: 1 Opacity of the node */
opacity: number;
/** Bounding box of the node in absolute space coordinates */
absoluteBoundingBox: Rectangle;
/** Render box of the node in absolute space coordinates. Can include drop shadows. Often bigger than `absoluteBoundingBox` */
absoluteRenderBounds: Rectangle;
/** Width and height of element. This is different from the width and height of the bounding box in that the absolute bounding box represents the element after scaling and rotation. Only present if geometry=paths is passed */
size?: Vector;
/** The top two rows of a matrix that represents the 2D transform of this node relative to its parent. The bottom row of the matrix is implicitly always (0, 0, 1). Use to transform coordinates in geometry. Only present if geometry=paths is passed */
relativeTransform?: Transform;
/** Does this node clip content outside of its bounds? */
clipsContent: boolean;
/** Whether this layer uses auto-layout to position its children. default NONE */
layoutMode: 'NONE' | 'HORIZONTAL' | 'VERTICAL';
/** Whether the primary axis has a fixed length (determined by the user) or an automatic length (determined by the layout engine). This property is only applicable for auto-layout frames. Default AUTO */
primaryAxisSizingMode: AxisSizingMode;
/** Whether the counter axis has a fixed length (determined by the user) or an automatic length (determined by the layout engine). This property is only applicable for auto-layout frames. Default AUTO */
counterAxisSizingMode: AxisSizingMode;
/** Determines how the auto-layout frame’s children should be aligned in the primary axis direction. This property is only applicable for auto-layout frames. Default MIN */
primaryAxisAlignItems: 'MIN' | 'CENTER' | 'MAX' | 'SPACE_BETWEEN';
/** Determines how the auto-layout frame’s children should be aligned in the counter axis direction. This property is only applicable for auto-layout frames. Default MIN */
counterAxisAlignItems: 'MIN' | 'CENTER' | 'MAX' | 'BASELINE';
/** default: 0. The padding between the left border of the frame and its children. This property is only applicable for auto-layout frames. */
paddingLeft: number;
/** default: 0. The padding between the right border of the frame and its children. This property is only applicable for auto-layout frames. */
paddingRight: number;
/** default: 0. The padding between the top border of the frame and its children. This property is only applicable for auto-layout frames. */
paddingTop: number;
/** default: 0. The padding between the bottom border of the frame and its children. This property is only applicable for auto-layout frames. */
paddingBottom: number;
/** @deprecated default: 0. The horizontal padding between the borders of the frame and its children. This property is only applicable for auto-layout frames. Deprecated in favor of setting individual paddings. */
horizontalPadding: number;
/** @deprecated default: 0. The vertical padding between the borders of the frame and its children. This property is only applicable for auto-layout frames. Deprecated in favor of setting individual paddings. */
verticalPadding: number;
/** default: 0. The distance between children of the frame. This property is only applicable for auto-layout frames. */
itemSpacing: number;
/** default: false. Applicable only if layoutMode != "NONE". */
itemReverseZIndex: boolean;
/** default: false. Applicable only if layoutMode != "NONE". */
strokesIncludedInLayout: boolean;
/** Defines the scrolling behavior of the frame, if there exist contents outside of the frame boundaries. The frame can either scroll vertically, horizontally, or in both directions to the extents of the content contained within it. This behavior can be observed in a prototype. Default NONE */
overflowDirection:
| 'NONE'
| 'HORIZONTAL_SCROLLING'
| 'VERTICAL_SCROLLING'
| 'HORIZONTAL_AND_VERTICAL_SCROLLING';
/** default: [] An array of layout grids attached to this node (see layout grids section for more details). GROUP nodes do not have this attribute */
layoutGrids?: LayoutGrid[];
/** default: [] An array of effects attached to this node (see effects section for more details) */
effects: Effect[];
/** default: false Does this node mask sibling nodes in front of it? */
isMask: boolean;
/** default: false Does this mask ignore fill style (like gradients) and effects? */
isMaskOutline: boolean;
/** default: AUTO */
layoutPositioning: 'AUTO' | 'ABSOLUTE';
}
/** A logical grouping of nodes */
export type GROUP = FRAME;
// {
// /** How this node blends with nodes behind it in the scene (see blend mode section for more details) */
// blendMode: BlendMode;
// children: Node[],
// }
/** A vector network, consisting of vertices and edges */
export interface VECTOR {
/** default: [] An array of export settings representing images to export from node */
exportSettings: ExportSetting[];
/** If true, layer is locked and cannot be edited, default `false` */
locked?: boolean;
/** How this node blends with nodes behind it in the scene (see blend mode section for more details) */
blendMode: BlendMode;
/** default: false Keep height and width constrained to same ratio */
preserveRatio?: boolean;
/** Determines if the layer should stretch along the parent’s counter axis. This property is only provided for direct children of auto-layout frames. */
layoutAlign: LayoutAlign;
/** default: 0. This property is applicable only for direct children of auto-layout frames, ignored otherwise. Determines whether a layer should stretch along the parent’s primary axis. A 0 corresponds to a fixed size and 1 corresponds to stretch. */
layoutGrow?: number;
/** Horizontal and vertical layout constraints for node */
constraints: LayoutConstraint;
/** default: null Node ID of node to transition to in prototyping */
transitionNodeID?: string | null;
/** default: null The duration of the prototyping transition on this node (in milliseconds). */
transitionDuration?: number | null;
/** default: null The easing curve used in the prototyping transition on this node. */
transitionEasing?: EasingType | null;
/** default: 1 Opacity of the node */
opacity?: number;
/** Bounding box of the node in absolute space coordinates */
absoluteBoundingBox: Rectangle;
/** Width and height of element. This is different from the width and height of the bounding box in that the absolute bounding box represents the element after scaling and rotation. Only present if geometry=paths is passed */
size?: Vector;
/** The top two rows of a matrix that represents the 2D transform of this node relative to its parent. The bottom row of the matrix is implicitly always (0, 0, 1). Use to transform coordinates in geometry. Only present if geometry=paths is passed */
relativeTransform?: Transform;
/** default: [] An array of effects attached to this node (see effects section for more details) */
effects?: Effect[];
/** default: false Does this node mask sibling nodes in front of it? */
isMask?: boolean;
/** default: [] An array of fill paints applied to the node */
fills: Paint[];
/** Only specified if parameter geometry=paths is used. An array of paths representing the object fill */
fillGeometry?: Path[];
/** Map from ID to PaintOverride for looking up fill overrides. To see which regions are overriden, you must use the geometry=paths option. Each path returned may have an overrideId which maps to this table. * */
fillOverrideTable: Record<number, PaintOverride>;
/** default: [] An array of stroke paints applied to the node */
strokes: Paint[];
/** The weight of strokes on the node */
strokeWeight: number;
/** The weight of strokes on different side of the node */
individualStrokeWeights?: {
top: number;
right: number;
left: number;
bottom: number;
};
/** default: NONE. A string enum with value of "NONE", "ROUND", "SQUARE", "LINE_ARROW", or "TRIANGLE_ARROW", describing the end caps of vector paths. */
strokeCap?: StrokeCap;
/** Only specified if parameter geometry=paths is used. An array of paths representing the object stroke */
strokeGeometry?: Path[];
/** Where stroke is drawn relative to the vector outline as a string enum
"INSIDE": draw stroke inside the shape boundary
"OUTSIDE": draw stroke outside the shape boundary
"CENTER": draw stroke centered along the shape boundary */
strokeAlign: StrokeAlign;
/** A string enum with value of "MITER", "BEVEL", or "ROUND", describing how corners in vector paths are rendered. */
strokeJoin?: StrokeJoin;
/** An array of floating point numbers describing the pattern of dash length and gap lengths that the vector path follows. For example a value of [1, 2] indicates that the path has a dash of length 1 followed by a gap of length 2, repeated. */
strokeDashes?: number[];
/** Only valid if strokeJoin is "MITER". The corner angle, in degrees, below which strokeJoin will be set to "BEVEL" to avoid super sharp corners. By default this is 28.96 degrees. */
strokeMiterAngle?: number;
/** A mapping of a StyleType to style ID (see Style) of styles present on this node. The style ID can be used to look up more information about the style in the top-level styles field. */
styles?: StylesMap;
/** default: AUTO */
layoutPositioning: 'AUTO' | 'ABSOLUTE';
}
/** A group that has a boolean operation applied to it */
export type BOOLEAN_OPERATION = VECTOR & {
/** An array of nodes that are being boolean operated on */