@@ -56,15 +56,13 @@ class Jira {
56
56
57
57
const workflow = data . values [ 0 ]
58
58
59
- // Build state machine structure
60
59
const stateMachine = {
61
60
name : workflow . id . name ,
62
61
states : { } ,
63
62
transitions : [ ] ,
64
63
transitionMap : new Map ( ) // For quick lookup: Map<fromStatusId, Map<toStatusId, transition>>
65
64
}
66
65
67
- // Process states
68
66
if ( workflow . statuses ) {
69
67
workflow . statuses . forEach ( status => {
70
68
stateMachine . states [ status . id ] = {
@@ -75,7 +73,6 @@ class Jira {
75
73
} )
76
74
}
77
75
78
- // Process transitions
79
76
if ( workflow . transitions ) {
80
77
workflow . transitions . forEach ( transition => {
81
78
const transitionInfo = {
@@ -157,7 +154,6 @@ class Jira {
157
154
* @returns {Array } All possible paths
158
155
*/
159
156
findAllTransitionPaths ( stateMachine , fromStatusName , toStatusName ) {
160
- // Convert names to IDs
161
157
let fromStatusId = null
162
158
let toStatusId = null
163
159
@@ -297,11 +293,9 @@ class Jira {
297
293
*/
298
294
async getWorkflowSchema ( projectKey ) {
299
295
try {
300
- // Get project details to find issue types
301
296
const project = await this . request ( `/project/${ projectKey } ` )
302
297
const projectData = await project . json ( )
303
298
304
- // Get workflow schemes
305
299
const workflowResponse = await this . request ( `/workflowscheme/project?projectId=${ projectData . id } ` )
306
300
const workflowData = await workflowResponse . json ( )
307
301
@@ -336,7 +330,6 @@ class Jira {
336
330
* @returns {Array } Shortest path of transitions
337
331
*/
338
332
findShortestTransitionPath ( stateMachine , fromStatusName , toStatusName , excludeStates = [ ] ) {
339
- // Convert names to IDs
340
333
let fromStatusId = null
341
334
let toStatusId = null
342
335
const excludeStatusIds = new Set ( )
@@ -357,7 +350,6 @@ class Jira {
357
350
return [ ] // Already at destination
358
351
}
359
352
360
- // Check if target status is in excluded states
361
353
if ( excludeStatusIds . has ( toStatusId ) ) {
362
354
console . warn ( `Target status "${ toStatusName } " is in the excluded states list` )
363
355
return null
@@ -379,7 +371,6 @@ class Jira {
379
371
}
380
372
381
373
if ( nextStatusId === toStatusId ) {
382
- // Found the target
383
374
return [ ...path , {
384
375
id : transition . id ,
385
376
name : transition . name ,
@@ -419,7 +410,6 @@ class Jira {
419
410
*/
420
411
async transitionIssue ( issueKey , targetStatusName , excludeStates = [ 'Blocked' , 'Rejected' ] ) {
421
412
try {
422
- // Get current issue status
423
413
const issueResponse = await this . request ( `/issue/${ issueKey } ?fields=status` )
424
414
const issueData = await issueResponse . json ( )
425
415
const currentStatusName = issueData . fields . status . name
@@ -449,12 +439,9 @@ class Jira {
449
439
console . log ( `Found shortest transition path with ${ shortestPath . length } steps:` )
450
440
shortestPath . forEach ( t => console . log ( ` ${ t . fromName } → ${ t . toName } (${ t . name } )` ) )
451
441
452
- // Execute transitions in sequence
453
442
for ( const transition of shortestPath ) {
454
- // Get available transitions for current state of the issue
455
443
const availableTransitions = await this . getTransitions ( issueKey )
456
444
457
- // Find the matching transition
458
445
const actualTransition = availableTransitions . find ( t =>
459
446
t . id === transition . id ||
460
447
( t . to . name === transition . toName && t . name === transition . name )
@@ -466,7 +453,6 @@ class Jira {
466
453
return false
467
454
}
468
455
469
- // Execute the transition
470
456
await this . request ( `/issue/${ issueKey } /transitions` , {
471
457
method : 'POST' ,
472
458
body : JSON . stringify ( {
0 commit comments