Comparing version 1.0.1 to 1.2.0
@@ -506,3 +506,3 @@ export interface Global { | ||
} | ||
export interface File { | ||
export interface FileResponse { | ||
readonly components: { | ||
@@ -517,2 +517,11 @@ readonly [key: string]: Component; | ||
} | ||
export interface FileImageResponse { | ||
readonly err: string | null; | ||
readonly images: { | ||
readonly [key: string]: string; | ||
}; | ||
} | ||
export interface CommentsResponse { | ||
readonly comments: ReadonlyArray<Comment>; | ||
} | ||
export interface FileSummary { | ||
@@ -524,1 +533,7 @@ readonly key: string; | ||
} | ||
export interface TeamProjectsResponse { | ||
readonly projects: ReadonlyArray<ProjectSummary>; | ||
} | ||
export interface ProjectFilesResponse { | ||
readonly files: ReadonlyArray<FileSummary>; | ||
} |
import * as Figma from './figmaTypes'; | ||
export * from './figmaTypes'; | ||
import { AxiosPromise } from 'axios'; | ||
export interface FileResponse { | ||
readonly data: Figma.File; | ||
} | ||
export interface FileImageParams { | ||
@@ -15,15 +12,2 @@ /** A list of node IDs to render */ | ||
} | ||
export interface FileImageResponse { | ||
readonly data: { | ||
readonly err: string | null; | ||
readonly images: { | ||
readonly [key: string]: string; | ||
}; | ||
}; | ||
} | ||
export interface CommentsResponse { | ||
readonly data: { | ||
readonly comments: ReadonlyArray<Figma.Comment>; | ||
}; | ||
} | ||
export interface PostCommentParams { | ||
@@ -35,23 +19,17 @@ /** The text contents of the comment to post */ | ||
} | ||
export interface PostCommentResponse { | ||
/** The Comment that was successfully posted */ | ||
readonly data: Figma.Comment; | ||
export interface ClientOptions { | ||
/** access token returned from OAuth authentication */ | ||
readonly accessToken?: string; | ||
/** personal access token obtained from account settings */ | ||
readonly personalAccessToken?: string; | ||
/** custom API root */ | ||
readonly apiRoot?: string; | ||
} | ||
export interface TeamProjectsResponse { | ||
readonly data: { | ||
readonly projects: ReadonlyArray<Figma.ProjectSummary>; | ||
}; | ||
} | ||
export interface ProjectFilesResponse { | ||
readonly data: { | ||
readonly files: ReadonlyArray<Figma.FileSummary>; | ||
}; | ||
} | ||
export declare const Client: (accessToken: string, apiRoot?: string) => { | ||
file: (fileId: string) => AxiosPromise<FileResponse>; | ||
fileImages: (fileId: string, params: FileImageParams) => AxiosPromise<FileImageResponse>; | ||
comments: (fileId: string) => AxiosPromise<CommentsResponse>; | ||
postComment: (fileId: string, params: PostCommentParams) => AxiosPromise<PostCommentResponse>; | ||
teamProjects: (teamId: string) => AxiosPromise<TeamProjectsResponse>; | ||
projectFiles: (projectId: string) => AxiosPromise<ProjectFilesResponse>; | ||
export declare const Client: (opts: ClientOptions) => { | ||
file: (fileId: string) => AxiosPromise<Figma.FileResponse>; | ||
fileImages: (fileId: string, params: FileImageParams) => AxiosPromise<Figma.FileImageResponse>; | ||
comments: (fileId: string) => AxiosPromise<Figma.CommentsResponse>; | ||
postComment: (fileId: string, params: PostCommentParams) => AxiosPromise<Figma.Comment>; | ||
teamProjects: (teamId: string) => AxiosPromise<Figma.TeamProjectsResponse>; | ||
projectFiles: (projectId: string) => AxiosPromise<Figma.ProjectFilesResponse>; | ||
}; |
@@ -11,8 +11,13 @@ "use strict"; | ||
const axios_1 = __importDefault(require("axios")); | ||
exports.Client = (accessToken, apiRoot) => { | ||
exports.Client = (opts) => { | ||
const headers = opts.accessToken | ||
? { | ||
Authorization: `Bearer: ${opts.accessToken}` | ||
} | ||
: { | ||
'X-Figma-Token': opts.personalAccessToken | ||
}; | ||
const client = axios_1.default.create({ | ||
baseURL: `${apiRoot || 'api.figma.com'}/v1/`, | ||
headers: { | ||
Authorization: `Bearer ${accessToken}` | ||
} | ||
baseURL: `https://${opts.apiRoot || 'api.figma.com'}/v1/`, | ||
headers | ||
}); | ||
@@ -68,2 +73,2 @@ return { | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Q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UFFLENBQUM7UUFFL0I7Ozs7Ozs7Ozs7O1dBV0c7UUFDSCxVQUFVLEVBQUUsQ0FDVixNQUFVLEVBQ1YsTUFBdUIsRUFDZ0IsRUFBRSxDQUN6QyxNQUFNLENBQUMsR0FBRyxDQUFDLFVBQVUsTUFBTSxFQUFFLEVBQUU7WUFDN0IsTUFBTSxvQkFDRCxNQUFNLElBQ1QsR0FBRyxFQUFFLE1BQU0sQ0FBQyxHQUFHLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxHQUMxQjtTQUNGLENBQUM7UUFFSjs7O1dBR0c7UUFDSCxRQUFRLEVBQUUsQ0FBQyxNQUFVLEVBQXdDLEVBQUUsQ0FDN0QsTUFBTSxDQUFDLEdBQUcsQ0FBQyxTQUFTLE1BQU0sV0FBVyxDQUFDO1FBRXhDOzs7O1dBSUc7UUFDSCxXQUFXLEVBQUUsQ0FDWCxNQUFVLEVBQ1YsTUFBeUIsRUFDSSxFQUFFLENBQy9CLE1BQU0sQ0FBQyxJQUFJLENBQUMsU0FBUyxNQUFNLFdBQVcsRUFBRSxNQUFNLENBQUM7UUFFakQ7Ozs7O1dBS0c7UUFDSCxZQUFZLEVBQUUsQ0FBQyxNQUFVLEVBQTRDLEVBQUUsQ0FDckUsTUFBTSxDQUFDLEdBQUcsQ0FBQyxTQUFTLE1BQU0sV0FBVyxDQUFDO1FBRXhDOzs7V0FHRztRQUNILFlBQVksRUFBRSxDQUFDLFNBQWEsRUFBNEMsRUFBRSxDQUN4RSxNQUFNLENBQUMsR0FBRyxDQUFDLFlBQVksU0FBUyxRQUFRLENBQUM7S0FDNUMsQ0FBQztBQUNKLENBQUMsQ0FBQyJ9 |
@@ -506,3 +506,3 @@ export interface Global { | ||
} | ||
export interface File { | ||
export interface FileResponse { | ||
readonly components: { | ||
@@ -517,2 +517,11 @@ readonly [key: string]: Component; | ||
} | ||
export interface FileImageResponse { | ||
readonly err: string | null; | ||
readonly images: { | ||
readonly [key: string]: string; | ||
}; | ||
} | ||
export interface CommentsResponse { | ||
readonly comments: ReadonlyArray<Comment>; | ||
} | ||
export interface FileSummary { | ||
@@ -524,1 +533,7 @@ readonly key: string; | ||
} | ||
export interface TeamProjectsResponse { | ||
readonly projects: ReadonlyArray<ProjectSummary>; | ||
} | ||
export interface ProjectFilesResponse { | ||
readonly files: ReadonlyArray<FileSummary>; | ||
} |
import * as Figma from './figmaTypes'; | ||
export * from './figmaTypes'; | ||
import { AxiosPromise } from 'axios'; | ||
export interface FileResponse { | ||
readonly data: Figma.File; | ||
} | ||
export interface FileImageParams { | ||
@@ -15,15 +12,2 @@ /** A list of node IDs to render */ | ||
} | ||
export interface FileImageResponse { | ||
readonly data: { | ||
readonly err: string | null; | ||
readonly images: { | ||
readonly [key: string]: string; | ||
}; | ||
}; | ||
} | ||
export interface CommentsResponse { | ||
readonly data: { | ||
readonly comments: ReadonlyArray<Figma.Comment>; | ||
}; | ||
} | ||
export interface PostCommentParams { | ||
@@ -35,23 +19,17 @@ /** The text contents of the comment to post */ | ||
} | ||
export interface PostCommentResponse { | ||
/** The Comment that was successfully posted */ | ||
readonly data: Figma.Comment; | ||
export interface ClientOptions { | ||
/** access token returned from OAuth authentication */ | ||
readonly accessToken?: string; | ||
/** personal access token obtained from account settings */ | ||
readonly personalAccessToken?: string; | ||
/** custom API root */ | ||
readonly apiRoot?: string; | ||
} | ||
export interface TeamProjectsResponse { | ||
readonly data: { | ||
readonly projects: ReadonlyArray<Figma.ProjectSummary>; | ||
}; | ||
} | ||
export interface ProjectFilesResponse { | ||
readonly data: { | ||
readonly files: ReadonlyArray<Figma.FileSummary>; | ||
}; | ||
} | ||
export declare const Client: (accessToken: string, apiRoot?: string) => { | ||
file: (fileId: string) => AxiosPromise<FileResponse>; | ||
fileImages: (fileId: string, params: FileImageParams) => AxiosPromise<FileImageResponse>; | ||
comments: (fileId: string) => AxiosPromise<CommentsResponse>; | ||
postComment: (fileId: string, params: PostCommentParams) => AxiosPromise<PostCommentResponse>; | ||
teamProjects: (teamId: string) => AxiosPromise<TeamProjectsResponse>; | ||
projectFiles: (projectId: string) => AxiosPromise<ProjectFilesResponse>; | ||
export declare const Client: (opts: ClientOptions) => { | ||
file: (fileId: string) => AxiosPromise<Figma.FileResponse>; | ||
fileImages: (fileId: string, params: FileImageParams) => AxiosPromise<Figma.FileImageResponse>; | ||
comments: (fileId: string) => AxiosPromise<Figma.CommentsResponse>; | ||
postComment: (fileId: string, params: PostCommentParams) => AxiosPromise<Figma.Comment>; | ||
teamProjects: (teamId: string) => AxiosPromise<Figma.TeamProjectsResponse>; | ||
projectFiles: (projectId: string) => AxiosPromise<Figma.ProjectFilesResponse>; | ||
}; |
export * from './figmaTypes'; | ||
import axios from 'axios'; | ||
export const Client = (accessToken, apiRoot) => { | ||
export const Client = (opts) => { | ||
const headers = opts.accessToken | ||
? { | ||
Authorization: `Bearer: ${opts.accessToken}` | ||
} | ||
: { | ||
'X-Figma-Token': opts.personalAccessToken | ||
}; | ||
const client = axios.create({ | ||
baseURL: `${apiRoot || 'api.figma.com'}/v1/`, | ||
headers: { | ||
Authorization: `Bearer ${accessToken}` | ||
} | ||
baseURL: `https://${opts.apiRoot || 'api.figma.com'}/v1/`, | ||
headers | ||
}); | ||
@@ -62,2 +67,2 @@ return { | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsY0FBYyxjQUFjLENBQUM7QUFDN0IsT0FBTyxLQUF1QixNQUFNLE9BQU8sQ0FBQztBQXFENUMsTUFBTSxDQUFDLE1BQU0sTUFBTSxHQUFHLENBQUMsV0FBbUIsRUFBRSxPQUFnQixFQUFFLEVBQUU7SUFDOUQsTUFBTSxNQUFNLEdBQUcsS0FBSyxDQUFDLE1BQU0sQ0FBQztRQUMxQixPQUFPL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UMsVUFBVSxNQUFNLEVBQUUsRUFBRTtZQUM3QixNQUFNLEVBQUU7Z0JBQ04sR0FBRyxNQUFNO2dCQUNULEdBQUcsRUFBRSxNQUFNLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxHQUFHLENBQUM7YUFDMUI7U0FDRixDQUFDO1FBRUo7OztXQUdHO1FBQ0gsUUFBUSxFQUFFLENBQUMsTUFBVSxFQUF3QyxFQUFFLENBQzdELE1BQU0sQ0FBQyxHQUFHLENBQUMsU0FBUyxNQUFNLFdBQVcsQ0FBQztRQUV4Qzs7OztXQUlHO1FBQ0gsV0FBVyxFQUFFLENBQ1gsTUFBVSxFQUNWLE1BQXlCLEVBQ0ksRUFBRSxDQUMvQixNQUFNLENBQUMsSUFBSSxDQUFDLFNBQVMsTUFBTSxXQUFXLEVBQUUsTUFBTSxDQUFDO1FBRWpEOzs7OztXQUtHO1FBQ0gsWUFBWSxFQUFFLENBQUMsTUFBVSxFQUE0QyxFQUFFLENBQ3JFLE1BQU0sQ0FBQyxHQUFHLENBQUMsU0FBUyxNQUFNLFdBQVcsQ0FBQztRQUV4Qzs7O1dBR0c7UUFDSCxZQUFZLEVBQUUsQ0FBQyxTQUFhLEVBQTRDLEVBQUUsQ0FDeEUsTUFBTSxDQUFDLEdBQUcsQ0FBQyxZQUFZLFNBQVMsUUFBUSxDQUFDO0tBQzVDLENBQUM7QUFDSixDQUFDLENBQUMifQ== |
{ | ||
"name": "figma-js", | ||
"version": "1.0.1", | ||
"version": "1.2.0", | ||
"description": "A simple wrapper for the Figma API", | ||
@@ -5,0 +5,0 @@ "main": "build/main/index.js", |
@@ -1,5 +0,57 @@ | ||
# figma-js | ||
# Figma.js | ||
A simple wrapper for the Figma API | ||
## Usage | ||
[Full documentation](http://jongold.github.io/figma-js) is available on the web, and most everything is typed with Typescript. | ||
### Creating a client | ||
Quickest start is to grab a personal access token from your Figma account settings page | ||
```typescript | ||
import * as Figma from 'figma-js'; | ||
const token = '12345'; | ||
const client = Figma.Client({ | ||
personalAccessToken: token | ||
}); | ||
``` | ||
Alternatively, if you're building an app with OAuth authentication, after you get back the OAuth access token… | ||
```typescript | ||
import * as Figma from 'figma-js'; | ||
const token = '12345'; | ||
const client = Figma.Client({ | ||
personalAccessToken: token | ||
}); | ||
``` | ||
### Doing cool things | ||
Once you have instantiated a client, have fun! | ||
```typescript | ||
client.file('file-id').then(({ data }) => { | ||
console.log(data); | ||
}); | ||
``` | ||
### Just reusing types | ||
All of the types in the Figma file format / API are exported. | ||
```typescript | ||
import * as Figma from 'figma-js'; | ||
const textNode: Figma.Text = { | ||
// … this should autocomplete if your editor is set up for it! | ||
}; | ||
``` | ||
## Contributing | ||
@@ -17,2 +69,7 @@ | ||
### Contributions welcomed | ||
* [ ] [generate types automatically](https://github.com/jongold/figma-js/issues/1) | ||
* [ ] [add tests](https://github.com/jongold/figma-js/issues/2) | ||
### Committing | ||
@@ -24,3 +81,8 @@ | ||
# instead of git commit | ||
git cz | ||
``` | ||
## Contributors | ||
* [@jongold](https://github.com/jongold/) (Airbnb) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
66804
15
87
0
1431