Skip to content

Commit 99926ac

Browse files
committed
linear
1 parent 6bc1946 commit 99926ac

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

plugins/linear/steps/create-ticket.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ type CreateIssueMutationResponse = {
3030
};
3131

3232
type CreateTicketResult =
33-
| { success: true; id: string; url: string; title: string }
34-
| { success: false; error: string };
33+
| { success: true; data: { id: string; url: string; title: string } }
34+
| { success: false; error: { message: string } };
3535

3636
export type CreateTicketCoreInput = {
3737
ticketTitle: string;
@@ -77,8 +77,10 @@ async function stepHandler(
7777
if (!apiKey) {
7878
return {
7979
success: false,
80-
error:
81-
"LINEAR_API_KEY is not configured. Please add it in Project Integrations.",
80+
error: {
81+
message:
82+
"LINEAR_API_KEY is not configured. Please add it in Project Integrations.",
83+
},
8284
};
8385
}
8486

@@ -94,15 +96,15 @@ async function stepHandler(
9496
if (teamsResult.errors?.length) {
9597
return {
9698
success: false,
97-
error: teamsResult.errors[0].message,
99+
error: { message: teamsResult.errors[0].message },
98100
};
99101
}
100102

101103
const firstTeam = teamsResult.data?.teams.nodes[0];
102104
if (!firstTeam) {
103105
return {
104106
success: false,
105-
error: "No teams found in Linear workspace",
107+
error: { message: "No teams found in Linear workspace" },
106108
};
107109
}
108110
targetTeamId = firstTeam.id;
@@ -130,28 +132,30 @@ async function stepHandler(
130132
if (createResult.errors?.length) {
131133
return {
132134
success: false,
133-
error: createResult.errors[0].message,
135+
error: { message: createResult.errors[0].message },
134136
};
135137
}
136138

137139
const issue = createResult.data?.issueCreate.issue;
138140
if (!issue) {
139141
return {
140142
success: false,
141-
error: "Failed to create issue",
143+
error: { message: "Failed to create issue" },
142144
};
143145
}
144146

145147
return {
146148
success: true,
147-
id: issue.id,
148-
url: issue.url,
149-
title: issue.title,
149+
data: {
150+
id: issue.id,
151+
url: issue.url,
152+
title: issue.title,
153+
},
150154
};
151155
} catch (error) {
152156
return {
153157
success: false,
154-
error: `Failed to create ticket: ${getErrorMessage(error)}`,
158+
error: { message: `Failed to create ticket: ${getErrorMessage(error)}` },
155159
};
156160
}
157161
}

plugins/linear/steps/find-issues.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ type LinearIssue = {
3737
};
3838

3939
type FindIssuesResult =
40-
| { success: true; issues: LinearIssue[]; count: number }
41-
| { success: false; error: string };
40+
| { success: true; data: { issues: LinearIssue[]; count: number } }
41+
| { success: false; error: { message: string } };
4242

4343
export type FindIssuesCoreInput = {
4444
linearAssigneeId?: string;
@@ -85,8 +85,10 @@ async function stepHandler(
8585
if (!apiKey) {
8686
return {
8787
success: false,
88-
error:
89-
"LINEAR_API_KEY is not configured. Please add it in Project Integrations.",
88+
error: {
89+
message:
90+
"LINEAR_API_KEY is not configured. Please add it in Project Integrations.",
91+
},
9092
};
9193
}
9294

@@ -132,7 +134,7 @@ async function stepHandler(
132134
if (result.errors?.length) {
133135
return {
134136
success: false,
135-
error: result.errors[0].message,
137+
error: { message: result.errors[0].message },
136138
};
137139
}
138140

@@ -149,13 +151,15 @@ async function stepHandler(
149151

150152
return {
151153
success: true,
152-
issues: mappedIssues,
153-
count: mappedIssues.length,
154+
data: {
155+
issues: mappedIssues,
156+
count: mappedIssues.length,
157+
},
154158
};
155159
} catch (error) {
156160
return {
157161
success: false,
158-
error: `Failed to find issues: ${getErrorMessage(error)}`,
162+
error: { message: `Failed to find issues: ${getErrorMessage(error)}` },
159163
};
160164
}
161165
}

0 commit comments

Comments
 (0)