/** * Figma REST API types * Based on @figma/rest-api-spec */ export interface Node { id: string; name: string; type: NodeType; visible?: boolean; locked?: boolean; absoluteBoundingBox?: Rect; absoluteRenderBounds?: Rect | null; relativeTransform?: Transform; children?: Node[]; fills?: Paint[]; strokes?: Paint[]; effects?: unknown[]; isMask?: boolean; fillGeometry?: PathGeometry[]; strokeGeometry?: PathGeometry[]; fillOverrideTable?: Record; } export type NodeType = "DOCUMENT" | "CANVAS" | "FRAME" | "GROUP" | "VECTOR" | "BOOLEAN_OPERATION" | "STAR" | "LINE" | "ELLIPSE" | "REGULAR_POLYGON" | "RECTANGLE" | "TEXT" | "SLICE" | "COMPONENT" | "COMPONENT_SET" | "INSTANCE" | "SECTION"; export interface DocumentNode extends Node { type: "DOCUMENT"; children: CanvasNode[]; } export interface CanvasNode extends Node { type: "CANVAS"; children: (FrameNode | SectionNode | ComponentNode | ComponentSetNode)[]; backgroundColor: Color; prototypeStartNodeID?: string; } export interface SectionNode extends Node { type: "SECTION"; children: (FrameNode | ComponentNode | ComponentSetNode)[]; sectionContentsHidden?: boolean; devStatus?: DevStatus | null; fills?: Paint[]; strokes?: Paint[]; strokeWeight?: number; } export interface FrameNode extends Node { type: "FRAME"; children?: Node[]; backgroundColor?: Color; fills?: Paint[]; strokes?: Paint[]; strokeWeight?: number; absoluteBoundingBox?: Rect; clipsContent?: boolean; } export interface ComponentNode extends Node { type: "COMPONENT"; children?: Node[]; backgroundColor?: Color; fills?: Paint[]; strokes?: Paint[]; strokeWeight?: number; absoluteBoundingBox?: Rect; } export interface ComponentSetNode extends Node { type: "COMPONENT_SET"; children: ComponentNode[]; backgroundColor?: Color; fills?: Paint[]; strokes?: Paint[]; strokeWeight?: number; absoluteBoundingBox?: Rect; } export interface Component { key: string; name: string; description: string; componentSetId?: string; documentationLinks: DocumentationLink[]; } export interface ComponentSet { key: string; name: string; description: string; documentationLinks: DocumentationLink[]; } export interface Style { key: string; name: string; description: string; styleType: StyleType; } export type StyleType = "FILL" | "TEXT" | "EFFECT" | "GRID"; export interface Color { r: number; g: number; b: number; a: number; } export interface Rect { x: number; y: number; width: number; height: number; } export interface Paint { type: PaintType; visible?: boolean; opacity?: number; color?: Color; blendMode?: BlendMode; scaleMode?: "FILL" | "FIT" | "CROP" | "TILE" | "STRETCH"; imageRef?: string; imageTransform?: Transform; filters?: Record; rotation?: number; scalingFactor?: number; } export type Transform = [[number, number, number], [number, number, number]]; export interface PathGeometry { path: string; windingRule: "NONZERO" | "EVENODD"; overrideID?: number; } export interface FillOverride { fills?: Paint[]; } export type PaintType = "SOLID" | "GRADIENT_LINEAR" | "GRADIENT_RADIAL" | "GRADIENT_ANGULAR" | "GRADIENT_DIAMOND" | "IMAGE" | "EMOJI"; export type BlendMode = "NORMAL" | "DARKEN" | "MULTIPLY" | "COLOR_BURN" | "LIGHTEN" | "SCREEN" | "COLOR_DODGE" | "OVERLAY" | "SOFT_LIGHT" | "HARD_LIGHT"; export interface DocumentationLink { uri: string; } export interface DevStatus { type: "READY_FOR_DEV" | "COMPLETED"; description?: string; } export interface GetFileResponse { name: string; lastModified: string; thumbnailUrl: string; editorType?: "figma" | "figjam"; version: string; document: DocumentNode; components: Record; componentSets: Record; schemaVersion: number; styles: Record; } export interface GetFileNodesResponse { nodes: Record; schemaVersion: number; }>; } export interface GetImagesResponse { err: string | null; images: Record; } export interface GetFileMetaResponse { name: string; lastModified: string; thumbnailUrl: string; version: string; } export interface GetImageFillsResponse { images?: Record; meta?: { images?: Record; }; } export interface ImageExportOptions { ids: string; version?: string; format?: "jpg" | "png" | "svg" | "pdf"; scale?: number; contents_only?: boolean; use_absolute_bounds?: boolean; svg_outline_text?: boolean; svg_include_id?: boolean; svg_include_node_id?: boolean; svg_simplify_stroke?: boolean; }