@gitkraken/provider-apis 0.24.0 → 0.24.2
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 +12 -0
- package/dist/index.js +22 -3
- package/dist/providerUtils/gitProvider.d.ts +2 -2
- package/dist/providers/github/github.d.ts +14 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.24.2
|
|
4
|
+
|
|
5
|
+
- make the `currentUser` argument optional for `getActionablePullRequests` and `groupPullRequestsIntoBuckets`
|
|
6
|
+
|
|
7
|
+
## 0.24.1
|
|
8
|
+
|
|
9
|
+
- fixed `getJiraProjectsForResources` so that the whole function doesn't throw if some of the resources can't be accessed (Jira, Jira Server)
|
|
10
|
+
- added `getOrgMembers` function (Github)
|
|
11
|
+
|
|
3
12
|
## 0.24.0
|
|
4
13
|
|
|
5
14
|
### ⚠️ Breaking Changes
|
|
@@ -7,6 +16,7 @@
|
|
|
7
16
|
Changed some fields on the `AzureGraphAccount` to be nullish to better reflect what the Azure DevOps REST API is sending us.
|
|
8
17
|
|
|
9
18
|
Old version of the type:
|
|
19
|
+
|
|
10
20
|
```ts
|
|
11
21
|
interface AzureGraphAccount {
|
|
12
22
|
descriptor: string;
|
|
@@ -21,6 +31,7 @@ interface AzureGraphAccount {
|
|
|
21
31
|
```
|
|
22
32
|
|
|
23
33
|
New version of the type:
|
|
34
|
+
|
|
24
35
|
```ts
|
|
25
36
|
interface AzureGraphAccount {
|
|
26
37
|
descriptor: string | null;
|
|
@@ -46,6 +57,7 @@ interface AzureGraphAccount {
|
|
|
46
57
|
Previously, users of this library were expected to supply a project name as an argument to Jira's `getIssuesForProject` function. But now, users are expected to supply a project key as an argument to Jira's `getIssuesForProject` function. As such, the `project` argument used by Jira's `getIssuesForProject` function has been renamed to `projectKey`. This is because project names can contain special characters (namely, `"`) that will result in the Jira API returning an error when used in a JQL query. Project keys do not have this issue, and should be used for Jira's `getIssuesForProject` query in the future.
|
|
47
58
|
|
|
48
59
|
This is how you should fetch issues from now on:
|
|
60
|
+
|
|
49
61
|
```ts
|
|
50
62
|
const projects = await jira.getJiraProjectsForResource({
|
|
51
63
|
resourceId,
|
package/dist/index.js
CHANGED
|
@@ -321,7 +321,7 @@ query getUserForUsername($login: String! $avatarSize: Int) {
|
|
|
321
321
|
${O(!0,B(n))}
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
|
-
`,variables:{login:t.username,avatarSize:t.avatarSize}},r)).body.data)==null?void 0:a.user;if(!i)throw new Error("User not found.");return{data:N({...i,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(i.avatarUrl,i.email,r)})}}async getOrgsForCurrentUser(t={},r={}){var i
|
|
324
|
+
`,variables:{login:t.username,avatarSize:t.avatarSize}},r)).body.data)==null?void 0:a.user;if(!i)throw new Error("User not found.");return{data:N({...i,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(i.avatarUrl,i.email,r)})}}async getOrgsForCurrentUser(t={},r={}){var i;let n=await R(this.config,{query:`
|
|
325
325
|
query getOrgsForCurrentUser($cursor: String, $first: Int!) {
|
|
326
326
|
viewer {
|
|
327
327
|
organizations(first: $first after: $cursor) {
|
|
@@ -340,7 +340,26 @@ query getOrgsForCurrentUser($cursor: String, $first: Int!) {
|
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
|
-
`,variables:{cursor:t.cursor,first:S}},r);if(!
|
|
343
|
+
`,variables:{cursor:t.cursor,first:S}},r);if(!n.body.data)throw new Error(((i=n.body.errors)==null?void 0:i[0].message)||n.statusText||"Unknown error");let o=n.body.data.viewer.organizations.nodes||[];return{pageInfo:n.body.data.viewer.organizations.pageInfo,data:o.map(a=>({id:a.databaseId.toString(),graphQLId:a.id,username:a.login,name:a.name||null,email:a.email||null,avatarUrl:a.avatarUrl}))}}async getOrgMembers(t,r={}){var i,a,u;let n=await R(this.config,{query:`
|
|
344
|
+
query getOrgMember($cursor: String, $first: Int!, $login: String!) {
|
|
345
|
+
viewer {
|
|
346
|
+
organization(login: $login) {
|
|
347
|
+
membersWithRole(first: $first after: $cursor) {
|
|
348
|
+
pageInfo {
|
|
349
|
+
endCursor
|
|
350
|
+
hasNextPage
|
|
351
|
+
}
|
|
352
|
+
nodes {
|
|
353
|
+
name
|
|
354
|
+
email
|
|
355
|
+
login
|
|
356
|
+
avatarUrl
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
`,variables:{cursor:t.cursor,first:S,login:t.org}},r);if(!n.body.data)throw new Error(((i=n.body.errors)==null?void 0:i[0].message)||n.statusText||"Unknown error");if(!((u=(a=n.body.data)==null?void 0:a.viewer.organization)!=null&&u.membersWithRole))throw new Error("Could not read the members of the organization");let o=n.body.data.viewer.organization.membersWithRole.nodes||[];return{pageInfo:n.body.data.viewer.organization.membersWithRole.pageInfo,data:o.map(l=>({name:l.name||null,email:l.email||null,username:l.login||null,avatarUrl:l.avatarUrl||null}))}}async getRepo(t,r={}){var o;let n=await R(this.config,{query:`
|
|
344
363
|
query getRepo($owner: String!, $name: String!) {
|
|
345
364
|
repository(owner: $owner, name: $name) {
|
|
346
365
|
${ut}
|
|
@@ -1085,4 +1104,4 @@ query getLabelsForRepo(
|
|
|
1085
1104
|
}
|
|
1086
1105
|
}
|
|
1087
1106
|
`,variables:{fullPath:`${r}/${n}`,after:o}},t);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(Et))??[]}}};var bs="https://api.atlassian.com/ex/jira",ve=10,qt=["assignee","comment","summary","created","creator","updated","votes","issuetype","status","labels","components","project"],St=(s,e,t)=>{var o,i,a,u;let r=s.fields.assignee,n=!t;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:qe(s.fields.creator,e,n),updatedDate:new Date(s.fields.updated),assignees:r?[qe(r,e,n)]:[],description:null,repository:null,project:{name:s.fields.project.name,resourceId:t??null,key:s.fields.project.key,namespace:null,id:s.fields.project.id},state:vs(s.fields.status),statusTransitions:((o=s.transitions)==null?void 0:o.map(ws))??[],components:((i=s.fields.components)==null?void 0:i.map(Ps))??[],type:s.fields.issuetype.name,upvoteCount:((a=s.fields.votes)==null?void 0:a.votes)||0,labels:((u=s.fields.labels)==null?void 0:u.map(l=>({color:null,description:null,id:null,name:l})))??[]}},ws=s=>{let e;switch(s.to.statusCategory.name){case"To Do":e="TO_DO";break;case"In Progress":e="IN_PROGRESS";break;default:e="DONE";break}return{name:s.name,id:s.id,to:{id:s.to.id,name:s.to.name,color:s.to.statusCategory.colorName,category:e}}},Ps=s=>({description:s.description??null,id:s.id,name:s.name}),Es=(s,e,t)=>t&&s.name?`${e}/secure/ViewProfile.jspa?name=${encodeURIComponent(s.name)}`:`${e}/jira/people/${s.accountId}`,qe=(s,e,t)=>({id:(t?s.key:s.accountId)??"",name:s.displayName,email:s.emailAddress,avatarUrl:s.avatarUrls["48x48"],username:s.displayName,url:Es(s,e,t)}),vs=s=>{let e;switch(s.statusCategory.name){case"To Do":e="TO_DO";break;case"In Progress":e="IN_PROGRESS";break;default:e="DONE";break}return{id:s.id,name:s.name,color:s.statusCategory.colorName,category:e}},V=(s,e,t)=>t?`${e.baseUrl||bs}/${t}`:`${(e==null?void 0:e.baseUrl)||s.baseUrl}`,Se=async(s,e,t,r={})=>{let{number:n,resourceId:o}=e||{},i=await s.request({url:`${V(s,r,o)}/rest/api/2/issue/${n}?fields=${qt.join(",")}&expand=transitions`,headers:f(r.token||s.token)});return{data:St(i.body,t,o)}},Ce=async(s,e,t,r={})=>{let{page:n,resourceId:o}=e||{},i=n??0,a=`statusCategory != Done AND (creator = currentUser() OR assignee = currentUser()
|
|
1088
|
-
OR comment ~ currentUser() OR summary ~ currentUser() OR description ~ currentUser())`,l=(await s.request({url:`${V(s,r,o)}/rest/api/2/search?jql=${a}&startAt=${i}&maxResults=${ve}&fields=${qt.join(",")}&expand=transitions`,headers:f(r.token||s.token)})).body.issues.map(d=>St(d,t,o)),p=l.length==ve;return{data:l,pageInfo:{hasNextPage:p,nextPage:p?i+l.length:null}}},ur=async(s,e,t,r={})=>{let{page:n,resourceId:o,jql:i}=e||{},a=n??0,l=(await s.request({url:`${V(s,r,o)}/rest/api/2/search?jql=${i.join(" AND ")}&startAt=${a}&maxResults=${ve}&fields=${qt.join(",")}&expand=transitions`,headers:f(r.token||s.token)})).body.issues.map(d=>St(d,t,o)),p=l.length==ve;return{data:l,pageInfo:{hasNextPage:p,nextPage:p?a+l.length:null}}},De=async(s,e,t,r={})=>{let{assigneeLogins:n,authorLogin:o,mentionLogin:i,page:a,projectKey:u,resourceId:l}=e||{},p=a??0,d=[`project = "${u}"`,"statusCategory != Done"];return o&&d.push(`creator in ("${o}")`),n&&n.length!==0&&d.push(`assignee in ("${n.join('", "')}")`),i&&d.push(`comment ~ "${i}"`),ur(s,{resourceId:l,jql:d,page:p},t,r)},Le=async(s,e,t,r={})=>{let{assigneeLogins:n,authorLogin:o,mentionLogin:i,page:a,projectKeys:u,resourceId:l}=e||{},p=a??0,c=["("+u.map(g=>`project = "${g}"`).join(" OR ")+")","statusCategory != Done"];return o&&c.push(`creator in ("${o}")`),n&&n.length!==0&&c.push(`assignee in ("${n.join('", "')}")`),i&&c.push(`comment ~ "${i}"`),ur(s,{resourceId:l,jql:c,page:p},t,r)},Ue=async(s,e,t={})=>{let{issue:r,labels:n}=e;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,t,r.project.resourceId??void 0)}/rest/api/2/issue/${r.id}`,body:JSON.stringify(o),headers:{...f(t.token||s.token),"Content-Type":"application/json"}})},Ae=async(s,e,t={})=>{let{issue:r,components:n}=e;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,t,r.project.resourceId??void 0)}/rest/api/2/issue/${r.id}`,body:JSON.stringify(o),headers:{...f(t.token||s.token),"Content-Type":"application/json"}})},$e=async(s,e,t={})=>{let{issue:r,status:n}=e;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,t,r.project.resourceId??void 0)}/rest/api/2/issue/${r.id}/transitions`,body:JSON.stringify(o),headers:{...f(t.token||s.token),"Content-Type":"application/json"}})},Ge=async(s,e,t={})=>{let{resourceId:r,projectIdOrKey:n}=e,o=new URL(`${V(s,t,r)}/rest/api/2/project/${n}/components`);return{data:(await s.request({url:o.toString(),headers:f(t.token||s.token)})).body}};var ie="https://api.atlassian.com/ex/jira",Ct=100,ae=class extends G{constructor(){super(...arguments);this._resourceUrlCache={}}async getResourceUrl(t,r={}){var i;let n=r.token||this.config.token;if(!n)return null;let o=this._resourceUrlCache[n];return o?o[t.resourceId]??null:(await this.getJiraResourcesForCurrentUser(r),((i=this._resourceUrlCache[n])==null?void 0:i[t.resourceId])??null)}async getCurrentUserForResource(t,r={}){let n=await this.getResourceUrl({resourceId:t.resourceId},r),o=await this.config.request({url:`${r.baseUrl||ie}/${t.resourceId}/rest/api/2/myself`,headers:f(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(t={}){let r=await this.config.request({url:`${t.baseUrl||"https://api.atlassian.com/"}/oauth/token/accessible-resources`,headers:f(t.token||this.config.token)}),n=t.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(t,r={}){let n=new URL(`${r.baseUrl||ie}/${t.resourceId}/rest/api/2/project/search`);n.searchParams.set("maxResults",Ct.toString()),t.cursor&&n.searchParams.set("startAt",t.cursor);let o=await this.config.request({url:n.toString(),headers:f(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:t.resourceId}))}}async getJiraProjectsForResources(t,r={}){let n=[];return await Promise.all(t.resourceIds.map(async o=>Ht(i=>this.getJiraProjectsForResource({resourceId:o,cursor:i},r)))).then((...o)=>{o.forEach(i=>{n=n.concat(...i)})}),{data:n}}async getAccountsForJiraProject(t,r={}){let{resourceId:n,projectKey:o,cursor:i}=t,a=await this.getResourceUrl({resourceId:n},r),u=new URL(`${r.baseUrl||ie}/${n}/rest/api/2/user/assignable/search`);u.searchParams.set("maxResults",Ct.toString()),i&&u.searchParams.set("startAt",i),u.searchParams.set("project",o);let l=await this.config.request({url:u.toString(),headers:f(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=>qe(p,a,!1))}}async getComponentsForJiraProject(t,r={}){return await Ge(this.config,t,r)}async getIssue(t,r={}){let n=await this.getResourceUrl({resourceId:t.resourceId},r);return await Se(this.config,t,n,r)}async getIssuesForProject(t,r={}){let n=await this.getResourceUrl({resourceId:t.resourceId},r);return await De(this.config,t,n,r)}async getIssuesForProjects(t,r={}){let n=await this.getResourceUrl({resourceId:t.resourceId},r);return await Le(this.config,t,n,r)}async getIssuesForResourceForCurrentUser(t,r={}){let n=await this.getResourceUrl({resourceId:t.resourceId},r);return await Ce(this.config,t,n,r)}async setIssueStatus(t,r={}){await $e(this.config,t,r)}async setIssueAssignee(t,r={}){let{issue:n,assignee:o}=t;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||ie}/${n.project.resourceId}/rest/api/2/issue/${n.id}/assignee`,body:JSON.stringify(i),headers:{...f(r.token||this.config.token),"Content-Type":"application/json"}})}async setIssueComponents(t,r={}){await Ae(this.config,t,r)}async setIssueLabels(t,r={}){await Ue(this.config,t,r)}async getLabelsForResource(t,r={}){let{resourceId:n,cursor:o}=t,i=new URL(`${r.baseUrl||ie}/${n}/rest/api/2/label`);i.searchParams.set("maxResults",Ct.toString()),o&&i.searchParams.set("startAt",o);let a=await this.config.request({url:i.toString(),headers:f(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 ue=class extends k{async getCurrentUser(e={}){let t=await this.config.request({url:`${(e==null?void 0:e.baseUrl)||this.config.baseUrl}/rest/api/2/myself`,headers:f((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:f((e==null?void 0:e.token)||this.config.token)})).body.map(r=>({id:r.id,name:r.name}))}}async getIssue(e,t={}){if(!t.baseUrl)throw new Error('Jira Server requires a "baseUrl" for this function.');return await Se(this.config,e,t.baseUrl,t)}async getIssuesForProject(e,t={}){if(!t.baseUrl)throw new Error('Jira Server requires a "baseUrl" for this function.');return await De(this.config,e,t.baseUrl,t)}async getIssuesForProjects(e,t={}){if(!t.baseUrl)throw new Error('Jira Server requires a "baseUrl" for this function.');return await Le(this.config,e,t.baseUrl,t)}async getIssuesForResourceForCurrentUser(e,t={}){if(!t.baseUrl)throw new Error('Jira Server requires a "baseUrl" for this function.');return await Ce(this.config,e,t.baseUrl,t)}async setIssueStatus(e,t={}){await $e(this.config,e,t)}async setIssueLabels(e,t={}){await Ue(this.config,e,t)}async setIssueComponents(e,t={}){await Ae(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:f(e.token||this.config.token)})).body.results.map(({displayName:r})=>({color:null,description:null,id:null,name:r}))}}async getComponentsForJiraProject(e,t={}){return await Ge(this.config,e,t)}};var M="https://api.trello.com",qs=1e3,Ss=(s,e)=>{let t=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(t.toISOString()),author:null,updatedDate:new Date(s.dateLastActivity),assignees:s.idMembers.map(r=>({id:r,username:null,name:null,email:null,avatarUrl:null,url:null})),description:null,state:e[s.idList??""]?{id:s.idList,name:e[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}))}},le=class extends G{async getCurrentUser(e,t={}){let r=await this.config.request({url:`${t.baseUrl||M}/1/members/me?key=${e.appKey}&token=${t.token||this.config.token}`,headers:f(t.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(e,t={}){return{data:(await this.config.request({url:`${t.baseUrl||M}/1/members/me/boards?fields=name&key=${e.appKey}&token=${t.token||this.config.token}&filter=open`,headers:f(t.token||this.config.token)})).body.map(n=>({id:n.id,name:n.name}))}}async getListsForTrelloBoard(e,t={}){let{appKey:r,boardId:n}=e;return{data:(await this.config.request({url:`${t.baseUrl||M}/1/boards/${n}/lists?key=${r}&token=${t.token||this.config.token}`,headers:f(t.token||this.config.token)})).body}}async getAccountsForTrelloBoard(e,t={}){let{appKey:r,boardId:n}=e;return{data:(await this.config.request({url:`${t.baseUrl||M}/1/boards/${n}/members?key=${r}&token=${t.token||this.config.token}`,headers:f(t.token||this.config.token)})).body.map(i=>({id:i.id,name:i.fullName,username:i.username,email:null,avatarUrl:null,url:null}))}}async getIssuesForBoard(e,t={}){let r=["-is:archived","sort:edited"],{appKey:n,boardId:o,filterText:i,assigneeLogins:a,trelloBoardListsById:u}=e||{};a&&r.push("@me");let l=`${i?`${i}`:""}${r.join(" ")} board:${o}`;return{data:(await this.config.request({url:`${t.baseUrl||M}/1/search?key=${n}&query=${l}&cards_limit=${qs}&token=${t.token||this.config.token}`,headers:f(t.token||this.config.token)})).body.cards.map(d=>Ss(d,u||{}))}}async updateIssue(e,t,r,n){return await this.config.request({method:"PUT",url:`${n.baseUrl||M}/1/cards/${t.id}?key=${e}&token=${n.token||this.config.token}&${r}`,headers:f(n.token||this.config.token)})}async setIssueStatus(e,t={}){let{appKey:r,issue:n,status:o}=e;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,t)).body.id)throw new Error("Could not set issue status")}async setIssueAssignees(e,t={}){let{appKey:r,issue:n,assignees:o}=e,i=o.map(l=>l.id),a=`idMembers=${encodeURIComponent(i.join(","))}`;if(!(await this.updateIssue(r,n,a,t)).body.id)throw new Error("Could not set issue status")}async setIssueLabels(e,t={}){let{appKey:r,issue:n,labels:o}=e,i=o.map(u=>u.id).join(",");if(!(await this.config.request({method:"PUT",url:`${t.baseUrl||M}/1/cards/${n.id}?key=${r}&token=${t.token||this.config.token}&idLabels=${encodeURIComponent(i)}`,headers:f(t.token||this.config.token)})).body.id)throw new Error("Could not set issue status")}async setIssueArchived(e,t={}){let{appKey:r,issue:n,archived:o}=e;if(!(await this.config.request({method:"PUT",url:`${t.baseUrl||M}/1/cards/${n.id}?key=${r}&token=${t.token||this.config.token}&closed=${o}`,headers:f(t.token||this.config.token)})).body.id)throw new Error("Could not update issue archived status")}async archiveIssue(e,t={}){await this.setIssueArchived({...e,archived:!0},t)}async unArchiveIssue(e,t={}){await this.setIssueArchived({...e,archived:!1},t)}async getLabelsForBoard(e,t={}){let{appKey:r,boardId:n}=e;return{data:(await this.config.request({url:`${t.baseUrl||M}/1/boards/${n}/labels?key=${r}&token=${t.token||this.config.token}`,headers:f(t.token||this.config.token)})).body.map(i=>({color:i.color,description:null,id:i.id,name:i.name}))}}};var Te={};x(Te,{default:()=>Cs});var Cs={};var Oe={};x(Oe,{default:()=>Ds});var Ds={};var xe={};x(xe,{restApiPullRequestToCommonPullRequest:()=>Ls});var Ls=s=>re(s);var Je={};x(Je,{decode:()=>Gs,decodeV0:()=>Ts,encode:()=>$s,validate:()=>As});var D=(t=>(t.Zero="0",t.One="1",t))(D||{}),L=(t=>(t.PullRequest="pr",t.Issue="issue",t))(L||{}),U=(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))(U||{});var ke=class{constructor(){}validate(e){if(!e.organizationName)throw new Error("organizationName is required");if(!e.projectId)throw new Error("projectId is required");if(!e.entityId)throw new Error("issueId is required")}encode(e){if(this.validate(e),!e.organizationName||!e.projectId||!e.entityId)throw new Error("Missing required fields for Azure DevOps issue uniqueId");let t=[];return t.push("azure"),t.push("issue"),t.push("1"),t.push(e.domain||""),t.push(e.organizationName),t.push(e.projectId),t.push(e.entityId),JSON.stringify(t)}decode(e){if(e.length<7)throw new Error("Invalid Azure DevOps issue uniqueId, check version");return{provider:e[0],entityType:e[1],version:e[2],domain:e[3]==""?null:e[3],resourceId:null,accountOrOrgId:null,organizationName:e[4],projectId:e[5],repoId:null,entityId:e[6]}}};var Ne=class{constructor(){}validate(e){if(!e.organizationName)throw new Error("organizationName is required");if(!e.projectId)throw new Error("projectId is required");if(!e.repoId)throw new Error("repoId is required");if(!e.entityId)throw new Error("entityId is required")}encode(e){if(this.validate(e),!e.organizationName||!e.projectId||!e.repoId||!e.entityId)throw new Error("Missing required fields for Azure DevOps pull request uniqueId");let t=[];return t.push("azure"),t.push("pr"),t.push("1"),t.push(e.domain||""),t.push(e.organizationName),t.push(e.projectId),t.push(e.repoId),t.push(e.entityId),JSON.stringify(t)}decode(e){if(e.length<8)throw new Error("Invalid Azure DevOps pull request uniqueId, check version");return{provider:e[0],entityType:e[1],version:e[2],domain:e[3]==""?null:e[3],resourceId:null,accountOrOrgId:null,organizationName:e[4],projectId:e[5],repoId:e[6],entityId:e[7]}}};var _e=class{constructor(){}validate(e){if(e.domain&&e.provider=="bitbucket")throw new Error("domain is only supported for BitbucketServer");if(!e.repoId)throw new Error("repoId is required");if(!e.entityId)throw new Error("issueId is required")}encode(e){if(this.validate(e),!e.repoId||!e.entityId)throw new Error("Missing required fields for Bitbucket DevOps issue uniqueId");let t=[];return t.push(e.domain?"bitbucketServer":"bitbucket"),t.push("issue"),t.push("1"),t.push(e.domain||""),t.push(e.repoId),t.push(e.entityId),JSON.stringify(t)}decode(e){if(e.length<6)throw new Error("Invalid Bitbucket DevOps issue uniqueId, check version");return{provider:e[0],entityType:e[1],version:e[2],domain:e[3]==""?null:e[3],resourceId:null,accountOrOrgId:null,organizationName:null,projectId:null,repoId:e[4],entityId:e[5]}}};var Qe=class{constructor(){}validate(e){if(e.domain&&e.provider=="bitbucket")throw new Error("domain is only supported for BitbucketServer");if(!e.repoId)throw new Error("repoId is required");if(!e.entityId)throw new Error("entityId is required")}encode(e){if(this.validate(e),!e.repoId||!e.entityId)throw new Error("Missing required fields for Bitbucket DevOps pull request uniqueId");let t=[];return t.push(e.domain?"bitbucketServer":"bitbucket"),t.push("pr"),t.push("1"),t.push(e.domain||""),t.push(e.repoId),t.push(e.entityId),JSON.stringify(t)}decode(e){if(e.length<6)throw new Error("Invalid Bitbucket DevOps pull request uniqueId, check version");return{provider:e[0],entityType:e[1],version:e[2],domain:e[3]==""?null:e[3],resourceId:null,accountOrOrgId:null,organizationName:null,projectId:null,repoId:e[4],entityId:e[5]}}};var Be=class{constructor(){}validate(e){if(e.domain&&e.provider=="github")throw new Error("domain is only supported for GithubEnterprise");if(!e.entityId)throw new Error("entityId is required")}encode(e){if(this.validate(e),!e.entityId)throw new Error("Missing required fields for Github issue uniqueId");let t=[];return t.push(e.domain?"githubEnterprise":"github"),t.push("issue"),t.push("1"),t.push(e.domain||""),t.push(e.entityId),JSON.stringify(t)}decode(e){if(e.length<5)throw new Error("Invalid Github issue uniqueId, check version");return{provider:e[0],entityType:e[1],version:e[2],domain:e[3]==""?null:e[3],resourceId:null,accountOrOrgId:null,organizationName:null,projectId:null,repoId:null,entityId:e[4]}}};var je=class{constructor(){}validate(e){if(e.domain&&e.provider=="github")throw new Error("domain is only supported for GithubEnterprise");if(!e.entityId)throw new Error("entityId is required")}encode(e){if(this.validate(e),!e.entityId)throw new Error("Missing required fields for Github pull request uniqueId");let t=[];return t.push(e.domain?"githubEnterprise":"github"),t.push("pr"),t.push("1"),t.push(e.domain||""),t.push(e.entityId),JSON.stringify(t)}decode(e){if(e.length<5)throw new Error("Invalid Github pull request uniqueId, check version");return{provider:e[0],entityType:e[1],version:e[2],domain:e[3]==""?null:e[3],resourceId:null,accountOrOrgId:null,organizationName:null,projectId:null,repoId:null,entityId:e[4]}}};var Fe=class{constructor(){}validate(e){if(e.domain&&e.provider=="gitlab")throw new Error("domain is only supported for GitlabSelfHosted");if(!e.entityId)throw new Error("entityId is required")}encode(e){if(this.validate(e),!e.entityId)throw new Error("Missing required fields for Gitlab issue uniqueId");let t=[];return t.push(e.domain?"gitlabSelfHosted":"gitlab"),t.push("issue"),t.push("1"),t.push(e.domain||""),t.push(e.entityId),JSON.stringify(t)}decode(e){if(e.length<5)throw new Error("Invalid Gitlab issue uniqueId, check version");return{provider:e[0],entityType:e[1],version:e[2],domain:e[3]==""?null:e[3],resourceId:null,accountOrOrgId:null,organizationName:null,projectId:null,repoId:null,entityId:e[4]}}};var Me=class{constructor(){}validate(e){if(e.domain&&e.provider=="gitlab")throw new Error("domain is only supported for GitlabSelfHosted");if(!e.entityId)throw new Error("entityId is required")}encode(e){if(this.validate(e),!e.entityId)throw new Error("Missing required fields for Gitlab pull request uniqueId");let t=[];return t.push(e.domain?"gitlabSelfHosted":"gitlab"),t.push("pr"),t.push("1"),t.push(e.domain||""),t.push(e.entityId),JSON.stringify(t)}decode(e){if(e.length<5)throw new Error("Invalid Gitlab pull request uniqueId, check version");return{provider:e[0],entityType:e[1],version:e[2],domain:e[3]==""?null:e[3],resourceId:null,accountOrOrgId:null,organizationName:null,projectId:null,repoId:null,entityId:e[4]}}};var ze=class{constructor(){}validate(e){if(e.domain&&e.provider=="jira")throw new Error("domain is only supported for JiraServer");if(e.resourceId&&e.provider=="jiraServer")throw new Error("resourceId is only supported for Jira Cloud");if(!e.resourceId&&e.provider=="jira")throw new Error("resourceId is required");if(!e.projectId)throw new Error("projectId is required");if(!e.entityId)throw new Error("entityId is required")}encode(e){if(this.validate(e),!e.projectId||!e.entityId)throw new Error("Missing required fields for Jira issue uniqueId");let t=[];return t.push(e.domain?"jiraServer":"jira"),t.push("issue"),t.push("1"),t.push(e.domain||""),t.push(e.resourceId||""),t.push(e.projectId),t.push(e.entityId),JSON.stringify(t)}decode(e){if(e.length<7)throw new Error("Invalid Jira issue uniqueId, check version");return{provider:e[0],entityType:e[1],version:e[2],domain:e[3]==""?null:e[3],resourceId:e[4]==""?null:e[4],accountOrOrgId:null,organizationName:null,projectId:e[5],repoId:null,entityId:e[6]}}};var He=class{constructor(){}validate(e){if(!e.accountOrOrgId)throw new Error("accountOrOrgId is required");if(!e.projectId)throw new Error("projectId is required");if(!e.entityId)throw new Error("entityId is required")}encode(e){if(this.validate(e),!e.accountOrOrgId||!e.projectId||!e.entityId)throw new Error("Missing required fields for Trello issue uniqueId");let t=[];return t.push("trello"),t.push("issue"),t.push("1"),t.push(""),t.push(e.accountOrOrgId),t.push(e.projectId),t.push(e.entityId),JSON.stringify(t)}decode(e){if(e.length<7)throw new Error("Invalid Trello issue uniqueId, check version");return{provider:e[0],entityType:e[1],version:e[2],domain:e[3]==""?null:e[3],resourceId:null,accountOrOrgId:e[4],organizationName:null,projectId:e[5],repoId:null,entityId:e[6]}}};var We=(s,e)=>{if(!e)throw new Error("entityType is required");if(!s)throw new Error("provider is required");switch(s){case"azure":return e==="pr"?new Ne:new ke;case"bitbucket":case"bitbucketServer":return e==="pr"?new Qe:new _e;case"github":case"githubEnterprise":return e==="pr"?new je:new Be;case"gitlab":case"gitlabSelfHosted":return e==="pr"?new Me:new Fe;case"jira":case"jiraServer":if(e==="pr")throw new Error("EntityType PullRequest is not valid for Jira");return new ze;case"trello":if(e==="pr")throw new Error("EntityType PullRequest is not valid for Jira");return new He;default:throw new Error("unknown provider")}},Us=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")},As=s=>{if(s.version==="0"){Us(s);return}We(s.provider,s.entityType).validate(s)},$s=s=>We(s.provider,s.entityType).encode(s),Gs=s=>{let e=JSON.parse(s);if(!e||!e.length)throw new Error("invalid issue unique id");return We(e[0],e[1]).decode(e)},Ts=(s,e,t)=>{if(!t)throw new Error("entityID is required");try{let r=JSON.parse(t);if(!r||!r.length)throw new Error("Invalid pull request uniqueId");let n=[s,e,"0",...r];return We(s,e).decode(n)}catch{return{provider:s,entityType:e,version:"0",domain:"",resourceId:null,accountOrOrgId:null,organizationName:null,projectId:null,repoId:null,entityId:t}}};var Ve={};x(Ve,{CHANGES_REQUESTED_ACTION_CATEGORY:()=>mr,CHANGES_REQUESTED_BUCKET_ID:()=>Tt,CONFLICTS_ACTION_CATEGORY:()=>cr,CONFLICTS_BUCKET_ID:()=>$t,DRAFT_ACTION_CATEGORY:()=>Ir,DRAFT_BUCKET_ID:()=>kt,FAILING_CI_ACTION_CATEGORY:()=>dr,FAILING_CI_BUCKET_ID:()=>At,NEEDS_MY_REVIEW_ACTION_CATEGORY:()=>gr,NEEDS_MY_REVIEW_BUCKET_ID:()=>Gt,OTHER_ACTION_CATEGORY:()=>Rr,OTHER_BUCKET_ID:()=>Nt,PINNED_BUCKET_ID:()=>Dt,READY_TO_MERGE_ACTION_CATEGORY:()=>lr,READY_TO_MERGE_BUCKET_ID:()=>Lt,REVIEWER_COMMENTED_ACTION_CATEGORY:()=>hr,REVIEWER_COMMENTED_BUCKET_ID:()=>Ot,SNOOZED_BUCKET_ID:()=>_t,UNASSIGNED_REVIEWERS_ACTION_CATEGORY:()=>pr,UNASSIGNED_REVIEWERS_BUCKET_ID:()=>Ut,WAITING_FOR_REVIEW_ACTION_CATEGORY:()=>fr,WAITING_FOR_REVIEW_BUCKET_ID:()=>xt,getActionablePullRequests:()=>yr,groupPullRequestsIntoBuckets:()=>Os});var $=(s,e,t,r)=>({id:s,faIconName:t,name:e,priority:r,pullRequests:[]}),Dt="pinned",Lt="readyToMerge",Ut="unassignedReviewers",At="failingCI",$t="conflicts",Gt="needsMyReview",Tt="changesRequested",Ot="reviewerCommented",xt="waitingForReview",kt="draft",Nt="other",_t="snoozed",lr="readyToMerge",pr="unassignedReviewers",dr="failingCI",cr="conflicts",gr="needsMyReview",mr="changesRequested",hr="reviewerCommented",fr="waitingForReview",Ir="draft",Rr="other",yr=(s,e,t)=>s.map(r=>{var u,l,p,d,c,g,m,I,w,h,y,q,C,Y;let o={...r,...{suggestedActionCategory:Rr,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}};o.viewer.isAuthor=((u=r.author)==null?void 0:u.id)===e.id,o.viewer.isAssignee=((l=r.assignees)==null?void 0:l.some(E=>E.id===e.id))??!1,o.viewer.isReviewer=((p=r.reviews)==null?void 0:p.some(E=>E.reviewer.id===e.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=((I=r.reviews)==null?void 0:I.filter(E=>E.state==="APPROVED").length)??0,o.changeRequestReviewCount=((w=r.reviews)==null?void 0:w.filter(E=>E.state==="CHANGES_REQUESTED").length)??0;let i=(h=t==null?void 0:t.enrichedItemsByUniqueId)==null?void 0:h[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=((q=(y=t==null?void 0:t.codeSuggestionsCountByPrUuid)==null?void 0:y[r.uuid])==null?void 0:q.count)||0;return a&&(o.codeSuggestionsCount=a),(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=lr),o.viewer.isAuthor&&r.isDraft&&(o.suggestedActionCategory=Ir),o.viewer.isAuthor&&r.reviewDecision==="REVIEW_REQUESTED"&&(o.suggestedActionCategory=fr,o.viewer.waitingOnReviews=!0),o.viewer.isAuthor&&r.reviewDecision==="COMMENTED"&&(o.suggestedActionCategory=hr),o.viewer.isAuthor&&o.failingCI&&(o.suggestedActionCategory=dr),o.viewer.isAuthor&&o.hasConflicts&&(o.suggestedActionCategory=cr),o.viewer.isAuthor&&(r.reviewDecision==="CHANGES_REQUESTED"||o.codeSuggestionsCount>0)&&(o.suggestedActionCategory=mr),o.viewer.isAuthor&&!((C=r.reviews)!=null&&C.length)&&(o.suggestedActionCategory=pr,o.viewer.shouldAssignReviewer=!0),(Y=r.reviews)!=null&&Y.some(E=>E.reviewer.id===e.id&&E.state==="REVIEW_REQUESTED")&&(o.suggestedActionCategory=gr,o.viewer.shouldReview=!0),o}),Os=(s,e,t)=>{let r={pinned:$(Dt,"Pinned","thumbtack",-1),readyToMerge:$(Lt,"Ready to Merge","code-merge",0),unassignedReviewers:$(Ut,"Unassigned Reviewers","user-plus",1),failingCI:$(At,"Failing CI","circle-x",2),conflicts:$($t,"Resolve Conflicts","triangle-exclamation",3),needsMyReview:$(Gt,"Needs My Review","eye",4),changesRequested:$(Tt,"Suggested Changes","file-plus",5),reviewerCommented:$(Ot,"Reviewer Commented","comment",6),waitingForReview:$(xt,"Waiting for Review","circle-pause",7),draft:$(kt,"Draft","compass-drafting",8),other:$(Nt,"Other","ellipsis",9),snoozed:$(_t,"Snoozed","snooze",10)},o=yr(s,e,t).reduce((i,a)=>(i[a.uuid]=a,i),{});return s.forEach(i=>{let a=o[i.uuid],u=!0;if(a.viewer.snoozed){r[_t].pullRequests.push(i);return}a.viewer.pinned&&r[Dt].pullRequests.push(i),(a.viewer.isAuthor||a.viewer.isAssignee&&!a.viewer.isReviewer)&&!a.isDraft&&a.viewer.canMerge&&a.mergeableState==="MERGEABLE"&&(!i.reviewDecision||i.reviewDecision==="APPROVED")&&(r[Lt].pullRequests.push(i),u=!1),a.viewer.shouldAssignReviewer&&(r[Ut].pullRequests.push(i),u=!1),a.viewer.isAuthor&&a.failingCI&&(r[At].pullRequests.push(i),u=!1),a.viewer.isAuthor&&a.hasConflicts&&(r[$t].pullRequests.push(i),u=!1),a.viewer.shouldReview&&(r[Gt].pullRequests.push(i),u=!1),a.viewer.isAuthor&&(a.reviewDecision==="CHANGES_REQUESTED"||a.codeSuggestionsCount>0)&&(r[Tt].pullRequests.push(i),u=!1),a.viewer.isAuthor&&a.reviewDecision==="COMMENTED"&&(r[Ot].pullRequests.push(i),u=!1),a.viewer.isAuthor&&a.reviewDecision==="REVIEW_REQUESTED"&&(r[xt].pullRequests.push(i),u=!1),a.isDraft&&(r[kt].pullRequests.push(i),u=!1),u&&r[Nt].pullRequests.push(i)}),Object.values(r).forEach(i=>{i.pullRequests.sort((a,u)=>o[a.uuid].priority-o[u.uuid].priority)}),r};var Ke={};x(Ke,{getPullRequestRank:()=>xs});var xs=(s,e,t)=>{var i,a,u;let r=0,n,o;return(i=s.reviews)==null||i.forEach(l=>{l.reviewer.id===e&&(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)===e?r+=1e3:(u=s.assignees)!=null&&u.find(l=>l.id===e)?r+=900:n==="REVIEW_REQUESTED"?r+=800:t&&(r+=700),o==="APPROVED"?s.mergeableState==="MERGEABLE"?r+=100:s.mergeableState==="CONFLICTS"?r+=90:r+=80:o=="CHANGES_REQUESTED"&&(r+=70),r};var Xe={};x(Xe,{default:()=>ks});var ks={};var Ye={};x(Ye,{default:()=>Ns});var Ns={};var Ze={};x(Ze,{default:()=>_s});var _s={};var br=(i=>(i.Conflicts="conflicts",i.Failure="failure",i.NotSet="notSet",i.Queued="queued",i.RejectedByPolicy="rejectedByPolicy",i.Succeeded="succeeded",i))(br||{});var wr=(t=>(t.Completed="COMPLETED",t.NotPlanned="NOT_PLANNED",t))(wr||{});var Qs=s=>{let e={request:s==null?void 0:s.request};return{azureDevOps:new ee({...e,...s==null?void 0:s.azureDevOps}),bitbucket:new te({...e,...s==null?void 0:s.bitbucket}),bitbucketServer:new se({...e,...s==null?void 0:s.bitbucketServer}),github:new ne({...e,...s==null?void 0:s.github}),gitlab:new oe({...e,...s==null?void 0:s.gitlab}),jira:new ae({...e,...s==null?void 0:s.jira}),jiraServer:new ue({...e,...s==null?void 0:s.jiraServer}),trello:new le({...e,...s==null?void 0:s.trello})}},Bs=Qs;var js={azureDevOps:Te,bitbucket:Oe,bitbucketServer:xe,github:Ke,gitlab:Xe,gitProvider:Ve,jira:Ye,trello:Ze,entityIdentifier:Je};
|
|
1107
|
+
OR comment ~ currentUser() OR summary ~ currentUser() OR description ~ currentUser())`,l=(await s.request({url:`${V(s,r,o)}/rest/api/2/search?jql=${a}&startAt=${i}&maxResults=${ve}&fields=${qt.join(",")}&expand=transitions`,headers:f(r.token||s.token)})).body.issues.map(d=>St(d,t,o)),p=l.length==ve;return{data:l,pageInfo:{hasNextPage:p,nextPage:p?i+l.length:null}}},ur=async(s,e,t,r={})=>{let{page:n,resourceId:o,jql:i}=e||{},a=n??0,l=(await s.request({url:`${V(s,r,o)}/rest/api/2/search?jql=${i.join(" AND ")}&startAt=${a}&maxResults=${ve}&fields=${qt.join(",")}&expand=transitions`,headers:f(r.token||s.token)})).body.issues.map(d=>St(d,t,o)),p=l.length==ve;return{data:l,pageInfo:{hasNextPage:p,nextPage:p?a+l.length:null}}},De=async(s,e,t,r={})=>{let{assigneeLogins:n,authorLogin:o,mentionLogin:i,page:a,projectKey:u,resourceId:l}=e||{},p=a??0,d=[`project = "${u}"`,"statusCategory != Done"];return o&&d.push(`creator in ("${o}")`),n&&n.length!==0&&d.push(`assignee in ("${n.join('", "')}")`),i&&d.push(`comment ~ "${i}"`),ur(s,{resourceId:l,jql:d,page:p},t,r)},Le=async(s,e,t,r={})=>{let{assigneeLogins:n,authorLogin:o,mentionLogin:i,page:a,projectKeys:u,resourceId:l}=e||{},p=a??0,c=["("+u.map(g=>`project = "${g}"`).join(" OR ")+")","statusCategory != Done"];return o&&c.push(`creator in ("${o}")`),n&&n.length!==0&&c.push(`assignee in ("${n.join('", "')}")`),i&&c.push(`comment ~ "${i}"`),ur(s,{resourceId:l,jql:c,page:p},t,r)},Ue=async(s,e,t={})=>{let{issue:r,labels:n}=e;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,t,r.project.resourceId??void 0)}/rest/api/2/issue/${r.id}`,body:JSON.stringify(o),headers:{...f(t.token||s.token),"Content-Type":"application/json"}})},Ae=async(s,e,t={})=>{let{issue:r,components:n}=e;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,t,r.project.resourceId??void 0)}/rest/api/2/issue/${r.id}`,body:JSON.stringify(o),headers:{...f(t.token||s.token),"Content-Type":"application/json"}})},$e=async(s,e,t={})=>{let{issue:r,status:n}=e;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,t,r.project.resourceId??void 0)}/rest/api/2/issue/${r.id}/transitions`,body:JSON.stringify(o),headers:{...f(t.token||s.token),"Content-Type":"application/json"}})},Ge=async(s,e,t={})=>{let{resourceId:r,projectIdOrKey:n}=e,o=new URL(`${V(s,t,r)}/rest/api/2/project/${n}/components`);return{data:(await s.request({url:o.toString(),headers:f(t.token||s.token)})).body}};var ie="https://api.atlassian.com/ex/jira",Ct=100,ae=class extends G{constructor(){super(...arguments);this._resourceUrlCache={}}async getResourceUrl(t,r={}){var i;let n=r.token||this.config.token;if(!n)return null;let o=this._resourceUrlCache[n];return o?o[t.resourceId]??null:(await this.getJiraResourcesForCurrentUser(r),((i=this._resourceUrlCache[n])==null?void 0:i[t.resourceId])??null)}async getCurrentUserForResource(t,r={}){let n=await this.getResourceUrl({resourceId:t.resourceId},r),o=await this.config.request({url:`${r.baseUrl||ie}/${t.resourceId}/rest/api/2/myself`,headers:f(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(t={}){let r=await this.config.request({url:`${t.baseUrl||"https://api.atlassian.com/"}/oauth/token/accessible-resources`,headers:f(t.token||this.config.token)}),n=t.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(t,r={}){let n=new URL(`${r.baseUrl||ie}/${t.resourceId}/rest/api/2/project/search`);n.searchParams.set("maxResults",Ct.toString()),t.cursor&&n.searchParams.set("startAt",t.cursor);let o=await this.config.request({url:n.toString(),headers:f(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:t.resourceId}))}}async getJiraProjectsForResources(t,r={}){let n=[];return await Promise.all(t.resourceIds.map(async o=>{try{return await Ht(i=>this.getJiraProjectsForResource({resourceId:o,cursor:i},r))}catch{return[]}})).then((...o)=>{o.forEach(i=>{n=n.concat(...i)})}),{data:n}}async getAccountsForJiraProject(t,r={}){let{resourceId:n,projectKey:o,cursor:i}=t,a=await this.getResourceUrl({resourceId:n},r),u=new URL(`${r.baseUrl||ie}/${n}/rest/api/2/user/assignable/search`);u.searchParams.set("maxResults",Ct.toString()),i&&u.searchParams.set("startAt",i),u.searchParams.set("project",o);let l=await this.config.request({url:u.toString(),headers:f(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=>qe(p,a,!1))}}async getComponentsForJiraProject(t,r={}){return await Ge(this.config,t,r)}async getIssue(t,r={}){let n=await this.getResourceUrl({resourceId:t.resourceId},r);return await Se(this.config,t,n,r)}async getIssuesForProject(t,r={}){let n=await this.getResourceUrl({resourceId:t.resourceId},r);return await De(this.config,t,n,r)}async getIssuesForProjects(t,r={}){let n=await this.getResourceUrl({resourceId:t.resourceId},r);return await Le(this.config,t,n,r)}async getIssuesForResourceForCurrentUser(t,r={}){let n=await this.getResourceUrl({resourceId:t.resourceId},r);return await Ce(this.config,t,n,r)}async setIssueStatus(t,r={}){await $e(this.config,t,r)}async setIssueAssignee(t,r={}){let{issue:n,assignee:o}=t;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||ie}/${n.project.resourceId}/rest/api/2/issue/${n.id}/assignee`,body:JSON.stringify(i),headers:{...f(r.token||this.config.token),"Content-Type":"application/json"}})}async setIssueComponents(t,r={}){await Ae(this.config,t,r)}async setIssueLabels(t,r={}){await Ue(this.config,t,r)}async getLabelsForResource(t,r={}){let{resourceId:n,cursor:o}=t,i=new URL(`${r.baseUrl||ie}/${n}/rest/api/2/label`);i.searchParams.set("maxResults",Ct.toString()),o&&i.searchParams.set("startAt",o);let a=await this.config.request({url:i.toString(),headers:f(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 ue=class extends k{async getCurrentUser(e={}){let t=await this.config.request({url:`${(e==null?void 0:e.baseUrl)||this.config.baseUrl}/rest/api/2/myself`,headers:f((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:f((e==null?void 0:e.token)||this.config.token)})).body.map(r=>({id:r.id,name:r.name}))}}async getIssue(e,t={}){if(!t.baseUrl)throw new Error('Jira Server requires a "baseUrl" for this function.');return await Se(this.config,e,t.baseUrl,t)}async getIssuesForProject(e,t={}){if(!t.baseUrl)throw new Error('Jira Server requires a "baseUrl" for this function.');return await De(this.config,e,t.baseUrl,t)}async getIssuesForProjects(e,t={}){if(!t.baseUrl)throw new Error('Jira Server requires a "baseUrl" for this function.');return await Le(this.config,e,t.baseUrl,t)}async getIssuesForResourceForCurrentUser(e,t={}){if(!t.baseUrl)throw new Error('Jira Server requires a "baseUrl" for this function.');return await Ce(this.config,e,t.baseUrl,t)}async setIssueStatus(e,t={}){await $e(this.config,e,t)}async setIssueLabels(e,t={}){await Ue(this.config,e,t)}async setIssueComponents(e,t={}){await Ae(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:f(e.token||this.config.token)})).body.results.map(({displayName:r})=>({color:null,description:null,id:null,name:r}))}}async getComponentsForJiraProject(e,t={}){return await Ge(this.config,e,t)}};var M="https://api.trello.com",qs=1e3,Ss=(s,e)=>{let t=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(t.toISOString()),author:null,updatedDate:new Date(s.dateLastActivity),assignees:s.idMembers.map(r=>({id:r,username:null,name:null,email:null,avatarUrl:null,url:null})),description:null,state:e[s.idList??""]?{id:s.idList,name:e[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}))}},le=class extends G{async getCurrentUser(e,t={}){let r=await this.config.request({url:`${t.baseUrl||M}/1/members/me?key=${e.appKey}&token=${t.token||this.config.token}`,headers:f(t.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(e,t={}){return{data:(await this.config.request({url:`${t.baseUrl||M}/1/members/me/boards?fields=name&key=${e.appKey}&token=${t.token||this.config.token}&filter=open`,headers:f(t.token||this.config.token)})).body.map(n=>({id:n.id,name:n.name}))}}async getListsForTrelloBoard(e,t={}){let{appKey:r,boardId:n}=e;return{data:(await this.config.request({url:`${t.baseUrl||M}/1/boards/${n}/lists?key=${r}&token=${t.token||this.config.token}`,headers:f(t.token||this.config.token)})).body}}async getAccountsForTrelloBoard(e,t={}){let{appKey:r,boardId:n}=e;return{data:(await this.config.request({url:`${t.baseUrl||M}/1/boards/${n}/members?key=${r}&token=${t.token||this.config.token}`,headers:f(t.token||this.config.token)})).body.map(i=>({id:i.id,name:i.fullName,username:i.username,email:null,avatarUrl:null,url:null}))}}async getIssuesForBoard(e,t={}){let r=["-is:archived","sort:edited"],{appKey:n,boardId:o,filterText:i,assigneeLogins:a,trelloBoardListsById:u}=e||{};a&&r.push("@me");let l=`${i?`${i}`:""}${r.join(" ")} board:${o}`;return{data:(await this.config.request({url:`${t.baseUrl||M}/1/search?key=${n}&query=${l}&cards_limit=${qs}&token=${t.token||this.config.token}`,headers:f(t.token||this.config.token)})).body.cards.map(d=>Ss(d,u||{}))}}async updateIssue(e,t,r,n){return await this.config.request({method:"PUT",url:`${n.baseUrl||M}/1/cards/${t.id}?key=${e}&token=${n.token||this.config.token}&${r}`,headers:f(n.token||this.config.token)})}async setIssueStatus(e,t={}){let{appKey:r,issue:n,status:o}=e;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,t)).body.id)throw new Error("Could not set issue status")}async setIssueAssignees(e,t={}){let{appKey:r,issue:n,assignees:o}=e,i=o.map(l=>l.id),a=`idMembers=${encodeURIComponent(i.join(","))}`;if(!(await this.updateIssue(r,n,a,t)).body.id)throw new Error("Could not set issue status")}async setIssueLabels(e,t={}){let{appKey:r,issue:n,labels:o}=e,i=o.map(u=>u.id).join(",");if(!(await this.config.request({method:"PUT",url:`${t.baseUrl||M}/1/cards/${n.id}?key=${r}&token=${t.token||this.config.token}&idLabels=${encodeURIComponent(i)}`,headers:f(t.token||this.config.token)})).body.id)throw new Error("Could not set issue status")}async setIssueArchived(e,t={}){let{appKey:r,issue:n,archived:o}=e;if(!(await this.config.request({method:"PUT",url:`${t.baseUrl||M}/1/cards/${n.id}?key=${r}&token=${t.token||this.config.token}&closed=${o}`,headers:f(t.token||this.config.token)})).body.id)throw new Error("Could not update issue archived status")}async archiveIssue(e,t={}){await this.setIssueArchived({...e,archived:!0},t)}async unArchiveIssue(e,t={}){await this.setIssueArchived({...e,archived:!1},t)}async getLabelsForBoard(e,t={}){let{appKey:r,boardId:n}=e;return{data:(await this.config.request({url:`${t.baseUrl||M}/1/boards/${n}/labels?key=${r}&token=${t.token||this.config.token}`,headers:f(t.token||this.config.token)})).body.map(i=>({color:i.color,description:null,id:i.id,name:i.name}))}}};var Te={};x(Te,{default:()=>Cs});var Cs={};var Oe={};x(Oe,{default:()=>Ds});var Ds={};var xe={};x(xe,{restApiPullRequestToCommonPullRequest:()=>Ls});var Ls=s=>re(s);var Je={};x(Je,{decode:()=>Gs,decodeV0:()=>Ts,encode:()=>$s,validate:()=>As});var D=(t=>(t.Zero="0",t.One="1",t))(D||{}),L=(t=>(t.PullRequest="pr",t.Issue="issue",t))(L||{}),U=(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))(U||{});var ke=class{constructor(){}validate(e){if(!e.organizationName)throw new Error("organizationName is required");if(!e.projectId)throw new Error("projectId is required");if(!e.entityId)throw new Error("issueId is required")}encode(e){if(this.validate(e),!e.organizationName||!e.projectId||!e.entityId)throw new Error("Missing required fields for Azure DevOps issue uniqueId");let t=[];return t.push("azure"),t.push("issue"),t.push("1"),t.push(e.domain||""),t.push(e.organizationName),t.push(e.projectId),t.push(e.entityId),JSON.stringify(t)}decode(e){if(e.length<7)throw new Error("Invalid Azure DevOps issue uniqueId, check version");return{provider:e[0],entityType:e[1],version:e[2],domain:e[3]==""?null:e[3],resourceId:null,accountOrOrgId:null,organizationName:e[4],projectId:e[5],repoId:null,entityId:e[6]}}};var Ne=class{constructor(){}validate(e){if(!e.organizationName)throw new Error("organizationName is required");if(!e.projectId)throw new Error("projectId is required");if(!e.repoId)throw new Error("repoId is required");if(!e.entityId)throw new Error("entityId is required")}encode(e){if(this.validate(e),!e.organizationName||!e.projectId||!e.repoId||!e.entityId)throw new Error("Missing required fields for Azure DevOps pull request uniqueId");let t=[];return t.push("azure"),t.push("pr"),t.push("1"),t.push(e.domain||""),t.push(e.organizationName),t.push(e.projectId),t.push(e.repoId),t.push(e.entityId),JSON.stringify(t)}decode(e){if(e.length<8)throw new Error("Invalid Azure DevOps pull request uniqueId, check version");return{provider:e[0],entityType:e[1],version:e[2],domain:e[3]==""?null:e[3],resourceId:null,accountOrOrgId:null,organizationName:e[4],projectId:e[5],repoId:e[6],entityId:e[7]}}};var _e=class{constructor(){}validate(e){if(e.domain&&e.provider=="bitbucket")throw new Error("domain is only supported for BitbucketServer");if(!e.repoId)throw new Error("repoId is required");if(!e.entityId)throw new Error("issueId is required")}encode(e){if(this.validate(e),!e.repoId||!e.entityId)throw new Error("Missing required fields for Bitbucket DevOps issue uniqueId");let t=[];return t.push(e.domain?"bitbucketServer":"bitbucket"),t.push("issue"),t.push("1"),t.push(e.domain||""),t.push(e.repoId),t.push(e.entityId),JSON.stringify(t)}decode(e){if(e.length<6)throw new Error("Invalid Bitbucket DevOps issue uniqueId, check version");return{provider:e[0],entityType:e[1],version:e[2],domain:e[3]==""?null:e[3],resourceId:null,accountOrOrgId:null,organizationName:null,projectId:null,repoId:e[4],entityId:e[5]}}};var Qe=class{constructor(){}validate(e){if(e.domain&&e.provider=="bitbucket")throw new Error("domain is only supported for BitbucketServer");if(!e.repoId)throw new Error("repoId is required");if(!e.entityId)throw new Error("entityId is required")}encode(e){if(this.validate(e),!e.repoId||!e.entityId)throw new Error("Missing required fields for Bitbucket DevOps pull request uniqueId");let t=[];return t.push(e.domain?"bitbucketServer":"bitbucket"),t.push("pr"),t.push("1"),t.push(e.domain||""),t.push(e.repoId),t.push(e.entityId),JSON.stringify(t)}decode(e){if(e.length<6)throw new Error("Invalid Bitbucket DevOps pull request uniqueId, check version");return{provider:e[0],entityType:e[1],version:e[2],domain:e[3]==""?null:e[3],resourceId:null,accountOrOrgId:null,organizationName:null,projectId:null,repoId:e[4],entityId:e[5]}}};var Be=class{constructor(){}validate(e){if(e.domain&&e.provider=="github")throw new Error("domain is only supported for GithubEnterprise");if(!e.entityId)throw new Error("entityId is required")}encode(e){if(this.validate(e),!e.entityId)throw new Error("Missing required fields for Github issue uniqueId");let t=[];return t.push(e.domain?"githubEnterprise":"github"),t.push("issue"),t.push("1"),t.push(e.domain||""),t.push(e.entityId),JSON.stringify(t)}decode(e){if(e.length<5)throw new Error("Invalid Github issue uniqueId, check version");return{provider:e[0],entityType:e[1],version:e[2],domain:e[3]==""?null:e[3],resourceId:null,accountOrOrgId:null,organizationName:null,projectId:null,repoId:null,entityId:e[4]}}};var je=class{constructor(){}validate(e){if(e.domain&&e.provider=="github")throw new Error("domain is only supported for GithubEnterprise");if(!e.entityId)throw new Error("entityId is required")}encode(e){if(this.validate(e),!e.entityId)throw new Error("Missing required fields for Github pull request uniqueId");let t=[];return t.push(e.domain?"githubEnterprise":"github"),t.push("pr"),t.push("1"),t.push(e.domain||""),t.push(e.entityId),JSON.stringify(t)}decode(e){if(e.length<5)throw new Error("Invalid Github pull request uniqueId, check version");return{provider:e[0],entityType:e[1],version:e[2],domain:e[3]==""?null:e[3],resourceId:null,accountOrOrgId:null,organizationName:null,projectId:null,repoId:null,entityId:e[4]}}};var Fe=class{constructor(){}validate(e){if(e.domain&&e.provider=="gitlab")throw new Error("domain is only supported for GitlabSelfHosted");if(!e.entityId)throw new Error("entityId is required")}encode(e){if(this.validate(e),!e.entityId)throw new Error("Missing required fields for Gitlab issue uniqueId");let t=[];return t.push(e.domain?"gitlabSelfHosted":"gitlab"),t.push("issue"),t.push("1"),t.push(e.domain||""),t.push(e.entityId),JSON.stringify(t)}decode(e){if(e.length<5)throw new Error("Invalid Gitlab issue uniqueId, check version");return{provider:e[0],entityType:e[1],version:e[2],domain:e[3]==""?null:e[3],resourceId:null,accountOrOrgId:null,organizationName:null,projectId:null,repoId:null,entityId:e[4]}}};var Me=class{constructor(){}validate(e){if(e.domain&&e.provider=="gitlab")throw new Error("domain is only supported for GitlabSelfHosted");if(!e.entityId)throw new Error("entityId is required")}encode(e){if(this.validate(e),!e.entityId)throw new Error("Missing required fields for Gitlab pull request uniqueId");let t=[];return t.push(e.domain?"gitlabSelfHosted":"gitlab"),t.push("pr"),t.push("1"),t.push(e.domain||""),t.push(e.entityId),JSON.stringify(t)}decode(e){if(e.length<5)throw new Error("Invalid Gitlab pull request uniqueId, check version");return{provider:e[0],entityType:e[1],version:e[2],domain:e[3]==""?null:e[3],resourceId:null,accountOrOrgId:null,organizationName:null,projectId:null,repoId:null,entityId:e[4]}}};var ze=class{constructor(){}validate(e){if(e.domain&&e.provider=="jira")throw new Error("domain is only supported for JiraServer");if(e.resourceId&&e.provider=="jiraServer")throw new Error("resourceId is only supported for Jira Cloud");if(!e.resourceId&&e.provider=="jira")throw new Error("resourceId is required");if(!e.projectId)throw new Error("projectId is required");if(!e.entityId)throw new Error("entityId is required")}encode(e){if(this.validate(e),!e.projectId||!e.entityId)throw new Error("Missing required fields for Jira issue uniqueId");let t=[];return t.push(e.domain?"jiraServer":"jira"),t.push("issue"),t.push("1"),t.push(e.domain||""),t.push(e.resourceId||""),t.push(e.projectId),t.push(e.entityId),JSON.stringify(t)}decode(e){if(e.length<7)throw new Error("Invalid Jira issue uniqueId, check version");return{provider:e[0],entityType:e[1],version:e[2],domain:e[3]==""?null:e[3],resourceId:e[4]==""?null:e[4],accountOrOrgId:null,organizationName:null,projectId:e[5],repoId:null,entityId:e[6]}}};var He=class{constructor(){}validate(e){if(!e.accountOrOrgId)throw new Error("accountOrOrgId is required");if(!e.projectId)throw new Error("projectId is required");if(!e.entityId)throw new Error("entityId is required")}encode(e){if(this.validate(e),!e.accountOrOrgId||!e.projectId||!e.entityId)throw new Error("Missing required fields for Trello issue uniqueId");let t=[];return t.push("trello"),t.push("issue"),t.push("1"),t.push(""),t.push(e.accountOrOrgId),t.push(e.projectId),t.push(e.entityId),JSON.stringify(t)}decode(e){if(e.length<7)throw new Error("Invalid Trello issue uniqueId, check version");return{provider:e[0],entityType:e[1],version:e[2],domain:e[3]==""?null:e[3],resourceId:null,accountOrOrgId:e[4],organizationName:null,projectId:e[5],repoId:null,entityId:e[6]}}};var We=(s,e)=>{if(!e)throw new Error("entityType is required");if(!s)throw new Error("provider is required");switch(s){case"azure":return e==="pr"?new Ne:new ke;case"bitbucket":case"bitbucketServer":return e==="pr"?new Qe:new _e;case"github":case"githubEnterprise":return e==="pr"?new je:new Be;case"gitlab":case"gitlabSelfHosted":return e==="pr"?new Me:new Fe;case"jira":case"jiraServer":if(e==="pr")throw new Error("EntityType PullRequest is not valid for Jira");return new ze;case"trello":if(e==="pr")throw new Error("EntityType PullRequest is not valid for Jira");return new He;default:throw new Error("unknown provider")}},Us=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")},As=s=>{if(s.version==="0"){Us(s);return}We(s.provider,s.entityType).validate(s)},$s=s=>We(s.provider,s.entityType).encode(s),Gs=s=>{let e=JSON.parse(s);if(!e||!e.length)throw new Error("invalid issue unique id");return We(e[0],e[1]).decode(e)},Ts=(s,e,t)=>{if(!t)throw new Error("entityID is required");try{let r=JSON.parse(t);if(!r||!r.length)throw new Error("Invalid pull request uniqueId");let n=[s,e,"0",...r];return We(s,e).decode(n)}catch{return{provider:s,entityType:e,version:"0",domain:"",resourceId:null,accountOrOrgId:null,organizationName:null,projectId:null,repoId:null,entityId:t}}};var Ve={};x(Ve,{CHANGES_REQUESTED_ACTION_CATEGORY:()=>mr,CHANGES_REQUESTED_BUCKET_ID:()=>Tt,CONFLICTS_ACTION_CATEGORY:()=>cr,CONFLICTS_BUCKET_ID:()=>$t,DRAFT_ACTION_CATEGORY:()=>Ir,DRAFT_BUCKET_ID:()=>kt,FAILING_CI_ACTION_CATEGORY:()=>dr,FAILING_CI_BUCKET_ID:()=>At,NEEDS_MY_REVIEW_ACTION_CATEGORY:()=>gr,NEEDS_MY_REVIEW_BUCKET_ID:()=>Gt,OTHER_ACTION_CATEGORY:()=>Rr,OTHER_BUCKET_ID:()=>Nt,PINNED_BUCKET_ID:()=>Dt,READY_TO_MERGE_ACTION_CATEGORY:()=>lr,READY_TO_MERGE_BUCKET_ID:()=>Lt,REVIEWER_COMMENTED_ACTION_CATEGORY:()=>hr,REVIEWER_COMMENTED_BUCKET_ID:()=>Ot,SNOOZED_BUCKET_ID:()=>_t,UNASSIGNED_REVIEWERS_ACTION_CATEGORY:()=>pr,UNASSIGNED_REVIEWERS_BUCKET_ID:()=>Ut,WAITING_FOR_REVIEW_ACTION_CATEGORY:()=>fr,WAITING_FOR_REVIEW_BUCKET_ID:()=>xt,getActionablePullRequests:()=>yr,groupPullRequestsIntoBuckets:()=>Os});var $=(s,e,t,r)=>({id:s,faIconName:t,name:e,priority:r,pullRequests:[]}),Dt="pinned",Lt="readyToMerge",Ut="unassignedReviewers",At="failingCI",$t="conflicts",Gt="needsMyReview",Tt="changesRequested",Ot="reviewerCommented",xt="waitingForReview",kt="draft",Nt="other",_t="snoozed",lr="readyToMerge",pr="unassignedReviewers",dr="failingCI",cr="conflicts",gr="needsMyReview",mr="changesRequested",hr="reviewerCommented",fr="waitingForReview",Ir="draft",Rr="other",yr=(s,e,t)=>s.map(r=>{var u,l,p,d,c,g,m,I,w,h,y,q,C,Y;let o={...r,...{suggestedActionCategory:Rr,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}};e&&(o.viewer.isAuthor=((u=r.author)==null?void 0:u.id)===e.id,o.viewer.isAssignee=((l=r.assignees)==null?void 0:l.some(E=>E.id===e.id))??!1,o.viewer.isReviewer=((p=r.reviews)==null?void 0:p.some(E=>E.reviewer.id===e.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=((I=r.reviews)==null?void 0:I.filter(E=>E.state==="APPROVED").length)??0,o.changeRequestReviewCount=((w=r.reviews)==null?void 0:w.filter(E=>E.state==="CHANGES_REQUESTED").length)??0;let i=(h=t==null?void 0:t.enrichedItemsByUniqueId)==null?void 0:h[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=((q=(y=t==null?void 0:t.codeSuggestionsCountByPrUuid)==null?void 0:y[r.uuid])==null?void 0:q.count)||0;return a&&(o.codeSuggestionsCount=a),(!e||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=lr),(!e||o.viewer.isAuthor)&&r.isDraft&&(o.suggestedActionCategory=Ir),(!e||o.viewer.isAuthor)&&r.reviewDecision==="REVIEW_REQUESTED"&&(o.suggestedActionCategory=fr,o.viewer.waitingOnReviews=!0),(!e||o.viewer.isAuthor)&&r.reviewDecision==="COMMENTED"&&(o.suggestedActionCategory=hr),(!e||o.viewer.isAuthor)&&o.failingCI&&(o.suggestedActionCategory=dr),(!e||o.viewer.isAuthor)&&o.hasConflicts&&(o.suggestedActionCategory=cr),(!e||o.viewer.isAuthor)&&(r.reviewDecision==="CHANGES_REQUESTED"||o.codeSuggestionsCount>0)&&(o.suggestedActionCategory=mr),(!e||o.viewer.isAuthor)&&!((C=r.reviews)!=null&&C.length)&&(o.suggestedActionCategory=pr,o.viewer.shouldAssignReviewer=!0),e&&((Y=r.reviews)!=null&&Y.some(E=>E.reviewer.id===e.id&&E.state==="REVIEW_REQUESTED"))&&(o.suggestedActionCategory=gr,o.viewer.shouldReview=!0),o}),Os=(s,e,t)=>{let r={pinned:$(Dt,"Pinned","thumbtack",-1),readyToMerge:$(Lt,"Ready to Merge","code-merge",0),unassignedReviewers:$(Ut,"Unassigned Reviewers","user-plus",1),failingCI:$(At,"Failing CI","circle-x",2),conflicts:$($t,"Resolve Conflicts","triangle-exclamation",3),needsMyReview:$(Gt,"Needs My Review","eye",4),changesRequested:$(Tt,"Suggested Changes","file-plus",5),reviewerCommented:$(Ot,"Reviewer Commented","comment",6),waitingForReview:$(xt,"Waiting for Review","circle-pause",7),draft:$(kt,"Draft","compass-drafting",8),other:$(Nt,"Other","ellipsis",9),snoozed:$(_t,"Snoozed","snooze",10)},o=yr(s,e,t).reduce((i,a)=>(i[a.uuid]=a,i),{});return s.forEach(i=>{let a=o[i.uuid],u=!0;if(a.viewer.snoozed){r[_t].pullRequests.push(i);return}a.viewer.pinned&&r[Dt].pullRequests.push(i),(!e||a.viewer.isAuthor||a.viewer.isAssignee&&!a.viewer.isReviewer)&&!a.isDraft&&a.viewer.canMerge&&a.mergeableState==="MERGEABLE"&&(!i.reviewDecision||i.reviewDecision==="APPROVED")&&(r[Lt].pullRequests.push(i),u=!1),a.viewer.shouldAssignReviewer&&(r[Ut].pullRequests.push(i),u=!1),(!e||a.viewer.isAuthor)&&a.failingCI&&(r[At].pullRequests.push(i),u=!1),(!e||a.viewer.isAuthor)&&a.hasConflicts&&(r[$t].pullRequests.push(i),u=!1),a.viewer.shouldReview&&(r[Gt].pullRequests.push(i),u=!1),(!e||a.viewer.isAuthor)&&(a.reviewDecision==="CHANGES_REQUESTED"||a.codeSuggestionsCount>0)&&(r[Tt].pullRequests.push(i),u=!1),(!e||a.viewer.isAuthor)&&a.reviewDecision==="COMMENTED"&&(r[Ot].pullRequests.push(i),u=!1),(!e||a.viewer.isAuthor)&&a.reviewDecision==="REVIEW_REQUESTED"&&(r[xt].pullRequests.push(i),u=!1),a.isDraft&&(r[kt].pullRequests.push(i),u=!1),u&&r[Nt].pullRequests.push(i)}),Object.values(r).forEach(i=>{i.pullRequests.sort((a,u)=>o[a.uuid].priority-o[u.uuid].priority)}),r};var Ke={};x(Ke,{getPullRequestRank:()=>xs});var xs=(s,e,t)=>{var i,a,u;let r=0,n,o;return(i=s.reviews)==null||i.forEach(l=>{l.reviewer.id===e&&(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)===e?r+=1e3:(u=s.assignees)!=null&&u.find(l=>l.id===e)?r+=900:n==="REVIEW_REQUESTED"?r+=800:t&&(r+=700),o==="APPROVED"?s.mergeableState==="MERGEABLE"?r+=100:s.mergeableState==="CONFLICTS"?r+=90:r+=80:o=="CHANGES_REQUESTED"&&(r+=70),r};var Xe={};x(Xe,{default:()=>ks});var ks={};var Ye={};x(Ye,{default:()=>Ns});var Ns={};var Ze={};x(Ze,{default:()=>_s});var _s={};var br=(i=>(i.Conflicts="conflicts",i.Failure="failure",i.NotSet="notSet",i.Queued="queued",i.RejectedByPolicy="rejectedByPolicy",i.Succeeded="succeeded",i))(br||{});var wr=(t=>(t.Completed="COMPLETED",t.NotPlanned="NOT_PLANNED",t))(wr||{});var Qs=s=>{let e={request:s==null?void 0:s.request};return{azureDevOps:new ee({...e,...s==null?void 0:s.azureDevOps}),bitbucket:new te({...e,...s==null?void 0:s.bitbucket}),bitbucketServer:new se({...e,...s==null?void 0:s.bitbucketServer}),github:new ne({...e,...s==null?void 0:s.github}),gitlab:new oe({...e,...s==null?void 0:s.gitlab}),jira:new ae({...e,...s==null?void 0:s.jira}),jiraServer:new ue({...e,...s==null?void 0:s.jiraServer}),trello:new le({...e,...s==null?void 0:s.trello})}},Bs=Qs;var js={azureDevOps:Te,bitbucket:Oe,bitbucketServer:xe,github:Ke,gitlab:Xe,gitProvider:Ve,jira:Ye,trello:Ze,entityIdentifier:Je};
|
|
@@ -22,11 +22,11 @@ export declare const REVIEWER_COMMENTED_ACTION_CATEGORY = "reviewerCommented";
|
|
|
22
22
|
export declare const WAITING_FOR_REVIEW_ACTION_CATEGORY = "waitingForReview";
|
|
23
23
|
export declare const DRAFT_ACTION_CATEGORY = "draft";
|
|
24
24
|
export declare const OTHER_ACTION_CATEGORY = "other";
|
|
25
|
-
export declare const getActionablePullRequests: (pullRequests: PullRequestWithUniqueID[], currentUser: Pick<Account, 'id'
|
|
25
|
+
export declare const getActionablePullRequests: (pullRequests: PullRequestWithUniqueID[], currentUser: Pick<Account, 'id'> | null, options?: {
|
|
26
26
|
enrichedItemsByUniqueId?: EnrichedItemsByUniqueId;
|
|
27
27
|
codeSuggestionsCountByPrUuid?: CodeSuggestionsCountByPrUuid;
|
|
28
28
|
}) => ActionablePullRequest[];
|
|
29
|
-
export declare const groupPullRequestsIntoBuckets: (pullRequests: PullRequestWithUniqueID[], currentUser: Pick<Account, 'id'
|
|
29
|
+
export declare const groupPullRequestsIntoBuckets: (pullRequests: PullRequestWithUniqueID[], currentUser: Pick<Account, 'id'> | null, options?: {
|
|
30
30
|
enrichedItemsByUniqueId?: EnrichedItemsByUniqueId;
|
|
31
31
|
codeSuggestionsCountByPrUuid?: CodeSuggestionsCountByPrUuid;
|
|
32
32
|
}) => PullRequestBuckets;
|
|
@@ -75,6 +75,20 @@ export declare class GitHub extends EnterpriseProvider implements GitProvider, I
|
|
|
75
75
|
avatarUrl: string;
|
|
76
76
|
}[];
|
|
77
77
|
}>;
|
|
78
|
+
getOrgMembers(input: {
|
|
79
|
+
org: string;
|
|
80
|
+
} & CursorPageInput, options?: EnterpriseOptions): Promise<{
|
|
81
|
+
pageInfo: {
|
|
82
|
+
endCursor: string | null;
|
|
83
|
+
hasNextPage: boolean;
|
|
84
|
+
};
|
|
85
|
+
data: {
|
|
86
|
+
name: string | null;
|
|
87
|
+
email: string | null;
|
|
88
|
+
username: string | null;
|
|
89
|
+
avatarUrl: string | null;
|
|
90
|
+
}[];
|
|
91
|
+
}>;
|
|
78
92
|
getRepo(input: GetRepoInput, options?: EnterpriseOptions): Promise<{
|
|
79
93
|
data: GitRepository;
|
|
80
94
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitkraken/provider-apis",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.2",
|
|
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",
|