diff --git a/docs/src/content/docs/reference/components/figma.md b/docs/src/content/docs/reference/components/figma.md index ff3892e7389..41f52eba8c0 100644 --- a/docs/src/content/docs/reference/components/figma.md +++ b/docs/src/content/docs/reference/components/figma.md @@ -50,6 +50,34 @@ Version: 1 ## Actions +### Get Comments +Gets a list of comments left on the file. + +#### Properties + +| Name | Type | Control Type | Description | +|:--------------:|:------------:|:--------------------:|:-------------------:| +| File Key | STRING | TEXT | File to get comments from. Figma file key copy from Figma file URL. | + + +### Output + + + +Type: OBJECT + + +#### Properties + +| Type | Control Type | +|:------------:|:--------------------:| +| [{STRING\(id), STRING\(file_key), STRING\(parent_id), {STRING\(id), STRING\(handle), STRING\(img_url), STRING\(email)}\(user)}] | ARRAY_BUILDER | + + + + + + ### Post Comment Posts a new comment on the file. diff --git a/server/libs/modules/components/figma/openapi.yaml b/server/libs/modules/components/figma/openapi.yaml index 6c55e983389..caaf18758c5 100644 --- a/server/libs/modules/components/figma/openapi.yaml +++ b/server/libs/modules/components/figma/openapi.yaml @@ -8,6 +8,48 @@ servers: - url: "https://api.figma.com" paths: /v1/files/{fileKey}/comments: + get: + summary: "Get Comments" + description: "Gets a list of comments left on the file." + operationId: "getComments" + parameters: + - name: "fileKey" + in: "path" + description: "File to get comments from. Figma file key copy from Figma file URL." + required: true + schema: + type: "string" + title: "File Key" + responses: + 200: + description: "Successful response." + content: + application/json: + schema: + type: "object" + properties: + body: + type: "array" + items: + type: "object" + properties: + id: + type: "string" + file_key: + type: "string" + parent_id: + type: "string" + user: + type: "object" + properties: + id: + type: "string" + handle: + type: "string" + img_url: + type: "string" + email: + type: "string" post: summary: "Post Comment" description: "Posts a new comment on the file." @@ -64,3 +106,4 @@ components: refreshUrl: "https://www.figma.com/api/oauth/refresh" scopes: file_comments:write: " " + files:read: "" diff --git a/server/libs/modules/components/figma/src/main/java/com/bytechef/component/figma/AbstractFigmaComponentHandler.java b/server/libs/modules/components/figma/src/main/java/com/bytechef/component/figma/AbstractFigmaComponentHandler.java index 063097d7d53..c914efc936a 100644 --- a/server/libs/modules/components/figma/src/main/java/com/bytechef/component/figma/AbstractFigmaComponentHandler.java +++ b/server/libs/modules/components/figma/src/main/java/com/bytechef/component/figma/AbstractFigmaComponentHandler.java @@ -20,6 +20,7 @@ import com.bytechef.component.OpenApiComponentHandler; import com.bytechef.component.definition.ComponentDefinition; +import com.bytechef.component.figma.action.FigmaGetCommentsAction; import com.bytechef.component.figma.action.FigmaPostCommentAction; import com.bytechef.component.figma.connection.FigmaConnection; @@ -34,7 +35,8 @@ public abstract class AbstractFigmaComponentHandler implements OpenApiComponentH .title("Figma") .description( "Figma is a cloud-based design and prototyping tool that enables teams to collaborate in real-time on user interface and user experience projects.")) - .actions(modifyActions(FigmaPostCommentAction.ACTION_DEFINITION)) + .actions(modifyActions(FigmaGetCommentsAction.ACTION_DEFINITION, + FigmaPostCommentAction.ACTION_DEFINITION)) .connection(modifyConnection(FigmaConnection.CONNECTION_DEFINITION)) .triggers(getTriggers()); diff --git a/server/libs/modules/components/figma/src/main/java/com/bytechef/component/figma/action/FigmaGetCommentsAction.java b/server/libs/modules/components/figma/src/main/java/com/bytechef/component/figma/action/FigmaGetCommentsAction.java new file mode 100644 index 00000000000..c2f4e9db50c --- /dev/null +++ b/server/libs/modules/components/figma/src/main/java/com/bytechef/component/figma/action/FigmaGetCommentsAction.java @@ -0,0 +1,66 @@ +/* + * Copyright 2023-present ByteChef Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.bytechef.component.figma.action; + +import static com.bytechef.component.OpenApiComponentHandler.PropertyType; +import static com.bytechef.component.definition.ComponentDsl.action; +import static com.bytechef.component.definition.ComponentDsl.array; +import static com.bytechef.component.definition.ComponentDsl.object; +import static com.bytechef.component.definition.ComponentDsl.outputSchema; +import static com.bytechef.component.definition.ComponentDsl.string; +import static com.bytechef.component.definition.Context.Http.ResponseType; + +import com.bytechef.component.definition.ComponentDsl; +import java.util.Map; + +/** + * Provides a list of the component actions. + * + * @generated + */ +public class FigmaGetCommentsAction { + public static final ComponentDsl.ModifiableActionDefinition ACTION_DEFINITION = action("getComments") + .title("Get Comments") + .description("Gets a list of comments left on the file.") + .metadata( + Map.of( + "method", "GET", + "path", "/v1/files/{fileKey}/comments" + + )) + .properties(string("fileKey").label("File Key") + .description("File to get comments from. Figma file key copy from Figma file URL.") + .required(true) + .metadata( + Map.of( + "type", PropertyType.PATH))) + .output(outputSchema(object() + .properties(array("body") + .items(object().properties(string("id").required(false), string("file_key").required(false), + string("parent_id").required(false), + object("user") + .properties(string("id").required(false), string("handle").required(false), + string("img_url").required(false), string("email").required(false)) + .required(false))) + .required(false)) + .metadata( + Map.of( + "responseType", ResponseType.JSON)))); + + private FigmaGetCommentsAction() { + } +} diff --git a/server/libs/modules/components/figma/src/main/java/com/bytechef/component/figma/connection/FigmaConnection.java b/server/libs/modules/components/figma/src/main/java/com/bytechef/component/figma/connection/FigmaConnection.java index 3bfd4f726c2..4b6046ba283 100644 --- a/server/libs/modules/components/figma/src/main/java/com/bytechef/component/figma/connection/FigmaConnection.java +++ b/server/libs/modules/components/figma/src/main/java/com/bytechef/component/figma/connection/FigmaConnection.java @@ -44,7 +44,7 @@ public class FigmaConnection { .label("Client Secret") .required(true)) .authorizationUrl((connectionParameters, context) -> "https://www.figma.com/oauth") - .scopes((connection, context) -> List.of("file_comments:write")) + .scopes((connection, context) -> List.of("file_comments:write", "files:read")) .tokenUrl((connectionParameters, context) -> "https://www.figma.com/api/oauth/token") .refreshUrl((connectionParameters, context) -> "https://www.figma.com/api/oauth/refresh")); diff --git a/server/libs/modules/components/figma/src/test/resources/definition/figma_v1.json b/server/libs/modules/components/figma/src/test/resources/definition/figma_v1.json index 7d48ab2a738..de9da903b33 100644 --- a/server/libs/modules/components/figma/src/test/resources/definition/figma_v1.json +++ b/server/libs/modules/components/figma/src/test/resources/definition/figma_v1.json @@ -14,6 +14,498 @@ "version" : 1, "title" : "Figma", "actions" : [ { + "batch" : null, + "deprecated" : null, + "description" : "Gets a list of comments left on the file.", + "help" : null, + "metadata" : { + "method" : "GET", + "path" : "/v1/files/{fileKey}/comments" + }, + "name" : "getComments", + "outputDefinition" : { + "output" : null, + "outputResponse" : { + "outputSchema" : { + "advancedOption" : null, + "description" : null, + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { + "responseType" : "JSON" + }, + "required" : null, + "name" : null, + "type" : "OBJECT", + "defaultValue" : null, + "exampleValue" : null, + "label" : null, + "placeholder" : null, + "additionalProperties" : null, + "multipleValues" : null, + "options" : null, + "properties" : [ { + "advancedOption" : null, + "description" : null, + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { }, + "required" : false, + "name" : "body", + "type" : "ARRAY", + "defaultValue" : null, + "exampleValue" : null, + "label" : null, + "placeholder" : null, + "items" : [ { + "advancedOption" : null, + "description" : null, + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { }, + "required" : null, + "name" : null, + "type" : "OBJECT", + "defaultValue" : null, + "exampleValue" : null, + "label" : null, + "placeholder" : null, + "additionalProperties" : null, + "multipleValues" : null, + "options" : null, + "properties" : [ { + "advancedOption" : null, + "description" : null, + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { }, + "required" : false, + "name" : "id", + "type" : "STRING", + "defaultValue" : null, + "exampleValue" : null, + "label" : null, + "placeholder" : null, + "controlType" : "TEXT", + "languageId" : null, + "maxLength" : null, + "minLength" : null, + "options" : null, + "optionsDataSource" : null + }, { + "advancedOption" : null, + "description" : null, + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { }, + "required" : false, + "name" : "file_key", + "type" : "STRING", + "defaultValue" : null, + "exampleValue" : null, + "label" : null, + "placeholder" : null, + "controlType" : "TEXT", + "languageId" : null, + "maxLength" : null, + "minLength" : null, + "options" : null, + "optionsDataSource" : null + }, { + "advancedOption" : null, + "description" : null, + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { }, + "required" : false, + "name" : "parent_id", + "type" : "STRING", + "defaultValue" : null, + "exampleValue" : null, + "label" : null, + "placeholder" : null, + "controlType" : "TEXT", + "languageId" : null, + "maxLength" : null, + "minLength" : null, + "options" : null, + "optionsDataSource" : null + }, { + "advancedOption" : null, + "description" : null, + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { }, + "required" : false, + "name" : "user", + "type" : "OBJECT", + "defaultValue" : null, + "exampleValue" : null, + "label" : null, + "placeholder" : null, + "additionalProperties" : null, + "multipleValues" : null, + "options" : null, + "properties" : [ { + "advancedOption" : null, + "description" : null, + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { }, + "required" : false, + "name" : "id", + "type" : "STRING", + "defaultValue" : null, + "exampleValue" : null, + "label" : null, + "placeholder" : null, + "controlType" : "TEXT", + "languageId" : null, + "maxLength" : null, + "minLength" : null, + "options" : null, + "optionsDataSource" : null + }, { + "advancedOption" : null, + "description" : null, + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { }, + "required" : false, + "name" : "handle", + "type" : "STRING", + "defaultValue" : null, + "exampleValue" : null, + "label" : null, + "placeholder" : null, + "controlType" : "TEXT", + "languageId" : null, + "maxLength" : null, + "minLength" : null, + "options" : null, + "optionsDataSource" : null + }, { + "advancedOption" : null, + "description" : null, + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { }, + "required" : false, + "name" : "img_url", + "type" : "STRING", + "defaultValue" : null, + "exampleValue" : null, + "label" : null, + "placeholder" : null, + "controlType" : "TEXT", + "languageId" : null, + "maxLength" : null, + "minLength" : null, + "options" : null, + "optionsDataSource" : null + }, { + "advancedOption" : null, + "description" : null, + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { }, + "required" : false, + "name" : "email", + "type" : "STRING", + "defaultValue" : null, + "exampleValue" : null, + "label" : null, + "placeholder" : null, + "controlType" : "TEXT", + "languageId" : null, + "maxLength" : null, + "minLength" : null, + "options" : null, + "optionsDataSource" : null + } ], + "controlType" : "OBJECT_BUILDER", + "optionsDataSource" : null + } ], + "controlType" : "OBJECT_BUILDER", + "optionsDataSource" : null + } ], + "maxItems" : null, + "minItems" : null, + "multipleValues" : null, + "options" : null, + "controlType" : "ARRAY_BUILDER", + "optionsDataSource" : null + } ], + "controlType" : "OBJECT_BUILDER", + "optionsDataSource" : null + }, + "sampleOutput" : null + }, + "outputSchema" : { + "advancedOption" : null, + "description" : null, + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { + "responseType" : "JSON" + }, + "required" : null, + "name" : null, + "type" : "OBJECT", + "defaultValue" : null, + "exampleValue" : null, + "label" : null, + "placeholder" : null, + "additionalProperties" : null, + "multipleValues" : null, + "options" : null, + "properties" : [ { + "advancedOption" : null, + "description" : null, + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { }, + "required" : false, + "name" : "body", + "type" : "ARRAY", + "defaultValue" : null, + "exampleValue" : null, + "label" : null, + "placeholder" : null, + "items" : [ { + "advancedOption" : null, + "description" : null, + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { }, + "required" : null, + "name" : null, + "type" : "OBJECT", + "defaultValue" : null, + "exampleValue" : null, + "label" : null, + "placeholder" : null, + "additionalProperties" : null, + "multipleValues" : null, + "options" : null, + "properties" : [ { + "advancedOption" : null, + "description" : null, + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { }, + "required" : false, + "name" : "id", + "type" : "STRING", + "defaultValue" : null, + "exampleValue" : null, + "label" : null, + "placeholder" : null, + "controlType" : "TEXT", + "languageId" : null, + "maxLength" : null, + "minLength" : null, + "options" : null, + "optionsDataSource" : null + }, { + "advancedOption" : null, + "description" : null, + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { }, + "required" : false, + "name" : "file_key", + "type" : "STRING", + "defaultValue" : null, + "exampleValue" : null, + "label" : null, + "placeholder" : null, + "controlType" : "TEXT", + "languageId" : null, + "maxLength" : null, + "minLength" : null, + "options" : null, + "optionsDataSource" : null + }, { + "advancedOption" : null, + "description" : null, + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { }, + "required" : false, + "name" : "parent_id", + "type" : "STRING", + "defaultValue" : null, + "exampleValue" : null, + "label" : null, + "placeholder" : null, + "controlType" : "TEXT", + "languageId" : null, + "maxLength" : null, + "minLength" : null, + "options" : null, + "optionsDataSource" : null + }, { + "advancedOption" : null, + "description" : null, + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { }, + "required" : false, + "name" : "user", + "type" : "OBJECT", + "defaultValue" : null, + "exampleValue" : null, + "label" : null, + "placeholder" : null, + "additionalProperties" : null, + "multipleValues" : null, + "options" : null, + "properties" : [ { + "advancedOption" : null, + "description" : null, + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { }, + "required" : false, + "name" : "id", + "type" : "STRING", + "defaultValue" : null, + "exampleValue" : null, + "label" : null, + "placeholder" : null, + "controlType" : "TEXT", + "languageId" : null, + "maxLength" : null, + "minLength" : null, + "options" : null, + "optionsDataSource" : null + }, { + "advancedOption" : null, + "description" : null, + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { }, + "required" : false, + "name" : "handle", + "type" : "STRING", + "defaultValue" : null, + "exampleValue" : null, + "label" : null, + "placeholder" : null, + "controlType" : "TEXT", + "languageId" : null, + "maxLength" : null, + "minLength" : null, + "options" : null, + "optionsDataSource" : null + }, { + "advancedOption" : null, + "description" : null, + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { }, + "required" : false, + "name" : "img_url", + "type" : "STRING", + "defaultValue" : null, + "exampleValue" : null, + "label" : null, + "placeholder" : null, + "controlType" : "TEXT", + "languageId" : null, + "maxLength" : null, + "minLength" : null, + "options" : null, + "optionsDataSource" : null + }, { + "advancedOption" : null, + "description" : null, + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { }, + "required" : false, + "name" : "email", + "type" : "STRING", + "defaultValue" : null, + "exampleValue" : null, + "label" : null, + "placeholder" : null, + "controlType" : "TEXT", + "languageId" : null, + "maxLength" : null, + "minLength" : null, + "options" : null, + "optionsDataSource" : null + } ], + "controlType" : "OBJECT_BUILDER", + "optionsDataSource" : null + } ], + "controlType" : "OBJECT_BUILDER", + "optionsDataSource" : null + } ], + "maxItems" : null, + "minItems" : null, + "multipleValues" : null, + "options" : null, + "controlType" : "ARRAY_BUILDER", + "optionsDataSource" : null + } ], + "controlType" : "OBJECT_BUILDER", + "optionsDataSource" : null + }, + "sampleOutput" : null + }, + "properties" : [ { + "advancedOption" : null, + "description" : "File to get comments from. Figma file key copy from Figma file URL.", + "displayCondition" : null, + "expressionEnabled" : null, + "hidden" : null, + "metadata" : { + "type" : "PATH" + }, + "required" : true, + "name" : "fileKey", + "type" : "STRING", + "defaultValue" : null, + "exampleValue" : null, + "label" : "File Key", + "placeholder" : null, + "controlType" : "TEXT", + "languageId" : null, + "maxLength" : null, + "minLength" : null, + "options" : null, + "optionsDataSource" : null + } ], + "title" : "Get Comments", + "workflowNodeDescription" : null, + "perform" : null, + "processErrorResponse" : null + }, { "batch" : null, "deprecated" : null, "description" : "Posts a new comment on the file.", @@ -348,9 +840,6 @@ "perform" : null, "processErrorResponse" : null } ], - "triggers" : [ ], - "unifiedApi" : null, - "dataStream" : null, "connection" : { "authorizations" : [ { "detectOn" : null, @@ -419,5 +908,8 @@ "authorizationRequired" : null, "baseUri" : { }, "test" : null - } + }, + "triggers" : [ ], + "unifiedApi" : null, + "dataStream" : null } \ No newline at end of file