Class: LinearToonMcp::Tools::SaveProject

Inherits:
Base
  • Object
show all
Defined in:
lib/linear_toon_mcp/tools/save_project.rb

Overview

Create or update a Linear project. id presence determines create vs update. On create, name and teams are required. Resolves human-friendly names to IDs for teams, lead, members, labels, status, and initiative. Linking to an initiative is a create-only convenience — use AddProjectToInitiative on existing projects.

Constant Summary collapse

PROJECT_FIELDS =

standard:enable Layout/LineLength

<<~GRAPHQL
  id
  name
  description
  url
  priority
  priorityLabel
  startDate
  targetDate
  status { id name }
  lead { id name }
  teams { nodes { id name } }
GRAPHQL
CREATE_MUTATION =
<<~GRAPHQL
  mutation($input: ProjectCreateInput!) {
    projectCreate(input: $input) {
      success
      project { #{PROJECT_FIELDS.strip} }
    }
  }
GRAPHQL
UPDATE_MUTATION =
<<~GRAPHQL
  mutation($id: String!, $input: ProjectUpdateInput!) {
    projectUpdate(id: $id, input: $input) {
      success
      project { #{PROJECT_FIELDS.strip} }
    }
  }
GRAPHQL
<<~GRAPHQL
  mutation($input: InitiativeToProjectCreateInput!) {
    initiativeToProjectCreate(input: $input) { success }
  }
GRAPHQL

Instance Method Summary collapse

Methods inherited from Base

call, #call, error_response, success_response

Instance Method Details

#perform(id: nil, **kwargs) ⇒ Object

standard:disable Naming/VariableName, Metrics/MethodLength



79
80
81
82
83
84
85
86
# File 'lib/linear_toon_mcp/tools/save_project.rb', line 79

def perform(id: nil, **kwargs)
  if id
    reject_create_only_on_update(initiative: kwargs[:initiative])
    update(id, kwargs)
  else
    create(kwargs)
  end
end