MCPcopy Create free account
hub / github.com/MigoXLab/coderio / fetchAndClean

Method fetchAndClean

src/tools/figma-tool/index.ts:61–81  ·  view source on GitHub ↗
(fileId: string, nodeId: string, token: string)

Source from the content-addressed store, hash-verified

59})
60class 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,

Callers 1

Calls 3

fetchFigmaNodeFunction · 0.90
fetchFigmaImagesFunction · 0.90
cleanFigmaFunction · 0.90

Tested by

no test coverage detected