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A,OAAA,CAAS,CAAA;AAAA,IAE3D,OAAO,CAAC,GAAA,KAAQ,OAAO,GAAA,CAAI,CAAA,OAAA,EAAU,GAAG,CAAA,CAAE;AAAA,GAC5C;AACF","file":"index.mjs","sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n","// export * from './lib/number';\nimport * as Figma from \"@design-sdk/figma-remote-types\";\nexport * from \"@design-sdk/figma-remote-types\";\n\nimport axios, { AxiosInstance, AxiosPromise } from \"axios\";\n\nexport interface FileParams {\n  /**\n   * A specific version ID to get. Omitting this will get the current version of the file\n   */\n  readonly version?: string;\n\n  /**\n   * A list of nodes that you care about in the document.\n   * If specified, only a subset of the document will be returned corresponding to the nodes listed, their children, and everything between the root node and the listed nodes\n   */\n  readonly ids?: ReadonlyArray<string>;\n\n  /**\n   * Positive integer representing how deep into the document tree to traverse.\n   * For example, setting this to 1 returns only Pages, setting it to 2 returns Pages and all top level objects on each page.\n   * Not setting this parameter returns all nodes\n   *\n   * if using typescript, for number bigger than typed number, use `n as any` - e.g. `100 as any`\n   *\n   * @allowed `>= 1` (`0` will throw an error)\n   */\n  readonly depth?: 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10; // any number greater than 0 is acceptable\n\n  /**\n   * Set to \"paths\" to export vector data\n   */\n  readonly geometry?: \"paths\";\n\n  /**\n   * A comma separated list of plugin IDs and/or the string \"shared\".\n   * Any data present in the document written by those plugins will be included in the result in the `pluginData` and `sharedPluginData` properties.\n   */\n  readonly plugin_data?: ReadonlyArray<string> | \"shared\";\n\n  /**\n   * Returns branch metadata for the requested file.\n   * If the file is a branch, the main file's key will be included in the returned response.\n   * If the file has branches, their metadata will be included in the returned response.\n   * @default false\n   */\n  readonly branch_data?: boolean;\n}\n\nexport interface FileNodesParams {\n  /** A list of node IDs to retrieve and convert */\n  readonly ids: ReadonlyArray<string>;\n\n  /**\n   * A specific version ID to get. Omitting this will get the current version of the file\n   */\n  readonly version?: string;\n\n  /**\n   * Positive integer representing how deep into the document tree to traverse. For example, setting this to 1 returns only Pages, setting it to 2 returns Pages and all top level objects on each page. Not setting this parameter returns all nodes\n   */\n  readonly depth?: number;\n\n  /**\n   * Set to \"paths\" to export vector data\n   */\n  readonly geometry?: string;\n\n  /**\n   * A comma separated list of plugin IDs and/or the string \"shared\".\n   * Any data present in the document written by those plugins will be included in the result in the `pluginData` and `sharedPluginData` properties.\n   */\n  readonly plugin_data?: ReadonlyArray<string> | \"shared\";\n}\n\nexport type exportFormatOptions = \"jpg\" | \"png\" | \"svg\" | \"pdf\";\n\nexport interface FileImageParams {\n  /** A list of node IDs to render */\n  readonly ids: ReadonlyArray<string>;\n  /** A number between 0.01 and 4, the image scaling factor */\n  readonly scale?: number;\n  /** A string enum for the image output format, can be \"jpg\", \"png\", \"svg\", or \"pdf\" */\n  readonly format?: exportFormatOptions;\n  /**\n   * Whether to include id attributes for all SVG elements.\n   * @default false\n   */\n  readonly svg_include_id?: boolean;\n  /**\n   * Whether to simplify inside/outside strokes and use stroke attribute if\n   * possible instead of <mask>.\n   * @default true\n   */\n  readonly svg_simplify_stroke?: boolean;\n  /**\n   * Use the full dimensions of the node regardless of whether or not it is cropped or the space around it is empty.\n   * Use this to export text nodes without cropping.\n   * @default false\n   */\n  readonly use_absolute_bounds?: boolean;\n  /** A specific version ID to use. Omitting this will use the current version of the file */\n  readonly version?: string;\n}\n\nexport interface PostCommentParams {\n  /** The text contents of the comment to post */\n  readonly message: string;\n  /** The absolute canvas position of where to place the comment */\n  readonly client_meta?: Figma.Vector2 | Figma.FrameOffset;\n  /** The comment to reply to, if any. This must be a root comment, that is, you cannot reply to a comment that is a reply itself (a reply has a parent_id). */\n  readonly comment_id?: string;\n}\n\nexport interface PostCommentReactionParams {\n  readonly emoji: Figma.Reaction[\"emoji\"];\n}\n\nexport interface DeleteCommentReactionParams {\n  readonly emoji: Figma.Reaction[\"emoji\"];\n}\n\nexport interface PaginationParams {\n  /**\n   * Number of items in a paged list of results.\n   * @default 30\n   */\n  readonly page_size?: number;\n  /**\n   * A map that indicates the starting/ending point from which objects are returned.\n   * The cursor value is an internally tracked integer that doesn't correspond to any Ids\n   */\n  readonly cursor?: { readonly before?: number; readonly after?: number };\n}\n\nexport interface ClientOptions {\n  /** access token returned from OAuth authentication */\n  readonly accessToken?: string;\n  /** personal access token obtained from account settings */\n  readonly personalAccessToken?: string;\n  /** custom API root */\n  readonly apiRoot?: string;\n}\n\nexport interface ClientInterface {\n  readonly client: AxiosInstance;\n  /**\n   * Returns the document refered to by :key as a JSON object.\n   * The file key can be parsed from any Figma file url:\n   * https://www.figma.com/file/:key/:title.\n   * The \"document\" attribute contains a Node of type DOCUMENT.\n   * @param {fileId} String File to export JSON from\n   * @see https://www.figma.com/developers/api#get-files-endpoint\n   */\n  readonly file: (\n    fileId: string,\n    params?: FileParams\n  ) => AxiosPromise<Figma.FileResponse>;\n\n  /**\n   * Returns a list of the versions of a file.\n   * The file key can be parsed from any Figma node url:\n   * https://www.figma.com/file/:key/:title.\n   * @param {fileId} String File to get version history from\n   * @see https://www.figma.com/developers/api#get-file-versions-endpoint\n   */\n  readonly fileVersions: (\n    fileId: string,\n    ids: ReadonlyArray<string>,\n    params?: FileNodesParams\n  ) => AxiosPromise<Figma.FileVersionsResponse>;\n\n  /**\n   * Returns the nodes referenced to by :ids as a JSON object.\n   * The nodes are retrieved from the Figma file referenced to by :key.\n   * The node Id and file key can be parsed from any Figma node url:\n   * https://www.figma.com/file/:key/:title?node-id=:id.\n   * @param {fileId} String File to export JSON from\n   * @param {params} FileNodesParams\n   * @see https://www.figma.com/developers/api#get-file-nodes-endpoint\n   */\n  readonly fileNodes: (\n    fileId: string,\n    params: FileNodesParams\n  ) => AxiosPromise<Figma.FileNodesResponse>;\n\n  /**\n   * If no error occurs, \"images\" will be populated with a map from\n   * node IDs to URLs of the rendered images, and \"status\" will be omitted.\n   * Important: the image map may contain values that are null.\n   * This indicates that rendering of that specific node has failed.\n   * This may be due to the node id not existing, or other reasons such\n   * has the node having no renderable components. It is guaranteed that\n   * any node that was requested for rendering will be represented in this\n   * map whether or not the render succeeded.\n   * @param {fileId} String File to export images from\n   * @param {params} FileImageParams\n   * @see https://www.figma.com/developers/api#get-images-endpoint\n   */\n  readonly fileImages: (\n    fileId: string,\n    params: FileImageParams\n  ) => AxiosPromise<Figma.FileImageResponse>;\n\n  /**\n   * Returns download links for all images present in image fills in a document.\n   * Image fills are how Figma represents any user supplied images.\n   * When you drag an image into Figma, we create a rectangle with a single\n   * fill that represents the image, and the user is able to transform the\n   * rectangle (and properties on the fill) as they wish.\n   *\n   * This endpoint returns a mapping from image references to the URLs at which\n   * the images may be download. Image URLs will expire after no more than 14 days.\n   * Image references are located in the output of the GET files endpoint under the\n   * imageRef attribute in a Paint.\n   * @param {fileId} String File to export images from\n   * @see https://www.figma.com/developers/api#get-image-fills-endpoint\n   */\n  readonly fileImageFills: (\n    fileId: string\n  ) => AxiosPromise<Figma.FileImageFillsResponse>;\n\n  /**\n   * A list of comments left on the file\n   * @param {fileId} String File to get comments from\n   * @see https://www.figma.com/developers/api#get-comments-endpoint\n   */\n  readonly comments: (fileId: string) => AxiosPromise<Figma.CommentsResponse>;\n\n  /**\n   * Posts a new comment on the file.\n   * @param {fileId} String File to post comment to\n   * @param {params} PostCommentParams\n   * @see https://www.figma.com/developers/api#post-comments-endpoint\n   */\n  readonly postComment: (\n    fileId: string,\n    params: PostCommentParams\n  ) => AxiosPromise<Figma.Comment>;\n\n  /**\n   * Delete a comment from the file\n   * @param {fileId} String File to delete comment from\n   * @param {commentId} String id of the comment to be deleted\n   * @see https://www.figma.com/developers/api#delete-comments-endpoint\n   */\n  readonly deleteComment: (\n    fileId: string,\n    commentId: string\n  ) => AxiosPromise<Figma.Comment>;\n\n  /**\n   * Gets a paginated list of reactions left on the comment.\n   * @param {fileId} String File to get comment containing reactions from\n   * @param {commentId} String Comment to get reactions from\n   * @see https://www.figma.com/developers/api#get-comment-reactions-endpoint\n   */\n  readonly commentReactions: (\n    fileId: string,\n    commentId: string\n  ) => AxiosPromise<Figma.CommentReactionsResponse>;\n\n  /**\n   * Posts a new comment reaction on a file comment.\n   * @param {fileId} String File to post comment reactions to\n   * @param {commentId} String ID of comment to react to\n   * @see https://www.figma.com/developers/api#post-comment-reactions-endpoint\n   */\n  readonly postCommentReaction: (\n    fileId: string,\n    commentId: string,\n    params: PostCommentReactionParams\n  ) => AxiosPromise<Figma.Reaction>;\n\n  /**\n   * Deletes a specific comment reaction. Only the person who made the comment reaction is allowed to delete it.\n   * @param {fileId} String File to delete comment reaction from\n   * @param {commentId} String Comment id of comment to delete reaction from\n   * @see https://www.figma.com/developers/api#delete-comment-reactions-endpoint\n   */\n  readonly deleteCommentReaction: (\n    fileId: string,\n    commentId: string,\n    params: DeleteCommentReactionParams\n  ) => AxiosPromise<Figma.Reaction>;\n\n  /**\n   * Get user information for the authenticated user.\n   * @see https://www.figma.com/developers/api#get-me-endpoint\n   */\n  readonly me: () => AxiosPromise<Figma.User & { readonly email: string }>;\n\n  /**\n   * Lists the projects for a specified team. Note that this will only\n   * return projects visible to the authenticated user or owner of the\n   * developer token.\n   * @param {teamId} String Id of the team to list projects from\n   * @see https://www.figma.com/developers/api#get-team-projects-endpoint\n   */\n  readonly teamProjects: (\n    teamId: string\n  ) => AxiosPromise<Figma.TeamProjectsResponse>;\n\n  /**\n   * List the files in a given project.\n   * @param {projectId} String Id of the project to list files from\n   * @see https://www.figma.com/developers/api#get-project-files-endpoint\n   */\n  readonly projectFiles: (\n    projectId: string\n  ) => AxiosPromise<Figma.ProjectFilesResponse>;\n\n  /**\n   * Get a paginated list of published components within a team library\n   * @param {teamId} String Id of the team to list components from\n   * @see https://www.figma.com/developers/api#get-team-components-endpoint\n   */\n  readonly teamComponents: (\n    teamId: string,\n    params?: PaginationParams\n  ) => AxiosPromise<Figma.TeamComponentsResponse>;\n\n  /**\n   * Get a list of published components within a file\n   * @param {fileId} String Id of the file to list components from\n   * @see https://www.figma.com/developers/api#get-file-components-endpoint\n   */\n  readonly fileComponents: (\n    fileId: string\n  ) => AxiosPromise<Figma.FileComponentsResponse>;\n\n  /**\n   * Get metadata on a component by key.\n   * @param {key} The unique identifier of the component.\n   * @see https://www.figma.com/developers/api#get-component-endpoint\n   */\n\n  readonly component: (key: string) => AxiosPromise<Figma.ComponentResponse>;\n\n  /**\n   * Get a paginated list of published styles within a team library\n   * @param {teamId} String Id of the team to list styles from\n   * @see https://www.figma.com/developers/api#get-team-styles-endpoint\n   */\n  readonly teamStyles: (\n    teamId: string,\n    params?: PaginationParams\n  ) => AxiosPromise<Figma.TeamStylesResponse>;\n\n  /**\n   * Get a list of published styles within a file\n   * @param {fileId} String Id of the file to list styles from\n   * @see https://www.figma.com/developers/api#get-file-styles-endpoint\n   */\n  readonly fileStyles: (\n    fileId: string\n  ) => AxiosPromise<Figma.FileStylesResponse>;\n\n  /**\n   * Get metadata on a style by key.\n   * @param {key} The unique identifier of the style.\n   * @see https://www.figma.com/developers/api#get-style-endpoint\n   */\n  readonly style: (key: string) => AxiosPromise<Figma.StyleResponse>;\n}\n\nexport const Client = (opts: ClientOptions): ClientInterface => {\n  const headers = opts.accessToken\n    ? {\n        Authorization: `Bearer ${opts.accessToken}`,\n      }\n    : {\n        \"X-Figma-Token\": opts.personalAccessToken,\n      };\n\n  const client = axios.create({\n    baseURL: `https://${opts.apiRoot || \"api.figma.com\"}/v1/`,\n    headers,\n  });\n\n  return {\n    client,\n\n    file: (fileId, params = {}) =>\n      client.get(`files/${fileId}`, {\n        params: {\n          ...params,\n          ids: params.ids ? params.ids.join(\",\") : \"\",\n        },\n      }),\n\n    fileVersions: (fileId) => client.get(`files/${fileId}/versions`),\n\n    fileNodes: (fileId, params) =>\n      client.get(`files/${fileId}/nodes`, {\n        params: {\n          ...params,\n          ids: params.ids.join(\",\"),\n        },\n      }),\n\n    fileImages: (fileId, params) =>\n      client.get(`images/${fileId}`, {\n        params: {\n          ...params,\n          ids: params.ids.join(\",\"),\n        },\n      }),\n\n    fileImageFills: (fileId) => client.get(`files/${fileId}/images`),\n\n    comments: (fileId) => client.get(`files/${fileId}/comments`),\n\n    postComment: (fileId, params) =>\n      client.post(`files/${fileId}/comments`, params),\n\n    deleteComment: (fileId, commentId) =>\n      client.delete(`files/${fileId}/comments/${commentId}`),\n\n    commentReactions: (fileId, commentId) =>\n      client.get(`files/${fileId}/comments/${commentId}/reactions`),\n\n    postCommentReaction: (fileId, commentId, params) =>\n      client.post(`files/${fileId}/comments/${commentId}/reactions`, params),\n\n    deleteCommentReaction: (fileId, commentId, params) =>\n      client.delete(`files/${fileId}/comments/${commentId}/reactions`, {\n        params,\n      }),\n\n    me: () => client.get(`me`),\n\n    teamProjects: (teamId) => client.get(`teams/${teamId}/projects`),\n\n    projectFiles: (projectId) => client.get(`projects/${projectId}/files`),\n\n    teamComponents: (teamId, params = {}) =>\n      client.get(`teams/${teamId}/components`, { params }),\n\n    fileComponents: (fileId) => client.get(`files/${fileId}/components`),\n\n    component: (key) => client.get(`components/${key}`),\n\n    teamStyles: (teamId, params = {}) =>\n      client.get(`teams/${teamId}/styles`, { params }),\n\n    fileStyles: (fileId) => client.get(`files/${fileId}/styles`),\n\n    style: (key) => client.get(`styles/${key}`),\n  };\n};\n"]}