Skip to content

2298 - add linear component #2577

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
527 changes: 527 additions & 0 deletions docs/content/docs/reference/components/linear.mdx

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions server/apps/server-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ implementation(project(":server:libs:modules:components:bolna"))
implementation(project(":server:libs:modules:components:json-file"))
implementation(project(":server:libs:modules:components:json-helper"))
implementation(project(":server:libs:modules:components:keap"))
implementation(project(":server:libs:modules:components:linear"))
implementation(project(":server:libs:modules:components:logger"))
implementation(project(":server:libs:modules:components:mailchimp"))
implementation(project(":server:libs:modules:components:mailerlite"))
Expand Down
1 change: 1 addition & 0 deletions server/ee/apps/worker-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ implementation(project(":server:libs:modules:components:graphql-client"))
implementation(project(":server:libs:modules:components:json-file"))
implementation(project(":server:libs:modules:components:json-helper"))
implementation(project(":server:libs:modules:components:keap"))
implementation(project(":server:libs:modules:components:linear"))
implementation(project(":server:libs:modules:components:logger"))
implementation(project(":server:libs:modules:components:mailchimp"))
implementation(project(":server:libs:modules:components:mailerlite"))
Expand Down
2 changes: 2 additions & 0 deletions server/libs/modules/components/linear/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version="1.0"

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright 2025 ByteChef
*
* 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.linear;

import static com.bytechef.component.definition.ComponentDsl.component;
import static com.bytechef.component.definition.ComponentDsl.tool;

import com.bytechef.component.ComponentHandler;
import com.bytechef.component.definition.ComponentCategory;
import com.bytechef.component.definition.ComponentDefinition;
import com.bytechef.component.linear.action.LinearCreateCommentAction;
import com.bytechef.component.linear.action.LinearCreateIssueAction;
import com.bytechef.component.linear.action.LinearCreateProjectAction;
import com.bytechef.component.linear.action.LinearRawGraphqlQueryAction;
import com.bytechef.component.linear.action.LinearUpdateIssueAction;
import com.bytechef.component.linear.action.LinearUpdateProjectAction;
import com.bytechef.component.linear.connection.LinearConnection;
import com.bytechef.component.linear.trigger.LinearNewIssueTrigger;
import com.bytechef.component.linear.trigger.LinearRemovedIssueTrigger;
import com.bytechef.component.linear.trigger.LinearUpdatedIssueTrigger;
import com.google.auto.service.AutoService;

/**
* @author Marija Horvat
*/
@AutoService(ComponentHandler.class)
public class LinearComponentHandler implements ComponentHandler {

private static final ComponentDefinition COMPONENT_DEFINITION = component("linear")
.title("Linear")
.description("Linear is a project management and issue tracking tool designed primarily for software teams.")
.icon("path:assets/linear.svg")
.categories(ComponentCategory.PROJECT_MANAGEMENT)
.connection(LinearConnection.CONNECTION_DEFINITION)
.actions(
LinearCreateIssueAction.ACTION_DEFINITION,
LinearUpdateIssueAction.ACTION_DEFINITION,
LinearCreateProjectAction.ACTION_DEFINITION,
LinearUpdateProjectAction.ACTION_DEFINITION,
LinearCreateCommentAction.ACTION_DEFINITION,
LinearRawGraphqlQueryAction.ACTION_DEFINITION)
.triggers(
LinearNewIssueTrigger.TRIGGER_DEFINITION,
LinearUpdatedIssueTrigger.TRIGGER_DEFINITION,
LinearRemovedIssueTrigger.TRIGGER_DEFINITION)
.clusterElements(
tool(LinearCreateIssueAction.ACTION_DEFINITION),
tool(LinearUpdateIssueAction.ACTION_DEFINITION),
tool(LinearCreateProjectAction.ACTION_DEFINITION),
tool(LinearUpdateProjectAction.ACTION_DEFINITION),
tool(LinearCreateCommentAction.ACTION_DEFINITION),
tool(LinearRawGraphqlQueryAction.ACTION_DEFINITION));

@Override
public ComponentDefinition getDefinition() {
return COMPONENT_DEFINITION;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* Copyright 2025 ByteChef
*
* 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.linear.action;

import static com.bytechef.component.definition.ComponentDsl.ModifiableActionDefinition;
import static com.bytechef.component.definition.ComponentDsl.action;
import static com.bytechef.component.definition.ComponentDsl.bool;
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.linear.constant.LinearConstants.BODY;
import static com.bytechef.component.linear.constant.LinearConstants.ISSUE_ID;
import static com.bytechef.component.linear.constant.LinearConstants.TEAM_ID;
import static com.bytechef.component.linear.util.LinearUtils.executeGraphQLQuery;

import com.bytechef.component.definition.Context;
import com.bytechef.component.definition.OptionsDataSource.ActionOptionsFunction;
import com.bytechef.component.definition.Parameters;
import com.bytechef.component.linear.util.LinearUtils;
import java.util.Map;

/**
* @author Marija Horvat
*/
public class LinearCreateCommentAction {

public static final ModifiableActionDefinition ACTION_DEFINITION = action("createComment")
.title("Create Comment")
.description("Creates a new comment.")
.properties(
string(TEAM_ID)
.label("Team ID")
.description("The ID of the team where this issue should be created.")
.options((ActionOptionsFunction<String>) LinearUtils::getTeamOptions)
.required(true),
string(ISSUE_ID)
.label("Issue ID")
.description("The identifier of the issue to update.")
.options((ActionOptionsFunction<String>) LinearUtils::getIssueOptions)
.optionsLookupDependsOn(TEAM_ID)
.required(true),
string(BODY)
.label("Comment Body")
.description("The comment content in markdown format.")
.required(true))
.output(
outputSchema(
object()
.properties(
bool("success")
.description(
"Whether the operation was successful."),
object("comment")
.description("The comment that was created.")
.properties(
string("id")
.description("The ID of the comment."),
object("issue")
.description("The issue ID that the comment is associated with.")
.properties(string("id")),
string("body")
.description("The comment content in markdown format.")))))
.perform(LinearCreateCommentAction::perform);

private LinearCreateCommentAction() {
}

public static Object perform(
Parameters inputParameters, Parameters connectionParameters, Context context) {

String query =
"mutation{commentCreate(input: {issueId: \"%s\", body: \"%s\"}){success comment{id issue{id} body}}}"
.formatted(
inputParameters.getRequiredString(ISSUE_ID),
inputParameters.getRequiredString(BODY));

Map<String, Object> body = executeGraphQLQuery(query, context);

if (body.get("data") instanceof Map<?, ?> data
&& data.get("commentCreate") instanceof Map<?, ?> commentCreate) {
return commentCreate;
}

return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
* Copyright 2025 ByteChef
*
* 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.linear.action;

import static com.bytechef.component.definition.ComponentDsl.action;
import static com.bytechef.component.definition.ComponentDsl.bool;
import static com.bytechef.component.definition.ComponentDsl.integer;
import static com.bytechef.component.definition.ComponentDsl.object;
import static com.bytechef.component.definition.ComponentDsl.option;
import static com.bytechef.component.definition.ComponentDsl.outputSchema;
import static com.bytechef.component.definition.ComponentDsl.string;
import static com.bytechef.component.linear.constant.LinearConstants.ASSIGNEE_ID;
import static com.bytechef.component.linear.constant.LinearConstants.DESCRIPTION;
import static com.bytechef.component.linear.constant.LinearConstants.PRIORITY;
import static com.bytechef.component.linear.constant.LinearConstants.STATE_ID;
import static com.bytechef.component.linear.constant.LinearConstants.TEAM_ID;
import static com.bytechef.component.linear.constant.LinearConstants.TITLE;
import static com.bytechef.component.linear.util.LinearUtils.executeGraphQLQuery;

import com.bytechef.component.definition.ComponentDsl.ModifiableActionDefinition;
import com.bytechef.component.definition.Context;
import com.bytechef.component.definition.OptionsDataSource.ActionOptionsFunction;
import com.bytechef.component.definition.Parameters;
import com.bytechef.component.linear.util.LinearUtils;
import java.util.Map;

/**
* @author Marija Horvat
*/
public class LinearCreateIssueAction {

public static final ModifiableActionDefinition ACTION_DEFINITION = action("createIssue")
.title("Create Issue")
.description("Creates a new issue.")
.properties(
string(TITLE)
.label("Issue Title")
.description("The title of the new issue.")
.required(true),
string(TEAM_ID)
.label("Team ID")
.description("The ID of the team where this issue should be created.")
.options((ActionOptionsFunction<String>) LinearUtils::getTeamOptions)
.required(true),
string(STATE_ID)
.label("Status")
.description("The status of the issue.")
.options((ActionOptionsFunction<String>) LinearUtils::getIssueStateOptions)
.required(true),
integer(PRIORITY)
.label("Priority")
.description("The priority of the issue.")
.options(
option("No priority", 0),
option("Urgent", 1),
option("High", 2),
option("Normal", 3),
option("Low", 4))
.defaultValue(0)
.required(false),
string(ASSIGNEE_ID)
.label("Assignee ID")
.description("The identifier of the user to assign the issue to.")
.options((ActionOptionsFunction<String>) LinearUtils::getAssigneeOptions)
.required(false),
string(DESCRIPTION)
.label("Description")
.description("The detailed description of the issue.")
.required(false))
.output(
outputSchema(
object()
.properties(
bool("success")
.description(
"Whether the operation was successful."),
object("issue")
.description("The issue that was created or updated.")
.properties(
string("id")
.description("The ID of the issue."),
string("title")
.description("The title of the issue.")))))
.perform(LinearCreateIssueAction::perform);

private LinearCreateIssueAction() {
}

public static Object perform(
Parameters inputParameters, Parameters connectionParameters, Context context) {

String query =
"mutation{issueCreate(input: {title: \"%s\", teamId: \"%s\", stateId: \"%s\", %s%s%s}){success issue{id title}}}"
.formatted(
inputParameters.getRequiredString(TITLE),
inputParameters.getRequiredString(TEAM_ID),
inputParameters.getRequiredString(STATE_ID),
inputParameters.getInteger(PRIORITY) != null
? "priority: %d, ".formatted(inputParameters.getInteger(PRIORITY)) : "",
inputParameters.getString(ASSIGNEE_ID) != null
? "assigneeId: \"%s\", ".formatted(inputParameters.getString(ASSIGNEE_ID)) : "",
inputParameters.getString(DESCRIPTION) != null
? "description: \"%s\"".formatted(inputParameters.getString(DESCRIPTION)) : "");

Map<String, Object> body = executeGraphQLQuery(query, context);

if (body.get("data") instanceof Map<?, ?> data && data.get("issueCreate") instanceof Map<?, ?> issueCreate) {
return issueCreate;
}

return null;
}
}
Loading