Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add component-sets features (variants) #48

Merged
merged 2 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/figmaTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,12 @@ export interface ComponentResponse {
readonly meta: FullComponentMetadata;
}

export interface ComponentSetResponse {
readonly error: boolean;
readonly status: number;
readonly meta: FullComponentMetadata;
}

export interface StyleResponse {
readonly error: boolean;
readonly status: number;
Expand Down Expand Up @@ -1040,6 +1046,23 @@ export interface FileComponentsResponse {
};
}

export interface TeamComponentSetsResponse {
readonly error: boolean;
readonly status: number;
readonly meta: {
readonly component_sets: ReadonlyArray<FullComponentMetadata>;
readonly cursor: PaginationMeta;
};
}

export interface FileComponentSetsResponse {
readonly error: boolean;
readonly status: number;
readonly meta: {
readonly component_sets: ReadonlyArray<FullComponentMetadata>;
};
}

export interface TeamStylesResponse {
readonly error: boolean;
readonly status: number;
Expand Down
34 changes: 34 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,33 @@ export interface ClientInterface {

readonly component: (key: string) => AxiosPromise<Figma.ComponentResponse>;

/**
* Get a paginated list of published component sets within a team library
* @param {teamId} String Id of the team to list components from
* @see https://www.figma.com/developers/api#get-team-component-sets-endpoint
*/
readonly teamComponentSets: (
teamId: string,
params?: PaginationParams
) => AxiosPromise<Figma.TeamComponentSetsResponse>;

/**
* Get a list of published component sets within a file
* @param {fileId} String Id of the file to list components from
* @see https://www.figma.com/developers/api#get-team-component-sets-endpoint
*/
readonly fileComponentSets: (
fileId: string
) => AxiosPromise<Figma.FileComponentSetsResponse>;

/**
* Get metadata on a component set by key.
* @param {key} The unique identifier of the component.
* @see https://www.figma.com/developers/api#get-component-sets-endpoint
*/

readonly componentSet: (key: string) => AxiosPromise<Figma.ComponentSetResponse>;

/**
* Get a paginated list of published styles within a team library
* @param {teamId} String Id of the team to list styles from
Expand Down Expand Up @@ -357,6 +384,13 @@ export const Client = (opts: ClientOptions): ClientInterface => {

component: (key) => client.get(`components/${key}`),

teamComponentSets: (teamId, params = {}) =>
client.get(`teams/${teamId}/component_sets`, { params }),

fileComponentSets: (fileId) => client.get(`files/${fileId}/component_sets`),

componentSet: (key) => client.get(`component_set/${key}`),

teamStyles: (teamId, params = {}) =>
client.get(`teams/${teamId}/styles`, { params }),

Expand Down