@gitkraken/provider-apis 0.25.5 → 0.25.6
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 +10 -1
- package/dist/index.js +1 -1
- package/dist/types/exportedTypes/types.d.ts +12 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.25.6
|
|
4
|
+
|
|
5
|
+
- added icon strings to some new Launchpad buckets
|
|
6
|
+
- updated types of Launchpad bucket types
|
|
7
|
+
|
|
3
8
|
## 0.25.5
|
|
4
9
|
|
|
10
|
+
- increase max issues per page from 10 to 100 (Jira, Jira Server)
|
|
5
11
|
- sort issues by updated date (Jira, Jira Server)
|
|
6
12
|
- add new launchpad bucketing functions
|
|
7
13
|
|
|
@@ -93,6 +99,7 @@ buckets === {
|
|
|
93
99
|
Bucket priority is assigned based on the alphabetical order of the bucket names.
|
|
94
100
|
|
|
95
101
|
The following PR bucketing functions have been added:
|
|
102
|
+
|
|
96
103
|
- groupPullRequestsByRepo
|
|
97
104
|
- groupPullRequestsByAssignee
|
|
98
105
|
- groupPullRequestsByAuthor
|
|
@@ -101,6 +108,7 @@ The following PR bucketing functions have been added:
|
|
|
101
108
|
- groupPullRequestsByGitKrakenTeam
|
|
102
109
|
|
|
103
110
|
The following issue bucketing functions have been added:
|
|
111
|
+
|
|
104
112
|
- groupIssuesByRepo
|
|
105
113
|
- groupIssuesByAssignee
|
|
106
114
|
- groupIssuesByAuthor
|
|
@@ -138,6 +146,7 @@ The following issue bucketing functions have been added:
|
|
|
138
146
|
We refactored the `EntityIndentifier` types to be more precise. The old types would allow the creation of identifiers that didn't make any sense.
|
|
139
147
|
|
|
140
148
|
For instance, using the old types, one could create a Bitbucket Server entity identifier that does not have a domain:
|
|
149
|
+
|
|
141
150
|
```ts
|
|
142
151
|
const id: BitbucketPullRequestEntityIdentifierInput = {
|
|
143
152
|
provider: EntityIdentifierProviderType.BitbucketServer,
|
|
@@ -145,7 +154,7 @@ const id: BitbucketPullRequestEntityIdentifierInput = {
|
|
|
145
154
|
version: EntityVersion.One,
|
|
146
155
|
repoId: 'test-repo',
|
|
147
156
|
entityId: '1',
|
|
148
|
-
domain: undefined
|
|
157
|
+
domain: undefined,
|
|
149
158
|
};
|
|
150
159
|
```
|
|
151
160
|
|
package/dist/index.js
CHANGED
|
@@ -1101,4 +1101,4 @@ query getLabelsForRepo(
|
|
|
1101
1101
|
}
|
|
1102
1102
|
}
|
|
1103
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(Ct))??[]}}};var Cs="https://api.atlassian.com/ex/jira",Ce=100,Ut=["assignee","comment","summary","created","creator","updated","votes","issuetype","status","labels","components","project","fixVersions"],At=(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:De(s.fields.creator,e,o),updatedDate:new Date(s.fields.updated),assignees:n?[De(n,e,o)]:[],description:null,repository:null,project:{name:s.fields.project.name,resourceId:r??null,key:s.fields.project.key,namespace:null,id:s.fields.project.id},state:Ls(s.fields.status),statusTransitions:((a=s.transitions)==null?void 0:a.map(Ds))??[],components:((u=s.fields.components)==null?void 0:u.map(Us))??[],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($s),fixVersions:s.fields.fixVersions.map(Gs)}},Ds=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}}},Us=s=>({description:s.description??null,id:s.id,name:s.name}),As=(s,t,e)=>e&&s.name?`${t}/secure/ViewProfile.jspa?name=${encodeURIComponent(s.name)}`:`${t}/jira/people/${s.accountId}`,De=(s,t,e)=>({id:(e?s.key:s.accountId)??"",name:s.displayName,email:s.emailAddress,avatarUrl:s.avatarUrls["48x48"],username:s.displayName,url:As(s,t,e)}),Ls=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}},$s=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}),Gs=s=>({id:s.id,description:s.description,name:s.name,archived:s.archived,released:s.released,releaseDate:s.releaseDate?new Date(s.releaseDate):null}),V=(s,t,e)=>e?`${t.baseUrl||Cs}/${e}`:`${(t==null?void 0:t.baseUrl)||s.baseUrl}`,Ue=async(s,t,e={})=>{let{resourceId:r}=t;return(await s.request({url:`${V(s,e,r)}/rest/api/2/field`,headers:I(e.token||s.token)})).body},Ae=async(s,t,e,r={})=>{let{number:n,resourceId:o,fields:i}=t||{},a=await s.request({url:`${V(s,r,o)}/rest/api/2/issue/${n}?fields=${Ut.join(",")}&expand=transitions`,headers:I(r.token||s.token)});return{data:At(a.body,i,e,o)}},Le=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
|
-
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:`${V(s,r,o)}/rest/api/2/search?jql=${p}&startAt=${u}&maxResults=${Ce}&fields=${Ut.join(",")}&expand=transitions`,headers:I(r.token||s.token)})).body.issues.map(m=>At(m,a,e,o)),g=c.length==Ce;return{data:c,pageInfo:{hasNextPage:g,nextPage:g?u+c.length:null}}},hr=async(s,t,e,r={})=>{let{page:n,resourceId:o,jql:i,fields:a}=t||{},u=n??0,l=[...Ut],p=a==null?void 0:a.Sprint;p&&l.push(p);let c=(await s.request({url:`${V(s,r,o)}/rest/api/2/search?jql=${i.join(" AND ")}&startAt=${u}&maxResults=${Ce}&fields=${l.join(",")}&expand=transitions`,headers:I(r.token||s.token)})).body.issues.map(m=>At(m,a,e,o)),g=c.length==Ce;return{data:c,pageInfo:{hasNextPage:g,nextPage:g?u+c.length:null}}},$e=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}"`)),hr(s,{resourceId:p,jql:g,page:c,fields:d},e,r)},Ge=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(h=>`project = "${h}"`).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(h=>m.push(`labels = "${h}"`)),hr(s,{resourceId:p,jql:m,fields:d,page:c},e,r)},Te=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:`${V(s,e,r.project.resourceId??void 0)}/rest/api/2/issue/${r.id}`,body:JSON.stringify(o),headers:{...I(e.token||s.token),"Content-Type":"application/json"}})},Oe=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:`${V(s,e,r.project.resourceId??void 0)}/rest/api/2/issue/${r.id}`,body:JSON.stringify(o),headers:{...I(e.token||s.token),"Content-Type":"application/json"}})},xe=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:`${V(s,e,r.project.resourceId??void 0)}/rest/api/2/issue/${r.id}/transitions`,body:JSON.stringify(o),headers:{...I(e.token||s.token),"Content-Type":"application/json"}})},ke=async(s,t,e={})=>{let{resourceId:r,projectIdOrKey:n}=t,o=new URL(`${V(s,e,r)}/rest/api/2/project/${n}/components`);return{data:(await s.request({url:o.toString(),headers:I(e.token||s.token)})).body}};var ue="https://api.atlassian.com/ex/jira",Lt=100,le=class extends x{constructor(){super(...arguments);this._resourceUrlCache={};this._issueFieldsCache={}}async getIssueFieldsForResource(e,r={}){if(!this._issueFieldsCache[e.resourceId]){let n=await Ue(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||ue}/${e.resourceId}/rest/api/2/myself`,headers:I(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:I(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||ue}/${e.resourceId}/rest/api/2/project/search`);n.searchParams.set("maxResults",Lt.toString()),e.cursor&&n.searchParams.set("startAt",e.cursor);let o=await this.config.request({url:n.toString(),headers:I(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 Xt(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||ue}/${n}/rest/api/2/user/assignable/search`);u.searchParams.set("maxResults",Lt.toString()),i&&u.searchParams.set("startAt",i),u.searchParams.set("project",o);let l=await this.config.request({url:u.toString(),headers:I(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=>De(p,a,!1))}}async getComponentsForJiraProject(e,r={}){return await ke(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 Ae(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 $e(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 Ge(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 Le(this.config,{...e,fields:n},o,r)}async setIssueStatus(e,r={}){await xe(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||ue}/${n.project.resourceId}/rest/api/2/issue/${n.id}/assignee`,body:JSON.stringify(i),headers:{...I(r.token||this.config.token),"Content-Type":"application/json"}})}async setIssueComponents(e,r={}){await Oe(this.config,e,r)}async setIssueLabels(e,r={}){await Te(this.config,e,r)}async getLabelsForResource(e,r={}){let{resourceId:n,cursor:o}=e,i=new URL(`${r.baseUrl||ue}/${n}/rest/api/2/label`);i.searchParams.set("maxResults",Lt.toString()),o&&i.searchParams.set("startAt",o);let a=await this.config.request({url:i.toString(),headers:I(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 pe=class extends B{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 Ue(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:I((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:I((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 Ae(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 $e(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 Ge(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 Le(this.config,{...e,fields:o},n,r)}async setIssueStatus(e,r={}){await xe(this.config,e,r)}async setIssueLabels(e,r={}){await Te(this.config,e,r)}async setIssueComponents(e,r={}){await Oe(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:I(e.token||this.config.token)})).body.results.map(({displayName:n})=>({color:null,description:null,id:null,name:n}))}}async getComponentsForJiraProject(e,r={}){return await ke(this.config,e,r)}};var Q="https://api.trello.com",Ts=1e3,Os=s=>({id:s.id,username:s.username,url:s.url,name:s.fullName,email:s.email,avatarUrl:s.avatarUrl}),xs=(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}))}},de=class extends x{async getCurrentUser(t,e={}){let r=await this.config.request({url:`${e.baseUrl||Q}/1/members/me?key=${t.appKey}&token=${e.token||this.config.token}`,headers:I(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||Q}/1/members/me/boards?fields=name&key=${t.appKey}&token=${e.token||this.config.token}&filter=open`,headers:I(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||Q}/1/boards/${n}/lists?key=${r}&token=${e.token||this.config.token}`,headers:I(e.token||this.config.token)})).body}}async getAccountForId(t,e={}){let{appKey:r,memberId:n}=t,o=await this.config.request({url:`${e.baseUrl||Q}/1/members/${n}/?key=${r}&token=${e.token||this.config.token}`});return{data:Os(o.body)}}async getAccountsForTrelloBoard(t,e={}){let{appKey:r,boardId:n}=t;return{data:(await this.config.request({url:`${e.baseUrl||Q}/1/boards/${n}/members?key=${r}&token=${e.token||this.config.token}`,headers:I(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||Q}/1/search?key=${n}&query=${p}&cards_limit=${Ts}&token=${e.token||this.config.token}&card_members=true`,headers:I(e.token||this.config.token)})).body.cards.map(c=>xs(c,l||{}))}}async updateIssue(t,e,r,n){return await this.config.request({method:"PUT",url:`${n.baseUrl||Q}/1/cards/${e.id}?key=${t}&token=${n.token||this.config.token}&${r}`,headers:I(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||Q}/1/cards/${n.id}?key=${r}&token=${e.token||this.config.token}&idLabels=${encodeURIComponent(i)}`,headers:I(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||Q}/1/cards/${n.id}?key=${r}&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(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||Q}/1/boards/${n}/labels?key=${r}&token=${e.token||this.config.token}`,headers:I(e.token||this.config.token)})).body.map(i=>({color:i.color,description:null,id:i.id,name:i.name}))}}};var Ne={};_(Ne,{default:()=>ks});var ks={};var _e={};_(_e,{default:()=>Ns});var Ns={};var Be={};_(Be,{restApiPullRequestToCommonPullRequest:()=>_s});var _s=s=>ne(s);var Ye={};_(Ye,{decode:()=>$t,decodeV0:()=>Fs,encode:()=>js,validate:()=>Qs});var A=(e=>(e.Zero="0",e.One="1",e))(A||{}),L=(e=>(e.PullRequest="pr",e.Issue="issue",e))(L||{}),C=(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))(C||{});var Qe=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 je=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 Fe=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 Me=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 ze=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 We=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 He=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 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 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 Ve=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 Ke=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 Xe=(s,t)=>{if(t!=="issue"&&t!=="pr")throw new Error("unknown entityType");switch(s){case"azure":return t==="pr"?new je:new Qe;case"bitbucket":case"bitbucketServer":return t==="pr"?new Me:new Fe;case"github":case"githubEnterprise":return t==="pr"?new We:new ze;case"gitlab":case"gitlabSelfHosted":return t==="pr"?new Je:new He;case"jira":case"jiraServer":if(t==="pr")throw new Error("EntityType PullRequest is not valid for Jira");return new Ve;case"trello":if(t==="pr")throw new Error("EntityType PullRequest is not valid for Jira");return new Ke;default:throw new Error("unknown provider")}},Bs=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")},Qs=s=>{if(s.version==="0"){Bs(s);return}Xe(s.provider,s.entityType).validate(s)},js=s=>Xe(s.provider,s.entityType).encode(s),$t=s=>{let t=JSON.parse(s);if(!t||!t.length)throw new Error("invalid issue unique id");return Xe(t[0],t[1]).decode(t)},Fs=(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 Xe(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 Ze={};_(Ze,{CHANGES_REQUESTED_ACTION_CATEGORY:()=>wr,CHANGES_REQUESTED_BUCKET_ID:()=>_t,CONFLICTS_ACTION_CATEGORY:()=>yr,CONFLICTS_BUCKET_ID:()=>kt,DRAFT_ACTION_CATEGORY:()=>Er,DRAFT_BUCKET_ID:()=>jt,FAILING_CI_ACTION_CATEGORY:()=>Rr,FAILING_CI_BUCKET_ID:()=>xt,NEEDS_MY_REVIEW_ACTION_CATEGORY:()=>br,NEEDS_MY_REVIEW_BUCKET_ID:()=>Nt,OTHER_ACTION_CATEGORY:()=>qr,OTHER_BUCKET_ID:()=>Ft,PINNED_BUCKET_ID:()=>Gt,READY_TO_MERGE_ACTION_CATEGORY:()=>fr,READY_TO_MERGE_BUCKET_ID:()=>Tt,REVIEWER_COMMENTED_ACTION_CATEGORY:()=>Pr,REVIEWER_COMMENTED_BUCKET_ID:()=>Bt,SNOOZED_BUCKET_ID:()=>Mt,UNASSIGNED_REVIEWERS_ACTION_CATEGORY:()=>Ir,UNASSIGNED_REVIEWERS_BUCKET_ID:()=>Ot,WAITING_FOR_REVIEW_ACTION_CATEGORY:()=>vr,WAITING_FOR_REVIEW_BUCKET_ID:()=>Qt,getActionablePullRequests:()=>Sr,groupPullRequestsByAssignee:()=>Ws,groupPullRequestsByAuthor:()=>Hs,groupPullRequestsByGitKrakenTeam:()=>Xs,groupPullRequestsByRepo:()=>zs,groupPullRequestsByReviewer:()=>Js,groupPullRequestsByWorkspace:()=>Ks,groupPullRequestsIntoBuckets:()=>Ms});var O=(s,t,e,r)=>({id:s,faIconName:e,name:t,priority:r,pullRequests:[]}),Gt="pinned",Tt="readyToMerge",Ot="unassignedReviewers",xt="failingCI",kt="conflicts",Nt="needsMyReview",_t="changesRequested",Bt="reviewerCommented",Qt="waitingForReview",jt="draft",Ft="other",Mt="snoozed",fr="readyToMerge",Ir="unassignedReviewers",Rr="failingCI",yr="conflicts",br="needsMyReview",wr="changesRequested",Pr="reviewerCommented",vr="waitingForReview",Er="draft",qr="other",Sr=(s,t,e)=>s.map(r=>{var u,l,p,d,c,g,m,h,R,w,f,v,$,D;let o={...r,...{suggestedActionCategory:qr,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(E=>E.id===t.id))??!1,o.viewer.isReviewer=((p=r.reviews)==null?void 0:p.some(E=>E.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(E=>E.state==="ERROR"||E.state==="FAILED"))??!1,o.commentReviewCount=((m=r.reviews)==null?void 0:m.filter(E=>E.state==="COMMENTED").length)??0,o.approvalReviewCount=((h=r.reviews)==null?void 0:h.filter(E=>E.state==="APPROVED").length)??0,o.changeRequestReviewCount=((R=r.reviews)==null?void 0:R.filter(E=>E.state==="CHANGES_REQUESTED").length)??0;let i=(w=e==null?void 0:e.enrichedItemsByUniqueId)==null?void 0:w[r.uuid];i!=null&&(o.viewer.enrichedItems=i,i.some(E=>E.type==="pin")&&(o.viewer.pinned=!0,o.priority-=800),i.some(E=>E.type==="snooze")&&(o.viewer.snoozed=!0));let a=((v=(f=e==null?void 0:e.codeSuggestionsCountByPrUuid)==null?void 0:f[r.uuid])==null?void 0:v.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=fr),(!t||o.viewer.isAuthor)&&r.isDraft&&(o.suggestedActionCategory=Er),(!t||o.viewer.isAuthor)&&r.reviewDecision==="REVIEW_REQUESTED"&&(o.suggestedActionCategory=vr,o.viewer.waitingOnReviews=!0),(!t||o.viewer.isAuthor)&&r.reviewDecision==="COMMENTED"&&(o.suggestedActionCategory=Pr),(!t||o.viewer.isAuthor)&&o.failingCI&&(o.suggestedActionCategory=Rr),(!t||o.viewer.isAuthor)&&o.hasConflicts&&(o.suggestedActionCategory=yr),(!t||o.viewer.isAuthor)&&(r.reviewDecision==="CHANGES_REQUESTED"||o.codeSuggestionsCount>0)&&(o.suggestedActionCategory=wr),(!t||o.viewer.isAuthor)&&!(($=r.reviews)!=null&&$.length)&&(o.suggestedActionCategory=Ir,o.viewer.shouldAssignReviewer=!0),t&&((D=r.reviews)!=null&&D.some(E=>E.reviewer.id===t.id&&E.state==="REVIEW_REQUESTED"))&&(o.suggestedActionCategory=br,o.viewer.shouldReview=!0),o}),Ms=(s,t,e)=>{let r={pinned:O(Gt,"Pinned","thumbtack",-1),readyToMerge:O(Tt,"Ready to Merge","code-merge",0),unassignedReviewers:O(Ot,"Unassigned Reviewers","user-plus",1),failingCI:O(xt,"Failing CI","circle-x",2),conflicts:O(kt,"Resolve Conflicts","triangle-exclamation",3),needsMyReview:O(Nt,"Needs My Review","eye",4),changesRequested:O(_t,"Suggested Changes","file-plus",5),reviewerCommented:O(Bt,"Reviewer Commented","comment",6),waitingForReview:O(Qt,"Waiting for Review","circle-pause",7),draft:O(jt,"Draft","compass-drafting",8),other:O(Ft,"Other","ellipsis",9),snoozed:O(Mt,"Snoozed","snooze",10)},o=Sr(s,t,e).reduce((i,a)=>(i[a.uuid]=a,i),{});return s.forEach(i=>{let a=o[i.uuid],u=!0;if(a.viewer.snoozed){r[Mt].pullRequests.push(i);return}a.viewer.pinned&&r[Gt].pullRequests.push(i),(!t||a.viewer.isAuthor||a.viewer.isAssignee&&!a.viewer.isReviewer)&&!a.isDraft&&a.viewer.canMerge&&a.mergeableState==="MERGEABLE"&&(!i.reviewDecision||i.reviewDecision==="APPROVED")&&(r[Tt].pullRequests.push(i),u=!1),a.viewer.shouldAssignReviewer&&(r[Ot].pullRequests.push(i),u=!1),(!t||a.viewer.isAuthor)&&a.failingCI&&(r[xt].pullRequests.push(i),u=!1),(!t||a.viewer.isAuthor)&&a.hasConflicts&&(r[kt].pullRequests.push(i),u=!1),a.viewer.shouldReview&&(r[Nt].pullRequests.push(i),u=!1),(!t||a.viewer.isAuthor)&&(a.reviewDecision==="CHANGES_REQUESTED"||a.codeSuggestionsCount>0)&&(r[_t].pullRequests.push(i),u=!1),(!t||a.viewer.isAuthor)&&a.reviewDecision==="COMMENTED"&&(r[Bt].pullRequests.push(i),u=!1),(!t||a.viewer.isAuthor)&&a.reviewDecision==="REVIEW_REQUESTED"&&(r[Qt].pullRequests.push(i),u=!1),a.isDraft&&(r[jt].pullRequests.push(i),u=!1),u&&r[Ft].pullRequests.push(i)}),Object.values(r).forEach(i=>{i.pullRequests.sort((a,u)=>o[a.uuid].priority-o[u.uuid].priority)}),r},zs=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}}),X(t)},Ws=s=>{let t="internal-no-assignees",e={[t]:{name:"No assignees",priority:-1,pullRequests:[],id:t}};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:ge(n,`Unknown Assignee ${Object.keys(e).length}`),priority:0,pullRequests:[r],id:o}}):e[t].pullRequests.push(r)}),X(e)},Hs=s=>{let t="internal-no-author",e={[t]:{name:"No author",priority:-1,pullRequests:[],id:t}};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:ge(r.author,`Unknown Author ${Object.keys(e).length}`),priority:0,pullRequests:[r],id:n}}else e[t].pullRequests.push(r)}),X(e)},Js=s=>{let t="internal-no-reviewer",e={[t]:{name:"No reviewers",priority:-1,pullRequests:[],id:t}};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:ge(n.reviewer,`Unknown Reviewer ${Object.keys(e).length}`),priority:0,pullRequests:[r],id:o}}):e[t].pullRequests.push(r)}),X(e)},Vs=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}`))??[]},Ks=(s,t)=>{let e="internal-no-workspace",r={[e]:{name:"No workspace",priority:-1,pullRequests:[],id:e}};if(t.length){let n=t.reduce((o,i)=>(Vs(i).forEach(u=>{o[u]?o[u].push(i):o[u]=[i]}),o),{});s.forEach(o=>{let{provider:i}=$t(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}}),l||r[e].pullRequests.push(o)})}else r[e].pullRequests=s;return X(r)},Xs=(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=>{if(c.members.some(m=>{var R,w;let h=(w=(R=t[m.id])==null?void 0:R[e])==null?void 0:w.providerID;return h&&u.has(h)})){a=!0;let m=c.id;o[m]?o[m].pullRequests.push(i):o[m]={name:c.name,priority:0,pullRequests:[i],id:m}}}),a||o[n].pullRequests.push(i)}):o[n].pullRequests=s,X(o)};var et={};_(et,{getPullRequestRank:()=>Ys});var Ys=(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 tt={};_(tt,{default:()=>Zs});var Zs={};var rt={};_(rt,{default:()=>en});var en={};var st={};_(st,{default:()=>tn});var tn={};var Cr=(i=>(i.Conflicts="conflicts",i.Failure="failure",i.NotSet="notSet",i.Queued="queued",i.RejectedByPolicy="rejectedByPolicy",i.Succeeded="succeeded",i))(Cr||{});var Dr=(e=>(e.Completed="COMPLETED",e.NotPlanned="NOT_PLANNED",e))(Dr||{});var rn=s=>{let t={request:s==null?void 0:s.request};return{azureDevOps:new re({...t,...s==null?void 0:s.azureDevOps}),bitbucket:new se({...t,...s==null?void 0:s.bitbucket}),bitbucketServer:new oe({...t,...s==null?void 0:s.bitbucketServer}),github:new ie({...t,...s==null?void 0:s.github}),gitlab:new ae({...t,...s==null?void 0:s.gitlab}),jira:new le({...t,...s==null?void 0:s.jira}),jiraServer:new pe({...t,...s==null?void 0:s.jiraServer}),trello:new de({...t,...s==null?void 0:s.trello})}},sn=rn;var nn={azureDevOps:Ne,bitbucket:_e,bitbucketServer:Be,github:et,gitlab:tt,gitProvider:Ze,jira:rt,trello:st,entityIdentifier:Ye};
|
|
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:`${V(s,r,o)}/rest/api/2/search?jql=${p}&startAt=${u}&maxResults=${Ce}&fields=${Ut.join(",")}&expand=transitions`,headers:I(r.token||s.token)})).body.issues.map(m=>At(m,a,e,o)),g=c.length==Ce;return{data:c,pageInfo:{hasNextPage:g,nextPage:g?u+c.length:null}}},hr=async(s,t,e,r={})=>{let{page:n,resourceId:o,jql:i,fields:a}=t||{},u=n??0,l=[...Ut],p=a==null?void 0:a.Sprint;p&&l.push(p);let c=(await s.request({url:`${V(s,r,o)}/rest/api/2/search?jql=${i.join(" AND ")}&startAt=${u}&maxResults=${Ce}&fields=${l.join(",")}&expand=transitions`,headers:I(r.token||s.token)})).body.issues.map(m=>At(m,a,e,o)),g=c.length==Ce;return{data:c,pageInfo:{hasNextPage:g,nextPage:g?u+c.length:null}}},$e=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}"`)),hr(s,{resourceId:p,jql:g,page:c,fields:d},e,r)},Ge=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(h=>`project = "${h}"`).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(h=>m.push(`labels = "${h}"`)),hr(s,{resourceId:p,jql:m,fields:d,page:c},e,r)},Te=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:`${V(s,e,r.project.resourceId??void 0)}/rest/api/2/issue/${r.id}`,body:JSON.stringify(o),headers:{...I(e.token||s.token),"Content-Type":"application/json"}})},Oe=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:`${V(s,e,r.project.resourceId??void 0)}/rest/api/2/issue/${r.id}`,body:JSON.stringify(o),headers:{...I(e.token||s.token),"Content-Type":"application/json"}})},xe=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:`${V(s,e,r.project.resourceId??void 0)}/rest/api/2/issue/${r.id}/transitions`,body:JSON.stringify(o),headers:{...I(e.token||s.token),"Content-Type":"application/json"}})},ke=async(s,t,e={})=>{let{resourceId:r,projectIdOrKey:n}=t,o=new URL(`${V(s,e,r)}/rest/api/2/project/${n}/components`);return{data:(await s.request({url:o.toString(),headers:I(e.token||s.token)})).body}};var ue="https://api.atlassian.com/ex/jira",Lt=100,le=class extends x{constructor(){super(...arguments);this._resourceUrlCache={};this._issueFieldsCache={}}async getIssueFieldsForResource(e,r={}){if(!this._issueFieldsCache[e.resourceId]){let n=await Ue(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||ue}/${e.resourceId}/rest/api/2/myself`,headers:I(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:I(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||ue}/${e.resourceId}/rest/api/2/project/search`);n.searchParams.set("maxResults",Lt.toString()),e.cursor&&n.searchParams.set("startAt",e.cursor);let o=await this.config.request({url:n.toString(),headers:I(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 Xt(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||ue}/${n}/rest/api/2/user/assignable/search`);u.searchParams.set("maxResults",Lt.toString()),i&&u.searchParams.set("startAt",i),u.searchParams.set("project",o);let l=await this.config.request({url:u.toString(),headers:I(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=>De(p,a,!1))}}async getComponentsForJiraProject(e,r={}){return await ke(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 Ae(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 $e(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 Ge(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 Le(this.config,{...e,fields:n},o,r)}async setIssueStatus(e,r={}){await xe(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||ue}/${n.project.resourceId}/rest/api/2/issue/${n.id}/assignee`,body:JSON.stringify(i),headers:{...I(r.token||this.config.token),"Content-Type":"application/json"}})}async setIssueComponents(e,r={}){await Oe(this.config,e,r)}async setIssueLabels(e,r={}){await Te(this.config,e,r)}async getLabelsForResource(e,r={}){let{resourceId:n,cursor:o}=e,i=new URL(`${r.baseUrl||ue}/${n}/rest/api/2/label`);i.searchParams.set("maxResults",Lt.toString()),o&&i.searchParams.set("startAt",o);let a=await this.config.request({url:i.toString(),headers:I(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 pe=class extends B{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 Ue(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:I((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:I((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 Ae(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 $e(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 Ge(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 Le(this.config,{...e,fields:o},n,r)}async setIssueStatus(e,r={}){await xe(this.config,e,r)}async setIssueLabels(e,r={}){await Te(this.config,e,r)}async setIssueComponents(e,r={}){await Oe(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:I(e.token||this.config.token)})).body.results.map(({displayName:n})=>({color:null,description:null,id:null,name:n}))}}async getComponentsForJiraProject(e,r={}){return await ke(this.config,e,r)}};var Q="https://api.trello.com",Ts=1e3,Os=s=>({id:s.id,username:s.username,url:s.url,name:s.fullName,email:s.email,avatarUrl:s.avatarUrl}),xs=(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}))}},de=class extends x{async getCurrentUser(t,e={}){let r=await this.config.request({url:`${e.baseUrl||Q}/1/members/me?key=${t.appKey}&token=${e.token||this.config.token}`,headers:I(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||Q}/1/members/me/boards?fields=name&key=${t.appKey}&token=${e.token||this.config.token}&filter=open`,headers:I(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||Q}/1/boards/${n}/lists?key=${r}&token=${e.token||this.config.token}`,headers:I(e.token||this.config.token)})).body}}async getAccountForId(t,e={}){let{appKey:r,memberId:n}=t,o=await this.config.request({url:`${e.baseUrl||Q}/1/members/${n}/?key=${r}&token=${e.token||this.config.token}`});return{data:Os(o.body)}}async getAccountsForTrelloBoard(t,e={}){let{appKey:r,boardId:n}=t;return{data:(await this.config.request({url:`${e.baseUrl||Q}/1/boards/${n}/members?key=${r}&token=${e.token||this.config.token}`,headers:I(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||Q}/1/search?key=${n}&query=${p}&cards_limit=${Ts}&token=${e.token||this.config.token}&card_members=true`,headers:I(e.token||this.config.token)})).body.cards.map(c=>xs(c,l||{}))}}async updateIssue(t,e,r,n){return await this.config.request({method:"PUT",url:`${n.baseUrl||Q}/1/cards/${e.id}?key=${t}&token=${n.token||this.config.token}&${r}`,headers:I(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||Q}/1/cards/${n.id}?key=${r}&token=${e.token||this.config.token}&idLabels=${encodeURIComponent(i)}`,headers:I(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||Q}/1/cards/${n.id}?key=${r}&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(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||Q}/1/boards/${n}/labels?key=${r}&token=${e.token||this.config.token}`,headers:I(e.token||this.config.token)})).body.map(i=>({color:i.color,description:null,id:i.id,name:i.name}))}}};var Ne={};_(Ne,{default:()=>ks});var ks={};var _e={};_(_e,{default:()=>Ns});var Ns={};var Be={};_(Be,{restApiPullRequestToCommonPullRequest:()=>_s});var _s=s=>ne(s);var Ye={};_(Ye,{decode:()=>$t,decodeV0:()=>Fs,encode:()=>js,validate:()=>Qs});var A=(e=>(e.Zero="0",e.One="1",e))(A||{}),L=(e=>(e.PullRequest="pr",e.Issue="issue",e))(L||{}),C=(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))(C||{});var Qe=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 je=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 Fe=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 Me=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 ze=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 We=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 He=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 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 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 Ve=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 Ke=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 Xe=(s,t)=>{if(t!=="issue"&&t!=="pr")throw new Error("unknown entityType");switch(s){case"azure":return t==="pr"?new je:new Qe;case"bitbucket":case"bitbucketServer":return t==="pr"?new Me:new Fe;case"github":case"githubEnterprise":return t==="pr"?new We:new ze;case"gitlab":case"gitlabSelfHosted":return t==="pr"?new Je:new He;case"jira":case"jiraServer":if(t==="pr")throw new Error("EntityType PullRequest is not valid for Jira");return new Ve;case"trello":if(t==="pr")throw new Error("EntityType PullRequest is not valid for Jira");return new Ke;default:throw new Error("unknown provider")}},Bs=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")},Qs=s=>{if(s.version==="0"){Bs(s);return}Xe(s.provider,s.entityType).validate(s)},js=s=>Xe(s.provider,s.entityType).encode(s),$t=s=>{let t=JSON.parse(s);if(!t||!t.length)throw new Error("invalid issue unique id");return Xe(t[0],t[1]).decode(t)},Fs=(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 Xe(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 Ze={};_(Ze,{CHANGES_REQUESTED_ACTION_CATEGORY:()=>wr,CHANGES_REQUESTED_BUCKET_ID:()=>_t,CONFLICTS_ACTION_CATEGORY:()=>yr,CONFLICTS_BUCKET_ID:()=>kt,DRAFT_ACTION_CATEGORY:()=>Er,DRAFT_BUCKET_ID:()=>jt,FAILING_CI_ACTION_CATEGORY:()=>Rr,FAILING_CI_BUCKET_ID:()=>xt,NEEDS_MY_REVIEW_ACTION_CATEGORY:()=>br,NEEDS_MY_REVIEW_BUCKET_ID:()=>Nt,OTHER_ACTION_CATEGORY:()=>qr,OTHER_BUCKET_ID:()=>Ft,PINNED_BUCKET_ID:()=>Gt,READY_TO_MERGE_ACTION_CATEGORY:()=>fr,READY_TO_MERGE_BUCKET_ID:()=>Tt,REVIEWER_COMMENTED_ACTION_CATEGORY:()=>Pr,REVIEWER_COMMENTED_BUCKET_ID:()=>Bt,SNOOZED_BUCKET_ID:()=>Mt,UNASSIGNED_REVIEWERS_ACTION_CATEGORY:()=>Ir,UNASSIGNED_REVIEWERS_BUCKET_ID:()=>Ot,WAITING_FOR_REVIEW_ACTION_CATEGORY:()=>vr,WAITING_FOR_REVIEW_BUCKET_ID:()=>Qt,getActionablePullRequests:()=>Sr,groupPullRequestsByAssignee:()=>Ws,groupPullRequestsByAuthor:()=>Hs,groupPullRequestsByGitKrakenTeam:()=>Xs,groupPullRequestsByRepo:()=>zs,groupPullRequestsByReviewer:()=>Js,groupPullRequestsByWorkspace:()=>Ks,groupPullRequestsIntoBuckets:()=>Ms});var O=(s,t,e,r)=>({id:s,faIconName:e,name:t,priority:r,pullRequests:[]}),Gt="pinned",Tt="readyToMerge",Ot="unassignedReviewers",xt="failingCI",kt="conflicts",Nt="needsMyReview",_t="changesRequested",Bt="reviewerCommented",Qt="waitingForReview",jt="draft",Ft="other",Mt="snoozed",fr="readyToMerge",Ir="unassignedReviewers",Rr="failingCI",yr="conflicts",br="needsMyReview",wr="changesRequested",Pr="reviewerCommented",vr="waitingForReview",Er="draft",qr="other",Sr=(s,t,e)=>s.map(r=>{var u,l,p,d,c,g,m,h,R,w,f,v,$,D;let o={...r,...{suggestedActionCategory:qr,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(E=>E.id===t.id))??!1,o.viewer.isReviewer=((p=r.reviews)==null?void 0:p.some(E=>E.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(E=>E.state==="ERROR"||E.state==="FAILED"))??!1,o.commentReviewCount=((m=r.reviews)==null?void 0:m.filter(E=>E.state==="COMMENTED").length)??0,o.approvalReviewCount=((h=r.reviews)==null?void 0:h.filter(E=>E.state==="APPROVED").length)??0,o.changeRequestReviewCount=((R=r.reviews)==null?void 0:R.filter(E=>E.state==="CHANGES_REQUESTED").length)??0;let i=(w=e==null?void 0:e.enrichedItemsByUniqueId)==null?void 0:w[r.uuid];i!=null&&(o.viewer.enrichedItems=i,i.some(E=>E.type==="pin")&&(o.viewer.pinned=!0,o.priority-=800),i.some(E=>E.type==="snooze")&&(o.viewer.snoozed=!0));let a=((v=(f=e==null?void 0:e.codeSuggestionsCountByPrUuid)==null?void 0:f[r.uuid])==null?void 0:v.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=fr),(!t||o.viewer.isAuthor)&&r.isDraft&&(o.suggestedActionCategory=Er),(!t||o.viewer.isAuthor)&&r.reviewDecision==="REVIEW_REQUESTED"&&(o.suggestedActionCategory=vr,o.viewer.waitingOnReviews=!0),(!t||o.viewer.isAuthor)&&r.reviewDecision==="COMMENTED"&&(o.suggestedActionCategory=Pr),(!t||o.viewer.isAuthor)&&o.failingCI&&(o.suggestedActionCategory=Rr),(!t||o.viewer.isAuthor)&&o.hasConflicts&&(o.suggestedActionCategory=yr),(!t||o.viewer.isAuthor)&&(r.reviewDecision==="CHANGES_REQUESTED"||o.codeSuggestionsCount>0)&&(o.suggestedActionCategory=wr),(!t||o.viewer.isAuthor)&&!(($=r.reviews)!=null&&$.length)&&(o.suggestedActionCategory=Ir,o.viewer.shouldAssignReviewer=!0),t&&((D=r.reviews)!=null&&D.some(E=>E.reviewer.id===t.id&&E.state==="REVIEW_REQUESTED"))&&(o.suggestedActionCategory=br,o.viewer.shouldReview=!0),o}),Ms=(s,t,e)=>{let r={pinned:O(Gt,"Pinned","thumbtack",-1),readyToMerge:O(Tt,"Ready to Merge","code-merge",0),unassignedReviewers:O(Ot,"Unassigned Reviewers","user-plus",1),failingCI:O(xt,"Failing CI","circle-x",2),conflicts:O(kt,"Resolve Conflicts","triangle-exclamation",3),needsMyReview:O(Nt,"Needs My Review","eye",4),changesRequested:O(_t,"Suggested Changes","file-plus",5),reviewerCommented:O(Bt,"Reviewer Commented","comment",6),waitingForReview:O(Qt,"Waiting for Review","circle-pause",7),draft:O(jt,"Draft","compass-drafting",8),other:O(Ft,"Other","ellipsis",9),snoozed:O(Mt,"Snoozed","snooze",10)},o=Sr(s,t,e).reduce((i,a)=>(i[a.uuid]=a,i),{});return s.forEach(i=>{let a=o[i.uuid],u=!0;if(a.viewer.snoozed){r[Mt].pullRequests.push(i);return}a.viewer.pinned&&r[Gt].pullRequests.push(i),(!t||a.viewer.isAuthor||a.viewer.isAssignee&&!a.viewer.isReviewer)&&!a.isDraft&&a.viewer.canMerge&&a.mergeableState==="MERGEABLE"&&(!i.reviewDecision||i.reviewDecision==="APPROVED")&&(r[Tt].pullRequests.push(i),u=!1),a.viewer.shouldAssignReviewer&&(r[Ot].pullRequests.push(i),u=!1),(!t||a.viewer.isAuthor)&&a.failingCI&&(r[xt].pullRequests.push(i),u=!1),(!t||a.viewer.isAuthor)&&a.hasConflicts&&(r[kt].pullRequests.push(i),u=!1),a.viewer.shouldReview&&(r[Nt].pullRequests.push(i),u=!1),(!t||a.viewer.isAuthor)&&(a.reviewDecision==="CHANGES_REQUESTED"||a.codeSuggestionsCount>0)&&(r[_t].pullRequests.push(i),u=!1),(!t||a.viewer.isAuthor)&&a.reviewDecision==="COMMENTED"&&(r[Bt].pullRequests.push(i),u=!1),(!t||a.viewer.isAuthor)&&a.reviewDecision==="REVIEW_REQUESTED"&&(r[Qt].pullRequests.push(i),u=!1),a.isDraft&&(r[jt].pullRequests.push(i),u=!1),u&&r[Ft].pullRequests.push(i)}),Object.values(r).forEach(i=>{i.pullRequests.sort((a,u)=>o[a.uuid].priority-o[u.uuid].priority)}),r},zs=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}}),X(t)},Ws=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:ge(n,`Unknown Assignee ${Object.keys(e).length}`),priority:0,pullRequests:[r],id:o}}):e[t].pullRequests.push(r)}),X(e)},Hs=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:ge(r.author,`Unknown Author ${Object.keys(e).length}`),priority:0,pullRequests:[r],id:n}}else e[t].pullRequests.push(r)}),X(e)},Js=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:ge(n.reviewer,`Unknown Reviewer ${Object.keys(e).length}`),priority:0,pullRequests:[r],id:o}}):e[t].pullRequests.push(r)}),X(e)},Vs=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}`))??[]},Ks=(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)=>(Vs(i).forEach(u=>{o[u]?o[u].push(i):o[u]=[i]}),o),{});s.forEach(o=>{let{provider:i}=$t(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 X(r)},Xs=(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(h=>{var w,f;let R=(f=(w=t[h.id])==null?void 0:w[e])==null?void 0:f.providerID;return R&&u.has(R)})){a=!0;let h=c.id;o[h]?o[h].pullRequests.push(i):o[h]={name:c.name,priority:0,pullRequests:[i],id:h,teamData:c}}}),a||o[n].pullRequests.push(i)}):o[n].pullRequests=s,X(o)};var et={};_(et,{getPullRequestRank:()=>Ys});var Ys=(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 tt={};_(tt,{default:()=>Zs});var Zs={};var rt={};_(rt,{default:()=>en});var en={};var st={};_(st,{default:()=>tn});var tn={};var Cr=(i=>(i.Conflicts="conflicts",i.Failure="failure",i.NotSet="notSet",i.Queued="queued",i.RejectedByPolicy="rejectedByPolicy",i.Succeeded="succeeded",i))(Cr||{});var Dr=(e=>(e.Completed="COMPLETED",e.NotPlanned="NOT_PLANNED",e))(Dr||{});var rn=s=>{let t={request:s==null?void 0:s.request};return{azureDevOps:new re({...t,...s==null?void 0:s.azureDevOps}),bitbucket:new se({...t,...s==null?void 0:s.bitbucket}),bitbucketServer:new oe({...t,...s==null?void 0:s.bitbucketServer}),github:new ie({...t,...s==null?void 0:s.github}),gitlab:new ae({...t,...s==null?void 0:s.gitlab}),jira:new le({...t,...s==null?void 0:s.jira}),jiraServer:new pe({...t,...s==null?void 0:s.jiraServer}),trello:new de({...t,...s==null?void 0:s.trello})}},sn=rn;var nn={azureDevOps:Ne,bitbucket:_e,bitbucketServer:Be,github:et,gitlab:tt,gitProvider:Ze,jira:rt,trello:st,entityIdentifier:Ye};
|
|
@@ -95,6 +95,8 @@ export interface PullRequestBucket extends PullRequestBucketBase {
|
|
|
95
95
|
export interface PullRequestGroupByBucket extends PullRequestBucketBase {
|
|
96
96
|
id: string;
|
|
97
97
|
accountData?: Account;
|
|
98
|
+
faIconName?: string;
|
|
99
|
+
teamData?: Team;
|
|
98
100
|
}
|
|
99
101
|
export type OrganizationMemberIdentityPrProvider = 'github' | 'gitlab' | 'bitbucket' | 'azure';
|
|
100
102
|
export type OrganizationMemberIdentityIssueProvider = 'github' | 'gitlab' | 'jira' | 'azure' | 'trello';
|
|
@@ -165,30 +167,29 @@ export interface Workspace {
|
|
|
165
167
|
id: string;
|
|
166
168
|
name: string;
|
|
167
169
|
azureOrganizationId?: string | null;
|
|
168
|
-
azureProject?: string;
|
|
170
|
+
azureProject?: string | null;
|
|
169
171
|
provider: string;
|
|
170
172
|
providerData?: {
|
|
171
173
|
repositories: {
|
|
172
174
|
nodes: {
|
|
173
175
|
name: string;
|
|
174
176
|
id: string;
|
|
175
|
-
repositoryId?: string;
|
|
176
|
-
providerOrganizationId?: string;
|
|
177
|
-
providerProjectName?: string;
|
|
177
|
+
repositoryId?: string | null;
|
|
178
|
+
providerOrganizationId?: string | null;
|
|
179
|
+
providerProjectName?: string | null;
|
|
178
180
|
}[];
|
|
179
181
|
};
|
|
180
|
-
};
|
|
182
|
+
} | null;
|
|
181
183
|
}
|
|
182
184
|
export interface OrganizationMemberIdentitiesMap {
|
|
183
|
-
[gkId: string]: {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
};
|
|
187
|
-
};
|
|
185
|
+
[gkId: string]: Record<OrganizationMemberIdentityPrProvider | OrganizationMemberIdentityIssueProvider, {
|
|
186
|
+
providerID: string;
|
|
187
|
+
}> | undefined;
|
|
188
188
|
}
|
|
189
189
|
export interface Team {
|
|
190
190
|
id: string;
|
|
191
|
-
|
|
191
|
+
iconUrl?: string | null;
|
|
192
|
+
members?: {
|
|
192
193
|
id: string;
|
|
193
194
|
}[];
|
|
194
195
|
name: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitkraken/provider-apis",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.6",
|
|
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",
|