(fileId: string, nodeId: string, token: string)
| 59 | }) |
| 60 | class FigmaTool { |
| 61 | async fetchAndClean(fileId: string, nodeId: string, token: string): Promise<FigmaFrameInfo | undefined> { |
| 62 | if (!fileId || !nodeId || !token) { |
| 63 | return undefined; |
| 64 | } |
| 65 | |
| 66 | const document = await fetchFigmaNode(fileId, nodeId, token); |
| 67 | if (!document || !document?.children?.length) { |
| 68 | throw new Error('Failed to fetch Figma document'); |
| 69 | } |
| 70 | |
| 71 | const images = await fetchFigmaImages(fileId, nodeId, token); |
| 72 | const thumbnail = images?.[nodeId] || ''; |
| 73 | if (!thumbnail) { |
| 74 | throw new Error('Failed to fetch Figma document thumbnail'); |
| 75 | } |
| 76 | document.thumbnailUrl = thumbnail; |
| 77 | |
| 78 | const cleanedDocument = cleanFigma(document); |
| 79 | |
| 80 | return cleanedDocument; |
| 81 | } |
| 82 | |
| 83 | async downloadImages( |
| 84 | fileId: string, |
no test coverage detected