1 | |
2 |
|
3 | |
4 | * Get Transitions |
5 | * List the workflow transitions the current user can perform on an issue in its current status. Pass `expand: "transitions.fields"` to see the fields each transition screen accepts. |
6 | */ |
7 | export async function main( |
8 | auth: RT.Jira, |
9 | issue_id_or_key: string, |
10 | transition_id: string | undefined, |
11 | expand: string | undefined, |
12 | skip_remote_only_condition: boolean | undefined, |
13 | include_unavailable_transitions: boolean | undefined, |
14 | sort_by_ops_bar_and_status: boolean | undefined |
15 | ) { |
16 | const url = new URL( |
17 | `https://${auth.domain}.atlassian.net/rest/api/3/issue/${issue_id_or_key}/transitions` |
18 | ) |
19 | if (transition_id != null && transition_id !== "") { |
20 | url.searchParams.append("transitionId", transition_id) |
21 | } |
22 | if (expand != null && expand !== "") { |
23 | url.searchParams.append("expand", expand) |
24 | } |
25 | if (skip_remote_only_condition) { |
26 | url.searchParams.append("skipRemoteOnlyCondition", "true") |
27 | } |
28 | if (include_unavailable_transitions) { |
29 | url.searchParams.append("includeUnavailableTransitions", "true") |
30 | } |
31 | if (sort_by_ops_bar_and_status) { |
32 | url.searchParams.append("sortByOpsBarAndStatus", "true") |
33 | } |
34 |
|
35 | const response = await fetch(url, { |
36 | method: "GET", |
37 | headers: { |
38 | Authorization: `Basic ${btoa(`${auth.username}:${auth.password}`)}`, |
39 | Accept: "application/json", |
40 | }, |
41 | }) |
42 |
|
43 | if (!response.ok) { |
44 | throw new Error(`${response.status} ${await response.text()}`) |
45 | } |
46 |
|
47 | return await response.json() |
48 | } |
49 |
|