@@ -11,8 +11,6 @@ export interface JiraConfig {
1111 email : string ;
1212 apiToken : string ;
1313 projectKey : string ;
14- forgeCommentUrl ?: string ;
15- forgeSharedSecret ?: string ;
1614}
1715
1816export class JiraAdapter implements IssueTrackerAdapter {
@@ -41,9 +39,7 @@ export class JiraAdapter implements IssueTrackerAdapter {
4139 if ( res . status === 404 ) {
4240 throw new IssueTrackerNotFoundError ( "Jira resource" , path ) ;
4341 }
44- throw new Error (
45- `Jira API error: ${ res . status } ${ res . statusText } on ${ path } ` ,
46- ) ;
42+ throw new Error ( `Jira API error: ${ res . status } ${ res . statusText } on ${ path } ` ) ;
4743 }
4844 if ( res . status === 204 ) return null ;
4945 try {
@@ -73,19 +69,17 @@ export class JiraAdapter implements IssueTrackerAdapter {
7369 ) ,
7470 labels : data . fields . labels ?? [ ] ,
7571 trackerStatus : data . fields . status ?. name ?? "" ,
76- attachments : ( data . fields . attachment ?? [ ] ) . map (
77- ( a : any ) : TicketAttachment => {
78- const contentUrl =
79- a . content == null ? undefined : String ( a . content ) . trim ( ) ;
80- return {
81- id : String ( a . id ) ,
82- filename : a . filename ?? "" ,
83- mimeType : a . mimeType ?? "application/octet-stream" ,
84- size : sanitizeAttachmentSize ( a . size ) ,
85- contentUrl : contentUrl || undefined ,
86- } ;
87- } ,
88- ) ,
72+ attachments : ( data . fields . attachment ?? [ ] ) . map ( ( a : any ) : TicketAttachment => {
73+ const contentUrl =
74+ a . content == null ? undefined : String ( a . content ) . trim ( ) ;
75+ return {
76+ id : String ( a . id ) ,
77+ filename : a . filename ?? "" ,
78+ mimeType : a . mimeType ?? "application/octet-stream" ,
79+ size : sanitizeAttachmentSize ( a . size ) ,
80+ contentUrl : contentUrl || undefined ,
81+ } ;
82+ } ) ,
8983 } ;
9084 }
9185
@@ -106,9 +100,6 @@ export class JiraAdapter implements IssueTrackerAdapter {
106100 }
107101
108102 async postComment ( id : string , comment : string ) : Promise < string | null > {
109- if ( this . config . forgeCommentUrl && this . config . forgeSharedSecret ) {
110- return this . postCommentViaForge ( id , comment ) ;
111- }
112103 const data = await this . request ( `/rest/api/3/issue/${ id } /comment` , {
113104 method : "POST" ,
114105 body : JSON . stringify ( {
@@ -124,34 +115,6 @@ export class JiraAdapter implements IssueTrackerAdapter {
124115 return `${ this . baseUrl } /browse/${ encodeURIComponent ( id ) } ?focusedCommentId=${ encodeURIComponent ( commentId ) } ` ;
125116 }
126117
127- private async postCommentViaForge (
128- id : string ,
129- comment : string ,
130- ) : Promise < string | null > {
131- const res = await fetch ( this . config . forgeCommentUrl ! , {
132- method : "POST" ,
133- headers : {
134- "Content-Type" : "application/json" ,
135- "x-shared-secret" : this . config . forgeSharedSecret ! ,
136- } ,
137- body : JSON . stringify ( { issueKey : id , body : comment } ) ,
138- } ) ;
139- if ( res . status === 404 ) {
140- throw new IssueTrackerNotFoundError ( "Jira issue" , id ) ;
141- }
142- if ( ! res . ok ) {
143- throw new Error (
144- `Forge postComment error: ${ res . status } ${ res . statusText } ` ,
145- ) ;
146- }
147- const data = ( await res . json ( ) ) as {
148- id ?: string | null ;
149- permalinkPath ?: string | null ;
150- } ;
151- if ( ! data ?. id || ! data ?. permalinkPath ) return null ;
152- return `${ this . baseUrl } /browse/${ encodeURIComponent ( id ) } ${ data . permalinkPath } ` ;
153- }
154-
155118 async downloadAttachment (
156119 url : string ,
157120 opts : { timeoutMs ?: number } = { } ,
@@ -238,9 +201,7 @@ function extractAdfText(adf: any): string {
238201
239202function extractAcceptanceCriteria ( description : any ) : string {
240203 const text = extractAdfText ( description ) ;
241- const match = text . match (
242- / a c c e p t a n c e c r i t e r i a [: \s] * ( [ \s \S ] * ?) (?: \n \n | \n # | $ ) / i,
243- ) ;
204+ const match = text . match ( / a c c e p t a n c e c r i t e r i a [: \s] * ( [ \s \S ] * ?) (?: \n \n | \n # | $ ) / i) ;
244205 return match ?. [ 1 ] ?. trim ( ) ?? "" ;
245206}
246207
0 commit comments