Skip to content

Commit f570592

Browse files
authored
fix(linear): update required fields (#2070)
1 parent e64b1c9 commit f570592

25 files changed

+385
-93
lines changed

apps/docs/content/docs/en/tools/linear.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ Fetch and filter issues from Linear
4242

4343
| Parameter | Type | Required | Description |
4444
| --------- | ---- | -------- | ----------- |
45-
| `teamId` | string | Yes | Linear team ID |
46-
| `projectId` | string | Yes | Linear project ID |
45+
| `teamId` | string | No | Linear team ID to filter by |
46+
| `projectId` | string | No | Linear project ID to filter by |
4747

4848
#### Output
4949

@@ -76,7 +76,7 @@ Create a new issue in Linear
7676
| Parameter | Type | Required | Description |
7777
| --------- | ---- | -------- | ----------- |
7878
| `teamId` | string | Yes | Linear team ID |
79-
| `projectId` | string | Yes | Linear project ID |
79+
| `projectId` | string | No | Linear project ID |
8080
| `title` | string | Yes | Issue title |
8181
| `description` | string | No | Issue description |
8282

@@ -240,7 +240,7 @@ Edit a comment in Linear
240240
| Parameter | Type | Required | Description |
241241
| --------- | ---- | -------- | ----------- |
242242
| `commentId` | string | Yes | Comment ID to update |
243-
| `body` | string | Yes | New comment text \(supports Markdown\) |
243+
| `body` | string | No | New comment text \(supports Markdown\) |
244244

245245
#### Output
246246

@@ -640,7 +640,7 @@ Add an attachment to an issue in Linear
640640
| --------- | ---- | -------- | ----------- |
641641
| `issueId` | string | Yes | Issue ID to attach to |
642642
| `url` | string | Yes | URL of the attachment |
643-
| `title` | string | No | Attachment title |
643+
| `title` | string | Yes | Attachment title |
644644
| `subtitle` | string | No | Attachment subtitle/description |
645645

646646
#### Output
@@ -676,7 +676,7 @@ Update an attachment metadata in Linear
676676
| Parameter | Type | Required | Description |
677677
| --------- | ---- | -------- | ----------- |
678678
| `attachmentId` | string | Yes | Attachment ID to update |
679-
| `title` | string | No | New attachment title |
679+
| `title` | string | Yes | New attachment title |
680680
| `subtitle` | string | No | New attachment subtitle |
681681

682682
#### Output

apps/sim/blocks/blocks/linear.ts

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,17 @@ export const LinearBlock: BlockConfig<LinearResponse> = {
146146
placeholder: 'Select a team',
147147
dependsOn: ['credential'],
148148
mode: 'basic',
149+
required: {
150+
field: 'operation',
151+
value: [
152+
'linear_create_issue',
153+
'linear_create_project',
154+
'linear_list_workflow_states',
155+
'linear_create_workflow_state',
156+
'linear_create_cycle',
157+
'linear_get_active_cycle',
158+
],
159+
},
149160
condition: {
150161
field: 'operation',
151162
value: [
@@ -172,6 +183,17 @@ export const LinearBlock: BlockConfig<LinearResponse> = {
172183
canonicalParamId: 'teamId',
173184
placeholder: 'Enter Linear team ID',
174185
mode: 'advanced',
186+
required: {
187+
field: 'operation',
188+
value: [
189+
'linear_create_issue',
190+
'linear_create_project',
191+
'linear_list_workflow_states',
192+
'linear_create_workflow_state',
193+
'linear_create_cycle',
194+
'linear_get_active_cycle',
195+
],
196+
},
175197
condition: {
176198
field: 'operation',
177199
value: [
@@ -201,6 +223,16 @@ export const LinearBlock: BlockConfig<LinearResponse> = {
201223
placeholder: 'Select a project',
202224
dependsOn: ['credential', 'teamId'],
203225
mode: 'basic',
226+
required: {
227+
field: 'operation',
228+
value: [
229+
'linear_get_project',
230+
'linear_update_project',
231+
'linear_archive_project',
232+
'linear_delete_project',
233+
'linear_list_project_updates',
234+
],
235+
},
204236
condition: {
205237
field: 'operation',
206238
value: [
@@ -223,6 +255,18 @@ export const LinearBlock: BlockConfig<LinearResponse> = {
223255
canonicalParamId: 'projectId',
224256
placeholder: 'Enter Linear project ID',
225257
mode: 'advanced',
258+
required: {
259+
field: 'operation',
260+
value: [
261+
'linear_get_project',
262+
'linear_update_project',
263+
'linear_archive_project',
264+
'linear_delete_project',
265+
'linear_create_project_update',
266+
'linear_list_project_updates',
267+
'linear_create_project_link',
268+
],
269+
},
226270
condition: {
227271
field: 'operation',
228272
value: [
@@ -299,7 +343,10 @@ export const LinearBlock: BlockConfig<LinearResponse> = {
299343
title: 'Comment',
300344
type: 'long-input',
301345
placeholder: 'Enter comment text',
302-
required: true,
346+
required: {
347+
field: 'operation',
348+
value: ['linear_create_comment', 'linear_create_project_update'],
349+
},
303350
condition: {
304351
field: 'operation',
305352
value: ['linear_create_comment', 'linear_update_comment', 'linear_create_project_update'],
@@ -505,6 +552,7 @@ export const LinearBlock: BlockConfig<LinearResponse> = {
505552
title: 'Title',
506553
type: 'short-input',
507554
placeholder: 'Enter attachment title',
555+
required: true,
508556
condition: {
509557
field: 'operation',
510558
value: ['linear_create_attachment', 'linear_update_attachment'],

apps/sim/tools/linear/archive_project.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,20 @@ export const linearArchiveProjectTool: ToolConfig<
6161
}
6262
}
6363

64+
const result = data.data.projectArchive
65+
if (!result.success) {
66+
return {
67+
success: false,
68+
error: 'Project archive was not successful',
69+
output: {},
70+
}
71+
}
72+
6473
return {
65-
success: data.data.projectArchive.success,
74+
success: true,
6675
output: {
67-
success: data.data.projectArchive.success,
68-
projectId: response.ok ? data.data.projectArchive.success : '',
76+
success: result.success,
77+
projectId: result.entity?.id || '',
6978
},
7079
}
7180
},

apps/sim/tools/linear/create_attachment.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const linearCreateAttachmentTool: ToolConfig<
3333
},
3434
title: {
3535
type: 'string',
36-
required: false,
36+
required: true,
3737
visibility: 'user-or-llm',
3838
description: 'Attachment title',
3939
},
@@ -61,10 +61,9 @@ export const linearCreateAttachmentTool: ToolConfig<
6161
const input: Record<string, any> = {
6262
issueId: params.issueId,
6363
url: params.url,
64+
title: params.title,
6465
}
6566

66-
if (params.title !== undefined && params.title !== null && params.title !== '')
67-
input.title = params.title
6867
if (params.subtitle !== undefined && params.subtitle !== null && params.subtitle !== '')
6968
input.subtitle = params.subtitle
7069

apps/sim/tools/linear/create_customer.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,16 @@ export const linearCreateCustomerTool: ToolConfig<
162162
}
163163

164164
const result = data.data.customerCreate
165+
if (!result.success) {
166+
return {
167+
success: false,
168+
error: 'Customer creation was not successful',
169+
output: {},
170+
}
171+
}
172+
165173
return {
166-
success: result.success,
174+
success: true,
167175
output: {
168176
customer: result.customer,
169177
},

apps/sim/tools/linear/create_customer_request.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,16 @@ export const linearCreateCustomerRequestTool: ToolConfig<
133133
}
134134

135135
const result = data.data.customerNeedCreate
136+
if (!result.success) {
137+
return {
138+
success: false,
139+
error: 'Customer request creation was not successful',
140+
output: {},
141+
}
142+
}
143+
136144
return {
137-
success: result.success,
145+
success: true,
138146
output: {
139147
customerNeed: result.need,
140148
},

apps/sim/tools/linear/create_customer_status.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,16 @@ export const linearCreateCustomerStatusTool: ToolConfig<
124124
}
125125

126126
const result = data.data.customerStatusCreate
127+
if (!result.success) {
128+
return {
129+
success: false,
130+
error: 'Customer status creation was not successful',
131+
output: {},
132+
}
133+
}
134+
127135
return {
128-
success: result.success,
136+
success: true,
129137
output: {
130138
customerStatus: result.status,
131139
},

apps/sim/tools/linear/create_customer_tier.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,16 @@ export const linearCreateCustomerTierTool: ToolConfig<
124124
}
125125

126126
const result = data.data.customerTierCreate
127+
if (!result.success) {
128+
return {
129+
success: false,
130+
error: 'Customer tier creation was not successful',
131+
output: {},
132+
}
133+
}
134+
127135
return {
128-
success: result.success,
136+
success: true,
129137
output: {
130138
customerTier: result.customerTier,
131139
},

apps/sim/tools/linear/create_issue.ts

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const linearCreateIssueTool: ToolConfig<LinearCreateIssueParams, LinearCr
2222
},
2323
projectId: {
2424
type: 'string',
25-
required: true,
25+
required: false,
2626
visibility: 'user-only',
2727
description: 'Linear project ID',
2828
},
@@ -56,17 +56,31 @@ export const linearCreateIssueTool: ToolConfig<LinearCreateIssueParams, LinearCr
5656
if (!params.title || !params.title.trim()) {
5757
throw new Error('Title is required to create a Linear issue')
5858
}
59+
60+
const input: Record<string, any> = {
61+
teamId: params.teamId,
62+
title: params.title,
63+
}
64+
65+
if (
66+
params.projectId !== undefined &&
67+
params.projectId !== null &&
68+
params.projectId !== ''
69+
) {
70+
input.projectId = params.projectId
71+
}
72+
if (
73+
params.description !== undefined &&
74+
params.description !== null &&
75+
params.description !== ''
76+
) {
77+
input.description = params.description
78+
}
79+
5980
return {
6081
query: `
61-
mutation CreateIssue($teamId: String!, $projectId: String!, $title: String!, $description: String) {
62-
issueCreate(
63-
input: {
64-
teamId: $teamId
65-
projectId: $projectId
66-
title: $title
67-
description: $description
68-
}
69-
) {
82+
mutation CreateIssue($input: IssueCreateInput!) {
83+
issueCreate(input: $input) {
7084
issue {
7185
id
7286
title
@@ -79,20 +93,33 @@ export const linearCreateIssueTool: ToolConfig<LinearCreateIssueParams, LinearCr
7993
}
8094
`,
8195
variables: {
82-
teamId: params.teamId,
83-
projectId: params.projectId,
84-
title: params.title,
85-
...(params.description !== undefined &&
86-
params.description !== null &&
87-
params.description !== '' && { description: params.description }),
96+
input,
8897
},
8998
}
9099
},
91100
},
92101

93102
transformResponse: async (response) => {
94103
const data = await response.json()
95-
const issue = data.data.issueCreate.issue
104+
105+
if (data.errors) {
106+
return {
107+
success: false,
108+
error: data.errors[0]?.message || 'Failed to create issue',
109+
output: {},
110+
}
111+
}
112+
113+
const result = data.data?.issueCreate
114+
if (!result) {
115+
return {
116+
success: false,
117+
error: 'Issue creation was not successful',
118+
output: {},
119+
}
120+
}
121+
122+
const issue = result.issue
96123
return {
97124
success: true,
98125
output: {

apps/sim/tools/linear/create_project.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,29 @@ export const linearCreateProjectTool: ToolConfig<
7878
name: params.name,
7979
}
8080

81-
if (params.description !== undefined) input.description = params.description
82-
if (params.leadId !== undefined) input.leadId = params.leadId
83-
if (params.startDate !== undefined) input.startDate = params.startDate
84-
if (params.targetDate !== undefined) input.targetDate = params.targetDate
85-
if (params.priority !== undefined) input.priority = Number(params.priority)
81+
if (
82+
params.description !== undefined &&
83+
params.description !== null &&
84+
params.description !== ''
85+
) {
86+
input.description = params.description
87+
}
88+
if (params.leadId !== undefined && params.leadId !== null && params.leadId !== '') {
89+
input.leadId = params.leadId
90+
}
91+
if (params.startDate !== undefined && params.startDate !== null && params.startDate !== '') {
92+
input.startDate = params.startDate
93+
}
94+
if (
95+
params.targetDate !== undefined &&
96+
params.targetDate !== null &&
97+
params.targetDate !== ''
98+
) {
99+
input.targetDate = params.targetDate
100+
}
101+
if (params.priority !== undefined && params.priority !== null) {
102+
input.priority = Number(params.priority)
103+
}
86104

87105
return {
88106
query: `

0 commit comments

Comments
 (0)