@gitkraken/provider-apis 0.26.3 → 0.26.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.26.4
4
+
5
+ - add `getTreeForRepo` (GitLab)
6
+
7
+ - fix problem where normalizing sprints for issues would throw an error (Jira Data Center)
8
+
3
9
  ## 0.26.3
4
10
 
5
11
  - add property `GitRepository.projectID` (Azure DevOps)
package/dist/index.js CHANGED
@@ -1100,5 +1100,5 @@ query getLabelsForRepo(
1100
1100
  }
1101
1101
  }
1102
1102
  }
1103
- `,variables:{fullPath:`${r}/${n}`,after:o}},e);return{pageInfo:((l=(u=(a=i.body.data)==null?void 0:a.project)==null?void 0:u.labels)==null?void 0:l.pageInfo)??{endCursor:null,hasNextPage:!1},data:((g=(c=(d=(p=i.body.data)==null?void 0:p.project)==null?void 0:d.labels)==null?void 0:c.nodes)==null?void 0:g.map(Dt))??[]}}async getTreeForRepo(t,e={}){let r=K(t.repo),n=new URL(t.cursor??`${Ce(this.config,e)}/projects/${encodeURIComponent(r)}/repository/tree`);n.searchParams.set("per_page","10000"),n.searchParams.set("recursive","true"),n.searchParams.set("pagination","keyset"),n.searchParams.set("ref",t.branch);let o=await this.config.request({url:n.toString(),headers:R(e.token||this.config.token)}),i=o.headers.link;return{data:o.body.map(Us),pageInfo:{endCursor:i?i.substring(1,i.indexOf(">")):null,hasNextPage:!!i}}}};var Gs="https://api.atlassian.com/ex/jira",Ae=100,At=["assignee","comment","summary","created","creator","updated","votes","issuetype","status","labels","components","project","fixVersions","description"],Lt=(s,t,e,r)=>{var a,u,l,p;let n=s.fields.assignee,o=!r,i=s.fields[(t==null?void 0:t.Sprint)??""]??[];return{id:s.id,commentCount:s.fields.comment.comments.length,number:s.key,title:s.fields.summary,url:e?`${e}/browse/${s.key}`:null,closedDate:null,createdDate:new Date(s.fields.created),author:Le(s.fields.creator,e,o),updatedDate:new Date(s.fields.updated),assignees:n?[Le(n,e,o)]:[],description:s.fields.description,repository:null,project:{name:s.fields.project.name,resourceId:r??null,key:s.fields.project.key,namespace:null,id:s.fields.project.id},state:xs(s.fields.status),statusTransitions:((a=s.transitions)==null?void 0:a.map(Ts))??[],components:((u=s.fields.components)==null?void 0:u.map(Os))??[],type:s.fields.issuetype.name,upvoteCount:((l=s.fields.votes)==null?void 0:l.votes)||0,labels:((p=s.fields.labels)==null?void 0:p.map(d=>({color:null,description:null,id:null,name:d})))??[],sprints:i.map(Ns),fixVersions:s.fields.fixVersions.map(_s)}},Ts=s=>{let t;switch(s.to.statusCategory.name){case"To Do":t="TO_DO";break;case"In Progress":t="IN_PROGRESS";break;default:t="DONE";break}return{name:s.name,id:s.id,to:{id:s.to.id,name:s.to.name,color:s.to.statusCategory.colorName,category:t}}},Os=s=>({description:s.description??null,id:s.id,name:s.name}),ks=(s,t,e)=>e&&s.name?`${t}/secure/ViewProfile.jspa?name=${encodeURIComponent(s.name)}`:`${t}/jira/people/${s.accountId}`,Le=(s,t,e)=>({id:(e?s.key:s.accountId)??"",name:s.displayName,email:s.emailAddress,avatarUrl:s.avatarUrls["48x48"],username:s.displayName,url:ks(s,t,e)}),xs=s=>{let t;switch(s.statusCategory.name){case"To Do":t="TO_DO";break;case"In Progress":t="IN_PROGRESS";break;default:t="DONE";break}return{id:s.id,name:s.name,color:s.statusCategory.colorName,category:t}},Ns=s=>({id:s.id.toString(),name:s.name,isActive:s.state==="active",startDate:s.startDate?new Date(s.startDate):null,endDate:s.endDate?new Date(s.endDate):null,completedDate:s.completeDate?new Date(s.completeDate):null}),_s=s=>({id:s.id,description:s.description,name:s.name,archived:s.archived,released:s.released,releaseDate:s.releaseDate?new Date(s.releaseDate):null}),X=(s,t,e)=>e?`${t.baseUrl||Gs}/${e}`:`${(t==null?void 0:t.baseUrl)||s.baseUrl}`,$e=async(s,t,e={})=>{let{resourceId:r}=t;return(await s.request({url:`${X(s,e,r)}/rest/api/2/field`,headers:R(e.token||s.token)})).body},Ge=async(s,t,e,r={})=>{let{number:n,resourceId:o,fields:i}=t||{},a=await s.request({url:`${X(s,r,o)}/rest/api/2/issue/${n}?fields=${At.join(",")}&expand=transitions`,headers:R(r.token||s.token)});return{data:Lt(a.body,i,e,o)}},Te=async(s,t,e,r={})=>{let{page:n,resourceId:o,labelNames:i,fields:a}=t||{},u=n??0,l=["statusCategory != Done",`(creator = currentUser() OR assignee = currentUser()
1103
+ `,variables:{fullPath:`${r}/${n}`,after:o}},e);return{pageInfo:((l=(u=(a=i.body.data)==null?void 0:a.project)==null?void 0:u.labels)==null?void 0:l.pageInfo)??{endCursor:null,hasNextPage:!1},data:((g=(c=(d=(p=i.body.data)==null?void 0:p.project)==null?void 0:d.labels)==null?void 0:c.nodes)==null?void 0:g.map(Dt))??[]}}async getTreeForRepo(t,e={}){let r=K(t.repo),n=new URL(t.cursor??`${Ce(this.config,e)}/projects/${encodeURIComponent(r)}/repository/tree`);n.searchParams.set("per_page","10000"),n.searchParams.set("recursive","true"),n.searchParams.set("pagination","keyset"),n.searchParams.set("ref",t.branch);let o=await this.config.request({url:n.toString(),headers:R(e.token||this.config.token)}),i=o.headers.link;return{data:o.body.map(Us),pageInfo:{endCursor:i?i.substring(1,i.indexOf(">")):null,hasNextPage:!!i}}}};var Gs="https://api.atlassian.com/ex/jira",Ae=100,At=["assignee","comment","summary","created","creator","updated","votes","issuetype","status","labels","components","project","fixVersions","description"],Lt=(s,t,e,r)=>{var a,u,l,p;let n=s.fields.assignee,o=!r,i=(s.fields[(t==null?void 0:t.Sprint)??""]??[]).filter(d=>typeof d=="object");return{id:s.id,commentCount:s.fields.comment.comments.length,number:s.key,title:s.fields.summary,url:e?`${e}/browse/${s.key}`:null,closedDate:null,createdDate:new Date(s.fields.created),author:Le(s.fields.creator,e,o),updatedDate:new Date(s.fields.updated),assignees:n?[Le(n,e,o)]:[],description:s.fields.description,repository:null,project:{name:s.fields.project.name,resourceId:r??null,key:s.fields.project.key,namespace:null,id:s.fields.project.id},state:xs(s.fields.status),statusTransitions:((a=s.transitions)==null?void 0:a.map(Ts))??[],components:((u=s.fields.components)==null?void 0:u.map(Os))??[],type:s.fields.issuetype.name,upvoteCount:((l=s.fields.votes)==null?void 0:l.votes)||0,labels:((p=s.fields.labels)==null?void 0:p.map(d=>({color:null,description:null,id:null,name:d})))??[],sprints:i.map(Ns),fixVersions:s.fields.fixVersions.map(_s)}},Ts=s=>{let t;switch(s.to.statusCategory.name){case"To Do":t="TO_DO";break;case"In Progress":t="IN_PROGRESS";break;default:t="DONE";break}return{name:s.name,id:s.id,to:{id:s.to.id,name:s.to.name,color:s.to.statusCategory.colorName,category:t}}},Os=s=>({description:s.description??null,id:s.id,name:s.name}),ks=(s,t,e)=>e&&s.name?`${t}/secure/ViewProfile.jspa?name=${encodeURIComponent(s.name)}`:`${t}/jira/people/${s.accountId}`,Le=(s,t,e)=>({id:(e?s.key:s.accountId)??"",name:s.displayName,email:s.emailAddress,avatarUrl:s.avatarUrls["48x48"],username:s.displayName,url:ks(s,t,e)}),xs=s=>{let t;switch(s.statusCategory.name){case"To Do":t="TO_DO";break;case"In Progress":t="IN_PROGRESS";break;default:t="DONE";break}return{id:s.id,name:s.name,color:s.statusCategory.colorName,category:t}},Ns=s=>({id:s.id.toString(),name:s.name,isActive:s.state==="active",startDate:s.startDate?new Date(s.startDate):null,endDate:s.endDate?new Date(s.endDate):null,completedDate:s.completeDate?new Date(s.completeDate):null}),_s=s=>({id:s.id,description:s.description,name:s.name,archived:s.archived,released:s.released,releaseDate:s.releaseDate?new Date(s.releaseDate):null}),X=(s,t,e)=>e?`${t.baseUrl||Gs}/${e}`:`${(t==null?void 0:t.baseUrl)||s.baseUrl}`,$e=async(s,t,e={})=>{let{resourceId:r}=t;return(await s.request({url:`${X(s,e,r)}/rest/api/2/field`,headers:R(e.token||s.token)})).body},Ge=async(s,t,e,r={})=>{let{number:n,resourceId:o,fields:i}=t||{},a=await s.request({url:`${X(s,r,o)}/rest/api/2/issue/${n}?fields=${At.join(",")}&expand=transitions`,headers:R(r.token||s.token)});return{data:Lt(a.body,i,e,o)}},Te=async(s,t,e,r={})=>{let{page:n,resourceId:o,labelNames:i,fields:a}=t||{},u=n??0,l=["statusCategory != Done",`(creator = currentUser() OR assignee = currentUser()
1104
1104
  OR comment ~ currentUser() OR summary ~ currentUser() OR description ~ currentUser())`];i&&i.forEach(m=>l.push(`labels = "${m}"`));let p=`${l.join(" AND ")} ORDER BY updated DESC`,c=(await s.request({url:`${X(s,r,o)}/rest/api/2/search?jql=${p}&startAt=${u}&maxResults=${Ae}&fields=${At.join(",")}&expand=transitions`,headers:R(r.token||s.token)})).body.issues.map(m=>Lt(m,a,e,o)),g=c.length==Ae;return{data:c,pageInfo:{hasNextPage:g,nextPage:g?u+c.length:null}}},Ir=async(s,t,e,r={})=>{let{page:n,resourceId:o,jql:i,fields:a}=t||{},u=n??0,l=[...At],p=a==null?void 0:a.Sprint;p&&l.push(p);let c=(await s.request({url:`${X(s,r,o)}/rest/api/2/search?jql=${i.join(" AND ")}&startAt=${u}&maxResults=${Ae}&fields=${l.join(",")}&expand=transitions`,headers:R(r.token||s.token)})).body.issues.map(m=>Lt(m,a,e,o)),g=c.length==Ae;return{data:c,pageInfo:{hasNextPage:g,nextPage:g?u+c.length:null}}},Oe=async(s,t,e,r={})=>{let{assigneeLogins:n,authorLogin:o,mentionLogin:i,labelNames:a,page:u,projectKey:l,resourceId:p,fields:d}=t||{},c=u??0,g=[`project = "${l}"`,"statusCategory != Done"];return o&&g.push(`creator in ("${o}")`),n&&n.length!==0&&g.push(`assignee in ("${n.join('", "')}")`),i&&g.push(`comment ~ "${i}"`),a&&a.forEach(m=>g.push(`labels = "${m}"`)),Ir(s,{resourceId:p,jql:g,page:c,fields:d},e,r)},ke=async(s,t,e,r={})=>{let{assigneeLogins:n,authorLogin:o,mentionLogin:i,labelNames:a,page:u,projectKeys:l,resourceId:p,fields:d}=t||{},c=u??0,m=["("+l.map(f=>`project = "${f}"`).join(" OR ")+")","statusCategory != Done"];return o&&m.push(`creator in ("${o}")`),n&&n.length!==0&&m.push(`assignee in ("${n.join('", "')}")`),i&&m.push(`comment ~ "${i}"`),a&&a.forEach(f=>m.push(`labels = "${f}"`)),Ir(s,{resourceId:p,jql:m,fields:d,page:c},e,r)},xe=async(s,t,e={})=>{let{issue:r,labels:n}=t;if(!r.project)throw new Error('Jira requires a "project" for this function.');let o={fields:{labels:n.map(i=>i.name)}};await s.request({method:"PUT",url:`${X(s,e,r.project.resourceId??void 0)}/rest/api/2/issue/${r.id}`,body:JSON.stringify(o),headers:{...R(e.token||s.token),"Content-Type":"application/json"}})},Ne=async(s,t,e={})=>{let{issue:r,components:n}=t;if(!r.project)throw new Error('Jira requires a "project" for this function.');let o={fields:{components:n.map(i=>({id:i.id}))}};await s.request({method:"PUT",url:`${X(s,e,r.project.resourceId??void 0)}/rest/api/2/issue/${r.id}`,body:JSON.stringify(o),headers:{...R(e.token||s.token),"Content-Type":"application/json"}})},_e=async(s,t,e={})=>{let{issue:r,status:n}=t;if(!r.project)throw new Error('Jira requires a "project" for this function.');if(!n.id)throw new Error('Jira requires a status "id" for this function.');let o={transition:{id:n.id}};await s.request({method:"POST",url:`${X(s,e,r.project.resourceId??void 0)}/rest/api/2/issue/${r.id}/transitions`,body:JSON.stringify(o),headers:{...R(e.token||s.token),"Content-Type":"application/json"}})},Be=async(s,t,e={})=>{let{resourceId:r,projectIdOrKey:n}=t,o=new URL(`${X(s,e,r)}/rest/api/2/project/${n}/components`);return{data:(await s.request({url:o.toString(),headers:R(e.token||s.token)})).body}};var ge="https://api.atlassian.com/ex/jira",$t=100,ue=class extends N{constructor(){super(...arguments);this._resourceUrlCache={};this._issueFieldsCache={}}async getIssueFieldsForResource(e,r={}){if(!this._issueFieldsCache[e.resourceId]){let n=await $e(this.config,e,r);this._issueFieldsCache[e.resourceId]=n.reduce((o,i)=>({...o,[i.name]:i.id}),{})}return this._issueFieldsCache[e.resourceId]??null}async getResourceUrl(e,r={}){var i;let n=r.token||this.config.token;if(!n)return null;let o=this._resourceUrlCache[n];return o?o[e.resourceId]??null:(await this.getJiraResourcesForCurrentUser(r),((i=this._resourceUrlCache[n])==null?void 0:i[e.resourceId])??null)}async getCurrentUserForResource(e,r={}){let n=await this.getResourceUrl({resourceId:e.resourceId},r),o=await this.config.request({url:`${r.baseUrl||ge}/${e.resourceId}/rest/api/2/myself`,headers:R(r.token||this.config.token)});return{data:{name:o.body.displayName,email:o.body.emailAddress,avatarUrl:o.body.avatarUrls["48x48"],id:o.body.accountId,username:o.body.displayName,url:n?`${n}/jira/people/${o.body.accountId}`:null}}}async getJiraResourcesForCurrentUser(e={}){let r=await this.config.request({url:`${e.baseUrl||"https://api.atlassian.com/"}/oauth/token/accessible-resources`,headers:R(e.token||this.config.token)}),n=e.token||this.config.token,o=n?this._resourceUrlCache[n]||{}:void 0,i=r.body.map(a=>(o&&(o[a.id]=a.url),{avatarUrl:a.avatarUrl,id:a.id,name:a.name,url:a.url}));return n&&(this._resourceUrlCache[n]=o),{data:i}}async getJiraProjectsForResource(e,r={}){let n=new URL(`${r.baseUrl||ge}/${e.resourceId}/rest/api/2/project/search`);n.searchParams.set("maxResults",$t.toString()),e.cursor&&n.searchParams.set("startAt",e.cursor);let o=await this.config.request({url:n.toString(),headers:R(r.token||this.config.token)});return{pageInfo:{hasNextPage:o.body.values.length!==0,endCursor:(o.body.startAt+o.body.values.length).toString()},data:o.body.values.map(i=>({id:i.id,key:i.key,name:i.name,resourceId:e.resourceId}))}}async getJiraProjectsForResources(e,r={}){let n=[];return await Promise.all(e.resourceIds.map(async o=>{try{return await Yt(i=>this.getJiraProjectsForResource({resourceId:o,cursor:i},r))}catch{return[]}})).then((...o)=>{o.forEach(i=>{n=n.concat(...i)})}),{data:n}}async getAccountsForJiraProject(e,r={}){let{resourceId:n,projectKey:o,cursor:i}=e,a=await this.getResourceUrl({resourceId:n},r),u=new URL(`${r.baseUrl||ge}/${n}/rest/api/2/user/assignable/search`);u.searchParams.set("maxResults",$t.toString()),i&&u.searchParams.set("startAt",i),u.searchParams.set("project",o);let l=await this.config.request({url:u.toString(),headers:R(r.token||this.config.token)});return{pageInfo:{hasNextPage:l.body.length!==0,endCursor:((i?parseInt(i):0)+l.body.length).toString()},data:l.body.filter(p=>p.accountType!=="app"&&p.active).map(p=>Le(p,a,!1))}}async getComponentsForJiraProject(e,r={}){return await Be(this.config,e,r)}async getIssue(e,r={}){let n=await this.getIssueFieldsForResource({resourceId:e.resourceId},r),o=await this.getResourceUrl({resourceId:e.resourceId},r);return await Ge(this.config,{...e,fields:n},o,r)}async getIssuesForProject(e,r={}){let n=await this.getIssueFieldsForResource({resourceId:e.resourceId},r),o=await this.getResourceUrl({resourceId:e.resourceId},r);return await Oe(this.config,{...e,fields:n},o,r)}async getIssuesForProjects(e,r={}){let n=await this.getIssueFieldsForResource({resourceId:e.resourceId},r),o=await this.getResourceUrl({resourceId:e.resourceId},r);return await ke(this.config,{...e,fields:n},o,r)}async getIssuesForResourceForCurrentUser(e,r={}){let n=await this.getIssueFieldsForResource({resourceId:e.resourceId},r),o=await this.getResourceUrl({resourceId:e.resourceId},r);return await Te(this.config,{...e,fields:n},o,r)}async setIssueStatus(e,r={}){await _e(this.config,e,r)}async setIssueAssignee(e,r={}){let{issue:n,assignee:o}=e;if(!n.project)throw new Error('Jira Cloud requires a "project" for this function.');if(!n.project.resourceId)throw new Error('Jira Cloud requires a project "resourceId" for this function.');let i={accountId:o==null?void 0:o.id};await this.config.request({method:"PUT",url:`${r.baseUrl||ge}/${n.project.resourceId}/rest/api/2/issue/${n.id}/assignee`,body:JSON.stringify(i),headers:{...R(r.token||this.config.token),"Content-Type":"application/json"}})}async setIssueComponents(e,r={}){await Ne(this.config,e,r)}async setIssueLabels(e,r={}){await xe(this.config,e,r)}async getLabelsForResource(e,r={}){let{resourceId:n,cursor:o}=e,i=new URL(`${r.baseUrl||ge}/${n}/rest/api/2/label`);i.searchParams.set("maxResults",$t.toString()),o&&i.searchParams.set("startAt",o);let a=await this.config.request({url:i.toString(),headers:R(r.token||this.config.token)});return{pageInfo:{hasNextPage:!a.body.isLast,endCursor:(a.body.startAt+a.body.values.length).toString()},data:a.body.values.map(u=>({color:null,description:null,id:null,name:u}))}}};var le=class extends Q{constructor(){super(...arguments);this._issueFieldsCache={}}async getIssueFieldsForResource(e={}){let r=(e==null?void 0:e.baseUrl)||this.config.baseUrl||"";if(!this._issueFieldsCache[r]){let n=await $e(this.config,{},e);this._issueFieldsCache[r]=n.reduce((o,i)=>({...o,[i.name]:i.id}),{})}return this._issueFieldsCache[r]??null}async getCurrentUser(e={}){let r=await this.config.request({url:`${(e==null?void 0:e.baseUrl)||this.config.baseUrl}/rest/api/2/myself`,headers:R((e==null?void 0:e.token)||this.config.token)});return{data:{name:r.body.displayName,email:r.body.emailAddress,avatarUrl:r.body.avatarUrls["48x48"],id:r.body.key,username:r.body.displayName,url:null}}}async getJiraProjects(e={}){return{data:(await this.config.request({url:`${(e==null?void 0:e.baseUrl)||this.config.baseUrl}/rest/api/2/project`,headers:R((e==null?void 0:e.token)||this.config.token)})).body.map(n=>({id:n.id,name:n.name}))}}async getIssue(e,r={}){let n=e.resourceUrl||r.baseUrl||this.config.baseUrl;if(!n)throw new Error('Jira Server requires a "resourceUrl" or "baseUrl" for this function.');let o=await this.getIssueFieldsForResource(r);return await Ge(this.config,{...e,fields:o},n,r)}async getIssuesForProject(e,r={}){let n=e.resourceUrl||r.baseUrl||this.config.baseUrl;if(!n)throw new Error('Jira Server requires a "resourceUrl" or "baseUrl" for this function.');let o=await this.getIssueFieldsForResource(r);return await Oe(this.config,{...e,fields:o},n,r)}async getIssuesForProjects(e,r={}){let n=e.resourceUrl||r.baseUrl||this.config.baseUrl;if(!n)throw new Error('Jira Server requires a "resourceUrl" or "baseUrl" for this function.');let o=await this.getIssueFieldsForResource(r);return await ke(this.config,{...e,fields:o},n,r)}async getIssuesForResourceForCurrentUser(e,r={}){let n=e.resourceUrl||r.baseUrl||this.config.baseUrl;if(!n)throw new Error('Jira Server requires a "resourceUrl" or "baseUrl" for this function.');let o=await this.getIssueFieldsForResource(r);return await Te(this.config,{...e,fields:o},n,r)}async setIssueStatus(e,r={}){await _e(this.config,e,r)}async setIssueLabels(e,r={}){await xe(this.config,e,r)}async setIssueComponents(e,r={}){await Ne(this.config,e,r)}async getLabels(e={}){return{data:(await this.config.request({url:`${(e==null?void 0:e.baseUrl)||this.config.baseUrl}/rest/api/2/jql/autocompletedata/suggestions?fieldName=labels`,headers:R(e.token||this.config.token)})).body.results.map(({displayName:n})=>({color:null,description:null,id:null,name:n}))}}async getComponentsForJiraProject(e,r={}){return await Be(this.config,e,r)}};var j="https://api.trello.com",Bs=1e3,Qs=s=>({id:s.id,username:s.username,url:s.url,name:s.fullName,email:s.email,avatarUrl:s.avatarUrl}),js=(s,t)=>{let e=new Date(1e3*parseInt(s.id.substring(0,8),16));return{id:s.id,commentCount:s.badges.comments,number:s.idShort.toString(),title:s.name,url:s.url,closedDate:null,createdDate:new Date(e.toISOString()),author:null,updatedDate:new Date(s.dateLastActivity),assignees:s.members.map(r=>({id:r.id,username:r.username,name:r.fullName,email:null,avatarUrl:r.avatarUrl,url:null})),description:null,state:t[s.idList??""]?{id:s.idList,name:t[s.idList].name,color:null}:null,type:null,repository:null,upvoteCount:s.badges.votes,labels:s.labels.map(r=>({color:r.color,description:null,id:r.id,name:r.name}))}},pe=class extends N{async getCurrentUser(t,e={}){let r=await this.config.request({url:`${e.baseUrl||j}/1/members/me?key=${t.appKey}&token=${e.token||this.config.token}`,headers:R(e.token||this.config.token)});return{data:{name:r.body.fullName,email:r.body.email,avatarUrl:r.body.avatarHash?`https://trello-members.s3.amazonaws.com/${r.body.id}/${r.body.avatarHash}/50.png`:null,id:r.body.id,username:r.body.username,url:r.body.url}}}async getBoardsForCurrentUser(t,e={}){return{data:(await this.config.request({url:`${e.baseUrl||j}/1/members/me/boards?fields=name&key=${t.appKey}&token=${e.token||this.config.token}&filter=open`,headers:R(e.token||this.config.token)})).body.map(n=>({id:n.id,name:n.name}))}}async getListsForTrelloBoard(t,e={}){let{appKey:r,boardId:n}=t;return{data:(await this.config.request({url:`${e.baseUrl||j}/1/boards/${n}/lists?key=${r}&token=${e.token||this.config.token}`,headers:R(e.token||this.config.token)})).body}}async getAccountForId(t,e={}){let{appKey:r,memberId:n}=t,o=await this.config.request({url:`${e.baseUrl||j}/1/members/${n}/?key=${r}&token=${e.token||this.config.token}`});return{data:Qs(o.body)}}async getAccountsForTrelloBoard(t,e={}){let{appKey:r,boardId:n}=t;return{data:(await this.config.request({url:`${e.baseUrl||j}/1/boards/${n}/members?key=${r}&token=${e.token||this.config.token}`,headers:R(e.token||this.config.token)})).body.map(i=>({id:i.id,name:i.fullName,username:i.username,email:null,avatarUrl:null,url:null}))}}async getIssuesForBoard(t,e={}){let r=["-is:archived","sort:edited"],{appKey:n,boardId:o,filterText:i,assigneeLogins:a,labelNamesOrColors:u,trelloBoardListsById:l}=t||{};a&&r.push("@me"),u&&u.forEach(c=>r.push(`label:"${c}"`));let p=`${i?`${i}`:""}${r.join(" ")} board:${o}`;return{data:(await this.config.request({url:`${e.baseUrl||j}/1/search?key=${n}&query=${p}&cards_limit=${Bs}&token=${e.token||this.config.token}&card_members=true`,headers:R(e.token||this.config.token)})).body.cards.map(c=>js(c,l||{}))}}async updateIssue(t,e,r,n){return await this.config.request({method:"PUT",url:`${n.baseUrl||j}/1/cards/${e.id}?key=${t}&token=${n.token||this.config.token}&${r}`,headers:R(n.token||this.config.token)})}async setIssueStatus(t,e={}){let{appKey:r,issue:n,status:o}=t;if(!o.id)throw new Error('Trello requires a status "id" for this function.');let i=`idList=${o.id}`;if(!(await this.updateIssue(r,n,i,e)).body.id)throw new Error("Could not set issue status")}async setIssueAssignees(t,e={}){let{appKey:r,issue:n,assignees:o}=t,i=o.map(l=>l.id),a=`idMembers=${encodeURIComponent(i.join(","))}`;if(!(await this.updateIssue(r,n,a,e)).body.id)throw new Error("Could not set issue status")}async setIssueLabels(t,e={}){let{appKey:r,issue:n,labels:o}=t,i=o.map(u=>u.id).join(",");if(!(await this.config.request({method:"PUT",url:`${e.baseUrl||j}/1/cards/${n.id}?key=${r}&token=${e.token||this.config.token}&idLabels=${encodeURIComponent(i)}`,headers:R(e.token||this.config.token)})).body.id)throw new Error("Could not set issue status")}async setIssueArchived(t,e={}){let{appKey:r,issue:n,archived:o}=t;if(!(await this.config.request({method:"PUT",url:`${e.baseUrl||j}/1/cards/${n.id}?key=${r}&token=${e.token||this.config.token}&closed=${o}`,headers:R(e.token||this.config.token)})).body.id)throw new Error("Could not update issue archived status")}async archiveIssue(t,e={}){await this.setIssueArchived({...t,archived:!0},e)}async unArchiveIssue(t,e={}){await this.setIssueArchived({...t,archived:!1},e)}async getLabelsForBoard(t,e={}){let{appKey:r,boardId:n}=t;return{data:(await this.config.request({url:`${e.baseUrl||j}/1/boards/${n}/labels?key=${r}&token=${e.token||this.config.token}`,headers:R(e.token||this.config.token)})).body.map(i=>({color:i.color,description:null,id:i.id,name:i.name}))}}};var Qe={};B(Qe,{default:()=>Fs});var Fs={};var je={};B(je,{default:()=>Ms});var Ms={};var Fe={};B(Fe,{restApiPullRequestToCommonPullRequest:()=>zs});var zs=s=>ce(s);var tt={};B(tt,{decode:()=>Gt,decodeV0:()=>Vs,encode:()=>Js,validate:()=>Hs});var G=(e=>(e.Zero="0",e.One="1",e))(G||{}),T=(e=>(e.PullRequest="pr",e.Issue="issue",e))(T||{}),A=(p=>(p.Azure="azure",p.Github="github",p.GithubEnterprise="githubEnterprise",p.Gitlab="gitlab",p.GitlabSelfHosted="gitlabSelfHosted",p.Bitbucket="bitbucket",p.BitbucketServer="bitbucketServer",p.Jira="jira",p.JiraServer="jiraServer",p.Trello="trello",p))(A||{});var Me=class{constructor(){}validate(t){if(!t.organizationName)throw new Error("organizationName is required");if(!t.projectId)throw new Error("projectId is required");if(!t.entityId)throw new Error("issueId is required")}encode(t){if(this.validate(t),!t.organizationName||!t.projectId||!t.entityId)throw new Error("Missing required fields for Azure DevOps issue uniqueId");let e=[];return e.push("azure"),e.push("issue"),e.push("1"),e.push(t.domain||""),e.push(t.organizationName),e.push(t.projectId),e.push(t.entityId),JSON.stringify(e)}decode(t){if(t.length<7)throw new Error("Invalid Azure DevOps issue uniqueId, check version");return{provider:t[0],entityType:t[1],version:t[2],domain:t[3]==""?null:t[3],resourceId:null,accountOrOrgId:null,organizationName:t[4],projectId:t[5],repoId:null,entityId:t[6]}}};var ze=class{constructor(){}validate(t){if(!t.organizationName)throw new Error("organizationName is required");if(!t.projectId)throw new Error("projectId is required");if(!t.repoId)throw new Error("repoId is required");if(!t.entityId)throw new Error("entityId is required")}encode(t){if(this.validate(t),!t.organizationName||!t.projectId||!t.repoId||!t.entityId)throw new Error("Missing required fields for Azure DevOps pull request uniqueId");let e=[];return e.push("azure"),e.push("pr"),e.push("1"),e.push(t.domain||""),e.push(t.organizationName),e.push(t.projectId),e.push(t.repoId),e.push(t.entityId),JSON.stringify(e)}decode(t){if(t.length<8)throw new Error("Invalid Azure DevOps pull request uniqueId, check version");return{provider:t[0],entityType:t[1],version:t[2],domain:t[3]==""?null:t[3],resourceId:null,accountOrOrgId:null,organizationName:t[4],projectId:t[5],repoId:t[6],entityId:t[7]}}};var We=class{constructor(){}validate(t){if(!t.repoId)throw new Error("repoId is required");if(!t.entityId)throw new Error("issueId is required")}encode(t){if(this.validate(t),!t.repoId||!t.entityId)throw new Error("Missing required fields for Bitbucket DevOps issue uniqueId");let e=[];return e.push(t.provider),e.push("issue"),e.push("1"),t.provider==="bitbucketServer"?e.push(t.domain):e.push(""),e.push(t.repoId),e.push(t.entityId),JSON.stringify(e)}decode(t){if(t.length<6)throw new Error("Invalid Bitbucket DevOps issue uniqueId, check version");return{provider:t[0],entityType:t[1],version:t[2],domain:t[3]==""?null:t[3],resourceId:null,accountOrOrgId:null,organizationName:null,projectId:null,repoId:t[4],entityId:t[5]}}};var He=class{constructor(){}validate(t){if(!t.repoId)throw new Error("repoId is required");if(!t.entityId)throw new Error("entityId is required")}encode(t){if(this.validate(t),!t.repoId||!t.entityId)throw new Error("Missing required fields for Bitbucket DevOps pull request uniqueId");let e=[];return e.push(t.provider),e.push("pr"),e.push("1"),t.provider==="bitbucketServer"?e.push(t.domain):e.push(""),e.push(t.repoId),e.push(t.entityId),JSON.stringify(e)}decode(t){if(t.length<6)throw new Error("Invalid Bitbucket DevOps pull request uniqueId, check version");return{provider:t[0],entityType:t[1],version:t[2],domain:t[3]==""?null:t[3],resourceId:null,accountOrOrgId:null,organizationName:null,projectId:null,repoId:t[4],entityId:t[5]}}};var Je=class{constructor(){}validate(t){if(!t.entityId)throw new Error("entityId is required")}encode(t){if(this.validate(t),!t.entityId)throw new Error("Missing required fields for Github issue uniqueId");let e=[];return e.push(t.provider),e.push("issue"),e.push("1"),t.provider==="githubEnterprise"?e.push(t.domain):e.push(""),e.push(t.entityId),JSON.stringify(e)}decode(t){if(t.length<5)throw new Error("Invalid Github issue uniqueId, check version");return{provider:t[0],entityType:t[1],version:t[2],domain:t[3]==""?null:t[3],resourceId:null,accountOrOrgId:null,organizationName:null,projectId:null,repoId:null,entityId:t[4]}}};var Ve=class{constructor(){}validate(t){if(!t.entityId)throw new Error("entityId is required")}encode(t){if(this.validate(t),!t.entityId)throw new Error("Missing required fields for Github pull request uniqueId");let e=[];return e.push(t.provider),e.push("pr"),e.push("1"),t.provider==="githubEnterprise"?e.push(t.domain):e.push(""),e.push(t.entityId),JSON.stringify(e)}decode(t){if(t.length<5)throw new Error("Invalid Github pull request uniqueId, check version");return{provider:t[0],entityType:t[1],version:t[2],domain:t[3]==""?null:t[3],resourceId:null,accountOrOrgId:null,organizationName:null,projectId:null,repoId:null,entityId:t[4]}}};var Ke=class{constructor(){}validate(t){if(!t.entityId)throw new Error("entityId is required")}encode(t){if(this.validate(t),!t.entityId)throw new Error("Missing required fields for Gitlab issue uniqueId");let e=[];return e.push(t.provider),e.push("issue"),e.push("1"),t.provider==="gitlabSelfHosted"?e.push(t.domain):e.push(""),e.push(t.entityId),JSON.stringify(e)}decode(t){if(t.length<5)throw new Error("Invalid Gitlab issue uniqueId, check version");return{provider:t[0],entityType:t[1],version:t[2],domain:t[3]==""?null:t[3],resourceId:null,accountOrOrgId:null,organizationName:null,projectId:null,repoId:null,entityId:t[4]}}};var Xe=class{constructor(){}validate(t){if(!t.entityId)throw new Error("entityId is required")}encode(t){if(this.validate(t),!t.entityId)throw new Error("Missing required fields for Gitlab pull request uniqueId");let e=[];return e.push(t.provider),e.push("pr"),e.push("1"),t.provider==="gitlabSelfHosted"?e.push(t.domain):e.push(""),e.push(t.entityId),JSON.stringify(e)}decode(t){if(t.length<5)throw new Error("Invalid Gitlab pull request uniqueId, check version");return{provider:t[0],entityType:t[1],version:t[2],domain:t[3]==""?null:t[3],resourceId:null,accountOrOrgId:null,organizationName:null,projectId:null,repoId:null,entityId:t[4]}}};var Ye=class{constructor(){}validate(t){if(!t.projectId)throw new Error("projectId is required");if(!t.entityId)throw new Error("entityId is required")}encode(t){if(this.validate(t),!t.projectId||!t.entityId)throw new Error("Missing required fields for Jira issue uniqueId");let e=[];return e.push(t.provider),e.push("issue"),e.push("1"),t.provider=="jira"?(e.push(""),e.push(t.resourceId)):(e.push(t.domain),e.push("")),e.push(t.projectId),e.push(t.entityId),JSON.stringify(e)}decode(t){if(t.length<7)throw new Error("Invalid Jira issue uniqueId, check version");return{provider:t[0],entityType:t[1],version:t[2],domain:t[3]==""?null:t[3],resourceId:t[4]==""?null:t[4],accountOrOrgId:null,organizationName:null,projectId:t[5],repoId:null,entityId:t[6]}}};var Ze=class{constructor(){}validate(t){if(!t.accountOrOrgId)throw new Error("accountOrOrgId is required");if(!t.projectId)throw new Error("projectId is required");if(!t.entityId)throw new Error("entityId is required")}encode(t){if(this.validate(t),!t.accountOrOrgId||!t.projectId||!t.entityId)throw new Error("Missing required fields for Trello issue uniqueId");let e=[];return e.push("trello"),e.push("issue"),e.push("1"),e.push(""),e.push(t.accountOrOrgId),e.push(t.projectId),e.push(t.entityId),JSON.stringify(e)}decode(t){if(t.length<7)throw new Error("Invalid Trello issue uniqueId, check version");return{provider:t[0],entityType:t[1],version:t[2],domain:t[3]==""?null:t[3],resourceId:null,accountOrOrgId:t[4],organizationName:null,projectId:t[5],repoId:null,entityId:t[6]}}};var et=(s,t)=>{if(t!=="issue"&&t!=="pr")throw new Error("unknown entityType");switch(s){case"azure":return t==="pr"?new ze:new Me;case"bitbucket":case"bitbucketServer":return t==="pr"?new He:new We;case"github":case"githubEnterprise":return t==="pr"?new Ve:new Je;case"gitlab":case"gitlabSelfHosted":return t==="pr"?new Xe:new Ke;case"jira":case"jiraServer":if(t==="pr")throw new Error("EntityType PullRequest is not valid for Jira");return new Ye;case"trello":if(t==="pr")throw new Error("EntityType PullRequest is not valid for Jira");return new Ze;default:throw new Error("unknown provider")}},Ws=s=>{if(!s.entityType)throw new Error("entityType is required");if(!s.provider)throw new Error("provider is required");if(!s.entityId)throw new Error("entityID is required")},Hs=s=>{if(s.version==="0"){Ws(s);return}et(s.provider,s.entityType).validate(s)},Js=s=>et(s.provider,s.entityType).encode(s),Gt=s=>{let t=JSON.parse(s);if(!t||!t.length)throw new Error("invalid issue unique id");return et(t[0],t[1]).decode(t)},Vs=(s,t,e)=>{if(!e)throw new Error("entityID is required");try{let r=JSON.parse(e);if(!r||!r.length)throw new Error("Invalid pull request uniqueId");let n=[s,t,"0",...r];return et(s,t).decode(n)}catch{return{provider:s,entityType:t,version:"0",domain:"",resourceId:null,accountOrOrgId:null,organizationName:null,projectId:null,repoId:null,entityId:e}}};var rt={};B(rt,{CHANGES_REQUESTED_ACTION_CATEGORY:()=>vr,CHANGES_REQUESTED_BUCKET_ID:()=>Bt,CONFLICTS_ACTION_CATEGORY:()=>wr,CONFLICTS_BUCKET_ID:()=>Nt,DRAFT_ACTION_CATEGORY:()=>Sr,DRAFT_BUCKET_ID:()=>Ft,FAILING_CI_ACTION_CATEGORY:()=>br,FAILING_CI_BUCKET_ID:()=>xt,NEEDS_MY_REVIEW_ACTION_CATEGORY:()=>Pr,NEEDS_MY_REVIEW_BUCKET_ID:()=>_t,OTHER_ACTION_CATEGORY:()=>Cr,OTHER_BUCKET_ID:()=>Mt,PINNED_BUCKET_ID:()=>Tt,READY_TO_MERGE_ACTION_CATEGORY:()=>Rr,READY_TO_MERGE_BUCKET_ID:()=>Ot,REVIEWER_COMMENTED_ACTION_CATEGORY:()=>Er,REVIEWER_COMMENTED_BUCKET_ID:()=>Qt,SNOOZED_BUCKET_ID:()=>zt,UNASSIGNED_REVIEWERS_ACTION_CATEGORY:()=>yr,UNASSIGNED_REVIEWERS_BUCKET_ID:()=>kt,WAITING_FOR_REVIEW_ACTION_CATEGORY:()=>qr,WAITING_FOR_REVIEW_BUCKET_ID:()=>jt,getActionablePullRequests:()=>Dr,groupPullRequestsByAssignee:()=>Ys,groupPullRequestsByAuthor:()=>Zs,groupPullRequestsByGitKrakenTeam:()=>sn,groupPullRequestsByRepo:()=>Xs,groupPullRequestsByReviewer:()=>en,groupPullRequestsByWorkspace:()=>rn,groupPullRequestsIntoBuckets:()=>Ks});var x=(s,t,e,r)=>({id:s,faIconName:e,name:t,priority:r,pullRequests:[]}),Tt="pinned",Ot="readyToMerge",kt="unassignedReviewers",xt="failingCI",Nt="conflicts",_t="needsMyReview",Bt="changesRequested",Qt="reviewerCommented",jt="waitingForReview",Ft="draft",Mt="other",zt="snoozed",Rr="readyToMerge",yr="unassignedReviewers",br="failingCI",wr="conflicts",Pr="needsMyReview",vr="changesRequested",Er="reviewerCommented",qr="waitingForReview",Sr="draft",Cr="other",Dr=(s,t,e)=>s.map(r=>{var u,l,p,d,c,g,m,f,y,P,h,I,E,L;let o={...r,...{suggestedActionCategory:Cr,priority:1e3,viewer:{canMerge:!1,isAuthor:!1,isAssignee:!1,isReviewer:!1,shouldMerge:!1,shouldAssignReviewer:!1,waitingOnReviews:!1,shouldReview:!1},failingCI:!1,hasConflicts:!1,changeRequestReviewCount:0,codeSuggestionsCount:0,commentReviewCount:0,approvalReviewCount:0}};t&&(o.viewer.isAuthor=((u=r.author)==null?void 0:u.id)===t.id,o.viewer.isAssignee=((l=r.assignees)==null?void 0:l.some(S=>S.id===t.id))??!1,o.viewer.isReviewer=((p=r.reviews)==null?void 0:p.some(S=>S.reviewer.id===t.id))??!1),o.viewer.canMerge=((d=r.permissions)==null?void 0:d.canMerge)??!0,o.hasConflicts=r.mergeableState==="CONFLICTS",o.failingCI=((g=(c=r.headCommit)==null?void 0:c.buildStatuses)==null?void 0:g.some(S=>S.state==="ERROR"||S.state==="FAILED"))||r.mergeableState==="FAILING_CHECKS",o.commentReviewCount=((m=r.reviews)==null?void 0:m.filter(S=>S.state==="COMMENTED").length)??0,o.approvalReviewCount=((f=r.reviews)==null?void 0:f.filter(S=>S.state==="APPROVED").length)??0,o.changeRequestReviewCount=((y=r.reviews)==null?void 0:y.filter(S=>S.state==="CHANGES_REQUESTED").length)??0;let i=(P=e==null?void 0:e.enrichedItemsByUniqueId)==null?void 0:P[r.uuid];i!=null&&(o.viewer.enrichedItems=i,i.some(S=>S.type==="pin")&&(o.viewer.pinned=!0,o.priority-=800),i.some(S=>S.type==="snooze")&&(o.viewer.snoozed=!0));let a=((I=(h=e==null?void 0:e.codeSuggestionsCountByPrUuid)==null?void 0:h[r.uuid])==null?void 0:I.count)||0;return a&&(o.codeSuggestionsCount=a),(!t||o.viewer.isAuthor||o.viewer.isAssignee&&!o.viewer.isReviewer)&&o.viewer.canMerge&&!o.isDraft&&!o.failingCI&&r.mergeableState==="MERGEABLE"&&(!r.reviewDecision||r.reviewDecision==="APPROVED")&&(o.viewer.shouldMerge=!0,o.suggestedActionCategory=Rr),(!t||o.viewer.isAuthor)&&r.isDraft&&(o.suggestedActionCategory=Sr),(!t||o.viewer.isAuthor)&&r.reviewDecision==="REVIEW_REQUESTED"&&(o.suggestedActionCategory=qr,o.viewer.waitingOnReviews=!0),(!t||o.viewer.isAuthor)&&r.reviewDecision==="COMMENTED"&&(o.suggestedActionCategory=Er),(!t||o.viewer.isAuthor)&&o.failingCI&&(o.suggestedActionCategory=br),(!t||o.viewer.isAuthor)&&o.hasConflicts&&(o.suggestedActionCategory=wr),(!t||o.viewer.isAuthor)&&(r.reviewDecision==="CHANGES_REQUESTED"||o.codeSuggestionsCount>0)&&(o.suggestedActionCategory=vr),(!t||o.viewer.isAuthor)&&!((E=r.reviews)!=null&&E.length)&&(o.suggestedActionCategory=yr,o.viewer.shouldAssignReviewer=!0),t&&((L=r.reviews)!=null&&L.some(S=>S.reviewer.id===t.id&&S.state==="REVIEW_REQUESTED"))&&(o.suggestedActionCategory=Pr,o.viewer.shouldReview=!0),o}),Ks=(s,t,e)=>{var i,a,u,l,p,d,c,g,m,f,y,P;let r={pinned:x(Tt,"Pinned","thumbtack",((i=e==null?void 0:e.bucketPriorityOverride)==null?void 0:i.pinned)??-1),readyToMerge:x(Ot,"Ready to Merge","code-merge",((a=e==null?void 0:e.bucketPriorityOverride)==null?void 0:a.readyToMerge)??0),unassignedReviewers:x(kt,"Unassigned Reviewers","user-plus",((u=e==null?void 0:e.bucketPriorityOverride)==null?void 0:u.unassignedReviewers)??1),failingCI:x(xt,"Failing CI","circle-x",((l=e==null?void 0:e.bucketPriorityOverride)==null?void 0:l.failingCI)??2),conflicts:x(Nt,"Resolve Conflicts","triangle-exclamation",((p=e==null?void 0:e.bucketPriorityOverride)==null?void 0:p.conflicts)??3),needsMyReview:x(_t,"Needs My Review","eye",((d=e==null?void 0:e.bucketPriorityOverride)==null?void 0:d.needsMyReview)??4),changesRequested:x(Bt,"Suggested Changes","file-plus",((c=e==null?void 0:e.bucketPriorityOverride)==null?void 0:c.changesRequested)??5),reviewerCommented:x(Qt,"Reviewer Commented","comment",((g=e==null?void 0:e.bucketPriorityOverride)==null?void 0:g.reviewerCommented)??6),waitingForReview:x(jt,"Waiting for Review","circle-pause",((m=e==null?void 0:e.bucketPriorityOverride)==null?void 0:m.waitingForReview)??7),draft:x(Ft,"Draft","compass-drafting",((f=e==null?void 0:e.bucketPriorityOverride)==null?void 0:f.draft)??8),other:x(Mt,"Other","ellipsis",((y=e==null?void 0:e.bucketPriorityOverride)==null?void 0:y.other)??9),snoozed:x(zt,"Snoozed","snooze",((P=e==null?void 0:e.bucketPriorityOverride)==null?void 0:P.snoozed)??10)},o=Dr(s,t,e).reduce((h,I)=>(h[I.uuid]=I,h),{});return s.forEach(h=>{let I=o[h.uuid],E=!0;if(I.viewer.snoozed){r[zt].pullRequests.push(h);return}I.viewer.pinned&&r[Tt].pullRequests.push(h),(!t||I.viewer.isAuthor||I.viewer.isAssignee&&!I.viewer.isReviewer)&&!I.isDraft&&I.viewer.canMerge&&I.mergeableState==="MERGEABLE"&&(!h.reviewDecision||h.reviewDecision==="APPROVED")&&(r[Ot].pullRequests.push(h),E=!1),I.viewer.shouldAssignReviewer&&(r[kt].pullRequests.push(h),E=!1),(!t||I.viewer.isAuthor)&&I.failingCI&&(r[xt].pullRequests.push(h),E=!1),(!t||I.viewer.isAuthor)&&I.hasConflicts&&(r[Nt].pullRequests.push(h),E=!1),I.viewer.shouldReview&&(r[_t].pullRequests.push(h),E=!1),(!t||I.viewer.isAuthor)&&(I.reviewDecision==="CHANGES_REQUESTED"||I.codeSuggestionsCount>0)&&(r[Bt].pullRequests.push(h),E=!1),(!t||I.viewer.isAuthor)&&I.reviewDecision==="COMMENTED"&&(r[Qt].pullRequests.push(h),E=!1),(!t||I.viewer.isAuthor)&&I.reviewDecision==="REVIEW_REQUESTED"&&(r[jt].pullRequests.push(h),E=!1),I.isDraft&&(r[Ft].pullRequests.push(h),E=!1),E&&r[Mt].pullRequests.push(h)}),Object.values(r).forEach(h=>{h.pullRequests.sort((I,E)=>o[I.uuid].priority-o[E.uuid].priority)}),r},Xs=s=>{let t={};return s.forEach(e=>{let r=e.repository.id;t[r]?t[r].pullRequests.push(e):t[r]={name:e.repository.name,priority:0,pullRequests:[e],id:r}}),Z(t)},Ys=s=>{let t="internal-no-assignees",e={[t]:{name:"No assignees",priority:-1,pullRequests:[],id:t,faIconName:"user-slash"}};return s.forEach(r=>{r.assignees&&r.assignees.length?r.assignees.forEach(n=>{let o=n.id;e[o]?e[o].pullRequests.push(r):e[o]={accountData:n,name:he(n,`Unknown Assignee ${Object.keys(e).length}`),priority:0,pullRequests:[r],id:o}}):e[t].pullRequests.push(r)}),Z(e)},Zs=s=>{let t="internal-no-author",e={[t]:{name:"No author",priority:-1,pullRequests:[],id:t,faIconName:"user-slash"}};return s.forEach(r=>{if(r.author){let n=r.author.id;e[n]?e[n].pullRequests.push(r):e[n]={accountData:r.author,name:he(r.author,`Unknown Author ${Object.keys(e).length}`),priority:0,pullRequests:[r],id:n}}else e[t].pullRequests.push(r)}),Z(e)},en=s=>{let t="internal-no-reviewer",e={[t]:{name:"No reviewers",priority:-1,pullRequests:[],id:t,faIconName:"user-slash"}};return s.forEach(r=>{r.reviews&&r.reviews.length?r.reviews.forEach(n=>{let o=n.reviewer.id;e[o]?e[o].pullRequests.push(r):e[o]={accountData:n.reviewer,name:he(n.reviewer,`Unknown Reviewer ${Object.keys(e).length}`),priority:0,pullRequests:[r],id:o}}):e[t].pullRequests.push(r)}),Z(e)},tn=s=>{var t;return s.azureProject?[`${s.azureProject}-${s.azureOrganizationId}`]:((t=s.providerData)==null?void 0:t.repositories.nodes.map(e=>`${s.provider}-${e.repositoryId}`))??[]},rn=(s,t)=>{let e="internal-no-workspace",r={[e]:{name:"No workspace",priority:-1,pullRequests:[],id:e,faIconName:"folder-xmark"}};if(t.length){let n=t.reduce((o,i)=>(tn(i).forEach(u=>{o[u]?o[u].push(i):o[u]=[i]}),o),{});s.forEach(o=>{let{provider:i}=Gt(o.uuid),a=i==="github"?o.repository.graphQLId:o.repository.id,u=i==="azure"?[`${i}-${a}`,`${o.repository.project}-${o.repository.owner.login}`]:[`${i}-${a}`],l=!1,p=u.reduce((d,c)=>n[c]?d.concat(n[c]):d,[]);p!=null&&p.length&&p.forEach(d=>{l=!0;let c=d.id;r[c]?r[c].pullRequests.push(o):r[c]={name:d.name,priority:0,pullRequests:[o],id:c,faIconName:"folder"}}),l||r[e].pullRequests.push(o)})}else r[e].pullRequests=s;return Z(r)},sn=(s,t,e,r)=>{let n="internal-no-team",o={[n]:{name:"No team",priority:-1,pullRequests:[],id:n}};return r.length?s.forEach(i=>{var l,p,d;let a=!1,u=new Set;u.add((l=i.author)==null?void 0:l.id),(p=i.assignees)==null||p.forEach(c=>u.add(c.id)),(d=i.reviews)==null||d.forEach(c=>u.add(c.reviewer.id)),r.forEach(c=>{var m;if((m=c.members)==null?void 0:m.some(f=>{var P,h;let y=(h=(P=t[f.id])==null?void 0:P[e])==null?void 0:h.providerID;return y&&u.has(y)})){a=!0;let f=c.id;o[f]?o[f].pullRequests.push(i):o[f]={name:c.name,priority:0,pullRequests:[i],id:f,teamData:c}}}),a||o[n].pullRequests.push(i)}):o[n].pullRequests=s,Z(o)};var st={};B(st,{getPullRequestRank:()=>nn});var nn=(s,t,e)=>{var i,a,u;let r=0,n,o;return(i=s.reviews)==null||i.forEach(l=>{l.reviewer.id===t&&(n=l.state),l.state==="CHANGES_REQUESTED"?o="CHANGES_REQUESTED":l.state==="APPROVED"&&o!=="CHANGES_REQUESTED"&&(o="APPROVED")}),o||(o="REVIEW_REQUESTED"),((a=s.author)==null?void 0:a.id)===t?r+=1e3:(u=s.assignees)!=null&&u.find(l=>l.id===t)?r+=900:n==="REVIEW_REQUESTED"?r+=800:e&&(r+=700),o==="APPROVED"?s.mergeableState==="MERGEABLE"?r+=100:s.mergeableState==="CONFLICTS"?r+=90:r+=80:o=="CHANGES_REQUESTED"&&(r+=70),r};var nt={};B(nt,{default:()=>on});var on={};var ot={};B(ot,{default:()=>an});var an={};var it={};B(it,{default:()=>un});var un={};var Ur=s=>{let t={request:s==null?void 0:s.request};return{azureDevOps:new te({...t,...s==null?void 0:s.azureDevOps}),bitbucket:new re({...t,...s==null?void 0:s.bitbucket}),bitbucketServer:new se({...t,...s==null?void 0:s.bitbucketServer}),github:new oe({...t,...s==null?void 0:s.github}),gitlab:new ae({...t,...s==null?void 0:s.gitlab}),jira:new ue({...t,...s==null?void 0:s.jira}),jiraServer:new le({...t,...s==null?void 0:s.jiraServer}),trello:new pe({...t,...s==null?void 0:s.trello})}};var Ar=(i=>(i.Conflicts="conflicts",i.Failure="failure",i.NotSet="notSet",i.Queued="queued",i.RejectedByPolicy="rejectedByPolicy",i.Succeeded="succeeded",i))(Ar||{});var Lr=(e=>(e.Completed="COMPLETED",e.NotPlanned="NOT_PLANNED",e))(Lr||{});var ln=Ur;var pn={azureDevOps:Qe,bitbucket:je,bitbucketServer:Fe,github:st,gitlab:nt,gitProvider:rt,jira:ot,trello:it,entityIdentifier:tt};
@@ -1100,5 +1100,5 @@ query getLabelsForRepo(
1100
1100
  }
1101
1101
  }
1102
1102
  }
1103
- `,variables:{fullPath:`${t}/${s}`,after:o}},e);return{pageInfo:((l=(u=(i=a.body.data)==null?void 0:i.project)==null?void 0:u.labels)==null?void 0:l.pageInfo)??{endCursor:null,hasNextPage:!1},data:((g=(c=(d=(p=a.body.data)==null?void 0:p.project)==null?void 0:d.labels)==null?void 0:c.nodes)==null?void 0:g.map(et))??[]}}async getTreeForRepo(n,e={}){let t=B(n.repo),s=new URL(n.cursor??`${Re(this.config,e)}/projects/${encodeURIComponent(t)}/repository/tree`);s.searchParams.set("per_page","10000"),s.searchParams.set("recursive","true"),s.searchParams.set("pagination","keyset"),s.searchParams.set("ref",n.branch);let o=await this.config.request({url:s.toString(),headers:I(e.token||this.config.token)}),a=o.headers.link;return{data:o.body.map(xr),pageInfo:{endCursor:a?a.substring(1,a.indexOf(">")):null,hasNextPage:!!a}}}};var Qr="https://api.atlassian.com/ex/jira",Pe=100,rt=["assignee","comment","summary","created","creator","updated","votes","issuetype","status","labels","components","project","fixVersions","description"],st=(r,n,e,t)=>{var i,u,l,p;let s=r.fields.assignee,o=!t,a=r.fields[(n==null?void 0:n.Sprint)??""]??[];return{id:r.id,commentCount:r.fields.comment.comments.length,number:r.key,title:r.fields.summary,url:e?`${e}/browse/${r.key}`:null,closedDate:null,createdDate:new Date(r.fields.created),author:we(r.fields.creator,e,o),updatedDate:new Date(r.fields.updated),assignees:s?[we(s,e,o)]:[],description:r.fields.description,repository:null,project:{name:r.fields.project.name,resourceId:t??null,key:r.fields.project.key,namespace:null,id:r.fields.project.id},state:Mr(r.fields.status),statusTransitions:((i=r.transitions)==null?void 0:i.map(_r))??[],components:((u=r.fields.components)==null?void 0:u.map(Br))??[],type:r.fields.issuetype.name,upvoteCount:((l=r.fields.votes)==null?void 0:l.votes)||0,labels:((p=r.fields.labels)==null?void 0:p.map(d=>({color:null,description:null,id:null,name:d})))??[],sprints:a.map(zr),fixVersions:r.fields.fixVersions.map(Hr)}},_r=r=>{let n;switch(r.to.statusCategory.name){case"To Do":n="TO_DO";break;case"In Progress":n="IN_PROGRESS";break;default:n="DONE";break}return{name:r.name,id:r.id,to:{id:r.to.id,name:r.to.name,color:r.to.statusCategory.colorName,category:n}}},Br=r=>({description:r.description??null,id:r.id,name:r.name}),jr=(r,n,e)=>e&&r.name?`${n}/secure/ViewProfile.jspa?name=${encodeURIComponent(r.name)}`:`${n}/jira/people/${r.accountId}`,we=(r,n,e)=>({id:(e?r.key:r.accountId)??"",name:r.displayName,email:r.emailAddress,avatarUrl:r.avatarUrls["48x48"],username:r.displayName,url:jr(r,n,e)}),Mr=r=>{let n;switch(r.statusCategory.name){case"To Do":n="TO_DO";break;case"In Progress":n="IN_PROGRESS";break;default:n="DONE";break}return{id:r.id,name:r.name,color:r.statusCategory.colorName,category:n}},zr=r=>({id:r.id.toString(),name:r.name,isActive:r.state==="active",startDate:r.startDate?new Date(r.startDate):null,endDate:r.endDate?new Date(r.endDate):null,completedDate:r.completeDate?new Date(r.completeDate):null}),Hr=r=>({id:r.id,description:r.description,name:r.name,archived:r.archived,released:r.released,releaseDate:r.releaseDate?new Date(r.releaseDate):null}),j=(r,n,e)=>e?`${n.baseUrl||Qr}/${e}`:`${(n==null?void 0:n.baseUrl)||r.baseUrl}`,Se=async(r,n,e={})=>{let{resourceId:t}=n;return(await r.request({url:`${j(r,e,t)}/rest/api/2/field`,headers:I(e.token||r.token)})).body},ve=async(r,n,e,t={})=>{let{number:s,resourceId:o,fields:a}=n||{},i=await r.request({url:`${j(r,t,o)}/rest/api/2/issue/${s}?fields=${rt.join(",")}&expand=transitions`,headers:I(t.token||r.token)});return{data:st(i.body,a,e,o)}},qe=async(r,n,e,t={})=>{let{page:s,resourceId:o,labelNames:a,fields:i}=n||{},u=s??0,l=["statusCategory != Done",`(creator = currentUser() OR assignee = currentUser()
1103
+ `,variables:{fullPath:`${t}/${s}`,after:o}},e);return{pageInfo:((l=(u=(i=a.body.data)==null?void 0:i.project)==null?void 0:u.labels)==null?void 0:l.pageInfo)??{endCursor:null,hasNextPage:!1},data:((g=(c=(d=(p=a.body.data)==null?void 0:p.project)==null?void 0:d.labels)==null?void 0:c.nodes)==null?void 0:g.map(et))??[]}}async getTreeForRepo(n,e={}){let t=B(n.repo),s=new URL(n.cursor??`${Re(this.config,e)}/projects/${encodeURIComponent(t)}/repository/tree`);s.searchParams.set("per_page","10000"),s.searchParams.set("recursive","true"),s.searchParams.set("pagination","keyset"),s.searchParams.set("ref",n.branch);let o=await this.config.request({url:s.toString(),headers:I(e.token||this.config.token)}),a=o.headers.link;return{data:o.body.map(xr),pageInfo:{endCursor:a?a.substring(1,a.indexOf(">")):null,hasNextPage:!!a}}}};var Qr="https://api.atlassian.com/ex/jira",Pe=100,rt=["assignee","comment","summary","created","creator","updated","votes","issuetype","status","labels","components","project","fixVersions","description"],st=(r,n,e,t)=>{var i,u,l,p;let s=r.fields.assignee,o=!t,a=(r.fields[(n==null?void 0:n.Sprint)??""]??[]).filter(d=>typeof d=="object");return{id:r.id,commentCount:r.fields.comment.comments.length,number:r.key,title:r.fields.summary,url:e?`${e}/browse/${r.key}`:null,closedDate:null,createdDate:new Date(r.fields.created),author:we(r.fields.creator,e,o),updatedDate:new Date(r.fields.updated),assignees:s?[we(s,e,o)]:[],description:r.fields.description,repository:null,project:{name:r.fields.project.name,resourceId:t??null,key:r.fields.project.key,namespace:null,id:r.fields.project.id},state:Mr(r.fields.status),statusTransitions:((i=r.transitions)==null?void 0:i.map(_r))??[],components:((u=r.fields.components)==null?void 0:u.map(Br))??[],type:r.fields.issuetype.name,upvoteCount:((l=r.fields.votes)==null?void 0:l.votes)||0,labels:((p=r.fields.labels)==null?void 0:p.map(d=>({color:null,description:null,id:null,name:d})))??[],sprints:a.map(zr),fixVersions:r.fields.fixVersions.map(Hr)}},_r=r=>{let n;switch(r.to.statusCategory.name){case"To Do":n="TO_DO";break;case"In Progress":n="IN_PROGRESS";break;default:n="DONE";break}return{name:r.name,id:r.id,to:{id:r.to.id,name:r.to.name,color:r.to.statusCategory.colorName,category:n}}},Br=r=>({description:r.description??null,id:r.id,name:r.name}),jr=(r,n,e)=>e&&r.name?`${n}/secure/ViewProfile.jspa?name=${encodeURIComponent(r.name)}`:`${n}/jira/people/${r.accountId}`,we=(r,n,e)=>({id:(e?r.key:r.accountId)??"",name:r.displayName,email:r.emailAddress,avatarUrl:r.avatarUrls["48x48"],username:r.displayName,url:jr(r,n,e)}),Mr=r=>{let n;switch(r.statusCategory.name){case"To Do":n="TO_DO";break;case"In Progress":n="IN_PROGRESS";break;default:n="DONE";break}return{id:r.id,name:r.name,color:r.statusCategory.colorName,category:n}},zr=r=>({id:r.id.toString(),name:r.name,isActive:r.state==="active",startDate:r.startDate?new Date(r.startDate):null,endDate:r.endDate?new Date(r.endDate):null,completedDate:r.completeDate?new Date(r.completeDate):null}),Hr=r=>({id:r.id,description:r.description,name:r.name,archived:r.archived,released:r.released,releaseDate:r.releaseDate?new Date(r.releaseDate):null}),j=(r,n,e)=>e?`${n.baseUrl||Qr}/${e}`:`${(n==null?void 0:n.baseUrl)||r.baseUrl}`,Se=async(r,n,e={})=>{let{resourceId:t}=n;return(await r.request({url:`${j(r,e,t)}/rest/api/2/field`,headers:I(e.token||r.token)})).body},ve=async(r,n,e,t={})=>{let{number:s,resourceId:o,fields:a}=n||{},i=await r.request({url:`${j(r,t,o)}/rest/api/2/issue/${s}?fields=${rt.join(",")}&expand=transitions`,headers:I(t.token||r.token)});return{data:st(i.body,a,e,o)}},qe=async(r,n,e,t={})=>{let{page:s,resourceId:o,labelNames:a,fields:i}=n||{},u=s??0,l=["statusCategory != Done",`(creator = currentUser() OR assignee = currentUser()
1104
1104
  OR comment ~ currentUser() OR summary ~ currentUser() OR description ~ currentUser())`];a&&a.forEach(m=>l.push(`labels = "${m}"`));let p=`${l.join(" AND ")} ORDER BY updated DESC`,c=(await r.request({url:`${j(r,t,o)}/rest/api/2/search?jql=${p}&startAt=${u}&maxResults=${Pe}&fields=${rt.join(",")}&expand=transitions`,headers:I(t.token||r.token)})).body.issues.map(m=>st(m,i,e,o)),g=c.length==Pe;return{data:c,pageInfo:{hasNextPage:g,nextPage:g?u+c.length:null}}},Lt=async(r,n,e,t={})=>{let{page:s,resourceId:o,jql:a,fields:i}=n||{},u=s??0,l=[...rt],p=i==null?void 0:i.Sprint;p&&l.push(p);let c=(await r.request({url:`${j(r,t,o)}/rest/api/2/search?jql=${a.join(" AND ")}&startAt=${u}&maxResults=${Pe}&fields=${l.join(",")}&expand=transitions`,headers:I(t.token||r.token)})).body.issues.map(m=>st(m,i,e,o)),g=c.length==Pe;return{data:c,pageInfo:{hasNextPage:g,nextPage:g?u+c.length:null}}},Ee=async(r,n,e,t={})=>{let{assigneeLogins:s,authorLogin:o,mentionLogin:a,labelNames:i,page:u,projectKey:l,resourceId:p,fields:d}=n||{},c=u??0,g=[`project = "${l}"`,"statusCategory != Done"];return o&&g.push(`creator in ("${o}")`),s&&s.length!==0&&g.push(`assignee in ("${s.join('", "')}")`),a&&g.push(`comment ~ "${a}"`),i&&i.forEach(m=>g.push(`labels = "${m}"`)),Lt(r,{resourceId:p,jql:g,page:c,fields:d},e,t)},Ce=async(r,n,e,t={})=>{let{assigneeLogins:s,authorLogin:o,mentionLogin:a,labelNames:i,page:u,projectKeys:l,resourceId:p,fields:d}=n||{},c=u??0,m=["("+l.map(h=>`project = "${h}"`).join(" OR ")+")","statusCategory != Done"];return o&&m.push(`creator in ("${o}")`),s&&s.length!==0&&m.push(`assignee in ("${s.join('", "')}")`),a&&m.push(`comment ~ "${a}"`),i&&i.forEach(h=>m.push(`labels = "${h}"`)),Lt(r,{resourceId:p,jql:m,fields:d,page:c},e,t)},De=async(r,n,e={})=>{let{issue:t,labels:s}=n;if(!t.project)throw new Error('Jira requires a "project" for this function.');let o={fields:{labels:s.map(a=>a.name)}};await r.request({method:"PUT",url:`${j(r,e,t.project.resourceId??void 0)}/rest/api/2/issue/${t.id}`,body:JSON.stringify(o),headers:{...I(e.token||r.token),"Content-Type":"application/json"}})},Ue=async(r,n,e={})=>{let{issue:t,components:s}=n;if(!t.project)throw new Error('Jira requires a "project" for this function.');let o={fields:{components:s.map(a=>({id:a.id}))}};await r.request({method:"PUT",url:`${j(r,e,t.project.resourceId??void 0)}/rest/api/2/issue/${t.id}`,body:JSON.stringify(o),headers:{...I(e.token||r.token),"Content-Type":"application/json"}})},Le=async(r,n,e={})=>{let{issue:t,status:s}=n;if(!t.project)throw new Error('Jira requires a "project" for this function.');if(!s.id)throw new Error('Jira requires a status "id" for this function.');let o={transition:{id:s.id}};await r.request({method:"POST",url:`${j(r,e,t.project.resourceId??void 0)}/rest/api/2/issue/${t.id}/transitions`,body:JSON.stringify(o),headers:{...I(e.token||r.token),"Content-Type":"application/json"}})},$e=async(r,n,e={})=>{let{resourceId:t,projectIdOrKey:s}=n,o=new URL(`${j(r,e,t)}/rest/api/2/project/${s}/components`);return{data:(await r.request({url:o.toString(),headers:I(e.token||r.token)})).body}};var ne="https://api.atlassian.com/ex/jira",nt=100,te=class extends ${constructor(){super(...arguments);this._resourceUrlCache={};this._issueFieldsCache={}}async getIssueFieldsForResource(e,t={}){if(!this._issueFieldsCache[e.resourceId]){let s=await Se(this.config,e,t);this._issueFieldsCache[e.resourceId]=s.reduce((o,a)=>({...o,[a.name]:a.id}),{})}return this._issueFieldsCache[e.resourceId]??null}async getResourceUrl(e,t={}){var a;let s=t.token||this.config.token;if(!s)return null;let o=this._resourceUrlCache[s];return o?o[e.resourceId]??null:(await this.getJiraResourcesForCurrentUser(t),((a=this._resourceUrlCache[s])==null?void 0:a[e.resourceId])??null)}async getCurrentUserForResource(e,t={}){let s=await this.getResourceUrl({resourceId:e.resourceId},t),o=await this.config.request({url:`${t.baseUrl||ne}/${e.resourceId}/rest/api/2/myself`,headers:I(t.token||this.config.token)});return{data:{name:o.body.displayName,email:o.body.emailAddress,avatarUrl:o.body.avatarUrls["48x48"],id:o.body.accountId,username:o.body.displayName,url:s?`${s}/jira/people/${o.body.accountId}`:null}}}async getJiraResourcesForCurrentUser(e={}){let t=await this.config.request({url:`${e.baseUrl||"https://api.atlassian.com/"}/oauth/token/accessible-resources`,headers:I(e.token||this.config.token)}),s=e.token||this.config.token,o=s?this._resourceUrlCache[s]||{}:void 0,a=t.body.map(i=>(o&&(o[i.id]=i.url),{avatarUrl:i.avatarUrl,id:i.id,name:i.name,url:i.url}));return s&&(this._resourceUrlCache[s]=o),{data:a}}async getJiraProjectsForResource(e,t={}){let s=new URL(`${t.baseUrl||ne}/${e.resourceId}/rest/api/2/project/search`);s.searchParams.set("maxResults",nt.toString()),e.cursor&&s.searchParams.set("startAt",e.cursor);let o=await this.config.request({url:s.toString(),headers:I(t.token||this.config.token)});return{pageInfo:{hasNextPage:o.body.values.length!==0,endCursor:(o.body.startAt+o.body.values.length).toString()},data:o.body.values.map(a=>({id:a.id,key:a.key,name:a.name,resourceId:e.resourceId}))}}async getJiraProjectsForResources(e,t={}){let s=[];return await Promise.all(e.resourceIds.map(async o=>{try{return await dt(a=>this.getJiraProjectsForResource({resourceId:o,cursor:a},t))}catch{return[]}})).then((...o)=>{o.forEach(a=>{s=s.concat(...a)})}),{data:s}}async getAccountsForJiraProject(e,t={}){let{resourceId:s,projectKey:o,cursor:a}=e,i=await this.getResourceUrl({resourceId:s},t),u=new URL(`${t.baseUrl||ne}/${s}/rest/api/2/user/assignable/search`);u.searchParams.set("maxResults",nt.toString()),a&&u.searchParams.set("startAt",a),u.searchParams.set("project",o);let l=await this.config.request({url:u.toString(),headers:I(t.token||this.config.token)});return{pageInfo:{hasNextPage:l.body.length!==0,endCursor:((a?parseInt(a):0)+l.body.length).toString()},data:l.body.filter(p=>p.accountType!=="app"&&p.active).map(p=>we(p,i,!1))}}async getComponentsForJiraProject(e,t={}){return await $e(this.config,e,t)}async getIssue(e,t={}){let s=await this.getIssueFieldsForResource({resourceId:e.resourceId},t),o=await this.getResourceUrl({resourceId:e.resourceId},t);return await ve(this.config,{...e,fields:s},o,t)}async getIssuesForProject(e,t={}){let s=await this.getIssueFieldsForResource({resourceId:e.resourceId},t),o=await this.getResourceUrl({resourceId:e.resourceId},t);return await Ee(this.config,{...e,fields:s},o,t)}async getIssuesForProjects(e,t={}){let s=await this.getIssueFieldsForResource({resourceId:e.resourceId},t),o=await this.getResourceUrl({resourceId:e.resourceId},t);return await Ce(this.config,{...e,fields:s},o,t)}async getIssuesForResourceForCurrentUser(e,t={}){let s=await this.getIssueFieldsForResource({resourceId:e.resourceId},t),o=await this.getResourceUrl({resourceId:e.resourceId},t);return await qe(this.config,{...e,fields:s},o,t)}async setIssueStatus(e,t={}){await Le(this.config,e,t)}async setIssueAssignee(e,t={}){let{issue:s,assignee:o}=e;if(!s.project)throw new Error('Jira Cloud requires a "project" for this function.');if(!s.project.resourceId)throw new Error('Jira Cloud requires a project "resourceId" for this function.');let a={accountId:o==null?void 0:o.id};await this.config.request({method:"PUT",url:`${t.baseUrl||ne}/${s.project.resourceId}/rest/api/2/issue/${s.id}/assignee`,body:JSON.stringify(a),headers:{...I(t.token||this.config.token),"Content-Type":"application/json"}})}async setIssueComponents(e,t={}){await Ue(this.config,e,t)}async setIssueLabels(e,t={}){await De(this.config,e,t)}async getLabelsForResource(e,t={}){let{resourceId:s,cursor:o}=e,a=new URL(`${t.baseUrl||ne}/${s}/rest/api/2/label`);a.searchParams.set("maxResults",nt.toString()),o&&a.searchParams.set("startAt",o);let i=await this.config.request({url:a.toString(),headers:I(t.token||this.config.token)});return{pageInfo:{hasNextPage:!i.body.isLast,endCursor:(i.body.startAt+i.body.values.length).toString()},data:i.body.values.map(u=>({color:null,description:null,id:null,name:u}))}}};var re=class extends T{constructor(){super(...arguments);this._issueFieldsCache={}}async getIssueFieldsForResource(e={}){let t=(e==null?void 0:e.baseUrl)||this.config.baseUrl||"";if(!this._issueFieldsCache[t]){let s=await Se(this.config,{},e);this._issueFieldsCache[t]=s.reduce((o,a)=>({...o,[a.name]:a.id}),{})}return this._issueFieldsCache[t]??null}async getCurrentUser(e={}){let t=await this.config.request({url:`${(e==null?void 0:e.baseUrl)||this.config.baseUrl}/rest/api/2/myself`,headers:I((e==null?void 0:e.token)||this.config.token)});return{data:{name:t.body.displayName,email:t.body.emailAddress,avatarUrl:t.body.avatarUrls["48x48"],id:t.body.key,username:t.body.displayName,url:null}}}async getJiraProjects(e={}){return{data:(await this.config.request({url:`${(e==null?void 0:e.baseUrl)||this.config.baseUrl}/rest/api/2/project`,headers:I((e==null?void 0:e.token)||this.config.token)})).body.map(s=>({id:s.id,name:s.name}))}}async getIssue(e,t={}){let s=e.resourceUrl||t.baseUrl||this.config.baseUrl;if(!s)throw new Error('Jira Server requires a "resourceUrl" or "baseUrl" for this function.');let o=await this.getIssueFieldsForResource(t);return await ve(this.config,{...e,fields:o},s,t)}async getIssuesForProject(e,t={}){let s=e.resourceUrl||t.baseUrl||this.config.baseUrl;if(!s)throw new Error('Jira Server requires a "resourceUrl" or "baseUrl" for this function.');let o=await this.getIssueFieldsForResource(t);return await Ee(this.config,{...e,fields:o},s,t)}async getIssuesForProjects(e,t={}){let s=e.resourceUrl||t.baseUrl||this.config.baseUrl;if(!s)throw new Error('Jira Server requires a "resourceUrl" or "baseUrl" for this function.');let o=await this.getIssueFieldsForResource(t);return await Ce(this.config,{...e,fields:o},s,t)}async getIssuesForResourceForCurrentUser(e,t={}){let s=e.resourceUrl||t.baseUrl||this.config.baseUrl;if(!s)throw new Error('Jira Server requires a "resourceUrl" or "baseUrl" for this function.');let o=await this.getIssueFieldsForResource(t);return await qe(this.config,{...e,fields:o},s,t)}async setIssueStatus(e,t={}){await Le(this.config,e,t)}async setIssueLabels(e,t={}){await De(this.config,e,t)}async setIssueComponents(e,t={}){await Ue(this.config,e,t)}async getLabels(e={}){return{data:(await this.config.request({url:`${(e==null?void 0:e.baseUrl)||this.config.baseUrl}/rest/api/2/jql/autocompletedata/suggestions?fieldName=labels`,headers:I(e.token||this.config.token)})).body.results.map(({displayName:s})=>({color:null,description:null,id:null,name:s}))}}async getComponentsForJiraProject(e,t={}){return await $e(this.config,e,t)}};var O="https://api.trello.com",Wr=1e3,Jr=r=>({id:r.id,username:r.username,url:r.url,name:r.fullName,email:r.email,avatarUrl:r.avatarUrl}),Kr=(r,n)=>{let e=new Date(1e3*parseInt(r.id.substring(0,8),16));return{id:r.id,commentCount:r.badges.comments,number:r.idShort.toString(),title:r.name,url:r.url,closedDate:null,createdDate:new Date(e.toISOString()),author:null,updatedDate:new Date(r.dateLastActivity),assignees:r.members.map(t=>({id:t.id,username:t.username,name:t.fullName,email:null,avatarUrl:t.avatarUrl,url:null})),description:null,state:n[r.idList??""]?{id:r.idList,name:n[r.idList].name,color:null}:null,type:null,repository:null,upvoteCount:r.badges.votes,labels:r.labels.map(t=>({color:t.color,description:null,id:t.id,name:t.name}))}},se=class extends ${async getCurrentUser(n,e={}){let t=await this.config.request({url:`${e.baseUrl||O}/1/members/me?key=${n.appKey}&token=${e.token||this.config.token}`,headers:I(e.token||this.config.token)});return{data:{name:t.body.fullName,email:t.body.email,avatarUrl:t.body.avatarHash?`https://trello-members.s3.amazonaws.com/${t.body.id}/${t.body.avatarHash}/50.png`:null,id:t.body.id,username:t.body.username,url:t.body.url}}}async getBoardsForCurrentUser(n,e={}){return{data:(await this.config.request({url:`${e.baseUrl||O}/1/members/me/boards?fields=name&key=${n.appKey}&token=${e.token||this.config.token}&filter=open`,headers:I(e.token||this.config.token)})).body.map(s=>({id:s.id,name:s.name}))}}async getListsForTrelloBoard(n,e={}){let{appKey:t,boardId:s}=n;return{data:(await this.config.request({url:`${e.baseUrl||O}/1/boards/${s}/lists?key=${t}&token=${e.token||this.config.token}`,headers:I(e.token||this.config.token)})).body}}async getAccountForId(n,e={}){let{appKey:t,memberId:s}=n,o=await this.config.request({url:`${e.baseUrl||O}/1/members/${s}/?key=${t}&token=${e.token||this.config.token}`});return{data:Jr(o.body)}}async getAccountsForTrelloBoard(n,e={}){let{appKey:t,boardId:s}=n;return{data:(await this.config.request({url:`${e.baseUrl||O}/1/boards/${s}/members?key=${t}&token=${e.token||this.config.token}`,headers:I(e.token||this.config.token)})).body.map(a=>({id:a.id,name:a.fullName,username:a.username,email:null,avatarUrl:null,url:null}))}}async getIssuesForBoard(n,e={}){let t=["-is:archived","sort:edited"],{appKey:s,boardId:o,filterText:a,assigneeLogins:i,labelNamesOrColors:u,trelloBoardListsById:l}=n||{};i&&t.push("@me"),u&&u.forEach(c=>t.push(`label:"${c}"`));let p=`${a?`${a}`:""}${t.join(" ")} board:${o}`;return{data:(await this.config.request({url:`${e.baseUrl||O}/1/search?key=${s}&query=${p}&cards_limit=${Wr}&token=${e.token||this.config.token}&card_members=true`,headers:I(e.token||this.config.token)})).body.cards.map(c=>Kr(c,l||{}))}}async updateIssue(n,e,t,s){return await this.config.request({method:"PUT",url:`${s.baseUrl||O}/1/cards/${e.id}?key=${n}&token=${s.token||this.config.token}&${t}`,headers:I(s.token||this.config.token)})}async setIssueStatus(n,e={}){let{appKey:t,issue:s,status:o}=n;if(!o.id)throw new Error('Trello requires a status "id" for this function.');let a=`idList=${o.id}`;if(!(await this.updateIssue(t,s,a,e)).body.id)throw new Error("Could not set issue status")}async setIssueAssignees(n,e={}){let{appKey:t,issue:s,assignees:o}=n,a=o.map(l=>l.id),i=`idMembers=${encodeURIComponent(a.join(","))}`;if(!(await this.updateIssue(t,s,i,e)).body.id)throw new Error("Could not set issue status")}async setIssueLabels(n,e={}){let{appKey:t,issue:s,labels:o}=n,a=o.map(u=>u.id).join(",");if(!(await this.config.request({method:"PUT",url:`${e.baseUrl||O}/1/cards/${s.id}?key=${t}&token=${e.token||this.config.token}&idLabels=${encodeURIComponent(a)}`,headers:I(e.token||this.config.token)})).body.id)throw new Error("Could not set issue status")}async setIssueArchived(n,e={}){let{appKey:t,issue:s,archived:o}=n;if(!(await this.config.request({method:"PUT",url:`${e.baseUrl||O}/1/cards/${s.id}?key=${t}&token=${e.token||this.config.token}&closed=${o}`,headers:I(e.token||this.config.token)})).body.id)throw new Error("Could not update issue archived status")}async archiveIssue(n,e={}){await this.setIssueArchived({...n,archived:!0},e)}async unArchiveIssue(n,e={}){await this.setIssueArchived({...n,archived:!1},e)}async getLabelsForBoard(n,e={}){let{appKey:t,boardId:s}=n;return{data:(await this.config.request({url:`${e.baseUrl||O}/1/boards/${s}/labels?key=${t}&token=${e.token||this.config.token}`,headers:I(e.token||this.config.token)})).body.map(a=>({color:a.color,description:null,id:a.id,name:a.name}))}}};var $t=r=>{let n={request:r==null?void 0:r.request};return{azureDevOps:new J({...n,...r==null?void 0:r.azureDevOps}),bitbucket:new K({...n,...r==null?void 0:r.bitbucket}),bitbucketServer:new V({...n,...r==null?void 0:r.bitbucketServer}),github:new Z({...n,...r==null?void 0:r.github}),gitlab:new ee({...n,...r==null?void 0:r.gitlab}),jira:new te({...n,...r==null?void 0:r.jira}),jiraServer:new re({...n,...r==null?void 0:r.jiraServer}),trello:new se({...n,...r==null?void 0:r.trello})}};var At=(a=>(a.Conflicts="conflicts",a.Failure="failure",a.NotSet="notSet",a.Queued="queued",a.RejectedByPolicy="rejectedByPolicy",a.Succeeded="succeeded",a))(At||{});var Gt=(e=>(e.Zero="0",e.One="1",e))(Gt||{}),Tt=(e=>(e.PullRequest="pr",e.Issue="issue",e))(Tt||{}),Ot=(p=>(p.Azure="azure",p.Github="github",p.GithubEnterprise="githubEnterprise",p.Gitlab="gitlab",p.GitlabSelfHosted="gitlabSelfHosted",p.Bitbucket="bitbucket",p.BitbucketServer="bitbucketServer",p.Jira="jira",p.JiraServer="jiraServer",p.Trello="trello",p))(Ot||{});var xt=(e=>(e.Completed="COMPLETED",e.NotPlanned="NOT_PLANNED",e))(xt||{});var Vr=$t;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitkraken/provider-apis",
3
- "version": "0.26.3",
3
+ "version": "0.26.4",
4
4
  "description": "An SDK around different third-party APIs that accepts and returns data in a common format.",
5
5
  "author": "Axosoft, LLC dba GitKraken",
6
6
  "license": "SEE LICENSE IN LICENSE",