@gitkraken/provider-apis 0.12.3 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.13.0
4
+
5
+ - added `getAccountsForRepo` (GitHub, GitLab)
6
+ - added `getAzureProjectScopeDescriptor` (Azure DevOps)
7
+ - added `getAccountsForAzureProject` (Azure DevOps)
8
+ - ⚠️ This adds `js-base64` as a dependency
9
+ - added `getAccountsForJiraProject` (Jira)
10
+ - added `getAccountsForTrelloBoard` (Trello)
11
+ - improved efficiency of `getPullRequestsAssociatedWithUser` (GitHub)
12
+
13
+ ## 0.12.4
14
+
15
+ - added `mergeStrategy` argument to `mergePullRequest` (Azure, BitBucket, GitHub, GitLab)
16
+ - fixed error parsing JSON when using GitKraken Client's fetch function
17
+
3
18
  ## 0.12.3
4
19
 
5
20
  - added `getPullRequestsForUser` (BitBucket)
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Ze=Object.create;var K=Object.defineProperty;var Ye=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var tt=Object.getPrototypeOf,rt=Object.prototype.hasOwnProperty;var x=(e,r)=>{for(var t in r)K(e,t,{get:r[t],enumerable:!0})},Ae=(e,r,t,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of et(r))!rt.call(e,n)&&n!==t&&K(e,n,{get:()=>r[n],enumerable:!(s=Ye(r,n))||s.enumerable});return e};var st=(e,r,t)=>(t=e!=null?Ze(tt(e)):{},Ae(r||!e||!e.__esModule?K(t,"default",{value:e,enumerable:!0}):t,e)),nt=e=>Ae(K({},"__esModule",{value:!0}),e);var rr={};x(rr,{AzureDevOps:()=>B,AzureDevopsUtils:()=>te,Bitbucket:()=>j,BitbucketServer:()=>F,BitbucketServerUtils:()=>se,BitbucketUtils:()=>re,GitHub:()=>M,GitHubUtils:()=>ne,GitLab:()=>W,GitLabUtils:()=>oe,Jira:()=>J,JiraUtils:()=>ae,Trello:()=>V,TrelloUtils:()=>ie,Utils:()=>tr,default:()=>er});module.exports=nt(rr);var C=100;var Oe=st(require("node-fetch")),ke=globalThis.fetch||Oe.default;var _e=e=>e.name==="fetch";var ot=async e=>{let r=e.headers.get("content-type")||"",t=null;if(r.startsWith("application/json"))e.body!==null&&e.size!==0&&(t=await e.json());else if(r.startsWith("text/"))t=await e.text();else throw new Error(`Unsupported content-type: ${r}`);let s={body:t,headers:Object.fromEntries(e.headers.entries()),status:e.status,statusText:e.statusText};if(!e.ok){let n=new Error(e.statusText);throw Object.assign(n,{response:s}),n}return s},le=e=>_e(e)?async({url:r,...t})=>{let s=await e(r,t);return ot(s)}:e;var E=class{constructor(r){this.config={...r,request:le((r==null?void 0:r.request)||ke)}}updateConfig(r){this.config={...this.config,...r,request:r.request?le(r.request):this.config.request}}},T=class extends E{};var m=(e,r)=>{let t={};return e&&(t.Authorization=`${r?"Basic":"Bearer"} ${e}`),t};var w=(e,r={})=>m(r.token||e.token,r.isPAT||e.isPAT),Ne=e=>e.url.replace("/_apis/git/repositories/","/_git/").replace(`/${e.repository.project.id}/`,`/${encodeURIComponent(e.repository.project.name)}/`).replace(`/${e.repository.id}/`,`/${encodeURIComponent(e.repository.name)}/`).replace("/pullRequests/","/pullrequest/");var Qe="https://app.vssps.visualstudio.com/_apis",$="https://dev.azure.com",at={active:"OPEN",completed:"MERGED",abandoned:"CLOSED"},it={10:"APPROVED",5:"APPROVED",0:"REVIEW_REQUESTED",[-5]:"CHANGES_REQUESTED",[-10]:"CHANGES_REQUESTED"},pe=e=>({id:e.id,name:e.displayName,username:e.uniqueName||e.displayName,email:null,avatarUrl:e.imageUrl}),X=e=>e.startsWith("refs/heads/")?e.replace("refs/heads/",""):e,Be=e=>{var r;return{id:e.pullRequestId.toString(),title:e.title,number:e.codeReviewId,state:at[e.status],isDraft:e.isDraft,commentCount:null,upvoteCount:null,author:pe(e.createdBy),createdDate:new Date(e.creationDate),updatedDate:new Date(e.closedDate||e.creationDate),closedDate:e.closedDate?new Date(e.closedDate):null,repository:{name:e.repository.name,owner:{login:void 0}},headCommit:{buildStatus:null},baseRef:{name:X(e.targetRefName),oid:e.lastMergeTargetCommit.commitId},headRef:{name:X(e.sourceRefName),oid:e.lastMergeSourceCommit.commitId},url:Ne(e),assignees:e.reviewers.map(pe),reviews:e.reviewers.filter(t=>t.vote!==0).map(t=>({reviewer:pe(t),state:it[t.vote]||"REVIEW_REQUESTED"})),additions:null,deletions:null,fileCount:null,commitCount:null,headRepository:null,mergeableState:"UNKNOWN",labels:((r=e.labels)==null?void 0:r.map(t=>({color:null,description:null,id:t.id,name:t.name})))??[]}},je=(e,r)=>({id:r.id,name:r.name,namespace:e,project:r.project.name,webUrl:r.webUrl,httpsUrl:r.remoteUrl,sshUrl:r.sshUrl,defaultBranch:r.defaultBranch?{name:X(r.defaultBranch)}:null,permission:null}),ut=(e,r)=>{var i,u;let t=e.fields,s=t["System.AssignedTo"],n=t["System.State"],a=t["System.WorkItemType"],o;return n&&a&&(o=(i=r[a])==null?void 0:i[n]),{id:e.id.toString(),number:e.id.toString(),title:t["System.Title"],commentCount:t["System.CommentCount"],author:{avatarUrl:t["System.CreatedBy"]._links.avatar.href,email:null,id:t["System.CreatedBy"].id,name:t["System.CreatedBy"].uniqueName,username:t["System.CreatedBy"].displayName},createdDate:new Date(t["System.CreatedDate"]),updatedDate:new Date(t["System.ChangedDate"]),url:e._links.html.href,assignees:s?[{avatarUrl:s._links.avatar.href,email:null,id:s.id,name:s.uniqueName,username:s.displayName}]:[],description:null,state:{name:(o==null?void 0:o.title)||n,color:null},type:t["System.WorkItemType"],repository:null,upvoteCount:0,labels:((u=e.fields["System.Tags"])==null?void 0:u.split(";").map(l=>({color:null,description:null,id:null,name:l.trim()})))??[]}},B=class extends E{async getCurrentUser(r={}){if(r.isPAT||this.config.isPAT)throw new Error("Azure DevOps does not support PATs for this function.");let t=await this.config.request({url:`${Qe}/profile/profiles/me`,headers:w(this.config,r)});return{data:{id:t.body.id,name:t.body.displayName,username:t.body.displayName,email:t.body.emailAddress,avatarUrl:null}}}async getCurrentUserForInstance(r,t={}){let n=(await this.config.request({url:`${$}/${encodeURIComponent(r.namespace)}/_apis/ConnectionData`,headers:w(this.config,t)})).body.authorizedUser;if(n.providerDisplayName==="Anonymous")throw new Error("Current user not found.");return{data:{id:n.id,name:n.providerDisplayName,username:n.providerDisplayName,email:n.properties.Account.$value,avatarUrl:null}}}async getUserForCommit(r,t={}){if(!r.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let n=(await this.config.request({url:`${$}/${encodeURIComponent(r.repo.namespace)}/${encodeURIComponent(r.repo.project)}/_apis/git/repositories/${encodeURIComponent(r.repo.name)}/commits/${r.oid}`,headers:w(this.config,t)})).body.author;return{data:{name:n.name,email:n.email,avatarUrl:n.imageUrl}}}async getOrgsForUser(r,t={}){return{data:(await this.config.request({url:`${Qe}/accounts?memberId=${r.userId}&api-version=6.0`,headers:w(this.config,t)})).body.value.map(n=>({id:n.accountId,name:n.accountName}))}}async getAzureProjects(r,t={}){let s=new URL(`${$}/${encodeURIComponent(r.namespace)}/_apis/projects`);s.searchParams.set("$top",C.toString()),r.cursor&&s.searchParams.set("$skip",r.cursor);let n=await this.config.request({url:s.toString(),headers:w(this.config,t)}),a=n.headers["x-ms-continuationtoken"];return{pageInfo:{hasNextPage:!!a,endCursor:a||null},data:n.body.value.map(o=>({id:o.id,name:o.name,namespace:r.namespace}))}}async getRepo(r,t={}){if(!r.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let s=await this.config.request({url:`${$}/${encodeURIComponent(r.namespace)}/${encodeURIComponent(r.project)}/_apis/git/repositories/${encodeURIComponent(r.name)}`,headers:w(this.config,t)});return{data:je(r.namespace,s.body)}}async getRepos(r,t={}){let s=[],n=[];return await Promise.all(r.map(async a=>{try{let o=await this.getRepo(a,t);s.push(o.data)}catch(o){n.push({input:a,error:o})}})),{data:s,errors:n}}async getReposForAzureProject(r,t={}){if(!r.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');return{data:(await this.config.request({url:`${$}/${encodeURIComponent(r.namespace)}/${encodeURIComponent(r.project)}/_apis/git/repositories`,headers:w(this.config,t)})).body.value.map(n=>je(r.namespace,n))}}async getRefs(r,t,s={}){if(!t.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let n=new URL(`${$}/${encodeURIComponent(t.repo.namespace)}/${encodeURIComponent(t.repo.project)}/_apis/git/repositories/${encodeURIComponent(t.repo.name)}/refs`);n.searchParams.set("filter",r),n.searchParams.set("$top",C.toString()),t.cursor&&n.searchParams.set("continuationToken",t.cursor);let a=await this.config.request({url:n.toString(),headers:w(this.config,s)}),o=a.headers["x-ms-continuationtoken"];return{pageInfo:{hasNextPage:!!o,endCursor:o||null},data:a.body.value.map(i=>({name:X(i.name),commit:{oid:i.objectId,authoredDate:null,committedDate:null}}))}}async getBranches(r,t={}){return this.getRefs("heads",r,t)}async getTags(r,t={}){return this.getRefs("tags",r,t)}async getPullRequestsForRepoBase(r,t={},s=100){let{page:n,repo:a,assigneeLogins:o,authorLogin:i}=r||{},u=n||1;if(!a.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let l="searchCriteria.status=1";return o&&o.length&&(l+=`&searchCriteria.reviewerId=${o[0]}`),i&&(l+=`&searchCriteria.creatorId=${i}`),await this.config.request({url:`${t.baseUrl||$}/${encodeURIComponent(a.namespace)}/${encodeURIComponent(a.project||"")}/_apis/git/repositories/${encodeURIComponent(a.name)}/pullRequests?${l}&%24top=${s}&%24skip=${(u-1)*s}`,headers:w(this.config,t)})}async getPullRequestsForRepo(r,t={}){let n=r.page||1,a=await this.getPullRequestsForRepoBase(r,t,100);return{pageInfo:{hasNextPage:a.body.value.length===100,nextPage:n+1},data:a.body.value.map(Be)}}async getPullRequestsForRepos(r,t={}){if(!r.repos.every(a=>a.project))throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{repos:s}=r||{},n=[];return await Promise.all(s.map(async a=>{try{(await this.getPullRequestsForRepoBase({repo:a,...r},t)).body.value.forEach(i=>{n.push(Be(i))})}catch(o){if(o.statusCode!==404&&o.statusCode!==401)throw o}})),{data:n}}async updatePullRequest(r,t,s,n){let{namespace:a,project:o,name:i}=r;return await this.config.request({method:"PATCH",url:`${n.baseUrl||$}/${encodeURIComponent(a)}/${encodeURIComponent(o||"")}/_apis/git/repositories/${i}/pullrequests/${t}?api-version=6.0`,body:s,headers:{...w(this.config,n),"Content-Type":"application/json"}})}async closePullRequest(r,t={}){if(!r.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{repo:s,pullRequestId:n}=r,a={status:"abandoned"};if(!(await this.updatePullRequest(s,n,JSON.stringify(a),t)).body.status)throw new Error("Could not close pull request")}async mergePullRequest(r,t={}){if(!r.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{repo:s,pullRequestId:n,expectedSourceSha:a}=r,o={lastMergeSourceCommit:{commitId:a},status:"completed"};if(!(await this.updatePullRequest(s,n,JSON.stringify(o),t)).body.status)throw new Error("Could not merge pull request")}async setPullRequestAsDraft(r,t={}){if(!r.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{repo:s,pullRequestId:n,isDraft:a}=r,o={isDraft:a};if(!(await this.updatePullRequest(s,n,JSON.stringify(o),t)).body.status)throw new Error("Could not set the pull request as draft")}async getIssuesForAzureProject(r,t={}){let{page:s,assigneeLogins:n,authorLogin:a,mentionLogin:o,statusByWorkItemIdByStatusId:i}=r||{},u=s||1,l=200,p=["[Microsoft.VSTS.Common.ClosedDate] = ''","[System.TeamProject] = @project","[Microsoft.VSTS.Common.ResolvedDate] = ''"];a&&p.push(`[System.CreatedBy] = '${a.replace("'","''")}'`),n&&n[0]&&p.push(`[System.AssignedTo] = '${n[0].replace("'","''")}'`),o&&p.push("[System.Id] IN (@recentMentions)");let d=`Select [Microsoft.VSTS.Common.ClosedDate], [Microsoft.VSTS.Common.ResolvedDate] From WorkItems Where ${p.join(" AND ")} order by [System.CreatedDate] desc`,c=await this.config.request({url:`${t.baseUrl||$}/${encodeURIComponent(r.namespace)}/${encodeURIComponent(r.project)}/_apis/wit/wiql?api-version=6.0`,body:JSON.stringify({query:d}),method:"POST",headers:{...w(this.config,t),"Content-Type":"application/json"}}),g=c.body.workItems.slice((u-1)*l,l*u).map(I=>I.id);if(g.length==0)return{pageInfo:{hasNextPage:!1,nextPage:null},data:[]};let R=await this.config.request({url:`${t.baseUrl||$}/${encodeURIComponent(r.namespace)}/${encodeURIComponent(r.project)}/_apis/wit/workitemsbatch?api-version=6.0`,body:JSON.stringify({ids:g,$expand:"Links"}),method:"POST",headers:{...w(this.config,t),"Content-Type":"application/json"}});return{pageInfo:{hasNextPage:c.body.workItems.length>l*u,nextPage:u+1},data:R.body.value.map(I=>ut(I,i||{}))}}async setIssueStatus(r,t={}){var l;if(!r.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{namespace:s,project:n,issueId:a,status:o}=r,i=[{op:"add",path:"/fields/System.State",value:o}];if(!((l=(await this.config.request({method:"PATCH",url:`${t.baseUrl||$}/${encodeURIComponent(s)}/${encodeURIComponent(n||"")}/_apis/wit/workitems/${a}?api-version=6.0`,body:JSON.stringify(i),headers:{...w(this.config,t),"Content-Type":"application/json-patch+json"}})).body.fields)!=null&&l["System.State"]))throw new Error("Could not set issue status")}async getIssueTypesForAzureProject(r,t={}){if(!r.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{namespace:s,project:n}=r;return{data:(await this.config.request({url:`${t.baseUrl||$}/${encodeURIComponent(s)}/${encodeURIComponent(n||"")}/_apis/wit/workitemtypes?api-version=6.0`,headers:{...w(this.config,t)}})).body.value}}async getLabelsForProject(r,t={}){let{namespace:s,project:n}=r;return{data:(await this.config.request({url:`${t.baseUrl||$}/${encodeURIComponent(s)}/${encodeURIComponent(n||"")}/_apis/wit/tags?api-version=6.0`,headers:{...w(this.config,t)}})).body.value.map(o=>({color:null,description:null,id:o.id,name:o.name}))}}};var S=(e,r={})=>m(r.token||e.token,r.isPAT||e.isPAT);var U="https://api.bitbucket.org/2.0",lt={OPEN:"OPEN",MERGED:"MERGED",DECLINED:"CLOSED"},Me=e=>({id:e.uuid,name:e.display_name||e.nickname,username:e.nickname||e.display_name,email:null,avatarUrl:e.links.avatar.href}),Fe=e=>{var r,t;return{id:e.uuid,namespace:e.workspace.slug,name:e.slug,webUrl:e.links.html.href,httpsUrl:((r=e.links.clone.find(s=>s.name==="https"))==null?void 0:r.href)??null,sshUrl:((t=e.links.clone.find(s=>s.name==="ssh"))==null?void 0:t.href)??null,defaultBranch:{name:e.mainbranch.name},permission:null}},ge=e=>{let r=e.id;return{id:r.toString(),title:e.title,number:r,state:lt[e.state],isDraft:!1,commentCount:e.comment_count,upvoteCount:null,author:Me(e.author),createdDate:new Date(e.created_on),updatedDate:new Date(e.updated_on),closedDate:null,repository:{name:e.source.repository.name,owner:{login:void 0}},headCommit:{buildStatus:null},baseRef:{name:e.destination.branch.name,oid:e.destination.commit.hash},headRef:{name:e.source.branch.name,oid:e.source.commit.hash},url:e.links.html.href,assignees:null,reviews:null,additions:null,deletions:null,fileCount:null,commitCount:null,headRepository:null,mergeableState:"UNKNOWN"}},j=class extends E{async refreshToken(r){return{data:(await this.config.request({url:"https://bitbucket.org/site/oauth2/access_token",method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:`Basic ${r.base64ClientIDColonClientSecret}`},body:`grant_type=refresh_token&refresh_token=${r.refreshToken}`})).body}}async getCurrentUser(r={}){let t=await this.config.request({url:`${U}/user`,headers:S(this.config,r)});return{data:Me(t.body)}}async getUserForCommit(r,t={}){var o;let n=(await this.config.request({url:`${U}/repositories/${r.repo.namespace}/${r.repo.name}/commit/${r.oid}`,headers:S(this.config,t)})).body.author,a=n.raw.match(/([^<]+)<(.+)>/);return{data:{name:a?a[1].trim():null,email:a?a[2]:null,avatarUrl:((o=n.user)==null?void 0:o.links.avatar.href)||null}}}async getRepo(r,t={}){let s=await this.config.request({url:`${U}/repositories/${r.namespace}/${r.name}`,headers:S(this.config,t)});return{data:Fe(s.body)}}async getRepos(r,t={}){let s=[],n=[];return await Promise.all(r.map(async a=>{try{let o=await this.getRepo(a,t);s.push(o.data)}catch(o){n.push({input:a,error:o})}})),{data:s,errors:n}}async getReposForCurrentUser(r={},t={}){let s=new URL(`${U}/repositories`);s.searchParams.set("role","member"),s.searchParams.set("pagelen",C.toString()),r.cursor&&s.searchParams.set("after",r.cursor);let n=await this.config.request({url:s.toString(),headers:S(this.config,t)}),a=!!n.body.next,o=null;return n.body.next&&(o=new URL(n.body.next).searchParams.get("after")),{pageInfo:{hasNextPage:a,endCursor:o},data:n.body.values.map(Fe)}}async getBranches(r,t={}){var o;let s=new URL(`${U}/repositories/${r.repo.namespace}/${r.repo.name}/refs/branches`);s.searchParams.set("page",((o=r.page)==null?void 0:o.toString())||"1"),s.searchParams.set("pagelen",C.toString());let n=await this.config.request({url:s.toString(),headers:S(this.config,t)}),a=!!n.body.next;return{pageInfo:{hasNextPage:a,nextPage:a?n.body.page+1:null},data:n.body.values.map(i=>{let u=new Date(i.target.date);return{name:i.name,commit:{oid:i.target.hash,authoredDate:u,committedDate:u}}})}}async getTags(r,t={}){let s=new URL(`${U}/repositories/${r.repo.namespace}/${r.repo.name}/refs/tags`);s.searchParams.set("pagelen",C.toString()),r.cursor&&s.searchParams.set("page",r.cursor);let n=await this.config.request({url:s.toString(),headers:S(this.config,t)}),a=!!n.body.next,o=null;return n.body.next&&(o=new URL(n.body.next).searchParams.get("page")),{pageInfo:{hasNextPage:a,endCursor:o},data:n.body.values.map(i=>{let u=new Date(i.target.date);return{name:i.name,commit:{oid:i.target.hash,authoredDate:u,committedDate:u}}})}}async getPullRequestsForUser(r,t={}){var o;let s=new URL(`${U}/pullrequests/${r.userId}`);s.searchParams.set("page",((o=r.page)==null?void 0:o.toString())||"1"),s.searchParams.set("pagelen","50");let n=await this.config.request({url:`${U}/pullrequests/${r.userId}`,headers:S(this.config,t)}),a=!!n.body.next;return{pageInfo:{hasNextPage:a,nextPage:a?n.body.page+1:null},data:n.body.values.map(ge)}}async getPullRequestsForRepoBase(r,t={}){var n;let s=new URL(`${U}/repositories/${encodeURI(r.repo.namespace)}/${encodeURI(r.repo.name)}/pullrequests?state=OPEN`);return s.searchParams.set("page",((n=r.page)==null?void 0:n.toString())||"1"),s.searchParams.set("pagelen","50"),await this.config.request({url:s.toString(),headers:S(this.config,t)})}async getPullRequestsForRepo(r,t={}){let s=[],n=await this.getPullRequestsForRepoBase(r,t);n.body.values.forEach(o=>{if(r.authorLogin&&o.author.uuid!==r.authorLogin)return null;s.push(ge(o))});let a=!!n.body.next;return{pageInfo:{hasNextPage:a,nextPage:a?n.body.page+1:null},data:s}}async getPullRequestsForRepos(r,t={}){let s=[];return await Promise.all(r.repos.map(async n=>{try{(await this.getPullRequestsForRepoBase({repo:n,...r},t)).body.values.forEach(o=>{if(r.authorLogin&&o.author.uuid!==r.authorLogin)return null;s.push(ge(o))})}catch(a){if(a.statusCode!==404&&a.statusCode!==401)throw a}})),{data:s}}async closePullRequest(r,t={}){let{repo:{namespace:s,name:n},pullRequestId:a}=r;if(!(await this.config.request({method:"POST",url:`${U}/repositories/${s}/${n}/pullrequests/${a}/decline`,headers:S(this.config,t)})).body.title)throw new Error("Could not close pull request")}async mergePullRequest(r,t={}){let{repo:{namespace:s,name:n},pullRequestId:a}=r;if(!(await this.config.request({method:"POST",url:`${U}/repositories/${s}/${n}/pullrequests/${a}/merge`,headers:S(this.config,t)})).body.title)throw new Error("Could not merge pull request")}};var F=class extends T{getBaseUrl(r){let t=r.baseUrl||this.config.baseUrl;if(!t)throw new Error('Bitbucket Server requires "baseUrl"');return t}getRequestHeaders(r){return m(r.token||this.config.token)}async getRepo(r,t={}){var n,a,o;let s=await this.config.request({url:`${this.getBaseUrl(t)}/projects/${r.namespace}/repos/${r.name}`,headers:this.getRequestHeaders(t)});return{data:{id:s.body.id.toString(),namespace:s.body.project.key,name:s.body.slug,webUrl:((n=s.body.links.self[0])==null?void 0:n.href)??null,httpsUrl:((a=s.body.links.clone.find(i=>i.name==="https"))==null?void 0:a.href)??null,sshUrl:((o=s.body.links.clone.find(i=>i.name==="ssh"))==null?void 0:o.href)??null,defaultBranch:null,permission:null}}}async getRepos(r,t={}){let s=[],n=[];return await Promise.all(r.map(async a=>{try{let o=await this.getRepo(a,t);s.push(o.data)}catch(o){n.push({input:a,error:o})}})),{data:s,errors:n}}};var me="https://api.github.com",pt=`${me}/graphql`,Y=`
1
+ "use strict";var et=Object.create;var K=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var st=Object.getPrototypeOf,nt=Object.prototype.hasOwnProperty;var A=(e,r)=>{for(var t in r)K(e,t,{get:r[t],enumerable:!0})},Oe=(e,r,t,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of rt(r))!nt.call(e,n)&&n!==t&&K(e,n,{get:()=>r[n],enumerable:!(s=tt(r,n))||s.enumerable});return e};var at=(e,r,t)=>(t=e!=null?et(st(e)):{},Oe(r||!e||!e.__esModule?K(t,"default",{value:e,enumerable:!0}):t,e)),ot=e=>Oe(K({},"__esModule",{value:!0}),e);var ar={};A(ar,{AzureDevOps:()=>B,AzureDevopsUtils:()=>re,Bitbucket:()=>F,BitbucketServer:()=>M,BitbucketServerUtils:()=>ne,BitbucketUtils:()=>se,GitHub:()=>z,GitHubUtils:()=>ae,GitLab:()=>H,GitLabUtils:()=>oe,Jira:()=>J,JiraUtils:()=>ie,Trello:()=>V,TrelloUtils:()=>ue,Utils:()=>nr,default:()=>sr});module.exports=ot(ar);var Me=require("js-base64");var S=100;var ke=at(require("node-fetch")),_e=globalThis.fetch||ke.default;var Ne=e=>e.name==="fetch";var it=async e=>{let r=e.headers.get("content-type")||"",t=null;if(r.startsWith("application/json")){let n=await e.text();t=n.trim().length>0?JSON.parse(n):null}else if(r.startsWith("text/"))t=await e.text();else throw new Error(`Unsupported content-type: ${r}`);let s={body:t,headers:Object.fromEntries(e.headers.entries()),status:e.status,statusText:e.statusText};if(!e.ok){let n=new Error(e.statusText);throw Object.assign(n,{response:s}),n}return s},pe=e=>Ne(e)?async({url:r,...t})=>{let s=await e(r,t);return it(s)}:e;var v=class{constructor(r){this.config={...r,request:pe((r==null?void 0:r.request)||_e)}}updateConfig(r){this.config={...this.config,...r,request:r.request?pe(r.request):this.config.request}}},T=class extends v{};var m=(e,r)=>{let t={};return e&&(t.Authorization=`${r?"Basic":"Bearer"} ${e}`),t};var P=(e,r={})=>m(r.token||e.token,r.isPAT||e.isPAT),Qe=e=>e.url.replace("/_apis/git/repositories/","/_git/").replace(`/${e.repository.project.id}/`,`/${encodeURIComponent(e.repository.project.name)}/`).replace(`/${e.repository.id}/`,`/${encodeURIComponent(e.repository.name)}/`).replace("/pullRequests/","/pullrequest/");var je="https://app.vssps.visualstudio.com/_apis",U="https://dev.azure.com",ut={active:"OPEN",completed:"MERGED",abandoned:"CLOSED"},lt={10:"APPROVED",5:"APPROVED",0:"REVIEW_REQUESTED",[-5]:"CHANGES_REQUESTED",[-10]:"CHANGES_REQUESTED"},de=e=>({id:e.id,name:e.displayName,username:e.uniqueName||e.displayName,email:null,avatarUrl:e.imageUrl}),X=e=>e.startsWith("refs/heads/")?e.replace("refs/heads/",""):e,Be=e=>{var r;return{id:e.pullRequestId.toString(),title:e.title,number:e.codeReviewId,state:ut[e.status],isDraft:e.isDraft,commentCount:null,upvoteCount:null,author:de(e.createdBy),createdDate:new Date(e.creationDate),updatedDate:new Date(e.closedDate||e.creationDate),closedDate:e.closedDate?new Date(e.closedDate):null,repository:{name:e.repository.name,owner:{login:void 0}},headCommit:{buildStatus:null},baseRef:{name:X(e.targetRefName),oid:e.lastMergeTargetCommit.commitId},headRef:{name:X(e.sourceRefName),oid:e.lastMergeSourceCommit.commitId},url:Qe(e),assignees:e.reviewers.map(de),reviews:e.reviewers.filter(t=>t.vote!==0).map(t=>({reviewer:de(t),state:lt[t.vote]||"REVIEW_REQUESTED"})),additions:null,deletions:null,fileCount:null,commitCount:null,headRepository:null,mergeableState:"UNKNOWN",labels:((r=e.labels)==null?void 0:r.map(t=>({color:null,description:null,id:t.id,name:t.name})))??[]}},Fe=(e,r)=>({id:r.id,name:r.name,namespace:e,project:r.project.name,webUrl:r.webUrl,httpsUrl:r.remoteUrl,sshUrl:r.sshUrl,defaultBranch:r.defaultBranch?{name:X(r.defaultBranch)}:null,permission:null}),pt=(e,r)=>{var i,u;let t=e.fields,s=t["System.AssignedTo"],n=t["System.State"],o=t["System.WorkItemType"],a;return n&&o&&(a=(i=r[o])==null?void 0:i[n]),{id:e.id.toString(),number:e.id.toString(),title:t["System.Title"],commentCount:t["System.CommentCount"],author:{avatarUrl:t["System.CreatedBy"]._links.avatar.href,email:null,id:t["System.CreatedBy"].id,name:t["System.CreatedBy"].uniqueName,username:t["System.CreatedBy"].displayName},createdDate:new Date(t["System.CreatedDate"]),updatedDate:new Date(t["System.ChangedDate"]),url:e._links.html.href,assignees:s?[{avatarUrl:s._links.avatar.href,email:null,id:s.id,name:s.uniqueName,username:s.displayName}]:[],description:null,state:{name:(a==null?void 0:a.title)||n,color:null},type:t["System.WorkItemType"],repository:null,upvoteCount:0,labels:((u=e.fields["System.Tags"])==null?void 0:u.split(";").map(l=>({color:null,description:null,id:null,name:l.trim()})))??[]}},B=class extends v{async getCurrentUser(r={}){if(r.isPAT||this.config.isPAT)throw new Error("Azure DevOps does not support PATs for this function.");let t=await this.config.request({url:`${je}/profile/profiles/me`,headers:P(this.config,r)});return{data:{id:t.body.id,name:t.body.displayName,username:t.body.displayName,email:t.body.emailAddress,avatarUrl:null}}}async getCurrentUserForInstance(r,t={}){let n=(await this.config.request({url:`${U}/${encodeURIComponent(r.namespace)}/_apis/ConnectionData`,headers:P(this.config,t)})).body.authorizedUser;if(n.providerDisplayName==="Anonymous")throw new Error("Current user not found.");return{data:{id:n.id,name:n.providerDisplayName,username:n.providerDisplayName,email:n.properties.Account.$value,avatarUrl:null}}}async getUserForCommit(r,t={}){if(!r.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let n=(await this.config.request({url:`${U}/${encodeURIComponent(r.repo.namespace)}/${encodeURIComponent(r.repo.project)}/_apis/git/repositories/${encodeURIComponent(r.repo.name)}/commits/${r.oid}`,headers:P(this.config,t)})).body.author;return{data:{name:n.name,email:n.email,avatarUrl:n.imageUrl}}}async getOrgsForUser(r,t={}){return{data:(await this.config.request({url:`${je}/accounts?memberId=${r.userId}&api-version=6.0`,headers:P(this.config,t)})).body.value.map(n=>({id:n.accountId,name:n.accountName}))}}async getAzureProjects(r,t={}){let s=new URL(`${U}/${encodeURIComponent(r.namespace)}/_apis/projects`);s.searchParams.set("$top",S.toString()),r.cursor&&s.searchParams.set("$skip",r.cursor);let n=await this.config.request({url:s.toString(),headers:P(this.config,t)}),o=n.headers["x-ms-continuationtoken"];return{pageInfo:{hasNextPage:!!o,endCursor:o||null},data:n.body.value.map(a=>({id:a.id,name:a.name,namespace:r.namespace}))}}async getAzureProjectScopeDescriptor(r,t={}){let{namespace:s,projectId:n}=r;return{data:{scope:(await this.config.request({url:`https://vssps.dev.azure.com/${encodeURIComponent(s)}/_apis/graph/descriptors/${n}?api-version=6.0`,headers:P(this.config,t)})).body.value}}}async getAccountsForAzureProject(r,t={}){let{namespace:s,projectScopeDescriptor:n}=r,o=new URL(`https://vssps.dev.azure.com/${encodeURIComponent(s)}/_apis/graph/users`);return n&&o.searchParams.set("scopeDescriptor",n),{data:(await this.config.request({url:o.toString(),headers:P(this.config,t)})).body.value.map(i=>{var u;return{id:Me.Base64.decode(i.descriptor.replace(/.+?\./,"")),name:i.displayName,username:i.displayName,email:i.mailAddress,avatarUrl:(u=i._links.avatar)==null?void 0:u.href}})}}async getRepo(r,t={}){if(!r.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let s=await this.config.request({url:`${U}/${encodeURIComponent(r.namespace)}/${encodeURIComponent(r.project)}/_apis/git/repositories/${encodeURIComponent(r.name)}`,headers:P(this.config,t)});return{data:Fe(r.namespace,s.body)}}async getRepos(r,t={}){let s=[],n=[];return await Promise.all(r.map(async o=>{try{let a=await this.getRepo(o,t);s.push(a.data)}catch(a){n.push({input:o,error:a})}})),{data:s,errors:n}}async getReposForAzureProject(r,t={}){if(!r.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');return{data:(await this.config.request({url:`${U}/${encodeURIComponent(r.namespace)}/${encodeURIComponent(r.project)}/_apis/git/repositories`,headers:P(this.config,t)})).body.value.map(n=>Fe(r.namespace,n))}}async getRefs(r,t,s={}){if(!t.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let n=new URL(`${U}/${encodeURIComponent(t.repo.namespace)}/${encodeURIComponent(t.repo.project)}/_apis/git/repositories/${encodeURIComponent(t.repo.name)}/refs`);n.searchParams.set("filter",r),n.searchParams.set("$top",S.toString()),t.cursor&&n.searchParams.set("continuationToken",t.cursor);let o=await this.config.request({url:n.toString(),headers:P(this.config,s)}),a=o.headers["x-ms-continuationtoken"];return{pageInfo:{hasNextPage:!!a,endCursor:a||null},data:o.body.value.map(i=>({name:X(i.name),commit:{oid:i.objectId,authoredDate:null,committedDate:null}}))}}async getBranches(r,t={}){return this.getRefs("heads",r,t)}async getTags(r,t={}){return this.getRefs("tags",r,t)}async getPullRequestsForRepoBase(r,t={},s=100){let{page:n,repo:o,assigneeLogins:a,authorLogin:i}=r||{},u=n||1;if(!o.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let l="searchCriteria.status=1";return a&&a.length&&(l+=`&searchCriteria.reviewerId=${a[0]}`),i&&(l+=`&searchCriteria.creatorId=${i}`),await this.config.request({url:`${t.baseUrl||U}/${encodeURIComponent(o.namespace)}/${encodeURIComponent(o.project||"")}/_apis/git/repositories/${encodeURIComponent(o.name)}/pullRequests?${l}&%24top=${s}&%24skip=${(u-1)*s}`,headers:P(this.config,t)})}async getPullRequestsForRepo(r,t={}){let n=r.page||1,o=await this.getPullRequestsForRepoBase(r,t,100);return{pageInfo:{hasNextPage:o.body.value.length===100,nextPage:n+1},data:o.body.value.map(Be)}}async getPullRequestsForRepos(r,t={}){if(!r.repos.every(o=>o.project))throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{repos:s}=r||{},n=[];return await Promise.all(s.map(async o=>{try{(await this.getPullRequestsForRepoBase({repo:o,...r},t)).body.value.forEach(i=>{n.push(Be(i))})}catch(a){if(a.statusCode!==404&&a.statusCode!==401)throw a}})),{data:n}}async updatePullRequest(r,t,s,n){let{namespace:o,project:a,name:i}=r;return await this.config.request({method:"PATCH",url:`${n.baseUrl||U}/${encodeURIComponent(o)}/${encodeURIComponent(a||"")}/_apis/git/repositories/${i}/pullrequests/${t}?api-version=6.0`,body:s,headers:{...P(this.config,n),"Content-Type":"application/json"}})}async closePullRequest(r,t={}){if(!r.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{repo:s,pullRequestId:n}=r,o={status:"abandoned"};if(!(await this.updatePullRequest(s,n,JSON.stringify(o),t)).body.status)throw new Error("Could not close pull request")}async mergePullRequest(r,t={}){if(!r.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{repo:s,pullRequestId:n,expectedSourceSha:o,mergeStrategy:a}=r,i;switch(a){case"MERGE_COMMIT":{i="noFastForward";break}case"REBASE":{i="rebase";break}case"REBASE_THEN_MERGE_COMMIT":{i="rebaseMerge";break}case"SQUASH":{i="squash";break}}let u={completionOptions:{mergeStrategy:i},lastMergeSourceCommit:{commitId:o},status:"completed"};if(!(await this.updatePullRequest(s,n,JSON.stringify(u),t)).body.status)throw new Error("Could not merge pull request")}async setPullRequestAsDraft(r,t={}){if(!r.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{repo:s,pullRequestId:n,isDraft:o}=r,a={isDraft:o};if(!(await this.updatePullRequest(s,n,JSON.stringify(a),t)).body.status)throw new Error("Could not set the pull request as draft")}async getIssuesForAzureProject(r,t={}){let{page:s,assigneeLogins:n,authorLogin:o,mentionLogin:a,statusByWorkItemIdByStatusId:i}=r||{},u=s||1,l=200,p=["[Microsoft.VSTS.Common.ClosedDate] = ''","[System.TeamProject] = @project","[Microsoft.VSTS.Common.ResolvedDate] = ''"];o&&p.push(`[System.CreatedBy] = '${o.replace("'","''")}'`),n&&n[0]&&p.push(`[System.AssignedTo] = '${n[0].replace("'","''")}'`),a&&p.push("[System.Id] IN (@recentMentions)");let d=`Select [Microsoft.VSTS.Common.ClosedDate], [Microsoft.VSTS.Common.ResolvedDate] From WorkItems Where ${p.join(" AND ")} order by [System.CreatedDate] desc`,c=await this.config.request({url:`${t.baseUrl||U}/${encodeURIComponent(r.namespace)}/${encodeURIComponent(r.project)}/_apis/wit/wiql?api-version=6.0`,body:JSON.stringify({query:d}),method:"POST",headers:{...P(this.config,t),"Content-Type":"application/json"}}),g=c.body.workItems.slice((u-1)*l,l*u).map(f=>f.id);if(g.length==0)return{pageInfo:{hasNextPage:!1,nextPage:null},data:[]};let I=await this.config.request({url:`${t.baseUrl||U}/${encodeURIComponent(r.namespace)}/${encodeURIComponent(r.project)}/_apis/wit/workitemsbatch?api-version=6.0`,body:JSON.stringify({ids:g,$expand:"Links"}),method:"POST",headers:{...P(this.config,t),"Content-Type":"application/json"}});return{pageInfo:{hasNextPage:c.body.workItems.length>l*u,nextPage:u+1},data:I.body.value.map(f=>pt(f,i||{}))}}async setIssueStatus(r,t={}){var l;if(!r.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{namespace:s,project:n,issueId:o,status:a}=r,i=[{op:"add",path:"/fields/System.State",value:a}];if(!((l=(await this.config.request({method:"PATCH",url:`${t.baseUrl||U}/${encodeURIComponent(s)}/${encodeURIComponent(n||"")}/_apis/wit/workitems/${o}?api-version=6.0`,body:JSON.stringify(i),headers:{...P(this.config,t),"Content-Type":"application/json-patch+json"}})).body.fields)!=null&&l["System.State"]))throw new Error("Could not set issue status")}async getIssueTypesForAzureProject(r,t={}){if(!r.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{namespace:s,project:n}=r;return{data:(await this.config.request({url:`${t.baseUrl||U}/${encodeURIComponent(s)}/${encodeURIComponent(n||"")}/_apis/wit/workitemtypes?api-version=6.0`,headers:{...P(this.config,t)}})).body.value}}async getLabelsForProject(r,t={}){let{namespace:s,project:n}=r;return{data:(await this.config.request({url:`${t.baseUrl||U}/${encodeURIComponent(s)}/${encodeURIComponent(n||"")}/_apis/wit/tags?api-version=6.0`,headers:{...P(this.config,t)}})).body.value.map(a=>({color:null,description:null,id:a.id,name:a.name}))}}};var E=(e,r={})=>m(r.token||e.token,r.isPAT||e.isPAT);var D="https://api.bitbucket.org/2.0",dt={OPEN:"OPEN",MERGED:"MERGED",DECLINED:"CLOSED"},We=e=>({id:e.uuid,name:e.display_name||e.nickname,username:e.nickname||e.display_name,email:null,avatarUrl:e.links.avatar.href}),ze=e=>{var r,t;return{id:e.uuid,namespace:e.workspace.slug,name:e.slug,webUrl:e.links.html.href,httpsUrl:((r=e.links.clone.find(s=>s.name==="https"))==null?void 0:r.href)??null,sshUrl:((t=e.links.clone.find(s=>s.name==="ssh"))==null?void 0:t.href)??null,defaultBranch:{name:e.mainbranch.name},permission:null}},he=e=>{let r=e.id;return{id:r.toString(),title:e.title,number:r,state:dt[e.state],isDraft:!1,commentCount:e.comment_count,upvoteCount:null,author:We(e.author),createdDate:new Date(e.created_on),updatedDate:new Date(e.updated_on),closedDate:null,repository:{name:e.source.repository.name,owner:{login:void 0}},headCommit:{buildStatus:null},baseRef:{name:e.destination.branch.name,oid:e.destination.commit.hash},headRef:{name:e.source.branch.name,oid:e.source.commit.hash},url:e.links.html.href,assignees:null,reviews:null,additions:null,deletions:null,fileCount:null,commitCount:null,headRepository:null,mergeableState:"UNKNOWN"}},F=class extends v{async refreshToken(r){return{data:(await this.config.request({url:"https://bitbucket.org/site/oauth2/access_token",method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:`Basic ${r.base64ClientIDColonClientSecret}`},body:`grant_type=refresh_token&refresh_token=${r.refreshToken}`})).body}}async getCurrentUser(r={}){let t=await this.config.request({url:`${D}/user`,headers:E(this.config,r)});return{data:We(t.body)}}async getUserForCommit(r,t={}){var a;let n=(await this.config.request({url:`${D}/repositories/${r.repo.namespace}/${r.repo.name}/commit/${r.oid}`,headers:E(this.config,t)})).body.author,o=n.raw.match(/([^<]+)<(.+)>/);return{data:{name:o?o[1].trim():null,email:o?o[2]:null,avatarUrl:((a=n.user)==null?void 0:a.links.avatar.href)||null}}}async getRepo(r,t={}){let s=await this.config.request({url:`${D}/repositories/${r.namespace}/${r.name}`,headers:E(this.config,t)});return{data:ze(s.body)}}async getRepos(r,t={}){let s=[],n=[];return await Promise.all(r.map(async o=>{try{let a=await this.getRepo(o,t);s.push(a.data)}catch(a){n.push({input:o,error:a})}})),{data:s,errors:n}}async getReposForCurrentUser(r={},t={}){let s=new URL(`${D}/repositories`);s.searchParams.set("role","member"),s.searchParams.set("pagelen",S.toString()),r.cursor&&s.searchParams.set("after",r.cursor);let n=await this.config.request({url:s.toString(),headers:E(this.config,t)}),o=!!n.body.next,a=null;return n.body.next&&(a=new URL(n.body.next).searchParams.get("after")),{pageInfo:{hasNextPage:o,endCursor:a},data:n.body.values.map(ze)}}async getBranches(r,t={}){var a;let s=new URL(`${D}/repositories/${r.repo.namespace}/${r.repo.name}/refs/branches`);s.searchParams.set("page",((a=r.page)==null?void 0:a.toString())||"1"),s.searchParams.set("pagelen",S.toString());let n=await this.config.request({url:s.toString(),headers:E(this.config,t)}),o=!!n.body.next;return{pageInfo:{hasNextPage:o,nextPage:o?n.body.page+1:null},data:n.body.values.map(i=>{let u=new Date(i.target.date);return{name:i.name,commit:{oid:i.target.hash,authoredDate:u,committedDate:u}}})}}async getTags(r,t={}){let s=new URL(`${D}/repositories/${r.repo.namespace}/${r.repo.name}/refs/tags`);s.searchParams.set("pagelen",S.toString()),r.cursor&&s.searchParams.set("page",r.cursor);let n=await this.config.request({url:s.toString(),headers:E(this.config,t)}),o=!!n.body.next,a=null;return n.body.next&&(a=new URL(n.body.next).searchParams.get("page")),{pageInfo:{hasNextPage:o,endCursor:a},data:n.body.values.map(i=>{let u=new Date(i.target.date);return{name:i.name,commit:{oid:i.target.hash,authoredDate:u,committedDate:u}}})}}async getPullRequestsForUser(r,t={}){var a;let s=new URL(`${D}/pullrequests/${r.userId}`);s.searchParams.set("page",((a=r.page)==null?void 0:a.toString())||"1"),s.searchParams.set("pagelen","50");let n=await this.config.request({url:`${D}/pullrequests/${r.userId}`,headers:E(this.config,t)}),o=!!n.body.next;return{pageInfo:{hasNextPage:o,nextPage:o?n.body.page+1:null},data:n.body.values.map(he)}}async getPullRequestsForRepoBase(r,t={}){var n;let s=new URL(`${D}/repositories/${encodeURI(r.repo.namespace)}/${encodeURI(r.repo.name)}/pullrequests?state=OPEN`);return s.searchParams.set("page",((n=r.page)==null?void 0:n.toString())||"1"),s.searchParams.set("pagelen","50"),await this.config.request({url:s.toString(),headers:E(this.config,t)})}async getPullRequestsForRepo(r,t={}){let s=[],n=await this.getPullRequestsForRepoBase(r,t);n.body.values.forEach(a=>{if(r.authorLogin&&a.author.uuid!==r.authorLogin)return null;s.push(he(a))});let o=!!n.body.next;return{pageInfo:{hasNextPage:o,nextPage:o?n.body.page+1:null},data:s}}async getPullRequestsForRepos(r,t={}){let s=[];return await Promise.all(r.repos.map(async n=>{try{(await this.getPullRequestsForRepoBase({repo:n,...r},t)).body.values.forEach(a=>{if(r.authorLogin&&a.author.uuid!==r.authorLogin)return null;s.push(he(a))})}catch(o){if(o.statusCode!==404&&o.statusCode!==401)throw o}})),{data:s}}async closePullRequest(r,t={}){let{repo:{namespace:s,name:n},pullRequestId:o}=r;if(!(await this.config.request({method:"POST",url:`${D}/repositories/${s}/${n}/pullrequests/${o}/decline`,headers:E(this.config,t)})).body.title)throw new Error("Could not close pull request")}async mergePullRequest(r,t={}){let{repo:{namespace:s,name:n},pullRequestId:o,mergeStrategy:a}=r,i;switch(a){case"MERGE_COMMIT":{i="merge_commit";break}case"FAST_FORWARD":{i="fast_forward";break}case"SQUASH":{i="squash";break}}let u={merge_strategy:i,type:"pullrequest"};if(!(await this.config.request({method:"POST",url:`${D}/repositories/${s}/${n}/pullrequests/${o}/merge`,body:JSON.stringify(u),headers:{...E(this.config,t),"Content-Type":"application/json"}})).body.title)throw new Error("Could not merge pull request")}};var M=class extends T{getBaseUrl(r){let t=r.baseUrl||this.config.baseUrl;if(!t)throw new Error('Bitbucket Server requires "baseUrl"');return t}getRequestHeaders(r){return m(r.token||this.config.token)}async getRepo(r,t={}){var n,o,a;let s=await this.config.request({url:`${this.getBaseUrl(t)}/projects/${r.namespace}/repos/${r.name}`,headers:this.getRequestHeaders(t)});return{data:{id:s.body.id.toString(),namespace:s.body.project.key,name:s.body.slug,webUrl:((n=s.body.links.self[0])==null?void 0:n.href)??null,httpsUrl:((o=s.body.links.clone.find(i=>i.name==="https"))==null?void 0:o.href)??null,sshUrl:((a=s.body.links.clone.find(i=>i.name==="ssh"))==null?void 0:a.href)??null,defaultBranch:null,permission:null}}}async getRepos(r,t={}){let s=[],n=[];return await Promise.all(r.map(async o=>{try{let a=await this.getRepo(o,t);s.push(a.data)}catch(a){n.push({input:o,error:a})}})),{data:s,errors:n}}};var fe="https://api.github.com",ct=`${fe}/graphql`,Y=`
2
2
  description
3
3
  dueOn
4
4
  id
@@ -6,12 +6,12 @@ number
6
6
  state
7
7
  title
8
8
  url
9
- `,ze=/\/api\/v\d+$/,ee=`
9
+ `,He=/\/api\/v\d+$/,ee=`
10
10
  color
11
11
  description
12
12
  id
13
13
  name
14
- `,dt=e=>{if(e.endsWith("/api/graphql"))throw new Error("The graphql endpoint is being used as the baseUrl. This package uses both GraphQL and REST APIs, and the REST version cannot be assumed. Use the REST endpoint as the baseUrl instead.")},ct=(e,r)=>{let t=r.baseUrl||e.baseUrl;return t?(t=t.replace(/\/$/,""),dt(t),ze.test(t)&&(t=t.replace(ze,"")),`${t}/api/graphql`):pt},h=(e,r,t)=>{let s=m(t.token||e.token);return s["X-Github-Next-Global-ID"]="1",s["Content-Type"]="application/json",e.request({url:ct(e,t),method:"POST",headers:s,body:JSON.stringify(r)})},gt={user:!0,"user:email":!0,"read:user":!0},k=e=>e.some(r=>gt[r]),q=(e=!1,r=!1)=>`
14
+ `,gt=e=>{if(e.endsWith("/api/graphql"))throw new Error("The graphql endpoint is being used as the baseUrl. This package uses both GraphQL and REST APIs, and the REST version cannot be assumed. Use the REST endpoint as the baseUrl instead.")},mt=(e,r)=>{let t=r.baseUrl||e.baseUrl;return t?(t=t.replace(/\/$/,""),gt(t),He.test(t)&&(t=t.replace(He,"")),`${t}/api/graphql`):ct},h=(e,r,t)=>{let s=m(t.token||e.token);return s["X-Github-Next-Global-ID"]="1",s["Content-Type"]="application/json",e.request({url:mt(e,t),method:"POST",headers:s,body:JSON.stringify(r)})},ht={user:!0,"user:email":!0,"read:user":!0},O=e=>e.some(r=>ht[r]),q=(e=!1,r=!1)=>`
15
15
  __typename
16
16
  id
17
17
  databaseId
@@ -19,13 +19,13 @@ name
19
19
  login
20
20
  ${r?"email":""}
21
21
  avatarUrl${e?"(size: $avatarSize)":""}
22
- `,We=(e=!1)=>`
22
+ `,Je=(e=!1)=>`
23
23
  __typename
24
24
  id
25
25
  databaseId
26
26
  login
27
27
  avatarUrl${e?"(size: $avatarSize)":""}
28
- `,mt=(e,r=!1)=>`
28
+ `,ft=(e,r=!1)=>`
29
29
  id
30
30
  databaseId
31
31
  number
@@ -36,7 +36,7 @@ author {
36
36
  ${q(!1,r)}
37
37
  }
38
38
  ... on Bot {
39
- ${We(!1)}
39
+ ${Je(!1)}
40
40
  }
41
41
  }
42
42
  commits(last: 1) {
@@ -131,7 +131,7 @@ labels(first: 100) {
131
131
  ${ee}
132
132
  }
133
133
  }
134
- `,ht=(e=!1)=>`
134
+ `,Rt=(e=!1)=>`
135
135
  id
136
136
  databaseId
137
137
  title
@@ -140,7 +140,7 @@ author {
140
140
  ${q(!1,e)}
141
141
  }
142
142
  ... on Bot {
143
- ${We(!1)}
143
+ ${Je(!1)}
144
144
  }
145
145
  }
146
146
  createdAt
@@ -173,7 +173,7 @@ labels(first: 100) {
173
173
  ${ee}
174
174
  }
175
175
  }
176
- `,ft={"-linked":"-linked",archived:"archived",assignee:"assignee",author:"author",base:"base",closed:"closed",commenter:"commenter",comments:"comments",created:"created",draft:"draft",head:"head",label:"label",language:"language",linked:"linked",in:"in",interactions:"interactions",involves:"involves",is:"is",mentions:"mentions",merged:"merged",milestone:"milestone",no:"no",org:"org",project:"project",reactions:"reactions",repo:"repo",review:"review","reviewed-by":"reviewed-by","review-requested":"review-requested",state:"state",status:"status",team:"team","team-review-requested":"team-review-requested",type:"type",updated:"updated",user:"user","user-review-requested":"user-review-requested"},Rt=new RegExp('(([^\\s]+:)?\\"(?:[^\\"\\\\]|\\\\.)*\\"?)|([^\\"\\s]+)',"g"),he=e=>{let r=[];return(e.match(Rt)??[]).forEach(s=>{if(s.includes(":")&&s!="is:closed"){let n=s.split(":")[0];ft[n]&&r.push(s)}}),r},fe=(e,r,t,s,n=!1)=>{let a=e==="issue";return{query:`
176
+ `,It={"-linked":"-linked",archived:"archived",assignee:"assignee",author:"author",base:"base",closed:"closed",commenter:"commenter",comments:"comments",created:"created",draft:"draft",head:"head",label:"label",language:"language",linked:"linked",in:"in",interactions:"interactions",involves:"involves",is:"is",mentions:"mentions",merged:"merged",milestone:"milestone",no:"no",org:"org",project:"project",reactions:"reactions",repo:"repo",review:"review","reviewed-by":"reviewed-by","review-requested":"review-requested",state:"state",status:"status",team:"team","team-review-requested":"team-review-requested",type:"type",updated:"updated",user:"user","user-review-requested":"user-review-requested"},bt=new RegExp('(([^\\s]+:)?\\"(?:[^\\"\\\\]|\\\\.)*\\"?)|([^\\"\\s]+)',"g"),Re=e=>{let r=[];return(e.match(bt)??[]).forEach(s=>{if(s.includes(":")&&s!="is:closed"){let n=s.split(":")[0];It[n]&&r.push(s)}}),r},Ie=(e,r,t,s,n=!1)=>{let o=e==="issue";return{query:`
177
177
  query SearchIssuesOrPullRequests($query: String! $after: String) {
178
178
  search(type:ISSUE query:$query first:100 after:$after) {
179
179
  pageInfo {
@@ -181,12 +181,12 @@ query SearchIssuesOrPullRequests($query: String! $after: String) {
181
181
  endCursor
182
182
  }
183
183
  nodes {
184
- ... on ${a?"Issue":"PullRequest"} {
185
- ${a?ht(s):mt(n,s)}
184
+ ... on ${o?"Issue":"PullRequest"} {
185
+ ${o?Rt(s):ft(n,s)}
186
186
  }
187
187
  }
188
188
  }
189
- }`,variables:{query:`is:${e} is:open ${r}`,after:t}}},It="Field 'isDraft' doesn't exist on type 'PullRequest'",He=(e=[])=>e.some(r=>(r==null?void 0:r.message)===It);var Re=`
189
+ }`,variables:{query:`is:${e} is:open ${r}`,after:t}}},yt="Field 'isDraft' doesn't exist on type 'PullRequest'",Ve=(e=[])=>e.some(r=>(r==null?void 0:r.message)===yt);var be=`
190
190
  id
191
191
  databaseId
192
192
  owner {
@@ -199,13 +199,27 @@ defaultBranchRef {
199
199
  name
200
200
  }
201
201
  viewerPermission
202
- `,be={__typename:"User",id:"U_kgDNJ5k",databaseId:10137,name:"Deleted user",login:"ghost",email:"",avatarUrl:"https://avatars.githubusercontent.com/u/10137?v=4"},bt={APPROVED:"APPROVED",CHANGES_REQUESTED:"CHANGES_REQUESTED",COMMENTED:"COMMENTED",REVIEW_REQUESTED:"REVIEW_REQUESTED"},yt={MERGEABLE:"MERGEABLE",CONFLICTING:"CONFLICTS",UNKNOWN:"UNKNOWN"},Pt={OPEN:"OPEN",CLOSED:"CLOSED"},ye=e=>({color:e.color,description:e.description,graphQLId:e.id,id:null,name:e.name}),Ie=e=>({id:e.databaseId.toString(),graphQLId:e.id,namespace:e.owner.login,name:e.name,webUrl:e.url,httpsUrl:e.url.endsWith(".git")?e.url:`${e.url}.git`,sshUrl:e.sshUrl,defaultBranch:e.defaultBranchRef,permission:e.viewerPermission}),wt={OPEN:"OPEN",CLOSED:"CLOSED",MERGED:"MERGED"},G=e=>({id:e.databaseId.toString(),graphQLId:e.id,name:e.name??e.login,username:e.login,email:e.email??null,avatarUrl:e.avatarUrl}),Ct=e=>{var l,p,d,c,g,R,I,P,y,b,v,L;let r=null;e.author?r=(e.author.__typename==="Bot",e.author):r=be;let t=(p=(l=e.commits.nodes)==null?void 0:l[0])==null?void 0:p.commit,s=((d=e.headRef)==null?void 0:d.target)||t,n=s==null?void 0:s.oid,a=t==null?void 0:t.oid,o=n===a?(g=(c=t==null?void 0:t.status)==null?void 0:c.contexts)==null?void 0:g[0]:null,i=(((R=e.reviewRequests)==null?void 0:R.nodes)||[]).filter(D=>!D.asCodeOwner),u=(I=e.headRepository)==null?void 0:I.url;return u&&!u.endsWith(".git")&&(u=`${u}.git`),{id:e.databaseId.toString(),graphQLId:e.id,title:e.title,number:e.number,state:wt[e.state],commentCount:e.comments.totalCount,upvoteCount:e.reactions.totalCount,author:r?G(r):null,createdDate:new Date(e.createdAt),isDraft:e.isDraft,repository:{name:e.repository.name,owner:{login:e.repository.owner.login}},headRepository:e.headRepository?{name:e.headRepository.name,owner:{login:e.headRepository.owner.login},remoteInfo:{cloneUrlHTTPS:u,cloneUrlSSH:e.headRepository.sshUrl}}:null,headCommit:{buildStatus:o||null},headRef:e.headRef?{name:e.headRef.name,oid:((P=e.headRef.target)==null?void 0:P.oid)??null}:null,baseRef:e.baseRef?{name:e.baseRef.name,oid:((y=e.baseRef.target)==null?void 0:y.oid)??null}:null,url:e.url,updatedDate:new Date(e.updatedAt),closedDate:e.closedAt?new Date(e.closedAt):null,assignees:e.assignees.nodes?e.assignees.nodes.map(G):null,reviews:i.map(D=>({reviewer:G(D.requestedReviewer),state:"REVIEW_REQUESTED"})).concat((((b=e.latestReviews)==null?void 0:b.nodes)||[]).map(D=>{let ue=D.author||be;return{reviewer:G(ue),state:bt[D.state]}})),additions:e.additions,deletions:e.deletions,fileCount:e.changedFiles,commitCount:e.commits.totalCount,mergeableState:yt[e.mergeable],milestone:e.milestone?Pe(e.milestone):null,labels:((L=(v=e.labels)==null?void 0:v.nodes)==null?void 0:L.map(ye))??[]}},vt=e=>{var t,s;let r=null;return e.author?r=(e.author.__typename==="Bot",e.author):r=be,{id:e.databaseId.toString(),graphQLId:e.id,number:e.number,title:e.title,author:G(r),commentCount:e.comments.totalCount,createdDate:new Date(e.createdAt),description:null,state:{name:Pt[e.state],color:null},type:null,repository:{name:e.repository.name,owner:{login:e.repository.owner.login}},url:e.url,updatedDate:new Date(e.updatedAt),assignees:e.assignees.nodes?e.assignees.nodes.map(G):[],upvoteCount:e.reactions.totalCount,milestone:e.milestone?Pe(e.milestone):null,labels:((s=(t=e.labels)==null?void 0:t.nodes)==null?void 0:s.map(ye))??[]}},Pe=e=>({id:e.number.toString(),graphQLId:e.id.toString(),number:e.number,title:e.title,description:e.description,isOpen:e.state=="OPEN",url:e.url,startDate:null,dueDate:e.dueOn?new Date(e.dueOn):null}),M=class extends T{constructor(){super(...arguments);this._scopesCache={}}async getScopes(t){let s=t.token||this.config.token;if(!s)return[];let n=this._scopesCache[s];if(!n){let o=(await h(this.config,{query:"query { rateLimit(dryRun: true) { __typename } }"},t)).headers["x-oauth-scopes"];n=o?o.split(", "):[],this._scopesCache[s]=n}return n}getEnterpriseAvatarUrlIfNeeded(t,s,n){let a=n.baseUrl||this.config.baseUrl;return!a||a.startsWith(me)?t:s?`https://avatars.githubusercontent.com/u/e?email=${encodeURIComponent(s)}`:""}async getCurrentUser(t={}){var o;let s=await this.getScopes(t),a=(o=(await h(this.config,{query:`
202
+ `,Pe={__typename:"User",id:"U_kgDNJ5k",databaseId:10137,name:"Deleted user",login:"ghost",email:"",avatarUrl:"https://avatars.githubusercontent.com/u/10137?v=4"},Pt={APPROVED:"APPROVED",CHANGES_REQUESTED:"CHANGES_REQUESTED",COMMENTED:"COMMENTED",REVIEW_REQUESTED:"REVIEW_REQUESTED"},wt={MERGEABLE:"MERGEABLE",CONFLICTING:"CONFLICTS",UNKNOWN:"UNKNOWN"},St={OPEN:"OPEN",CLOSED:"CLOSED"},we=e=>({color:e.color,description:e.description,graphQLId:e.id,id:null,name:e.name}),ye=e=>({id:e.databaseId.toString(),graphQLId:e.id,namespace:e.owner.login,name:e.name,webUrl:e.url,httpsUrl:e.url.endsWith(".git")?e.url:`${e.url}.git`,sshUrl:e.sshUrl,defaultBranch:e.defaultBranchRef,permission:e.viewerPermission}),Ct={OPEN:"OPEN",CLOSED:"CLOSED",MERGED:"MERGED"},G=e=>({id:e.databaseId.toString(),graphQLId:e.id,name:e.name??e.login,username:e.login,email:e.email??null,avatarUrl:e.avatarUrl}),Ut=e=>{var l,p,d,c,g,I,f,w,y,b,C,L;let r=null;e.author?r=(e.author.__typename==="Bot",e.author):r=Pe;let t=(p=(l=e.commits.nodes)==null?void 0:l[0])==null?void 0:p.commit,s=((d=e.headRef)==null?void 0:d.target)||t,n=s==null?void 0:s.oid,o=t==null?void 0:t.oid,a=n===o?(g=(c=t==null?void 0:t.status)==null?void 0:c.contexts)==null?void 0:g[0]:null,i=(((I=e.reviewRequests)==null?void 0:I.nodes)||[]).filter($=>!$.asCodeOwner),u=(f=e.headRepository)==null?void 0:f.url;return u&&!u.endsWith(".git")&&(u=`${u}.git`),{id:e.databaseId.toString(),graphQLId:e.id,title:e.title,number:e.number,state:Ct[e.state],commentCount:e.comments.totalCount,upvoteCount:e.reactions.totalCount,author:r?G(r):null,createdDate:new Date(e.createdAt),isDraft:e.isDraft,repository:{name:e.repository.name,owner:{login:e.repository.owner.login}},headRepository:e.headRepository?{name:e.headRepository.name,owner:{login:e.headRepository.owner.login},remoteInfo:{cloneUrlHTTPS:u,cloneUrlSSH:e.headRepository.sshUrl}}:null,headCommit:{buildStatus:a||null},headRef:e.headRef?{name:e.headRef.name,oid:((w=e.headRef.target)==null?void 0:w.oid)??null}:null,baseRef:e.baseRef?{name:e.baseRef.name,oid:((y=e.baseRef.target)==null?void 0:y.oid)??null}:null,url:e.url,updatedDate:new Date(e.updatedAt),closedDate:e.closedAt?new Date(e.closedAt):null,assignees:e.assignees.nodes?e.assignees.nodes.map(G):null,reviews:i.map($=>({reviewer:G($.requestedReviewer),state:"REVIEW_REQUESTED"})).concat((((b=e.latestReviews)==null?void 0:b.nodes)||[]).map($=>{let le=$.author||Pe;return{reviewer:G(le),state:Pt[$.state]}})),additions:e.additions,deletions:e.deletions,fileCount:e.changedFiles,commitCount:e.commits.totalCount,mergeableState:wt[e.mergeable],milestone:e.milestone?Se(e.milestone):null,labels:((L=(C=e.labels)==null?void 0:C.nodes)==null?void 0:L.map(we))??[]}},$t=e=>{var t,s;let r=null;return e.author?r=(e.author.__typename==="Bot",e.author):r=Pe,{id:e.databaseId.toString(),graphQLId:e.id,number:e.number,title:e.title,author:G(r),commentCount:e.comments.totalCount,createdDate:new Date(e.createdAt),description:null,state:{name:St[e.state],color:null},type:null,repository:{name:e.repository.name,owner:{login:e.repository.owner.login}},url:e.url,updatedDate:new Date(e.updatedAt),assignees:e.assignees.nodes?e.assignees.nodes.map(G):[],upvoteCount:e.reactions.totalCount,milestone:e.milestone?Se(e.milestone):null,labels:((s=(t=e.labels)==null?void 0:t.nodes)==null?void 0:s.map(we))??[]}},Se=e=>({id:e.number.toString(),graphQLId:e.id.toString(),number:e.number,title:e.title,description:e.description,isOpen:e.state=="OPEN",url:e.url,startDate:null,dueDate:e.dueOn?new Date(e.dueOn):null}),z=class extends T{constructor(){super(...arguments);this._scopesCache={}}async getScopes(t){let s=t.token||this.config.token;if(!s)return[];let n=this._scopesCache[s];if(!n){let a=(await h(this.config,{query:"query { rateLimit(dryRun: true) { __typename } }"},t)).headers["x-oauth-scopes"];n=a?a.split(", "):[],this._scopesCache[s]=n}return n}getEnterpriseAvatarUrlIfNeeded(t,s,n){let o=n.baseUrl||this.config.baseUrl;return!o||o.startsWith(fe)?t:s?`https://avatars.githubusercontent.com/u/e?email=${encodeURIComponent(s)}`:""}async getCurrentUser(t={}){var a;let s=await this.getScopes(t),o=(a=(await h(this.config,{query:`
203
203
  query getCurrentUser {
204
204
  viewer {
205
- ${q(!1,k(s))}
205
+ ${q(!1,O(s))}
206
206
  }
207
207
  }
208
- `},t)).body.data)==null?void 0:o.viewer;if(!a)throw new Error("Current user not found.");return{data:G(a)}}async getUserForCommit(t,s={}){var i,u;let a=(i=(await h(this.config,{query:`
208
+ `},t)).body.data)==null?void 0:a.viewer;if(!o)throw new Error("Current user not found.");return{data:G(o)}}async getAccountsForRepo(t,s={}){var l,p,d,c,g,I;let n=await this.getScopes(s),{repo:{namespace:o,name:a},cursor:i}=t,u=await h(this.config,{query:`
209
+ query getAccountsForRepo($owner: String!, $name: String! $cursor: String, $first: Int!) {
210
+ repository(owner: $owner, name: $name) {
211
+ assignableUsers(first: $first, after: $cursor) {
212
+ nodes {
213
+ ${q(!1,O(n))}
214
+ }
215
+ pageInfo {
216
+ endCursor
217
+ hasNextPage
218
+ }
219
+ }
220
+ }
221
+ }
222
+ `,variables:{owner:o,name:a,cursor:i,first:S}},s);if(!u.body.data)throw new Error(((l=u.body.errors)==null?void 0:l[0].message)||u.statusText||"Unknown error");return{pageInfo:((d=(p=u.body.data.repository)==null?void 0:p.assignableUsers)==null?void 0:d.pageInfo)??{endCursor:null,hasNextPage:!1},data:((I=(g=(c=u.body.data.repository)==null?void 0:c.assignableUsers)==null?void 0:g.nodes)==null?void 0:I.map(G))??[]}}async getUserForCommit(t,s={}){var i,u;let o=(i=(await h(this.config,{query:`
209
223
  query getUserForCommit(
210
224
  $owner: String!
211
225
  $name: String!
@@ -224,23 +238,23 @@ query getUserForCommit(
224
238
  }
225
239
  }
226
240
  }
227
- `,variables:{owner:t.repo.namespace,name:t.repo.name,oid:t.oid,avatarSize:t.avatarSize}},s)).body.data)==null?void 0:i.repository;if(!a)throw new Error("Repository not found.");let o=(u=a.object)==null?void 0:u.author;if(!o)throw new Error("Commit not found.");return{data:{name:o.name,email:o.email,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(o.avatarUrl,o.email,s)}}}async getAccountForEmail(t,s={}){var i,u,l;let n=await this.getScopes(s),o=(l=(u=(i=(await h(this.config,{query:`
241
+ `,variables:{owner:t.repo.namespace,name:t.repo.name,oid:t.oid,avatarSize:t.avatarSize}},s)).body.data)==null?void 0:i.repository;if(!o)throw new Error("Repository not found.");let a=(u=o.object)==null?void 0:u.author;if(!a)throw new Error("Commit not found.");return{data:{name:a.name,email:a.email,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(a.avatarUrl,a.email,s)}}}async getAccountForEmail(t,s={}){var i,u,l;let n=await this.getScopes(s),a=(l=(u=(i=(await h(this.config,{query:`
228
242
  query getAccountForEmail($query: String! $avatarSize: Int) {
229
243
  search(query: $query, type: USER, first: 1) {
230
244
  nodes {
231
245
  ... on User {
232
- ${q(!0,k(n))}
246
+ ${q(!0,O(n))}
233
247
  }
234
248
  }
235
249
  }
236
250
  }
237
- `,variables:{query:`in:email ${t.email}`,avatarSize:t.avatarSize}},s)).body.data)==null?void 0:i.search)==null?void 0:u.nodes)==null?void 0:l[0];if(!o)throw new Error("User not found.");return{data:G({...o,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(o.avatarUrl,o.email,s)})}}async getAccountForUsername(t,s={}){var i;let n=await this.getScopes(s),o=(i=(await h(this.config,{query:`
251
+ `,variables:{query:`in:email ${t.email}`,avatarSize:t.avatarSize}},s)).body.data)==null?void 0:i.search)==null?void 0:u.nodes)==null?void 0:l[0];if(!a)throw new Error("User not found.");return{data:G({...a,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(a.avatarUrl,a.email,s)})}}async getAccountForUsername(t,s={}){var i;let n=await this.getScopes(s),a=(i=(await h(this.config,{query:`
238
252
  query getUserForUsername($login: String! $avatarSize: Int) {
239
253
  user(login: $login) {
240
- ${q(!0,k(n))}
254
+ ${q(!0,O(n))}
241
255
  }
242
256
  }
243
- `,variables:{login:t.username,avatarSize:t.avatarSize}},s)).body.data)==null?void 0:i.user;if(!o)throw new Error("User not found.");return{data:G({...o,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(o.avatarUrl,o.email,s)})}}async getOrgsForCurrentUser(t={},s={}){var o,i;let n=await h(this.config,{query:`
257
+ `,variables:{login:t.username,avatarSize:t.avatarSize}},s)).body.data)==null?void 0:i.user;if(!a)throw new Error("User not found.");return{data:G({...a,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(a.avatarUrl,a.email,s)})}}async getOrgsForCurrentUser(t={},s={}){var a,i;let n=await h(this.config,{query:`
244
258
  query getOrgsForCurrentUser($cursor: String, $first: Int!) {
245
259
  viewer {
246
260
  organizations(first: $first after: $cursor) {
@@ -259,22 +273,22 @@ query getOrgsForCurrentUser($cursor: String, $first: Int!) {
259
273
  }
260
274
  }
261
275
  }
262
- `,variables:{cursor:t.cursor,first:C}},s);if(!((o=n.body.data)!=null&&o.viewer.organizations))throw new Error(((i=n.body.errors)==null?void 0:i[0].message)||n.statusText||"Unknown error");let a=n.body.data.viewer.organizations.nodes||[];return{pageInfo:n.body.data.viewer.organizations.pageInfo,data:a.map(u=>({id:u.databaseId.toString(),graphQLId:u.id,username:u.login,name:u.name||null,email:u.email||null,avatarUrl:u.avatarUrl}))}}async getRepo(t,s={}){var a;let n=await h(this.config,{query:`
276
+ `,variables:{cursor:t.cursor,first:S}},s);if(!((a=n.body.data)!=null&&a.viewer.organizations))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(u=>({id:u.databaseId.toString(),graphQLId:u.id,username:u.login,name:u.name||null,email:u.email||null,avatarUrl:u.avatarUrl}))}}async getRepo(t,s={}){var o;let n=await h(this.config,{query:`
263
277
  query getRepo($owner: String!, $name: String!) {
264
278
  repository(owner: $owner, name: $name) {
265
- ${Re}
279
+ ${be}
266
280
  }
267
281
  }
268
- `,variables:{owner:t.namespace,name:t.name}},s);if(!((a=n.body.data)!=null&&a.repository))throw new Error(`Repository ${t.namespace}/${t.name} not found`);return{data:Ie(n.body.data.repository)}}async getRepos(t,s={}){let n=t.map(({namespace:u,name:l},p)=>`
282
+ `,variables:{owner:t.namespace,name:t.name}},s);if(!((o=n.body.data)!=null&&o.repository))throw new Error(`Repository ${t.namespace}/${t.name} not found`);return{data:ye(n.body.data.repository)}}async getRepos(t,s={}){let n=t.map(({namespace:u,name:l},p)=>`
269
283
  getRepo_${p}: repository(owner: "${u}", name: "${l}") {
270
- ${Re}
284
+ ${be}
271
285
  }
272
286
  `).join(`
273
- `),a=await h(this.config,{query:`
287
+ `),o=await h(this.config,{query:`
274
288
  query batchGetRepos {
275
289
  ${n}
276
290
  }
277
- `},s);if(!a.body.data)throw new Error(a.statusText||"Unknown error");let o=[],i=[];return t.forEach((u,l)=>{let p=a.body.data[`getRepo_${l}`];p?o.push(Ie(p)):i.push({input:u})}),{data:o,errors:i}}async getReposForUsernames(t,s={}){var o;if(!t.usernames.length)return{pageInfo:{endCursor:null,hasNextPage:!1},data:[]};let n=await h(this.config,{query:`
291
+ `},s);if(!o.body.data)throw new Error(o.statusText||"Unknown error");let a=[],i=[];return t.forEach((u,l)=>{let p=o.body.data[`getRepo_${l}`];p?a.push(ye(p)):i.push({input:u})}),{data:a,errors:i}}async getReposForUsernames(t,s={}){var a;if(!t.usernames.length)return{pageInfo:{endCursor:null,hasNextPage:!1},data:[]};let n=await h(this.config,{query:`
278
292
  query getReposForUsernames($query: String!, $cursor: String, $first: Int!) {
279
293
  search(query: $query, type: REPOSITORY, first: $first, after: $cursor) {
280
294
  pageInfo {
@@ -283,12 +297,12 @@ query getReposForUsernames($query: String!, $cursor: String, $first: Int!) {
283
297
  }
284
298
  nodes {
285
299
  ... on Repository {
286
- ${Re}
300
+ ${be}
287
301
  }
288
302
  }
289
303
  }
290
304
  }
291
- `,variables:{query:`fork:true ${t.usernames.map(i=>`user:${i}`).join(" ")}`,cursor:t.cursor,first:C}},s);if(!n.body.data)throw new Error(((o=n.body.errors)==null?void 0:o[0].message)||n.statusText||"Unknown error");let a=n.body.data.search.nodes||[];return{pageInfo:n.body.data.search.pageInfo,data:a.map(Ie)}}async getReposForOwners(t,s={}){return this.getReposForUsernames({usernames:t.owners.filter(n=>n.username).map(n=>n.username),cursor:t.cursor},s)}async getRefs(t,s,n={}){var u;let o=(u=(await h(this.config,{query:`
305
+ `,variables:{query:`fork:true ${t.usernames.map(i=>`user:${i}`).join(" ")}`,cursor:t.cursor,first:S}},s);if(!n.body.data)throw new Error(((a=n.body.errors)==null?void 0:a[0].message)||n.statusText||"Unknown error");let o=n.body.data.search.nodes||[];return{pageInfo:n.body.data.search.pageInfo,data:o.map(ye)}}async getReposForOwners(t,s={}){return this.getReposForUsernames({usernames:t.owners.filter(n=>n.username).map(n=>n.username),cursor:t.cursor},s)}async getRefs(t,s,n={}){var u;let a=(u=(await h(this.config,{query:`
292
306
  query getRefs($owner: String!, $name: String!, $refPrefix: String!, $cursor: String, $first: Int!) {
293
307
  repository(owner: $owner, name: $name) {
294
308
  refs(refPrefix: $refPrefix first: $first after: $cursor) {
@@ -309,7 +323,7 @@ query getRefs($owner: String!, $name: String!, $refPrefix: String!, $cursor: Str
309
323
  }
310
324
  }
311
325
  }
312
- `,variables:{owner:s.repo.namespace,name:s.repo.name,refPrefix:t,cursor:s.cursor,first:C}},n)).body.data)==null?void 0:u.repository;if(!o)throw new Error("Repository not found.");let i=o.refs;return i?{pageInfo:i.pageInfo,data:(i.nodes||[]).map(l=>{var d;let p=(d=l.target)!=null&&d.oid?l.target:null;return{name:l.name,commit:p?{oid:p.oid,authoredDate:new Date(p.authoredDate),committedDate:new Date(p.committedDate)}:null}})}:{pageInfo:{endCursor:null,hasNextPage:!1},data:[]}}async getBranches(t,s={}){return this.getRefs("refs/heads/",t,s)}async getTags(t,s={}){return this.getRefs("refs/tags/",t,s)}async getBlame(t,s={}){var i;let a=(i=(await h(this.config,{query:`
326
+ `,variables:{owner:s.repo.namespace,name:s.repo.name,refPrefix:t,cursor:s.cursor,first:S}},n)).body.data)==null?void 0:u.repository;if(!a)throw new Error("Repository not found.");let i=a.refs;return i?{pageInfo:i.pageInfo,data:(i.nodes||[]).map(l=>{var d;let p=(d=l.target)!=null&&d.oid?l.target:null;return{name:l.name,commit:p?{oid:p.oid,authoredDate:new Date(p.authoredDate),committedDate:new Date(p.committedDate)}:null}})}:{pageInfo:{endCursor:null,hasNextPage:!1},data:[]}}async getBranches(t,s={}){return this.getRefs("refs/heads/",t,s)}async getTags(t,s={}){return this.getRefs("refs/tags/",t,s)}async getBlame(t,s={}){var i;let o=(i=(await h(this.config,{query:`
313
327
  query getBlame($owner: String!, $name: String!, $ref: String!, $path: String!) {
314
328
  repository(owner: $owner, name: $name) {
315
329
  object(expression: $ref) {
@@ -348,61 +362,69 @@ query getBlame($owner: String!, $name: String!, $ref: String!, $path: String!) {
348
362
  }
349
363
  }
350
364
  }
351
- `,variables:{owner:t.repo.namespace,name:t.repo.name,ref:t.ref,path:t.path}},s)).body.data)==null?void 0:i.repository;if(!a)throw new Error("Repository not found.");let o=a.object;if(!o||!("blame"in o))throw new Error("Ref not found.");if(o.blame.ranges.length===0)throw new Error("File not found.");return{data:{ranges:o.blame.ranges.map(u=>{var l;return{startingLine:u.startingLine,endingLine:u.endingLine,commit:{oid:u.commit.oid,parentOids:((l=u.commit.parents.nodes)==null?void 0:l.map(p=>p.oid))||[],authoredDate:new Date(u.commit.authoredDate),author:u.commit.author?{name:u.commit.author.name,email:u.commit.author.email,avatarUrl:u.commit.author.avatarUrl}:null,committedDate:new Date(u.commit.committedDate),committer:u.commit.committer?{name:u.commit.committer.name,email:u.commit.committer.email,avatarUrl:u.commit.committer.avatarUrl}:null,message:u.commit.message,fileCount:u.commit.changedFilesIfAvailable,additions:u.commit.additions,deletions:u.commit.deletions}}})}}}async searchPullRequests(t,s={}){var l,p;let n=await this.getScopes(s),a=k(n),o=d=>{let c=d&&typeof t.isDraft=="boolean"?`${t.query} draft:${t.isDraft}`:t.query;return fe("pr",c,t.cursor,a,d)},i=await h(this.config,o(!0),s);i.body.errors&&He(i.body.errors)&&(this.config.baseUrl||s.baseUrl)&&(i=await h(this.config,o(!1),s));let{data:u}=i.body;if(!u)throw new Error(((l=i.body.errors)==null?void 0:l[0].message)||i.statusText||"Unknown error");return{pageInfo:{hasNextPage:u.search.pageInfo.hasNextPage,endCursor:u.search.pageInfo.endCursor},data:((p=u.search.nodes)==null?void 0:p.map(Ct))||[]}}async searchIssues(t,s={}){var u,l;let n=await this.getScopes(s),a=k(n),o=await h(this.config,fe("issue",t.query,t.cursor,a),s),{data:i}=o.body;if(!i)throw new Error(((u=o.body.errors)==null?void 0:u[0].message)||o.statusText||"Unknown error");return{pageInfo:{hasNextPage:i.search.pageInfo.hasNextPage,endCursor:i.search.pageInfo.endCursor},data:((l=i.search.nodes)==null?void 0:l.map(vt))||[]}}async getPullRequestsAssociatedWithUser(t,s={}){var g;let[n,a,o]=((g=t.cursor)==null?void 0:g.split(";"))||[void 0,void 0,void 0];if(t.cursor&&n==="null"&&a==="null"&&o==="null")return{pageInfo:{hasNextPage:!1,endCursor:"null;null;null"},data:[]};let[i,u,l]=await Promise.all([this.searchPullRequests({query:`author:${t.username}`,cursor:n},s),this.searchPullRequests({query:`assignee:${t.username}`,cursor:a},s),this.searchPullRequests({query:`review-requested:${t.username}`,cursor:o},s)]),p={},d=[],c=R=>{p[R.id]||(p[R.id]=!0,d.push(R))};return i.data.forEach(c),u.data.forEach(c),l.data.forEach(c),{pageInfo:{hasNextPage:i.pageInfo.hasNextPage||u.pageInfo.hasNextPage||l.pageInfo.hasNextPage,endCursor:`${(i==null?void 0:i.pageInfo.hasNextPage)&&(i==null?void 0:i.pageInfo.endCursor)||"null"};${(u==null?void 0:u.pageInfo.hasNextPage)&&(u==null?void 0:u.pageInfo.endCursor)||"null"};${(l==null?void 0:l.pageInfo.hasNextPage)&&(l==null?void 0:l.pageInfo.endCursor)||"null"}`},data:d}}async getPullRequestsForRepos(t,s={}){let{assigneeLogins:n,updatedBefore:a,authorLogin:o,repos:i,reviewRequestedLogin:u,startQuery:l,mentionLogin:p}=t,d=he(l||"");return i.forEach(c=>{d.push(`repo:${c.namespace}/${c.name}`)}),n&&n.forEach(c=>{d.push(`assignee:${c}`)}),a&&d.push(`updated:<${a}`),o&&d.push(`author:${o}`),u&&d.push(`review-requested:${u}`),p&&d.push(`mentions:${p}`),this.searchPullRequests({query:`sort:updated ${d.join(" ")}`,isDraft:t.isDraft,cursor:t.cursor},s)}async closePullRequest(t,s={}){var i,u,l;let{pullRequestGraphQLId:n}=t,a=`mutation ClosePullRequest($pullRequestGraphQLId: ID!) {
365
+ `,variables:{owner:t.repo.namespace,name:t.repo.name,ref:t.ref,path:t.path}},s)).body.data)==null?void 0:i.repository;if(!o)throw new Error("Repository not found.");let a=o.object;if(!a||!("blame"in a))throw new Error("Ref not found.");if(a.blame.ranges.length===0)throw new Error("File not found.");return{data:{ranges:a.blame.ranges.map(u=>{var l;return{startingLine:u.startingLine,endingLine:u.endingLine,commit:{oid:u.commit.oid,parentOids:((l=u.commit.parents.nodes)==null?void 0:l.map(p=>p.oid))||[],authoredDate:new Date(u.commit.authoredDate),author:u.commit.author?{name:u.commit.author.name,email:u.commit.author.email,avatarUrl:u.commit.author.avatarUrl}:null,committedDate:new Date(u.commit.committedDate),committer:u.commit.committer?{name:u.commit.committer.name,email:u.commit.committer.email,avatarUrl:u.commit.committer.avatarUrl}:null,message:u.commit.message,fileCount:u.commit.changedFilesIfAvailable,additions:u.commit.additions,deletions:u.commit.deletions}}})}}}async searchPullRequests(t,s={}){var l,p;let n=await this.getScopes(s),o=O(n),a=d=>{let c=d&&typeof t.isDraft=="boolean"?`${t.query} draft:${t.isDraft}`:t.query;return Ie("pr",c,t.cursor,o,d)},i=await h(this.config,a(!0),s);i.body.errors&&Ve(i.body.errors)&&(this.config.baseUrl||s.baseUrl)&&(i=await h(this.config,a(!1),s));let{data:u}=i.body;if(!u)throw new Error(((l=i.body.errors)==null?void 0:l[0].message)||i.statusText||"Unknown error");return{pageInfo:{hasNextPage:u.search.pageInfo.hasNextPage,endCursor:u.search.pageInfo.endCursor},data:((p=u.search.nodes)==null?void 0:p.map(Ut))||[]}}async searchIssues(t,s={}){var u,l;let n=await this.getScopes(s),o=O(n),a=await h(this.config,Ie("issue",t.query,t.cursor,o),s),{data:i}=a.body;if(!i)throw new Error(((u=a.body.errors)==null?void 0:u[0].message)||a.statusText||"Unknown error");return{pageInfo:{hasNextPage:i.search.pageInfo.hasNextPage,endCursor:i.search.pageInfo.endCursor},data:((l=i.search.nodes)==null?void 0:l.map($t))||[]}}async getPullRequestsAssociatedWithUser(t,s={}){return this.searchPullRequests({query:`involves:${t.username}`,cursor:t.cursor},s)}async getPullRequestsForRepos(t,s={}){let{assigneeLogins:n,updatedBefore:o,authorLogin:a,repos:i,reviewRequestedLogin:u,startQuery:l,mentionLogin:p}=t,d=Re(l||"");return i.forEach(c=>{d.push(`repo:${c.namespace}/${c.name}`)}),n&&n.forEach(c=>{d.push(`assignee:${c}`)}),o&&d.push(`updated:<${o}`),a&&d.push(`author:${a}`),u&&d.push(`review-requested:${u}`),p&&d.push(`mentions:${p}`),this.searchPullRequests({query:`sort:updated ${d.join(" ")}`,isDraft:t.isDraft,cursor:t.cursor},s)}async closePullRequest(t,s={}){var i,u,l;let{pullRequestGraphQLId:n}=t,o=`mutation ClosePullRequest($pullRequestGraphQLId: ID!) {
352
366
  closePullRequest(input: { pullRequestId: $pullRequestGraphQLId }) {
353
367
  pullRequest {
354
368
  id
355
369
  }
356
370
  }
357
- }`;if(!((l=(u=(i=(await h(this.config,{query:`${a}`,variables:{pullRequestGraphQLId:n}},s)).body.data)==null?void 0:i.closePullRequest)==null?void 0:u.pullRequest)!=null&&l.id))throw new Error("Could not close pull request")}async mergePullRequest(t,s={}){var u,l,p;let{pullRequestGraphQLId:n,expectedSourceSha:a}=t,o=`mutation MergePullRequest($pullRequestGraphQLId: ID!, $expectedSourceSha: GitObjectID!) {
358
- mergePullRequest(input: { pullRequestId: $pullRequestGraphQLId, expectedHeadOid: $expectedSourceSha }) {
371
+ }`;if(!((l=(u=(i=(await h(this.config,{query:`${o}`,variables:{pullRequestGraphQLId:n}},s)).body.data)==null?void 0:i.closePullRequest)==null?void 0:u.pullRequest)!=null&&l.id))throw new Error("Could not close pull request")}async mergePullRequest(t,s={}){var p,d,c;let{pullRequestGraphQLId:n,expectedSourceSha:o,mergeStrategy:a}=t,i;switch(a){case"MERGE_COMMIT":{i="MERGE";break}case"REBASE":{i="REBASE";break}case"SQUASH":{i="SQUASH";break}}let u=`mutation MergePullRequest(
372
+ $pullRequestGraphQLId: ID!,
373
+ $expectedSourceSha: GitObjectID!,
374
+ $mergeStrategy: PullRequestMergeMethod,
375
+ ) {
376
+ mergePullRequest(input: {
377
+ pullRequestId: $pullRequestGraphQLId,
378
+ expectedHeadOid: $expectedSourceSha,
379
+ mergeMethod: $mergeStrategy,
380
+ }) {
359
381
  pullRequest {
360
382
  id
361
383
  }
362
384
  }
363
- }`;if(!((p=(l=(u=(await h(this.config,{query:`${o}`,variables:{pullRequestGraphQLId:n,expectedSourceSha:a}},s)).body.data)==null?void 0:u.mergePullRequest)==null?void 0:l.pullRequest)!=null&&p.id))throw new Error("Could not merge pull request")}async setPullRequestMilestone(t,s={}){var u,l,p;let{pullRequestGraphQLId:n,milestoneGraphQLId:a}=t,o=`mutation SetPullRequestMilestone($pullRequestGraphQLId: ID!, $milestoneGraphQLId: ID) {
385
+ }`;if(!((c=(d=(p=(await h(this.config,{query:`${u}`,variables:{pullRequestGraphQLId:n,expectedSourceSha:o,mergeStrategy:i}},s)).body.data)==null?void 0:p.mergePullRequest)==null?void 0:d.pullRequest)!=null&&c.id))throw new Error("Could not merge pull request")}async setPullRequestMilestone(t,s={}){var u,l,p;let{pullRequestGraphQLId:n,milestoneGraphQLId:o}=t,a=`mutation SetPullRequestMilestone($pullRequestGraphQLId: ID!, $milestoneGraphQLId: ID) {
364
386
  updatePullRequest(input: { pullRequestId: $pullRequestGraphQLId, milestoneId: $milestoneGraphQLId }) {
365
387
  pullRequest {
366
388
  id
367
389
  }
368
390
  }
369
- }`;if(!((p=(l=(u=(await h(this.config,{query:`${o}`,variables:{pullRequestGraphQLId:n,milestoneGraphQLId:a}},s)).body.data)==null?void 0:u.updatePullRequest)==null?void 0:l.pullRequest)!=null&&p.id))throw new Error("Could not set milestone of pull request")}async markPullRequestReadyForReview(t,s){var o,i,u;let n=`mutation MarkReadyToReview($pullRequestGraphQLId: ID!) {
391
+ }`;if(!((p=(l=(u=(await h(this.config,{query:`${a}`,variables:{pullRequestGraphQLId:n,milestoneGraphQLId:o}},s)).body.data)==null?void 0:u.updatePullRequest)==null?void 0:l.pullRequest)!=null&&p.id))throw new Error("Could not set milestone of pull request")}async markPullRequestReadyForReview(t,s){var a,i,u;let n=`mutation MarkReadyToReview($pullRequestGraphQLId: ID!) {
370
392
  markPullRequestReadyForReview(input: { pullRequestId: $pullRequestGraphQLId }) {
371
393
  pullRequest {
372
394
  id
373
395
  }
374
396
  }
375
- }`;if(!((u=(i=(o=(await h(this.config,{query:n,variables:{pullRequestGraphQLId:t}},s)).body.data)==null?void 0:o.markPullRequestReadyForReview)==null?void 0:i.pullRequest)!=null&&u.id))throw new Error("Could not mark pull request ready to review")}async convertPullRequestToDraft(t,s){var o,i,u;let n=`mutation ConvertToDraft($pullRequestGraphQLId: ID!) {
397
+ }`;if(!((u=(i=(a=(await h(this.config,{query:n,variables:{pullRequestGraphQLId:t}},s)).body.data)==null?void 0:a.markPullRequestReadyForReview)==null?void 0:i.pullRequest)!=null&&u.id))throw new Error("Could not mark pull request ready to review")}async convertPullRequestToDraft(t,s){var a,i,u;let n=`mutation ConvertToDraft($pullRequestGraphQLId: ID!) {
376
398
  convertPullRequestToDraft(input: { pullRequestId: $pullRequestGraphQLId }) {
377
399
  pullRequest {
378
400
  id
379
401
  }
380
402
  }
381
- }`;if(!((u=(i=(o=(await h(this.config,{query:n,variables:{pullRequestGraphQLId:t}},s)).body.data)==null?void 0:o.convertPullRequestToDraft)==null?void 0:i.pullRequest)!=null&&u.id))throw new Error("Could not convert pull request to draft")}async setPullRequestAsDraft(t,s={}){let{pullRequestGraphQLId:n,isDraft:a}=t;if(a){await this.convertPullRequestToDraft(n,s);return}await this.markPullRequestReadyForReview(n,s)}async getIssuesAssociatedWithUser(t,s={}){var d;let[n,a]=((d=t.cursor)==null?void 0:d.split(";"))||[void 0,void 0];if(t.cursor&&n==="null"&&a==="null")return{pageInfo:{hasNextPage:!1,endCursor:"null;null"},data:[]};let[o,i]=await Promise.all([this.searchIssues({query:`author:${t.username}`,cursor:n},s),this.searchIssues({query:`assignee:${t.username}`,cursor:a},s)]),u={},l=[],p=c=>{u[c.id]||(u[c.id]=!0,l.push(c))};return o.data.forEach(p),i.data.forEach(p),{pageInfo:{hasNextPage:o.pageInfo.hasNextPage||i.pageInfo.hasNextPage,endCursor:`${(o==null?void 0:o.pageInfo.hasNextPage)&&(o==null?void 0:o.pageInfo.endCursor)||"null"};${(i==null?void 0:i.pageInfo.hasNextPage)&&(i==null?void 0:i.pageInfo.endCursor)||"null"}`},data:l}}async getIssuesForRepos(t,s={}){let n=he(t.startQuery||""),{cursor:a,assigneeLogins:o,updatedBefore:i,authorLogin:u,mentionLogin:l}=t;return t.repos.forEach(p=>{n.push(`repo:${p.namespace}/${p.name}`)}),o&&o.forEach(p=>{n.push(`assignee:${p}`)}),i&&n.push(`updated:<${i}`),u&&n.push(`author:${u}`),l&&n.push(`mentions:${l}`),this.searchIssues({query:`sort:updated ${n.join(" ")}`,cursor:a},s)}async closeIssueWithReason(t,s,n){var i,u,l;let a=`mutation CloseIssueWithReason($issueGraphQLId: ID!, $closeReason: IssueClosedStateReason!) {
403
+ }`;if(!((u=(i=(a=(await h(this.config,{query:n,variables:{pullRequestGraphQLId:t}},s)).body.data)==null?void 0:a.convertPullRequestToDraft)==null?void 0:i.pullRequest)!=null&&u.id))throw new Error("Could not convert pull request to draft")}async setPullRequestAsDraft(t,s={}){let{pullRequestGraphQLId:n,isDraft:o}=t;if(o){await this.convertPullRequestToDraft(n,s);return}await this.markPullRequestReadyForReview(n,s)}async getIssuesAssociatedWithUser(t,s={}){var d;let[n,o]=((d=t.cursor)==null?void 0:d.split(";"))||[void 0,void 0];if(t.cursor&&n==="null"&&o==="null")return{pageInfo:{hasNextPage:!1,endCursor:"null;null"},data:[]};let[a,i]=await Promise.all([this.searchIssues({query:`author:${t.username}`,cursor:n},s),this.searchIssues({query:`assignee:${t.username}`,cursor:o},s)]),u={},l=[],p=c=>{u[c.id]||(u[c.id]=!0,l.push(c))};return a.data.forEach(p),i.data.forEach(p),{pageInfo:{hasNextPage:a.pageInfo.hasNextPage||i.pageInfo.hasNextPage,endCursor:`${(a==null?void 0:a.pageInfo.hasNextPage)&&(a==null?void 0:a.pageInfo.endCursor)||"null"};${(i==null?void 0:i.pageInfo.hasNextPage)&&(i==null?void 0:i.pageInfo.endCursor)||"null"}`},data:l}}async getIssuesForRepos(t,s={}){let n=Re(t.startQuery||""),{cursor:o,assigneeLogins:a,updatedBefore:i,authorLogin:u,mentionLogin:l}=t;return t.repos.forEach(p=>{n.push(`repo:${p.namespace}/${p.name}`)}),a&&a.forEach(p=>{n.push(`assignee:${p}`)}),i&&n.push(`updated:<${i}`),u&&n.push(`author:${u}`),l&&n.push(`mentions:${l}`),this.searchIssues({query:`sort:updated ${n.join(" ")}`,cursor:o},s)}async closeIssueWithReason(t,s,n){var i,u,l;let o=`mutation CloseIssueWithReason($issueGraphQLId: ID!, $closeReason: IssueClosedStateReason!) {
382
404
  closeIssue(input: { issueId: $issueGraphQLId, stateReason: $closeReason }) {
383
405
  issue {
384
406
  id
385
407
  }
386
408
  }
387
- }`;if(!((l=(u=(i=(await h(this.config,{query:a,variables:{issueGraphQLId:t,closeReason:s}},n)).body.data)==null?void 0:i.closeIssue)==null?void 0:u.issue)!=null&&l.id))throw new Error("Could not close issue with reason")}async closeIssueWithoutReason(t,s){var o,i,u;let n=`mutation SetIssueState($issueGraphQLId: ID!) {
409
+ }`;if(!((l=(u=(i=(await h(this.config,{query:o,variables:{issueGraphQLId:t,closeReason:s}},n)).body.data)==null?void 0:i.closeIssue)==null?void 0:u.issue)!=null&&l.id))throw new Error("Could not close issue with reason")}async closeIssueWithoutReason(t,s){var a,i,u;let n=`mutation SetIssueState($issueGraphQLId: ID!) {
388
410
  updateIssue(input: { id: $issueGraphQLId, state: CLOSED }) {
389
411
  issue {
390
412
  id
391
413
  }
392
414
  }
393
- }`;if(!((u=(i=(o=(await h(this.config,{query:n,variables:{issueGraphQLId:t}},s)).body.data)==null?void 0:o.updateIssue)==null?void 0:i.issue)!=null&&u.id))throw new Error("Could not close issue")}async reopenIssue(t,s){var o,i,u;let n=`mutation ReOpenIssue($issueGraphQLId: ID!) {
415
+ }`;if(!((u=(i=(a=(await h(this.config,{query:n,variables:{issueGraphQLId:t}},s)).body.data)==null?void 0:a.updateIssue)==null?void 0:i.issue)!=null&&u.id))throw new Error("Could not close issue")}async reopenIssue(t,s){var a,i,u;let n=`mutation ReOpenIssue($issueGraphQLId: ID!) {
394
416
  reopenIssue(input: { issueId: $issueGraphQLId }) {
395
417
  issue {
396
418
  id
397
419
  }
398
420
  }
399
- }`;if(!((u=(i=(o=(await h(this.config,{query:n,variables:{issueGraphQLId:t}},s)).body.data)==null?void 0:o.reopenIssue)==null?void 0:i.issue)!=null&&u.id))throw new Error("Could not reopen issue")}async setIssueStatus(t,s={}){let{issueGraphQLId:n,status:a,closeReason:o}=t;if(o&&a=="OPEN")throw new Error("Did not expect closeReason to be set when trying to reopen issue");a=="OPEN"?await this.reopenIssue(n,s):a=="CLOSED"&&!o?await this.closeIssueWithoutReason(n,s):o&&await this.closeIssueWithReason(n,o,s)}async setIssueMilestone(t,s={}){var u,l,p;let{issueGraphQLId:n,milestoneGraphQLId:a}=t,o=`mutation SetIssueMilestone($issueGraphQLId: ID!, $milestoneGraphQLId: ID) {
421
+ }`;if(!((u=(i=(a=(await h(this.config,{query:n,variables:{issueGraphQLId:t}},s)).body.data)==null?void 0:a.reopenIssue)==null?void 0:i.issue)!=null&&u.id))throw new Error("Could not reopen issue")}async setIssueStatus(t,s={}){let{issueGraphQLId:n,status:o,closeReason:a}=t;if(a&&o=="OPEN")throw new Error("Did not expect closeReason to be set when trying to reopen issue");o=="OPEN"?await this.reopenIssue(n,s):o=="CLOSED"&&!a?await this.closeIssueWithoutReason(n,s):a&&await this.closeIssueWithReason(n,a,s)}async setIssueMilestone(t,s={}){var u,l,p;let{issueGraphQLId:n,milestoneGraphQLId:o}=t,a=`mutation SetIssueMilestone($issueGraphQLId: ID!, $milestoneGraphQLId: ID) {
400
422
  updateIssue(input: { id: $issueGraphQLId, milestoneId: $milestoneGraphQLId }) {
401
423
  issue {
402
424
  id
403
425
  }
404
426
  }
405
- }`;if(!((p=(l=(u=(await h(this.config,{query:`${o}`,variables:{issueGraphQLId:n,milestoneGraphQLId:a}},s)).body.data)==null?void 0:u.updateIssue)==null?void 0:l.issue)!=null&&p.id))throw new Error("Could not set milestone of issue")}async getMilestonesForRepo(t,s={}){var u,l,p,d;let{repo:{namespace:n,name:a},cursor:o}=t,i=await h(this.config,{query:`
427
+ }`;if(!((p=(l=(u=(await h(this.config,{query:`${a}`,variables:{issueGraphQLId:n,milestoneGraphQLId:o}},s)).body.data)==null?void 0:u.updateIssue)==null?void 0:l.issue)!=null&&p.id))throw new Error("Could not set milestone of issue")}async getMilestonesForRepo(t,s={}){var u,l,p,d;let{repo:{namespace:n,name:o},cursor:a}=t,i=await h(this.config,{query:`
406
428
  query getLabelsForRepo($owner: String!, $name: String! $cursor: String, $first: Int!) {
407
429
  repository(owner: $owner, name: $name) {
408
430
  milestones(first: $first, after: $cursor) {
@@ -416,7 +438,7 @@ query getLabelsForRepo($owner: String!, $name: String! $cursor: String, $first:
416
438
  }
417
439
  }
418
440
  }
419
- `,variables:{owner:n,name:a,cursor:o,first:C}},s);if(!i.body.data)throw new Error(((u=i.body.errors)==null?void 0:u[0].message)||i.statusText||"Unknown error");return{pageInfo:((l=i.body.data.repository.milestones)==null?void 0:l.pageInfo)??{endCursor:null,hasNextPage:!1},data:((d=(p=i.body.data.repository.milestones)==null?void 0:p.nodes)==null?void 0:d.map(Pe))??[]}}async getLabelsForRepo(t,s={}){var u,l,p,d;let{repo:{namespace:n,name:a},cursor:o}=t,i=await h(this.config,{query:`
441
+ `,variables:{owner:n,name:o,cursor:a,first:S}},s);if(!i.body.data)throw new Error(((u=i.body.errors)==null?void 0:u[0].message)||i.statusText||"Unknown error");return{pageInfo:((l=i.body.data.repository.milestones)==null?void 0:l.pageInfo)??{endCursor:null,hasNextPage:!1},data:((d=(p=i.body.data.repository.milestones)==null?void 0:p.nodes)==null?void 0:d.map(Se))??[]}}async getLabelsForRepo(t,s={}){var u,l,p,d;let{repo:{namespace:n,name:o},cursor:a}=t,i=await h(this.config,{query:`
420
442
  query getLabelsForRepo($owner: String!, $name: String! $cursor: String, $first: Int!) {
421
443
  repository(owner: $owner, name: $name) {
422
444
  labels(first: $first, after: $cursor) {
@@ -430,7 +452,7 @@ query getLabelsForRepo($owner: String!, $name: String! $cursor: String, $first:
430
452
  }
431
453
  }
432
454
  }
433
- `,variables:{owner:n,name:a,cursor:o,first:C}},s);if(!i.body.data)throw new Error(((u=i.body.errors)==null?void 0:u[0].message)||i.statusText||"Unknown error");return{pageInfo:((l=i.body.data.repository.labels)==null?void 0:l.pageInfo)??{endCursor:null,hasNextPage:!1},data:((d=(p=i.body.data.repository.labels)==null?void 0:p.nodes)==null?void 0:d.map(ye))??[]}}};var $t="https://gitlab.com/api/v4",Dt="https://gitlab.com/api/graphql",Je=/\/api\/v\d+$/,Ve=e=>{if(e.endsWith("/api/graphql"))throw new Error("The graphql endpoint is being used as the baseUrl. This package uses both GraphQL and REST APIs, and the REST version cannot be assumed. Use the REST endpoint as the baseUrl instead.")},we=(e,r)=>{let t=r.baseUrl||e.baseUrl;return t?(t=t.replace(/\/$/,""),Ve(t),t):$t},Et=(e,r)=>{let t=r.baseUrl||e.baseUrl;return t?(t=t.replace(/\/$/,""),Ve(t),Je.test(t)&&(t=t.replace(Je,"")),`${t}/api/graphql`):Dt},f=(e,r,t)=>{let s=m(t.token||e.token);return e.request({url:Et(e,t),method:"POST",headers:{...s,"Content-Type":"application/json"},body:JSON.stringify(r)})};var Ke=e=>e.split("/").slice(0,-1).join("/"),_=e=>({namespace:Ke(e.fullPath),name:e.path,webUrl:e.webUrl}),St={assigned:"assignedMergeRequests",authored:"authoredMergeRequests",reviewRequested:"reviewRequestedMergeRequests"},Ut={CAN_BE_MERGED:"MERGEABLE",CANNOT_BE_MERGED:"CONFLICTS",CANNOT_BE_MERGED_RECHECK:"UNKNOWN",UNCHECKED:"UNKNOWN",CHECKING:"UNKNOWN"},Ue="gid://gitlab/User/",z="gid://gitlab/Project/",qt="gid://gitlab/MergeRequest/",Lt="gid://gitlab/Issue/",Gt="gid://gitlab/ProjectLabel/",Xe="gid://gitlab/Milestone/",qe=`
455
+ `,variables:{owner:n,name:o,cursor:a,first:S}},s);if(!i.body.data)throw new Error(((u=i.body.errors)==null?void 0:u[0].message)||i.statusText||"Unknown error");return{pageInfo:((l=i.body.data.repository.labels)==null?void 0:l.pageInfo)??{endCursor:null,hasNextPage:!1},data:((d=(p=i.body.data.repository.labels)==null?void 0:p.nodes)==null?void 0:d.map(we))??[]}}};var vt="https://gitlab.com/api/v4",Et="https://gitlab.com/api/graphql",Ke=/\/api\/v\d+$/,Xe=e=>{if(e.endsWith("/api/graphql"))throw new Error("The graphql endpoint is being used as the baseUrl. This package uses both GraphQL and REST APIs, and the REST version cannot be assumed. Use the REST endpoint as the baseUrl instead.")},Ce=(e,r)=>{let t=r.baseUrl||e.baseUrl;return t?(t=t.replace(/\/$/,""),Xe(t),t):vt},Dt=(e,r)=>{let t=r.baseUrl||e.baseUrl;return t?(t=t.replace(/\/$/,""),Xe(t),Ke.test(t)&&(t=t.replace(Ke,"")),`${t}/api/graphql`):Et},R=(e,r,t)=>{let s=m(t.token||e.token);return e.request({url:Dt(e,t),method:"POST",headers:{...s,"Content-Type":"application/json"},body:JSON.stringify(r)})};var Ze=e=>e.split("/").slice(0,-1).join("/"),Q=e=>({namespace:Ze(e.fullPath),name:e.path,webUrl:e.webUrl}),qt={assigned:"assignedMergeRequests",authored:"authoredMergeRequests",reviewRequested:"reviewRequestedMergeRequests"},Gt={CAN_BE_MERGED:"MERGEABLE",CANNOT_BE_MERGED:"CONFLICTS",CANNOT_BE_MERGED_RECHECK:"UNKNOWN",UNCHECKED:"UNKNOWN",CHECKING:"UNKNOWN"},Ge="gid://gitlab/User/",W="gid://gitlab/Project/",Lt="gid://gitlab/MergeRequest/",xt="gid://gitlab/Issue/",At="gid://gitlab/ProjectLabel/",Ye="gid://gitlab/Milestone/",Le=`
434
456
  description
435
457
  dueDate
436
458
  id
@@ -439,7 +461,7 @@ startDate
439
461
  state
440
462
  title
441
463
  webPath
442
- `,Ce=`
464
+ `,Ue=`
443
465
  id
444
466
  path
445
467
  fullPath
@@ -449,24 +471,24 @@ sshUrlToRepo
449
471
  repository {
450
472
  rootRef
451
473
  }
452
- `,A=`
474
+ `,x=`
453
475
  id
454
476
  name
455
477
  username
456
478
  publicEmail
457
479
  avatarUrl
458
- `,Le=`
480
+ `,xe=`
459
481
  color
460
482
  description
461
483
  id
462
484
  title
463
- `,ve=`
485
+ `,$e=`
464
486
  author {
465
- ${A}
487
+ ${x}
466
488
  }
467
489
  assignees {
468
490
  nodes {
469
- ${A}
491
+ ${x}
470
492
  }
471
493
  }
472
494
  createdAt
@@ -476,7 +498,7 @@ id
476
498
  iid
477
499
  labels {
478
500
  nodes {
479
- ${Le}
501
+ ${xe}
480
502
  }
481
503
  }
482
504
  state
@@ -487,13 +509,13 @@ upvotes
487
509
  userNotesCount
488
510
  webUrl
489
511
  milestone {
490
- ${qe}
512
+ ${Le}
491
513
  }
492
- `,$e=(e,r)=>`
514
+ `,ve=(e,r)=>`
493
515
  id
494
516
  state
495
517
  author {
496
- ${A}
518
+ ${x}
497
519
  }
498
520
  diffRefs {
499
521
  baseSha
@@ -518,12 +540,12 @@ targetBranch
518
540
  sourceBranch
519
541
  assignees {
520
542
  nodes {
521
- ${A}
543
+ ${x}
522
544
  }
523
545
  }
524
546
  reviewers {
525
547
  nodes {
526
- ${A}
548
+ ${x}
527
549
  mergeRequestInteraction {
528
550
  approved
529
551
  reviewState
@@ -533,18 +555,18 @@ reviewers {
533
555
  mergeStatusEnum
534
556
  labels {
535
557
  nodes {
536
- ${Le}
558
+ ${xe}
537
559
  }
538
560
  }
539
561
  ${e?"project { path fullPath webUrl }":""}
540
- ${r?`milestone { ${qe} }`:""}
541
- `,O=e=>`${e.namespace}/${e.name}`,xt=e=>`${e.namespace}/${e.name}`,De=e=>{var r;return{id:e.id.replace(z,""),graphQLId:e.id,namespace:Ke(e.fullPath),name:e.path,webUrl:e.webUrl,httpsUrl:e.httpUrlToRepo,sshUrl:e.sshUrlToRepo,defaultBranch:(r=e.repository)!=null&&r.rootRef?{name:e.repository.rootRef}:null,permission:null}},Tt={opened:"OPEN",merged:"MERGED",closed:"CLOSED"},N=e=>({id:e.id.replace(Ue,""),graphQLId:e.id,name:e.name,username:e.username,email:e.publicEmail,avatarUrl:e.avatarUrl}),Ge=e=>({color:e.color,description:e.description,id:e.id.replace(Gt,""),graphQLId:e.id,name:e.title}),Ee=(e,r)=>{var t,s,n,a,o,i,u,l,p;return{id:e.id.replace(qt,""),graphQLId:e.id,title:e.title,number:parseInt(e.iid,10),state:Tt[e.state],commentCount:e.userNotesCount||0,upvoteCount:e.upvotes,author:e.author?N(e.author):null,createdDate:new Date(e.createdAt),isDraft:e.draft,repository:{name:r.name,owner:{login:r.namespace}},headRepository:null,headCommit:{buildStatus:null},baseRef:{name:e.targetBranch,oid:((t=e.diffRefs)==null?void 0:t.baseSha)??null},headRef:{name:e.sourceBranch,oid:((s=e.diffRefs)==null?void 0:s.headSha)??null},url:e.webUrl,updatedDate:new Date(e.updatedAt),closedDate:e.mergedAt?new Date(e.mergedAt):null,assignees:(n=e.assignees)!=null&&n.nodes?e.assignees.nodes.map(N):null,reviews:(a=e.reviewers)!=null&&a.nodes?e.reviewers.nodes.map(d=>{var c,g;return{reviewer:N(d),state:(c=d.mergeRequestInteraction)!=null&&c.approved?"APPROVED":((g=d.mergeRequestInteraction)==null?void 0:g.reviewState)==="REVIEWED"?"CHANGES_REQUESTED":"CHANGES_REQUESTED"}}):null,additions:((o=e.diffStatsSummary)==null?void 0:o.additions)||0,deletions:((i=e.diffStatsSummary)==null?void 0:i.deletions)||0,fileCount:((u=e.diffStatsSummary)==null?void 0:u.fileCount)||0,commitCount:e.commitCount||0,mergeableState:Ut[e.mergeStatusEnum],milestone:e.milestone?xe(e.milestone,r.webUrl):null,labels:((p=(l=e.labels)==null?void 0:l.nodes)==null?void 0:p.map(Ge))??[]}},Se=(e,r)=>{var t,s;return{author:{avatarUrl:e.author.avatarUrl,email:null,graphQLId:e.author.id,id:e.author.id.replace(Ue,""),name:e.author.name,username:e.author.username},assignees:e.assignees.nodes.map(n=>({avatarUrl:n.avatarUrl,email:null,graphQLId:n.id,id:n.id.replace(Ue,""),name:n.name,username:n.username})),commentCount:e.userNotesCount,createdDate:new Date(e.createdAt),description:e.description,graphQLId:e.id,id:e.id.replace(Lt,""),labels:((s=(t=e.labels)==null?void 0:t.nodes)==null?void 0:s.map(Ge))??[],number:e.iid,repository:{name:r.name,owner:{login:r.namespace}},updatedDate:new Date(e.updatedAt),upvoteCount:e.upvotes,state:{name:e.state,color:null},type:e.type,title:e.title,url:e.webUrl,milestone:e.milestone?xe(e.milestone,r.webUrl):null}},xe=(e,r)=>({id:e.id.replace(Xe,""),graphQLId:e.id,number:parseInt(e.iid,10),title:e.title,description:e.description,isOpen:e.state==="active",url:`${r}/-/${e.webPath.replace(/.+?\/-\//,"")}`,startDate:e.startDate?new Date(e.startDate):null,dueDate:e.dueDate?new Date(e.dueDate):null}),W=class extends T{async getCurrentUser(r={}){var n;let s=(n=(await f(this.config,{query:`
562
+ ${r?`milestone { ${Le} }`:""}
563
+ `,k=e=>`${e.namespace}/${e.name}`,Tt=e=>`${e.namespace}/${e.name}`,Ee=e=>{var r;return{id:e.id.replace(W,""),graphQLId:e.id,namespace:Ze(e.fullPath),name:e.path,webUrl:e.webUrl,httpsUrl:e.httpUrlToRepo,sshUrl:e.sshUrlToRepo,defaultBranch:(r=e.repository)!=null&&r.rootRef?{name:e.repository.rootRef}:null,permission:null}},Ot={opened:"OPEN",merged:"MERGED",closed:"CLOSED"},_=e=>({id:e.id.replace(Ge,""),graphQLId:e.id,name:e.name,username:e.username,email:e.publicEmail,avatarUrl:e.avatarUrl}),Ae=e=>({color:e.color,description:e.description,id:e.id.replace(At,""),graphQLId:e.id,name:e.title}),De=(e,r)=>{var t,s,n,o,a,i,u,l,p;return{id:e.id.replace(Lt,""),graphQLId:e.id,title:e.title,number:parseInt(e.iid,10),state:Ot[e.state],commentCount:e.userNotesCount||0,upvoteCount:e.upvotes,author:e.author?_(e.author):null,createdDate:new Date(e.createdAt),isDraft:e.draft,repository:{name:r.name,owner:{login:r.namespace}},headRepository:null,headCommit:{buildStatus:null},baseRef:{name:e.targetBranch,oid:((t=e.diffRefs)==null?void 0:t.baseSha)??null},headRef:{name:e.sourceBranch,oid:((s=e.diffRefs)==null?void 0:s.headSha)??null},url:e.webUrl,updatedDate:new Date(e.updatedAt),closedDate:e.mergedAt?new Date(e.mergedAt):null,assignees:(n=e.assignees)!=null&&n.nodes?e.assignees.nodes.map(_):null,reviews:(o=e.reviewers)!=null&&o.nodes?e.reviewers.nodes.map(d=>{var c,g;return{reviewer:_(d),state:(c=d.mergeRequestInteraction)!=null&&c.approved?"APPROVED":((g=d.mergeRequestInteraction)==null?void 0:g.reviewState)==="REVIEWED"?"CHANGES_REQUESTED":"CHANGES_REQUESTED"}}):null,additions:((a=e.diffStatsSummary)==null?void 0:a.additions)||0,deletions:((i=e.diffStatsSummary)==null?void 0:i.deletions)||0,fileCount:((u=e.diffStatsSummary)==null?void 0:u.fileCount)||0,commitCount:e.commitCount||0,mergeableState:Gt[e.mergeStatusEnum],milestone:e.milestone?Te(e.milestone,r.webUrl):null,labels:((p=(l=e.labels)==null?void 0:l.nodes)==null?void 0:p.map(Ae))??[]}},qe=(e,r)=>{var t,s;return{author:{avatarUrl:e.author.avatarUrl,email:null,graphQLId:e.author.id,id:e.author.id.replace(Ge,""),name:e.author.name,username:e.author.username},assignees:e.assignees.nodes.map(n=>({avatarUrl:n.avatarUrl,email:null,graphQLId:n.id,id:n.id.replace(Ge,""),name:n.name,username:n.username})),commentCount:e.userNotesCount,createdDate:new Date(e.createdAt),description:e.description,graphQLId:e.id,id:e.id.replace(xt,""),labels:((s=(t=e.labels)==null?void 0:t.nodes)==null?void 0:s.map(Ae))??[],number:e.iid,repository:{name:r.name,owner:{login:r.namespace}},updatedDate:new Date(e.updatedAt),upvoteCount:e.upvotes,state:{name:e.state,color:null},type:e.type,title:e.title,url:e.webUrl,milestone:e.milestone?Te(e.milestone,r.webUrl):null}},Te=(e,r)=>({id:e.id.replace(Ye,""),graphQLId:e.id,number:parseInt(e.iid,10),title:e.title,description:e.description,isOpen:e.state==="active",url:`${r}/-/${e.webPath.replace(/.+?\/-\//,"")}`,startDate:e.startDate?new Date(e.startDate):null,dueDate:e.dueDate?new Date(e.dueDate):null}),H=class extends T{async getCurrentUser(r={}){var n;let s=(n=(await R(this.config,{query:`
542
564
  query getCurrentUser {
543
565
  currentUser {
544
- ${A}
566
+ ${x}
545
567
  }
546
568
  }
547
- `},r)).body.data)==null?void 0:n.currentUser;if(!s)throw new Error("Current user not found.");return{data:N(s)}}async getUserForCommit(r,t={}){var o,i,u,l;let s=O(r.repo),a=(l=(u=(i=(o=(await f(this.config,{query:`
569
+ `},r)).body.data)==null?void 0:n.currentUser;if(!s)throw new Error("Current user not found.");return{data:_(s)}}async getUserForCommit(r,t={}){var a,i,u,l;let s=k(r.repo),o=(l=(u=(i=(a=(await R(this.config,{query:`
548
570
  query getUserForCommit($fullPath: ID!, $oid: String!) {
549
571
  project(fullPath: $fullPath) {
550
572
  repository {
@@ -558,36 +580,57 @@ query getUserForCommit($fullPath: ID!, $oid: String!) {
558
580
  }
559
581
  }
560
582
  }
561
- `,variables:{fullPath:s,oid:r.oid}},t)).body.data)==null?void 0:o.project)==null?void 0:i.repository)==null?void 0:u.tree)==null?void 0:l.lastCommit;if(!a)throw new Error("Commit not found.");return{data:{name:a.authorName,email:a.authorEmail,avatarUrl:a.authorGravatar}}}async getAccountForEmail(r,t={}){var a,o,i;let n=(i=(o=(a=(await f(this.config,{query:`
583
+ `,variables:{fullPath:s,oid:r.oid}},t)).body.data)==null?void 0:a.project)==null?void 0:i.repository)==null?void 0:u.tree)==null?void 0:l.lastCommit;if(!o)throw new Error("Commit not found.");return{data:{name:o.authorName,email:o.authorEmail,avatarUrl:o.authorGravatar}}}async getAccountForEmail(r,t={}){var o,a,i;let n=(i=(a=(o=(await R(this.config,{query:`
562
584
  query getAccountForEmail($email: String!) {
563
585
  users(search: $email) {
564
586
  nodes {
565
- ${A}
587
+ ${x}
566
588
  }
567
589
  }
568
590
  }
569
- `,variables:{email:r.email}},t)).body.data)==null?void 0:a.users)==null?void 0:o.nodes)==null?void 0:i[0];if(!n)throw new Error("User not found.");return{data:N(n)}}async getAccountForUsername(r,t={}){var a;let n=(a=(await f(this.config,{query:`
591
+ `,variables:{email:r.email}},t)).body.data)==null?void 0:o.users)==null?void 0:a.nodes)==null?void 0:i[0];if(!n)throw new Error("User not found.");return{data:_(n)}}async getAccountForUsername(r,t={}){var o;let n=(o=(await R(this.config,{query:`
570
592
  query getAccountForUsername($username: String!) {
571
593
  user(username: $username) {
572
- ${A}
594
+ ${x}
595
+ }
596
+ }
597
+ `,variables:{username:r.username}},t)).body.data)==null?void 0:o.user;if(!n)throw new Error("User not found.");return{data:_(n)}}async getAccountsForRepo(r,t={}){var u,l,p,d,c,g,I;let{repo:{namespace:s,name:n},cursor:o}=r,a=await R(this.config,{query:`
598
+ query getAccountsForRepo(
599
+ $fullPath: ID!
600
+ $after: String
601
+ ) {
602
+ project(
603
+ fullPath: $fullPath
604
+ ) {
605
+ projectMembers(after: $after) {
606
+ nodes {
607
+ user {
608
+ ${x}
609
+ }
610
+ }
611
+ pageInfo {
612
+ endCursor
613
+ hasNextPage
614
+ }
615
+ }
573
616
  }
574
617
  }
575
- `,variables:{username:r.username}},t)).body.data)==null?void 0:a.user;if(!n)throw new Error("User not found.");return{data:N(n)}}async getRepo(r,t={}){var a;let s=O(r),n=await f(this.config,{query:`
618
+ `,variables:{fullPath:`${s}/${n}`,after:o}},t),i=(d=(p=(l=(u=a.body.data)==null?void 0:u.project)==null?void 0:l.projectMembers)==null?void 0:p.nodes)==null?void 0:d.map(f=>f.user).filter(f=>f!==null);return{pageInfo:((I=(g=(c=a.body.data)==null?void 0:c.project)==null?void 0:g.projectMembers)==null?void 0:I.pageInfo)??{endCursor:null,hasNextPage:!1},data:(i==null?void 0:i.map(_))??[]}}async getRepo(r,t={}){var o;let s=k(r),n=await R(this.config,{query:`
576
619
  query getRepo($fullPath: ID!) {
577
620
  project(fullPath: $fullPath) {
578
- ${Ce}
621
+ ${Ue}
579
622
  }
580
623
  }
581
- `,variables:{fullPath:s}},t);if(!((a=n.body.data)!=null&&a.project))throw new Error(`Repository ${s} not found`);return{data:De(n.body.data.project)}}async getRepos(r,t={}){let n=r.map(O).map((u,l)=>`
624
+ `,variables:{fullPath:s}},t);if(!((o=n.body.data)!=null&&o.project))throw new Error(`Repository ${s} not found`);return{data:Ee(n.body.data.project)}}async getRepos(r,t={}){let n=r.map(k).map((u,l)=>`
582
625
  getRepo_${l}: project(fullPath: "${u}") {
583
- ${Ce}
626
+ ${Ue}
584
627
  }
585
628
  `).join(`
586
- `),a=await f(this.config,{query:`
629
+ `),o=await R(this.config,{query:`
587
630
  query batchGetRepos {
588
631
  ${n}
589
632
  }
590
- `},t);if(!a.body.data)throw new Error(a.statusText||"Unknown error");let o=[],i=[];return r.forEach((u,l)=>{let p=a.body.data[`getRepo_${l}`];p?o.push(De(p)):i.push({input:u})}),{data:o,errors:i}}async getReposForCurrentUser(r={},t={}){var a,o,i,u,l,p;let s=await f(this.config,{query:`
633
+ `},t);if(!o.body.data)throw new Error(o.statusText||"Unknown error");let a=[],i=[];return r.forEach((u,l)=>{let p=o.body.data[`getRepo_${l}`];p?a.push(Ee(p)):i.push({input:u})}),{data:a,errors:i}}async getReposForCurrentUser(r={},t={}){var o,a,i,u,l,p;let s=await R(this.config,{query:`
591
634
  query getReposForCurrentUser($after: String) {
592
635
  projects(membership: true first: 100 after: $after) {
593
636
  pageInfo {
@@ -595,11 +638,11 @@ query getReposForCurrentUser($after: String) {
595
638
  hasNextPage
596
639
  }
597
640
  nodes {
598
- ${Ce}
641
+ ${Ue}
599
642
  }
600
643
  }
601
644
  }
602
- `,variables:{after:r.cursor}},t);if(!((a=s.body.data)!=null&&a.projects))throw new Error(((o=s.body.errors)==null?void 0:o[0].message)||s.statusText||"Unknown error");let n=((u=(i=s.body.data)==null?void 0:i.projects)==null?void 0:u.nodes)||[];return{pageInfo:(p=(l=s.body.data)==null?void 0:l.projects)==null?void 0:p.pageInfo,data:n.map(De)}}async getRefs(r,t,s={}){var u;let n=O(t.repo),a=new URL(`${we(this.config,s)}/projects/${encodeURIComponent(n)}/repository/${r}`);a.searchParams.set("page",((u=t.page)==null?void 0:u.toString())||"1"),a.searchParams.set("per_page",C.toString());let o=await this.config.request({url:a.toString(),headers:m(s.token||this.config.token)}),i=o.headers["x-next-page"];return{pageInfo:{hasNextPage:!!i,nextPage:i?parseInt(i,10):null},data:o.body.map(l=>({name:l.name,commit:{oid:l.commit.id,authoredDate:new Date(l.commit.authored_date),committedDate:new Date(l.commit.committed_date)}}))}}async getBranches(r,t={}){return this.getRefs("branches",r,t)}async getTags(r,t={}){return this.getRefs("tags",r,t)}async getBlame(r,t={}){let s=O(r.repo),n=new URL(`${we(this.config,t)}/projects/${encodeURIComponent(s)}/repository/files/${encodeURIComponent(r.path)}/blame`);n.searchParams.set("ref",r.ref);let a=await this.config.request({url:n.toString(),headers:m(t.token||this.config.token)}),o=0;return{data:{ranges:a.body.map(i=>{let u=o+1;return o+=i.lines.length,{startingLine:u,endingLine:o,commit:{oid:i.commit.id,parentOids:i.commit.parent_ids,authoredDate:new Date(i.commit.authored_date),author:{name:i.commit.author_name,email:i.commit.author_email,avatarUrl:null},committedDate:new Date(i.commit.committed_date),committer:{name:i.commit.committer_name,email:i.commit.committer_email,avatarUrl:null},message:i.commit.message,fileCount:null,additions:null,deletions:null}}})}}}async getPullRequestsForUser(r,t={}){var o,i;let s=St[r.association],n=await f(this.config,{query:`
645
+ `,variables:{after:r.cursor}},t);if(!((o=s.body.data)!=null&&o.projects))throw new Error(((a=s.body.errors)==null?void 0:a[0].message)||s.statusText||"Unknown error");let n=((u=(i=s.body.data)==null?void 0:i.projects)==null?void 0:u.nodes)||[];return{pageInfo:(p=(l=s.body.data)==null?void 0:l.projects)==null?void 0:p.pageInfo,data:n.map(Ee)}}async getRefs(r,t,s={}){var u;let n=k(t.repo),o=new URL(`${Ce(this.config,s)}/projects/${encodeURIComponent(n)}/repository/${r}`);o.searchParams.set("page",((u=t.page)==null?void 0:u.toString())||"1"),o.searchParams.set("per_page",S.toString());let a=await this.config.request({url:o.toString(),headers:m(s.token||this.config.token)}),i=a.headers["x-next-page"];return{pageInfo:{hasNextPage:!!i,nextPage:i?parseInt(i,10):null},data:a.body.map(l=>({name:l.name,commit:{oid:l.commit.id,authoredDate:new Date(l.commit.authored_date),committedDate:new Date(l.commit.committed_date)}}))}}async getBranches(r,t={}){return this.getRefs("branches",r,t)}async getTags(r,t={}){return this.getRefs("tags",r,t)}async getBlame(r,t={}){let s=k(r.repo),n=new URL(`${Ce(this.config,t)}/projects/${encodeURIComponent(s)}/repository/files/${encodeURIComponent(r.path)}/blame`);n.searchParams.set("ref",r.ref);let o=await this.config.request({url:n.toString(),headers:m(t.token||this.config.token)}),a=0;return{data:{ranges:o.body.map(i=>{let u=a+1;return a+=i.lines.length,{startingLine:u,endingLine:a,commit:{oid:i.commit.id,parentOids:i.commit.parent_ids,authoredDate:new Date(i.commit.authored_date),author:{name:i.commit.author_name,email:i.commit.author_email,avatarUrl:null},committedDate:new Date(i.commit.committed_date),committer:{name:i.commit.committer_name,email:i.commit.committer_email,avatarUrl:null},message:i.commit.message,fileCount:null,additions:null,deletions:null}}})}}}async getPullRequestsForUser(r,t={}){var a,i;let s=qt[r.association],n=await R(this.config,{query:`
603
646
  query getPullRequestsForUser($username: String! $cursor: String) {
604
647
  user(username: $username) {
605
648
  ${s}(state:opened first:100 after:$cursor) {
@@ -608,12 +651,12 @@ query getPullRequestsForUser($username: String! $cursor: String) {
608
651
  hasNextPage
609
652
  }
610
653
  nodes {
611
- ${$e(!0,!0)}
654
+ ${ve(!0,!0)}
612
655
  }
613
656
  }
614
657
  }
615
658
  }
616
- `,variables:{username:r.username,cursor:r.cursor}},t);if(!n.body.data)throw new Error(((o=n.body.errors)==null?void 0:o[0].message)||n.statusText||"Unknown error");if(!n.body.data.user)throw new Error("User not found");let a=n.body.data.user[s];if(!a)throw new Error("Unexpected response");return{pageInfo:a.pageInfo,data:((i=a.nodes)==null?void 0:i.map(u=>Ee(u,_(u.project))))||[]}}async getPullRequestsAssociatedWithUser(r,t={}){var c;let[s,n,a]=((c=r.cursor)==null?void 0:c.split(";"))||[void 0,void 0,void 0];if(r.cursor&&s==="null"&&n==="null"&&a==="null")return{pageInfo:{hasNextPage:!1,endCursor:"null;null;null"},data:[]};let[o,i,u]=await Promise.all([this.getPullRequestsForUser({username:r.username,association:"authored",cursor:s},t),this.getPullRequestsForUser({username:r.username,association:"assigned",cursor:n},t),this.getPullRequestsForUser({username:r.username,association:"reviewRequested",cursor:a},t)]),l={},p=[],d=g=>{l[g.id]||(l[g.id]=!0,p.push(g))};return o.data.forEach(d),i.data.forEach(d),u.data.forEach(d),{pageInfo:{hasNextPage:o.pageInfo.hasNextPage||i.pageInfo.hasNextPage||u.pageInfo.hasNextPage,endCursor:`${(o==null?void 0:o.pageInfo.hasNextPage)&&(o==null?void 0:o.pageInfo.endCursor)||"null"};${(i==null?void 0:i.pageInfo.hasNextPage)&&(i==null?void 0:i.pageInfo.endCursor)||"null"};${(u==null?void 0:u.pageInfo.hasNextPage)&&(u==null?void 0:u.pageInfo.endCursor)||"null"}`},data:p}}getVariablesForPullRequests(r){let{updatedBefore:t,isDraft:s,authorLogin:n,assigneeLogins:a,reviewRequestedLogin:o}=r||{},i={},u=[],l=[],p=(d,c,g)=>{u.push(`$${d}: ${g}`),l.push(`${d}: $${d}`),i[d]=c};return t&&p("updatedBefore",t,"Time"),n&&p("authorUsername",n,"String"),a&&p("assigneeUsername",a[0],"String"),s!=null&&p("draft",s,"Boolean"),o&&p("reviewerUsername",o,"String"),{variables:i,variableTypes:u,mergeRequestArguments:l}}async getPullRequestsForRepo(r,t={}){var I,P,y;let{cursor:s,repo:n}=r||{},a=O(n),{variables:o,variableTypes:i,mergeRequestArguments:u}=this.getVariablesForPullRequests(r),l={fullPath:a,...o},p=await f(this.config,{query:`
659
+ `,variables:{username:r.username,cursor:r.cursor}},t);if(!n.body.data)throw new Error(((a=n.body.errors)==null?void 0:a[0].message)||n.statusText||"Unknown error");if(!n.body.data.user)throw new Error("User not found");let o=n.body.data.user[s];if(!o)throw new Error("Unexpected response");return{pageInfo:o.pageInfo,data:((i=o.nodes)==null?void 0:i.map(u=>De(u,Q(u.project))))||[]}}async getPullRequestsAssociatedWithUser(r,t={}){var c;let[s,n,o]=((c=r.cursor)==null?void 0:c.split(";"))||[void 0,void 0,void 0];if(r.cursor&&s==="null"&&n==="null"&&o==="null")return{pageInfo:{hasNextPage:!1,endCursor:"null;null;null"},data:[]};let[a,i,u]=await Promise.all([this.getPullRequestsForUser({username:r.username,association:"authored",cursor:s},t),this.getPullRequestsForUser({username:r.username,association:"assigned",cursor:n},t),this.getPullRequestsForUser({username:r.username,association:"reviewRequested",cursor:o},t)]),l={},p=[],d=g=>{l[g.id]||(l[g.id]=!0,p.push(g))};return a.data.forEach(d),i.data.forEach(d),u.data.forEach(d),{pageInfo:{hasNextPage:a.pageInfo.hasNextPage||i.pageInfo.hasNextPage||u.pageInfo.hasNextPage,endCursor:`${(a==null?void 0:a.pageInfo.hasNextPage)&&(a==null?void 0:a.pageInfo.endCursor)||"null"};${(i==null?void 0:i.pageInfo.hasNextPage)&&(i==null?void 0:i.pageInfo.endCursor)||"null"};${(u==null?void 0:u.pageInfo.hasNextPage)&&(u==null?void 0:u.pageInfo.endCursor)||"null"}`},data:p}}getVariablesForPullRequests(r){let{updatedBefore:t,isDraft:s,authorLogin:n,assigneeLogins:o,reviewRequestedLogin:a}=r||{},i={},u=[],l=[],p=(d,c,g)=>{u.push(`$${d}: ${g}`),l.push(`${d}: $${d}`),i[d]=c};return t&&p("updatedBefore",t,"Time"),n&&p("authorUsername",n,"String"),o&&p("assigneeUsername",o[0],"String"),s!=null&&p("draft",s,"Boolean"),a&&p("reviewerUsername",a,"String"),{variables:i,variableTypes:u,mergeRequestArguments:l}}async getPullRequestsForRepo(r,t={}){var f,w,y;let{cursor:s,repo:n}=r||{},o=k(n),{variables:a,variableTypes:i,mergeRequestArguments:u}=this.getVariablesForPullRequests(r),l={fullPath:o,...a},p=await R(this.config,{query:`
617
660
  query getPullRequestsForRepo(
618
661
  $fullPath: ID!
619
662
  $after: String
@@ -637,16 +680,16 @@ query getPullRequestsForRepo(
637
680
  hasNextPage
638
681
  }
639
682
  nodes {
640
- ${$e(!1,!0)}
683
+ ${ve(!1,!0)}
641
684
  }
642
685
  }
643
686
  }
644
687
  }
645
- `,variables:{...l,after:s}},t),d=[],c=(I=p.body.data)==null?void 0:I.project,g=_(c||{fullPath:"",path:"",webUrl:""});return(((P=c==null?void 0:c.mergeRequests)==null?void 0:P.nodes)||[]).forEach(b=>{d.push(Ee(b,g))}),{pageInfo:(y=c==null?void 0:c.mergeRequests)==null?void 0:y.pageInfo,data:d}}async getPullRequestsForRepos(r,t={}){var c,g,R,I,P;let{cursor:s}=r||{},n=r.repoIds.map(y=>y.toString().startsWith(z)?y:`${z}${y}`),{variables:a,variableTypes:o,mergeRequestArguments:i}=this.getVariablesForPullRequests(r),u={projectIds:n,...a},l=await f(this.config,{query:`
688
+ `,variables:{...l,after:s}},t),d=[],c=(f=p.body.data)==null?void 0:f.project,g=Q(c||{fullPath:"",path:"",webUrl:""});return(((w=c==null?void 0:c.mergeRequests)==null?void 0:w.nodes)||[]).forEach(b=>{d.push(De(b,g))}),{pageInfo:(y=c==null?void 0:c.mergeRequests)==null?void 0:y.pageInfo,data:d}}async getPullRequestsForRepos(r,t={}){var c,g,I,f,w;let{cursor:s}=r||{},n=r.repoIds.map(y=>y.toString().startsWith(W)?y:`${W}${y}`),{variables:o,variableTypes:a,mergeRequestArguments:i}=this.getVariablesForPullRequests(r),u={projectIds:n,...o},l=await R(this.config,{query:`
646
689
  query getPullRequests(
647
690
  $projectIds: [ID!]
648
691
  $after: String
649
- ${o.length?o.join(" "):""}
692
+ ${a.length?a.join(" "):""}
650
693
  ) {
651
694
  projects(
652
695
  ids: $projectIds
@@ -667,52 +710,62 @@ query getPullRequests(
667
710
  ${i.length?i.join(" "):""}
668
711
  ) {
669
712
  nodes {
670
- ${$e(!1,!1)}
713
+ ${ve(!1,!1)}
671
714
  }
672
715
  }
673
716
  }
674
717
  }
675
718
  }
676
- `,variables:{...u,after:s}},t),p=[];return(((g=(c=l.body.data)==null?void 0:c.projects)==null?void 0:g.nodes)||[]).forEach(y=>{var L;let b=_(y);(((L=y.mergeRequests)==null?void 0:L.nodes)||[]).forEach(D=>{p.push(Ee(D,b))})}),{pageInfo:(P=(I=(R=l.body)==null?void 0:R.data)==null?void 0:I.projects)==null?void 0:P.pageInfo,data:p}}async closePullRequest(r,t={}){var l,p,d;let{repo:{namespace:s,name:n},pullRequestId:a}=r,o=`mutation ClosePullRequest($fullPath: ID!, $pullRequestId: String!) {
719
+ `,variables:{...u,after:s}},t),p=[];return(((g=(c=l.body.data)==null?void 0:c.projects)==null?void 0:g.nodes)||[]).forEach(y=>{var L;let b=Q(y);(((L=y.mergeRequests)==null?void 0:L.nodes)||[]).forEach($=>{p.push(De($,b))})}),{pageInfo:(w=(f=(I=l.body)==null?void 0:I.data)==null?void 0:f.projects)==null?void 0:w.pageInfo,data:p}}async closePullRequest(r,t={}){var l,p,d;let{repo:{namespace:s,name:n},pullRequestId:o}=r,a=`mutation ClosePullRequest($fullPath: ID!, $pullRequestId: String!) {
677
720
  mergeRequestUpdate(input: { projectPath: $fullPath, iid: $pullRequestId, state: CLOSED }) {
678
721
  errors,
679
722
  mergeRequest {
680
723
  id
681
724
  }
682
725
  }
683
- }`,u=(l=(await f(this.config,{query:o,variables:{fullPath:`${s}/${n}`,pullRequestId:a}},t)).body.data)==null?void 0:l.mergeRequestUpdate;if(!((p=u==null?void 0:u.mergeRequest)!=null&&p.id)||((d=u==null?void 0:u.errors)==null?void 0:d.length)!==0)throw new Error("Could not close pull request")}async mergePullRequest(r,t={}){var p,d,c;let{repo:{namespace:s,name:n},pullRequestId:a,expectedSourceSha:o}=r,i=`mutation MergePullRequest($fullPath: ID!, $pullRequestId: String!, $expectedSourceSha: String!) {
684
- mergeRequestAccept(input: { projectPath: $fullPath, iid: $pullRequestId, sha: $expectedSourceSha }) {
726
+ }`,u=(l=(await R(this.config,{query:a,variables:{fullPath:`${s}/${n}`,pullRequestId:o}},t)).body.data)==null?void 0:l.mergeRequestUpdate;if(!((p=u==null?void 0:u.mergeRequest)!=null&&p.id)||((d=u==null?void 0:u.errors)==null?void 0:d.length)!==0)throw new Error("Could not close pull request")}async mergePullRequest(r,t={}){var d,c,g;let{repo:{namespace:s,name:n},pullRequestId:o,expectedSourceSha:a,mergeStrategy:i}=r,u=`mutation MergePullRequest(
727
+ $fullPath: ID!,
728
+ $pullRequestId: String!,
729
+ $expectedSourceSha: String!,
730
+ $squash: Boolean!,
731
+ ) {
732
+ mergeRequestAccept(input: {
733
+ projectPath: $fullPath,
734
+ iid: $pullRequestId,
735
+ sha: $expectedSourceSha,
736
+ squash: $squash,
737
+ }) {
685
738
  errors,
686
- mergeRequest {
739
+ mergeRequest {
687
740
  id
688
741
  }
689
- }
690
- }`,l=(p=(await f(this.config,{query:i,variables:{fullPath:`${s}/${n}`,pullRequestId:a,expectedSourceSha:o}},t)).body.data)==null?void 0:p.mergeRequestAccept;if(!((d=l==null?void 0:l.mergeRequest)!=null&&d.id)||((c=l==null?void 0:l.errors)==null?void 0:c.length)!==0)throw new Error("Could not merge pull request")}async setPullRequestMilestone(r,t={}){var p,d,c;let{repo:{namespace:s,name:n},pullRequestId:a,milestoneGraphQLId:o}=r,i=`mutation SetPullRequestMilestone($fullPath: ID!, $pullRequestId: String!, $milestoneGraphQLId: MilestoneID) {
742
+ }
743
+ }`,p=(d=(await R(this.config,{query:u,variables:{fullPath:`${s}/${n}`,pullRequestId:o,expectedSourceSha:a,squash:i==="SQUASH"}},t)).body.data)==null?void 0:d.mergeRequestAccept;if(!((c=p==null?void 0:p.mergeRequest)!=null&&c.id)||((g=p==null?void 0:p.errors)==null?void 0:g.length)!==0)throw new Error("Could not merge pull request")}async setPullRequestMilestone(r,t={}){var p,d,c;let{repo:{namespace:s,name:n},pullRequestId:o,milestoneGraphQLId:a}=r,i=`mutation SetPullRequestMilestone($fullPath: ID!, $pullRequestId: String!, $milestoneGraphQLId: MilestoneID) {
691
744
  mergeRequestSetMilestone(input: { projectPath: $fullPath, iid: $pullRequestId, milestoneId: $milestoneGraphQLId }) {
692
745
  errors,
693
746
  mergeRequest {
694
747
  id
695
748
  }
696
749
  }
697
- }`,u=await f(this.config,{query:i,variables:{fullPath:`${s}/${n}`,pullRequestId:a,milestoneGraphQLId:o}},t),l=(p=u.body.data)==null?void 0:p.mergeRequestSetMilestone;if(!((d=l==null?void 0:l.mergeRequest)!=null&&d.id)||u.body.errors||((c=l==null?void 0:l.errors)==null?void 0:c.length)!==0)throw new Error("Could not set milestone of pull request")}async setPullRequestAsDraft(r,t={}){var p,d,c;let{repo:{namespace:s,name:n},pullRequestId:a,isDraft:o}=r,i=`mutation MergeRequestSetDraft($fullPath: ID!, $pullRequestId: String!, $isDraft: Boolean!) {
750
+ }`,u=await R(this.config,{query:i,variables:{fullPath:`${s}/${n}`,pullRequestId:o,milestoneGraphQLId:a}},t),l=(p=u.body.data)==null?void 0:p.mergeRequestSetMilestone;if(!((d=l==null?void 0:l.mergeRequest)!=null&&d.id)||u.body.errors||((c=l==null?void 0:l.errors)==null?void 0:c.length)!==0)throw new Error("Could not set milestone of pull request")}async setPullRequestAsDraft(r,t={}){var p,d,c;let{repo:{namespace:s,name:n},pullRequestId:o,isDraft:a}=r,i=`mutation MergeRequestSetDraft($fullPath: ID!, $pullRequestId: String!, $isDraft: Boolean!) {
698
751
  mergeRequestSetDraft(input: { projectPath: $fullPath, iid: $pullRequestId, draft: $isDraft }) {
699
752
  errors,
700
753
  mergeRequest {
701
754
  id
702
755
  }
703
756
  }
704
- }`,l=(p=(await f(this.config,{query:i,variables:{fullPath:`${s}/${n}`,pullRequestId:a,isDraft:o}},t)).body.data)==null?void 0:p.mergeRequestSetDraft;if(!((d=l==null?void 0:l.mergeRequest)!=null&&d.id)||((c=l==null?void 0:l.errors)==null?void 0:c.length)!==0)throw new Error("Could not set pull request as draft")}async getIssue(r,t={}){var a,o,i;let s=xt(r),n=await f(this.config,{query:`
757
+ }`,l=(p=(await R(this.config,{query:i,variables:{fullPath:`${s}/${n}`,pullRequestId:o,isDraft:a}},t)).body.data)==null?void 0:p.mergeRequestSetDraft;if(!((d=l==null?void 0:l.mergeRequest)!=null&&d.id)||((c=l==null?void 0:l.errors)==null?void 0:c.length)!==0)throw new Error("Could not set pull request as draft")}async getIssue(r,t={}){var o,a,i;let s=Tt(r),n=await R(this.config,{query:`
705
758
  query GetSingleIssue($projectId: ID!, $issueId: String!) {
706
759
  project(fullPath: $projectId) {
707
760
  path
708
761
  fullPath
709
762
  webUrl
710
763
  issue(iid: $issueId) {
711
- ${ve}
764
+ ${$e}
712
765
  }
713
766
  }
714
767
  }
715
- `,variables:{issueId:r.id,projectId:s}},t);if(!((a=n.body.data)!=null&&a.project))throw new Error(`Repository ${s} not found`);if(!((i=(o=n.body.data)==null?void 0:o.project)!=null&&i.issue))throw new Error(`Issue ${r.id} not found`);return{data:Se(n.body.data.project.issue,_(n.body.data.project))}}getVariablesForIssues(r){let{updatedBefore:t,authorLogin:s,assigneeLogins:n}=r||{},a={},o=[],i=[],u=(l,p,d)=>{o.push(`$${l}: ${d}`),i.push(`${l}: $${l}`),a[l]=p};return t&&u("updatedBefore",t,"Time"),s&&u("authorUsername",s,"String"),n&&u("assigneeUsername",n[0],"String"),{variables:a,variableTypes:o,issueArguments:i}}async getIssuesForRepo(r,t={}){var P,y,b;let{cursor:s,repo:n}=r||{},a=O(n),{variables:o,variableTypes:i,issueArguments:u}=this.getVariablesForIssues(r),l={fullPath:a,...o},p=`
768
+ `,variables:{issueId:r.id,projectId:s}},t);if(!((o=n.body.data)!=null&&o.project))throw new Error(`Repository ${s} not found`);if(!((i=(a=n.body.data)==null?void 0:a.project)!=null&&i.issue))throw new Error(`Issue ${r.id} not found`);return{data:qe(n.body.data.project.issue,Q(n.body.data.project))}}getVariablesForIssues(r){let{updatedBefore:t,authorLogin:s,assigneeLogins:n}=r||{},o={},a=[],i=[],u=(l,p,d)=>{a.push(`$${l}: ${d}`),i.push(`${l}: $${l}`),o[l]=p};return t&&u("updatedBefore",t,"Time"),s&&u("authorUsername",s,"String"),n&&u("assigneeUsername",n[0],"String"),{variables:o,variableTypes:a,issueArguments:i}}async getIssuesForRepo(r,t={}){var w,y,b;let{cursor:s,repo:n}=r||{},o=k(n),{variables:a,variableTypes:i,issueArguments:u}=this.getVariablesForIssues(r),l={fullPath:o,...a},p=`
716
769
  query GetIssuesFromProject(
717
770
  $fullPath: ID!
718
771
  $after: String
@@ -732,7 +785,7 @@ query GetSingleIssue($projectId: ID!, $issueId: String!) {
732
785
  ${u.length?u.join(" "):""}
733
786
  ) {
734
787
  nodes {
735
- ${ve}
788
+ ${$e}
736
789
  }
737
790
  pageInfo {
738
791
  endCursor
@@ -740,11 +793,11 @@ query GetSingleIssue($projectId: ID!, $issueId: String!) {
740
793
  }
741
794
  }
742
795
  }
743
- }`,d=await f(this.config,{query:p,variables:{...l,after:s}},t),c=[],g=(P=d.body.data)==null?void 0:P.project,R=_(g||{fullPath:"",path:"",webUrl:""});return(((y=g==null?void 0:g.issues)==null?void 0:y.nodes)||[]).forEach(v=>{c.push(Se(v,R))}),{pageInfo:(b=g==null?void 0:g.issues)==null?void 0:b.pageInfo,data:c.sort((v,L)=>(v.updatedDate||v.createdDate).getTime()-(L.updatedDate||L.createdDate).getTime())}}async getIssuesForRepos(r,t={}){var g,R,I,P,y;let{cursor:s}=r||{},n=r.repoIds.map(b=>b.toString().startsWith(z)?b:`${z}${b}`),{variables:a,variableTypes:o,mergeRequestArguments:i}=this.getVariablesForPullRequests(r),u={projectIds:n,...a},l=`
796
+ }`,d=await R(this.config,{query:p,variables:{...l,after:s}},t),c=[],g=(w=d.body.data)==null?void 0:w.project,I=Q(g||{fullPath:"",path:"",webUrl:""});return(((y=g==null?void 0:g.issues)==null?void 0:y.nodes)||[]).forEach(C=>{c.push(qe(C,I))}),{pageInfo:(b=g==null?void 0:g.issues)==null?void 0:b.pageInfo,data:c.sort((C,L)=>(C.updatedDate||C.createdDate).getTime()-(L.updatedDate||L.createdDate).getTime())}}async getIssuesForRepos(r,t={}){var g,I,f,w,y;let{cursor:s}=r||{},n=r.repoIds.map(b=>b.toString().startsWith(W)?b:`${W}${b}`),{variables:o,variableTypes:a,mergeRequestArguments:i}=this.getVariablesForPullRequests(r),u={projectIds:n,...o},l=`
744
797
  query GetIssuesFromProject(
745
798
  $projectIds: [ID!]
746
799
  $after: String
747
- ${o.length?o.join(" "):""}
800
+ ${a.length?a.join(" "):""}
748
801
  ) {
749
802
  projects(
750
803
  ids: $projectIds
@@ -765,18 +818,18 @@ query GetSingleIssue($projectId: ID!, $issueId: String!) {
765
818
  ${i.length?i.join(" "):""}
766
819
  ) {
767
820
  nodes {
768
- ${ve}
821
+ ${$e}
769
822
  }
770
823
  }
771
824
  }
772
825
  }
773
- }`,p=await f(this.config,{query:l,variables:{...u,after:s}},t),d=[];return(((R=(g=p.body.data)==null?void 0:g.projects)==null?void 0:R.nodes)||[]).forEach(b=>{var D;let v=_(b);(((D=b.issues)==null?void 0:D.nodes)||[]).forEach(ue=>d.push(Se(ue,v)))}),{pageInfo:(y=(P=(I=p.body)==null?void 0:I.data)==null?void 0:P.projects)==null?void 0:y.pageInfo,data:d.sort((b,v)=>(b.updatedDate||b.createdDate).getTime()-(v.updatedDate||v.createdDate).getTime())}}async setIssueStatus(r,t={}){var l,p,d;let{repo:{namespace:s,name:n},issueId:a,status:o}=r,i=`mutation SetIssueState($fullPath: ID!, $issueId: String!, $status: IssueStateEvent!) {
826
+ }`,p=await R(this.config,{query:l,variables:{...u,after:s}},t),d=[];return(((I=(g=p.body.data)==null?void 0:g.projects)==null?void 0:I.nodes)||[]).forEach(b=>{var $;let C=Q(b);((($=b.issues)==null?void 0:$.nodes)||[]).forEach(le=>d.push(qe(le,C)))}),{pageInfo:(y=(w=(f=p.body)==null?void 0:f.data)==null?void 0:w.projects)==null?void 0:y.pageInfo,data:d.sort((b,C)=>(b.updatedDate||b.createdDate).getTime()-(C.updatedDate||C.createdDate).getTime())}}async setIssueStatus(r,t={}){var l,p,d;let{repo:{namespace:s,name:n},issueId:o,status:a}=r,i=`mutation SetIssueState($fullPath: ID!, $issueId: String!, $status: IssueStateEvent!) {
774
827
  updateIssue(input: { projectPath: $fullPath, iid: $issueId, stateEvent: $status }) {
775
828
  issue {
776
829
  id
777
830
  }
778
831
  }
779
- }`;if(!((d=(p=(l=(await f(this.config,{query:i,variables:{fullPath:`${s}/${n}`,issueId:a,status:o}},t)).body.data)==null?void 0:l.updateIssue)==null?void 0:p.issue)!=null&&d.id))throw new Error("Could not set issue status")}async setIssueMilestone(r,t={}){var p,d,c,g;let{repo:{namespace:s,name:n},issueId:a}=r,o=((p=r.milestoneGraphQLId)==null?void 0:p.replace(Xe,""))??"",i=`mutation SetIssueMilestone($fullPath: ID!, $issueId: String!, $milestoneGraphQLId: ID) {
832
+ }`;if(!((d=(p=(l=(await R(this.config,{query:i,variables:{fullPath:`${s}/${n}`,issueId:o,status:a}},t)).body.data)==null?void 0:l.updateIssue)==null?void 0:p.issue)!=null&&d.id))throw new Error("Could not set issue status")}async setIssueMilestone(r,t={}){var p,d,c,g;let{repo:{namespace:s,name:n},issueId:o}=r,a=((p=r.milestoneGraphQLId)==null?void 0:p.replace(Ye,""))??"",i=`mutation SetIssueMilestone($fullPath: ID!, $issueId: String!, $milestoneGraphQLId: ID) {
780
833
  updateIssue(input: { projectPath: $fullPath, iid: $issueId, milestoneId: $milestoneGraphQLId }) {
781
834
  errors
782
835
  issue {
@@ -786,7 +839,7 @@ query GetSingleIssue($projectId: ID!, $issueId: String!) {
786
839
  }
787
840
  }
788
841
  }
789
- }`,u=await f(this.config,{query:i,variables:{fullPath:`${s}/${n}`,issueId:a,milestoneGraphQLId:o}},t),l=(d=u.body.data)==null?void 0:d.updateIssue;if(!((c=l==null?void 0:l.issue)!=null&&c.id)||u.body.errors||((g=l==null?void 0:l.errors)==null?void 0:g.length)!==0)throw new Error("Could not set milestone of issue")}async getMilestonesForRepo(r,t={}){var i,u,l,p,d,c,g;let{repo:{namespace:s,name:n},cursor:a}=r,o=await f(this.config,{query:`
842
+ }`,u=await R(this.config,{query:i,variables:{fullPath:`${s}/${n}`,issueId:o,milestoneGraphQLId:a}},t),l=(d=u.body.data)==null?void 0:d.updateIssue;if(!((c=l==null?void 0:l.issue)!=null&&c.id)||u.body.errors||((g=l==null?void 0:l.errors)==null?void 0:g.length)!==0)throw new Error("Could not set milestone of issue")}async getMilestonesForRepo(r,t={}){var i,u,l,p,d,c,g;let{repo:{namespace:s,name:n},cursor:o}=r,a=await R(this.config,{query:`
790
843
  query getLabelsForRepo(
791
844
  $fullPath: ID!
792
845
  $after: String
@@ -797,7 +850,7 @@ query getLabelsForRepo(
797
850
  webUrl
798
851
  milestones(after: $after) {
799
852
  nodes {
800
- ${qe}
853
+ ${Le}
801
854
  }
802
855
  pageInfo {
803
856
  endCursor
@@ -806,7 +859,7 @@ query getLabelsForRepo(
806
859
  }
807
860
  }
808
861
  }
809
- `,variables:{fullPath:`${s}/${n}`,after:a}},t);return{pageInfo:((l=(u=(i=o.body.data)==null?void 0:i.project)==null?void 0:u.milestones)==null?void 0:l.pageInfo)??{endCursor:null,hasNextPage:!1},data:((g=(c=(d=(p=o.body.data)==null?void 0:p.project)==null?void 0:d.milestones)==null?void 0:c.nodes)==null?void 0:g.map(R=>{var I,P;return xe(R,((P=(I=o.body.data)==null?void 0:I.project)==null?void 0:P.webUrl)||"")}))??[]}}async getLabelsForRepo(r,t={}){var i,u,l,p,d,c,g;let{repo:{namespace:s,name:n},cursor:a}=r,o=await f(this.config,{query:`
862
+ `,variables:{fullPath:`${s}/${n}`,after:o}},t);return{pageInfo:((l=(u=(i=a.body.data)==null?void 0:i.project)==null?void 0:u.milestones)==null?void 0:l.pageInfo)??{endCursor:null,hasNextPage:!1},data:((g=(c=(d=(p=a.body.data)==null?void 0:p.project)==null?void 0:d.milestones)==null?void 0:c.nodes)==null?void 0:g.map(I=>{var f,w;return Te(I,((w=(f=a.body.data)==null?void 0:f.project)==null?void 0:w.webUrl)||"")}))??[]}}async getLabelsForRepo(r,t={}){var i,u,l,p,d,c,g;let{repo:{namespace:s,name:n},cursor:o}=r,a=await R(this.config,{query:`
810
863
  query getLabelsForRepo(
811
864
  $fullPath: ID!
812
865
  $after: String
@@ -816,7 +869,7 @@ query getLabelsForRepo(
816
869
  ) {
817
870
  labels(after: $after) {
818
871
  nodes {
819
- ${Le}
872
+ ${xe}
820
873
  }
821
874
  pageInfo {
822
875
  endCursor
@@ -825,4 +878,4 @@ query getLabelsForRepo(
825
878
  }
826
879
  }
827
880
  }
828
- `,variables:{fullPath:`${s}/${n}`,after:a}},t);return{pageInfo:((l=(u=(i=o.body.data)==null?void 0:i.project)==null?void 0:u.labels)==null?void 0:l.pageInfo)??{endCursor:null,hasNextPage:!1},data:((g=(c=(d=(p=o.body.data)==null?void 0:p.project)==null?void 0:d.labels)==null?void 0:c.nodes)==null?void 0:g.map(Ge))??[]}}};var H="https://api.atlassian.com/ex/jira",Te=100,At=e=>{var t,s,n,a,o,i;let r=e.fields.assignee;return{id:e.id,commentCount:e.fields.comment.comments.length,number:e.key,title:e.fields.summary,url:e.self,createdDate:new Date(e.fields.created),author:{id:e.fields.creator.accountId,name:e.fields.creator.displayName,email:e.fields.creator.emailAddress,avatarUrl:e.fields.creator.avatarUrls["32x32"],username:e.fields.creator.displayName},updatedDate:new Date(e.fields.updated),assignees:r?[{id:r.accountId,name:r.displayName,email:r.emailAddress,avatarUrl:r.avatarUrls["32x32"],username:r.displayName}]:[],description:null,repository:null,state:{name:(t=e.fields.status)==null?void 0:t.name,color:(n=(s=e.fields.status)==null?void 0:s.statusCategory)==null?void 0:n.colorName},statusTransitions:((a=e.transitions)==null?void 0:a.map(Ot))??[],type:e.fields.issuetype.name,upvoteCount:((o=e.fields.votes)==null?void 0:o.votes)||0,labels:((i=e.fields.labels)==null?void 0:i.map(u=>({color:null,description:null,id:null,name:u})))??[]}},Ot=e=>({name:e.name,id:e.id}),J=class extends E{async getCurrentUserForResource(r,t={}){let s=await this.config.request({url:`${t.baseUrl||H}/${r.resourceId}/rest/api/2/myself`,headers:m(t.token||this.config.token)});return{data:{name:s.body.displayName,email:s.body.emailAddress,avatarUrl:s.body.avatarUrls["48x48"],id:s.body.accountId,username:s.body.displayName}}}async getJiraResourcesForCurrentUser(r={}){return{data:(await this.config.request({url:`${r.baseUrl||"https://api.atlassian.com/"}/oauth/token/accessible-resources`,headers:m(r.token||this.config.token)})).body.map(s=>({avatarUrl:s.avatarUrl,id:s.id,name:s.name}))}}async getJiraProjectsForResource(r,t={}){let s=new URL(`${t.baseUrl||H}/${r.resourceId}/rest/api/2/project/search`);s.searchParams.set("maxResults",Te.toString()),r.cursor&&s.searchParams.set("startAt",r.cursor);let n=await this.config.request({url:s.toString(),headers:m(t.token||this.config.token)});return{pageInfo:{hasNextPage:n.body.values.length!==0,endCursor:(n.body.startAt+n.body.values.length).toString()},data:n.body.values.map(a=>({id:a.id,name:a.name,resourceId:r.resourceId}))}}async getJiraProjectsForResources(r,t={}){let s=[];return await Promise.all(r.resourceIds.map(async n=>{let a=await this.getJiraProjectsForResource({resourceId:n},t);s.push(...a.data)})),{data:s}}async getIssuesForProject(r,t={}){let{assigneeLogins:s,authorLogin:n,mentionLogin:a,project:o}=r||{},i=[`project = "${o}"`];return n&&i.push(`creator in ("${n}")`),s&&s.length!==0&&i.push(`assignee in ("${s.join('", "')}")`),a&&i.push(`comment ~ "${a}"`),{data:(await this.config.request({url:`${t.baseUrl||H}/${r.resourceId}/rest/api/2/search?jql=${i.join(" AND ")}&startAt=0&maxResults=${Te}&fields=${["assignee","comment","summary","created","creator","updated","votes","issuetype","status","labels"].join(",")}&expand=transitions`,headers:m(t.token||this.config.token)})).body.issues.map(At)}}async setIssueStatus(r,t={}){let{resourceId:s,issueId:n,status:a}=r,o={transition:{id:a}};await this.config.request({method:"POST",url:`${t.baseUrl||H}/${s}/rest/api/2/issue/${n}/transitions`,body:JSON.stringify(o),headers:{...m(t.token||this.config.token),"Content-Type":"application/json"}})}async getLabelsForResource(r,t={}){let{resourceId:s,cursor:n}=r,a=new URL(`${t.baseUrl||H}/${s}/rest/api/2/label`);a.searchParams.set("maxResults",Te.toString()),n&&a.searchParams.set("startAt",n);let o=await this.config.request({url:a.toString(),headers:m(t.token||this.config.token)});return{pageInfo:{hasNextPage:!o.body.isLast,endCursor:(o.body.startAt+o.body.values.length).toString()},data:o.body.values.map(i=>({color:null,description:null,id:null,name:i}))}}};var Q="https://api.trello.com",kt=1e3,_t=(e,r)=>{let t=new Date(1e3*parseInt(e.id.substring(0,8),16));return{id:e.id,commentCount:e.badges.comments,number:e.idShort.toString(),title:e.name,url:e.url,createdDate:new Date(t.toISOString()),author:null,updatedDate:new Date(e.dateLastActivity),assignees:e.idMembers.map(s=>({id:s,username:null,name:null,email:null,avatarUrl:null})),description:null,state:r[e.idList??""]?{name:r[e.idList].name,color:null}:null,type:null,repository:null,upvoteCount:e.badges.votes,labels:e.labels.map(s=>({color:s.color,description:null,id:s.id,name:s.name}))}},V=class extends E{async getCurrentUser(r,t={}){let s=await this.config.request({url:`${t.baseUrl||Q}/1/members/me?key=${r.appKey}&token=${t.token||this.config.token}`,headers:m(t.token||this.config.token)});return{data:{name:s.body.fullName,email:s.body.email,avatarUrl:s.body.avatarHash?`https://trello-members.s3.amazonaws.com/${s.body.id}/${s.body.avatarHash}/50.png`:null,id:s.body.id,username:s.body.username}}}async getBoardsForCurrentUser(r,t={}){return{data:(await this.config.request({url:`${t.baseUrl||Q}/1/members/me/boards?fields=name&key=${r.appKey}&token=${t.token||this.config.token}&filter=open`,headers:m(t.token||this.config.token)})).body.map(n=>({id:n.id,name:n.name}))}}async getListsForTrelloBoard(r,t={}){let{appKey:s,boardId:n}=r;return{data:(await this.config.request({url:`${t.baseUrl||Q}/1/boards/${n}/lists?key=${s}&token=${t.token||this.config.token}`,headers:m(t.token||this.config.token)})).body}}async getIssuesForBoard(r,t={}){let s=["-is:archived","sort:edited"],{appKey:n,boardId:a,filterText:o,assigneeLogins:i,trelloBoardListsById:u}=r||{};i&&s.push("@me");let l=`${o?`${o}`:""}${s.join(" ")} board:${a}`;return{data:(await this.config.request({url:`${t.baseUrl||Q}/1/search?key=${n}&query=${l}&cards_limit=${kt}&token=${t.token||this.config.token}`,headers:m(t.token||this.config.token)})).body.cards.map(d=>_t(d,u||{}))}}async setIssueStatus(r,t={}){let{appKey:s,cardId:n,status:a}=r;if(!(await this.config.request({method:"PUT",url:`${t.baseUrl||Q}/1/cards/${n}?key=${s}&token=${t.token||this.config.token}&idList=${a}`,headers:m(t.token||this.config.token)})).body.id)throw new Error("Could not set issue status")}async getLabelsForBoard(r,t={}){let{appKey:s,boardId:n}=r;return{data:(await this.config.request({url:`${t.baseUrl||Q}/1/boards/${n}/labels?key=${s}&token=${t.token||this.config.token}`,headers:m(t.token||this.config.token)})).body.map(o=>({color:o.color,description:null,id:o.id,name:o.name}))}}};var te={};x(te,{getIssueUniqueId:()=>Nt,getPullRequestUniqueId:()=>Qt});var Nt=(e,r,t,s="")=>{let n=[];return n.push(s),n.push(e),n.push(r),n.push(t),JSON.stringify(n)},Qt=(e,r,t,s,n="")=>{let a=[];return a.push(n),a.push(e),a.push(r),a.push(t),a.push(s),JSON.stringify(a)};var re={};x(re,{getIssueUniqueId:()=>Bt,getPullRequestUniqueId:()=>jt});var Bt=(e,r)=>JSON.stringify(["",e,r]),jt=(e,r)=>JSON.stringify(["",e,r]);var se={};x(se,{getIssueUniqueId:()=>Ft,getPullRequestUniqueId:()=>Mt});var Ft=(e,r,t)=>JSON.stringify([t,e,r]),Mt=(e,r,t)=>JSON.stringify([t,e,r]);var ne={};x(ne,{getIssueUniqueId:()=>zt,getPullRequestRank:()=>Ht,getPullRequestUniqueId:()=>Wt});var zt=(e,r="")=>{let t=[];return t.push(r),t.push(e),JSON.stringify(t)},Wt=(e,r="")=>{let t=[];return t.push(r),t.push(e),JSON.stringify(t)},Ht=(e,r,t)=>{var o,i,u;let s=0,n,a;return(o=e.reviews)==null||o.forEach(l=>{l.reviewer.id===r&&(n=l.state),l.state==="CHANGES_REQUESTED"?a="CHANGES_REQUESTED":l.state==="APPROVED"&&a!=="CHANGES_REQUESTED"&&(a="APPROVED")}),a||(a="REVIEW_REQUESTED"),((i=e.author)==null?void 0:i.id)===r?s+=1e3:(u=e.assignees)!=null&&u.find(l=>l.id===r)?s+=900:n==="REVIEW_REQUESTED"?s+=800:t&&(s+=700),a==="APPROVED"?e.mergeableState==="MERGEABLE"?s+=100:e.mergeableState==="CONFLICTS"?s+=90:s+=80:a=="CHANGES_REQUESTED"&&(s+=70),s};var oe={};x(oe,{getIssueUniqueId:()=>Jt,getPullRequestUniqueId:()=>Vt});var Jt=(e,r="")=>{let t=[];return t.push(r),t.push(e),JSON.stringify(t)},Vt=(e,r="")=>{let t=[];return t.push(r),t.push(e),JSON.stringify(t)};var ae={};x(ae,{getIssueUniqueId:()=>Kt,getJiraServerIssueUniqueId:()=>Xt});var Kt=(e,r,t)=>{let s=[];return s.push(""),s.push(e),s.push(r),s.push(t),JSON.stringify(s)},Xt=(e,r,t)=>{let s=[];return s.push(t),s.push(""),s.push(e),s.push(r),JSON.stringify(s)};var ie={};x(ie,{getIssueUniqueId:()=>Zt});var Zt=(e,r,t,s="")=>{let n=[];return n.push(s),n.push(e),n.push(r),n.push(t),JSON.stringify(n)};var Yt=e=>{let r={request:e==null?void 0:e.request};return{azureDevOps:new B({...r,...e==null?void 0:e.azureDevOps}),bitbucket:new j({...r,...e==null?void 0:e.bitbucket}),bitbucketServer:new F({...r,...e==null?void 0:e.bitbucketServer}),github:new M({...r,...e==null?void 0:e.github}),gitlab:new W({...r,...e==null?void 0:e.gitlab}),jira:new J({...r,...e==null?void 0:e.jira}),trello:new V({...r,...e==null?void 0:e.trello})}},er=Yt;var tr={azureDevOps:te,bitbucket:re,bitbucketServer:se,github:ne,gitlab:oe,jira:ae,trello:ie};
881
+ `,variables:{fullPath:`${s}/${n}`,after:o}},t);return{pageInfo:((l=(u=(i=a.body.data)==null?void 0:i.project)==null?void 0:u.labels)==null?void 0:l.pageInfo)??{endCursor:null,hasNextPage:!1},data:((g=(c=(d=(p=a.body.data)==null?void 0:p.project)==null?void 0:d.labels)==null?void 0:c.nodes)==null?void 0:g.map(Ae))??[]}}};var j="https://api.atlassian.com/ex/jira",te=100,kt=(e,r)=>{var s,n,o,a,i,u;let t=e.fields.assignee;return{id:e.id,commentCount:e.fields.comment.comments.length,number:e.key,title:e.fields.summary,url:r?`${r}/browse/${e.key}`:null,createdDate:new Date(e.fields.created),author:{id:e.fields.creator.accountId,name:e.fields.creator.displayName,email:e.fields.creator.emailAddress,avatarUrl:e.fields.creator.avatarUrls["32x32"],username:e.fields.creator.displayName},updatedDate:new Date(e.fields.updated),assignees:t?[{id:t.accountId,name:t.displayName,email:t.emailAddress,avatarUrl:t.avatarUrls["32x32"],username:t.displayName}]:[],description:null,repository:null,state:{name:(s=e.fields.status)==null?void 0:s.name,color:(o=(n=e.fields.status)==null?void 0:n.statusCategory)==null?void 0:o.colorName},statusTransitions:((a=e.transitions)==null?void 0:a.map(_t))??[],type:e.fields.issuetype.name,upvoteCount:((i=e.fields.votes)==null?void 0:i.votes)||0,labels:((u=e.fields.labels)==null?void 0:u.map(l=>({color:null,description:null,id:null,name:l})))??[]}},_t=e=>({name:e.name,id:e.id}),Nt=e=>({id:e.accountId,name:e.displayName,email:e.emailAddress,avatarUrl:e.avatarUrls["48x48"],username:e.displayName}),J=class extends v{constructor(){super(...arguments);this._resourceUrlCache={}}async getResourceUrl(t,s={}){var a;let n=s.token||this.config.token;if(!n)return null;let o=this._resourceUrlCache[n];return o?o[t.resourceId]??null:(await this.getJiraResourcesForCurrentUser(s),((a=this._resourceUrlCache[n])==null?void 0:a[t.resourceId])??null)}async getCurrentUserForResource(t,s={}){let n=await this.config.request({url:`${s.baseUrl||j}/${t.resourceId}/rest/api/2/myself`,headers:m(s.token||this.config.token)});return{data:{name:n.body.displayName,email:n.body.emailAddress,avatarUrl:n.body.avatarUrls["48x48"],id:n.body.accountId,username:n.body.displayName}}}async getJiraResourcesForCurrentUser(t={}){let s=await this.config.request({url:`${t.baseUrl||"https://api.atlassian.com/"}/oauth/token/accessible-resources`,headers:m(t.token||this.config.token)}),n=t.token||this.config.token,o=n?this._resourceUrlCache[n]||{}:void 0,a=s.body.map(i=>(o&&(o[i.id]=i.url),{avatarUrl:i.avatarUrl,id:i.id,name:i.name,url:i.url}));return n&&(this._resourceUrlCache[n]=o),{data:a}}async getJiraProjectsForResource(t,s={}){let n=new URL(`${s.baseUrl||j}/${t.resourceId}/rest/api/2/project/search`);n.searchParams.set("maxResults",te.toString()),t.cursor&&n.searchParams.set("startAt",t.cursor);let o=await this.config.request({url:n.toString(),headers:m(s.token||this.config.token)});return{pageInfo:{hasNextPage:o.body.values.length!==0,endCursor:(o.body.startAt+o.body.values.length).toString()},data:o.body.values.map(a=>({id:a.id,key:a.key,name:a.name,resourceId:t.resourceId}))}}async getJiraProjectsForResources(t,s={}){let n=[];return await Promise.all(t.resourceIds.map(async o=>{let a=await this.getJiraProjectsForResource({resourceId:o},s);n.push(...a.data)})),{data:n}}async getAccountsForJiraProject(t,s={}){let{resourceId:n,projectKey:o,cursor:a}=t,i=new URL(`${s.baseUrl||j}/${n}/rest/api/2/user/assignable/search`);i.searchParams.set("maxResults",te.toString()),a&&i.searchParams.set("startAt",a),i.searchParams.set("project",o);let u=await this.config.request({url:i.toString(),headers:m(s.token||this.config.token)});return{pageInfo:{hasNextPage:u.body.length!==0,endCursor:((a?parseInt(a):0)+u.body.length).toString()},data:u.body.filter(l=>l.accountType!=="app"&&l.active).map(Nt)}}async getIssuesForProject(t,s={}){let{assigneeLogins:n,authorLogin:o,mentionLogin:a,project:i}=t||{},u=[`project = "${i}"`];o&&u.push(`creator in ("${o}")`),n&&n.length!==0&&u.push(`assignee in ("${n.join('", "')}")`),a&&u.push(`comment ~ "${a}"`);let l=await this.config.request({url:`${s.baseUrl||j}/${t.resourceId}/rest/api/2/search?jql=${u.join(" AND ")}&startAt=0&maxResults=${te}&fields=${["assignee","comment","summary","created","creator","updated","votes","issuetype","status","labels"].join(",")}&expand=transitions`,headers:m(s.token||this.config.token)}),p=await this.getResourceUrl({resourceId:t.resourceId},s);return{data:l.body.issues.map(d=>kt(d,p))}}async setIssueStatus(t,s={}){let{resourceId:n,issueId:o,status:a}=t,i={transition:{id:a}};await this.config.request({method:"POST",url:`${s.baseUrl||j}/${n}/rest/api/2/issue/${o}/transitions`,body:JSON.stringify(i),headers:{...m(s.token||this.config.token),"Content-Type":"application/json"}})}async getLabelsForResource(t,s={}){let{resourceId:n,cursor:o}=t,a=new URL(`${s.baseUrl||j}/${n}/rest/api/2/label`);a.searchParams.set("maxResults",te.toString()),o&&a.searchParams.set("startAt",o);let i=await this.config.request({url:a.toString(),headers:m(s.token||this.config.token)});return{pageInfo:{hasNextPage:!i.body.isLast,endCursor:(i.body.startAt+i.body.values.length).toString()},data:i.body.values.map(u=>({color:null,description:null,id:null,name:u}))}}};var N="https://api.trello.com",Qt=1e3,jt=(e,r)=>{let t=new Date(1e3*parseInt(e.id.substring(0,8),16));return{id:e.id,commentCount:e.badges.comments,number:e.idShort.toString(),title:e.name,url:e.url,createdDate:new Date(t.toISOString()),author:null,updatedDate:new Date(e.dateLastActivity),assignees:e.idMembers.map(s=>({id:s,username:null,name:null,email:null,avatarUrl:null})),description:null,state:r[e.idList??""]?{name:r[e.idList].name,color:null}:null,type:null,repository:null,upvoteCount:e.badges.votes,labels:e.labels.map(s=>({color:s.color,description:null,id:s.id,name:s.name}))}},V=class extends v{async getCurrentUser(r,t={}){let s=await this.config.request({url:`${t.baseUrl||N}/1/members/me?key=${r.appKey}&token=${t.token||this.config.token}`,headers:m(t.token||this.config.token)});return{data:{name:s.body.fullName,email:s.body.email,avatarUrl:s.body.avatarHash?`https://trello-members.s3.amazonaws.com/${s.body.id}/${s.body.avatarHash}/50.png`:null,id:s.body.id,username:s.body.username}}}async getBoardsForCurrentUser(r,t={}){return{data:(await this.config.request({url:`${t.baseUrl||N}/1/members/me/boards?fields=name&key=${r.appKey}&token=${t.token||this.config.token}&filter=open`,headers:m(t.token||this.config.token)})).body.map(n=>({id:n.id,name:n.name}))}}async getListsForTrelloBoard(r,t={}){let{appKey:s,boardId:n}=r;return{data:(await this.config.request({url:`${t.baseUrl||N}/1/boards/${n}/lists?key=${s}&token=${t.token||this.config.token}`,headers:m(t.token||this.config.token)})).body}}async getAccountsForTrelloBoard(r,t={}){let{appKey:s,boardId:n}=r;return{data:(await this.config.request({url:`${t.baseUrl||N}/1/boards/${n}/members?key=${s}&token=${t.token||this.config.token}`,headers:m(t.token||this.config.token)})).body.map(a=>({id:a.id,name:a.fullName,username:a.username,email:null,avatarUrl:null}))}}async getIssuesForBoard(r,t={}){let s=["-is:archived","sort:edited"],{appKey:n,boardId:o,filterText:a,assigneeLogins:i,trelloBoardListsById:u}=r||{};i&&s.push("@me");let l=`${a?`${a}`:""}${s.join(" ")} board:${o}`;return{data:(await this.config.request({url:`${t.baseUrl||N}/1/search?key=${n}&query=${l}&cards_limit=${Qt}&token=${t.token||this.config.token}`,headers:m(t.token||this.config.token)})).body.cards.map(d=>jt(d,u||{}))}}async setIssueStatus(r,t={}){let{appKey:s,cardId:n,status:o}=r;if(!(await this.config.request({method:"PUT",url:`${t.baseUrl||N}/1/cards/${n}?key=${s}&token=${t.token||this.config.token}&idList=${o}`,headers:m(t.token||this.config.token)})).body.id)throw new Error("Could not set issue status")}async getLabelsForBoard(r,t={}){let{appKey:s,boardId:n}=r;return{data:(await this.config.request({url:`${t.baseUrl||N}/1/boards/${n}/labels?key=${s}&token=${t.token||this.config.token}`,headers:m(t.token||this.config.token)})).body.map(a=>({color:a.color,description:null,id:a.id,name:a.name}))}}};var re={};A(re,{getIssueUniqueId:()=>Bt,getPullRequestUniqueId:()=>Ft});var Bt=(e,r,t,s="")=>{let n=[];return n.push(s),n.push(e),n.push(r),n.push(t),JSON.stringify(n)},Ft=(e,r,t,s,n="")=>{let o=[];return o.push(n),o.push(e),o.push(r),o.push(t),o.push(s),JSON.stringify(o)};var se={};A(se,{getIssueUniqueId:()=>Mt,getPullRequestUniqueId:()=>zt});var Mt=(e,r)=>JSON.stringify(["",e,r]),zt=(e,r)=>JSON.stringify(["",e,r]);var ne={};A(ne,{getIssueUniqueId:()=>Wt,getPullRequestUniqueId:()=>Ht});var Wt=(e,r,t)=>JSON.stringify([t,e,r]),Ht=(e,r,t)=>JSON.stringify([t,e,r]);var ae={};A(ae,{getIssueUniqueId:()=>Jt,getPullRequestRank:()=>Kt,getPullRequestUniqueId:()=>Vt});var Jt=(e,r="")=>{let t=[];return t.push(r),t.push(e),JSON.stringify(t)},Vt=(e,r="")=>{let t=[];return t.push(r),t.push(e),JSON.stringify(t)},Kt=(e,r,t)=>{var a,i,u;let s=0,n,o;return(a=e.reviews)==null||a.forEach(l=>{l.reviewer.id===r&&(n=l.state),l.state==="CHANGES_REQUESTED"?o="CHANGES_REQUESTED":l.state==="APPROVED"&&o!=="CHANGES_REQUESTED"&&(o="APPROVED")}),o||(o="REVIEW_REQUESTED"),((i=e.author)==null?void 0:i.id)===r?s+=1e3:(u=e.assignees)!=null&&u.find(l=>l.id===r)?s+=900:n==="REVIEW_REQUESTED"?s+=800:t&&(s+=700),o==="APPROVED"?e.mergeableState==="MERGEABLE"?s+=100:e.mergeableState==="CONFLICTS"?s+=90:s+=80:o=="CHANGES_REQUESTED"&&(s+=70),s};var oe={};A(oe,{getIssueUniqueId:()=>Xt,getPullRequestUniqueId:()=>Zt});var Xt=(e,r="")=>{let t=[];return t.push(r),t.push(e),JSON.stringify(t)},Zt=(e,r="")=>{let t=[];return t.push(r),t.push(e),JSON.stringify(t)};var ie={};A(ie,{getIssueUniqueId:()=>Yt,getJiraServerIssueUniqueId:()=>er});var Yt=(e,r,t)=>{let s=[];return s.push(""),s.push(e),s.push(r),s.push(t),JSON.stringify(s)},er=(e,r,t)=>{let s=[];return s.push(t),s.push(""),s.push(e),s.push(r),JSON.stringify(s)};var ue={};A(ue,{getIssueUniqueId:()=>tr});var tr=(e,r,t,s="")=>{let n=[];return n.push(s),n.push(e),n.push(r),n.push(t),JSON.stringify(n)};var rr=e=>{let r={request:e==null?void 0:e.request};return{azureDevOps:new B({...r,...e==null?void 0:e.azureDevOps}),bitbucket:new F({...r,...e==null?void 0:e.bitbucket}),bitbucketServer:new M({...r,...e==null?void 0:e.bitbucketServer}),github:new z({...r,...e==null?void 0:e.github}),gitlab:new H({...r,...e==null?void 0:e.gitlab}),jira:new J({...r,...e==null?void 0:e.jira}),trello:new V({...r,...e==null?void 0:e.trello})}},sr=rr;var nr={azureDevOps:re,bitbucket:se,bitbucketServer:ne,github:ae,gitlab:oe,jira:ie,trello:ue};
@@ -1,5 +1,5 @@
1
1
  import { PagedResult, Result } from '../../types';
2
- import { CursorPageInput, EnterpriseOptions, GetRepoErrorData, GetRepoInput, GitProvider, GitPullRequest, GitRepository, NumberedPageInput, Options } from '../gitProvider';
2
+ import { CursorPageInput, EnterpriseOptions, GetRepoErrorData, GetRepoInput, GitMergeStrategy, GitProvider, GitPullRequest, GitRepository, NumberedPageInput, Options } from '../gitProvider';
3
3
  import { Issue } from '../issueProvider';
4
4
  import { Provider } from '../provider';
5
5
  import { WorkItemType } from './azureDevOpsTypes';
@@ -64,6 +64,26 @@ export declare class AzureDevOps extends Provider implements GitProvider {
64
64
  getAzureProjects(input: {
65
65
  namespace: string;
66
66
  } & CursorPageInput, options?: Options): Promise<PagedResult<AzureProject>>;
67
+ getAzureProjectScopeDescriptor(input: {
68
+ namespace: string;
69
+ projectId: string;
70
+ }, options?: Options): Promise<{
71
+ data: {
72
+ scope: string;
73
+ };
74
+ }>;
75
+ getAccountsForAzureProject(input: {
76
+ namespace: string;
77
+ projectScopeDescriptor?: string;
78
+ }, options?: Options): Promise<{
79
+ data: {
80
+ id: string;
81
+ name: string;
82
+ username: string;
83
+ email: string;
84
+ avatarUrl: string | undefined;
85
+ }[];
86
+ }>;
67
87
  getRepo(input: AzureGetRepoInput, options?: Options): Promise<{
68
88
  data: GitRepository;
69
89
  }>;
@@ -135,6 +155,7 @@ export declare class AzureDevOps extends Provider implements GitProvider {
135
155
  repo: GetRepoInput;
136
156
  pullRequestId: string;
137
157
  expectedSourceSha: string;
158
+ mergeStrategy?: GitMergeStrategy.MergeCommit | GitMergeStrategy.Rebase | GitMergeStrategy.RebaseThenMergeCommit | GitMergeStrategy.Squash;
138
159
  }, options?: EnterpriseOptions): Promise<void>;
139
160
  setPullRequestAsDraft(input: {
140
161
  repo: GetRepoInput;
@@ -1,4 +1,4 @@
1
- import { Account, CursorPageInput, GetRepoErrorData, GetRepoInput, GitProvider, GitPullRequest, GitRepository, NumberedPageInput, Options } from '../gitProvider';
1
+ import { Account, CursorPageInput, GetRepoErrorData, GetRepoInput, GitMergeStrategy, GitProvider, GitPullRequest, GitRepository, NumberedPageInput, Options } from '../gitProvider';
2
2
  import { Provider } from '../provider';
3
3
  export interface RefreshTokenResponse {
4
4
  access_token: string;
@@ -108,5 +108,6 @@ export declare class Bitbucket extends Provider implements GitProvider {
108
108
  repo: GetRepoInput;
109
109
  pullRequestId: string;
110
110
  expectedSourceSha: string;
111
+ mergeStrategy?: GitMergeStrategy.MergeCommit | GitMergeStrategy.FastForward | GitMergeStrategy.Squash;
111
112
  }, options?: Options): Promise<void>;
112
113
  }
@@ -83,6 +83,13 @@ export interface GitBlame {
83
83
  };
84
84
  }[];
85
85
  }
86
+ export declare enum GitMergeStrategy {
87
+ MergeCommit = "MERGE_COMMIT",
88
+ Rebase = "REBASE",
89
+ RebaseThenMergeCommit = "REBASE_THEN_MERGE_COMMIT",
90
+ FastForward = "FAST_FORWARD",
91
+ Squash = "SQUASH"
92
+ }
86
93
  export declare enum GitPullRequestState {
87
94
  Open = "OPEN",
88
95
  Closed = "CLOSED",
@@ -1,4 +1,4 @@
1
- import { Account, CursorPageInput, EnterpriseOptions, GetRepoErrorData, GetRepoInput, GitLabel, GitMilestone, GitProvider, GitPullRequest, GitRepository, Organization } from '../gitProvider';
1
+ import { Account, CursorPageInput, EnterpriseOptions, GetRepoErrorData, GetRepoInput, GitLabel, GitMergeStrategy, GitMilestone, GitProvider, GitPullRequest, GitRepository, Organization } from '../gitProvider';
2
2
  import { Issue } from '../issueProvider';
3
3
  import { EnterpriseProvider } from '../provider';
4
4
  import { FetchIssuesData, FetchPullRequestsData } from './githubTypes';
@@ -9,6 +9,15 @@ export declare class GitHub extends EnterpriseProvider implements GitProvider {
9
9
  getCurrentUser(options?: EnterpriseOptions): Promise<{
10
10
  data: Account;
11
11
  }>;
12
+ getAccountsForRepo(input: {
13
+ repo: GetRepoInput;
14
+ } & CursorPageInput, options?: EnterpriseOptions): Promise<{
15
+ pageInfo: {
16
+ endCursor: string | null;
17
+ hasNextPage: boolean;
18
+ };
19
+ data: Account[];
20
+ }>;
12
21
  getUserForCommit(input: {
13
22
  repo: GetRepoInput;
14
23
  oid: string;
@@ -166,7 +175,7 @@ export declare class GitHub extends EnterpriseProvider implements GitProvider {
166
175
  } & CursorPageInput, options?: EnterpriseOptions): Promise<{
167
176
  pageInfo: {
168
177
  hasNextPage: boolean;
169
- endCursor: string;
178
+ endCursor: string | null;
170
179
  };
171
180
  data: GitPullRequest[];
172
181
  }>;
@@ -183,6 +192,7 @@ export declare class GitHub extends EnterpriseProvider implements GitProvider {
183
192
  mergePullRequest(input: {
184
193
  pullRequestGraphQLId: string;
185
194
  expectedSourceSha: string;
195
+ mergeStrategy?: GitMergeStrategy.MergeCommit | GitMergeStrategy.Rebase | GitMergeStrategy.Squash;
186
196
  }, options?: EnterpriseOptions): Promise<void>;
187
197
  setPullRequestMilestone(input: {
188
198
  pullRequestGraphQLId: string;
@@ -1,4 +1,4 @@
1
- import { Account, CursorPageInput, EnterpriseOptions, GetRepoErrorData, GetRepoInput, GitLabel, GitProvider, GitPullRequest, GitRepository, NumberedPageInput } from '../gitProvider';
1
+ import { Account, CursorPageInput, EnterpriseOptions, GetRepoErrorData, GetRepoInput, GitLabel, GitMergeStrategy, GitProvider, GitPullRequest, GitRepository, NumberedPageInput } from '../gitProvider';
2
2
  import { GetIssueInput, Issue, IssueProvider } from '../issueProvider';
3
3
  import { EnterpriseProvider } from '../provider';
4
4
  export type PullRequestState = 'opened' | 'merged' | 'closed';
@@ -27,6 +27,15 @@ export declare class GitLab extends EnterpriseProvider implements GitProvider, I
27
27
  }, options?: EnterpriseOptions): Promise<{
28
28
  data: Account;
29
29
  }>;
30
+ getAccountsForRepo(input: {
31
+ repo: GetRepoInput;
32
+ } & CursorPageInput, options?: EnterpriseOptions): Promise<{
33
+ pageInfo: {
34
+ endCursor: string | null;
35
+ hasNextPage: boolean;
36
+ };
37
+ data: Account[];
38
+ }>;
30
39
  getRepo(input: GetRepoInput, options?: EnterpriseOptions): Promise<{
31
40
  data: GitRepository;
32
41
  }>;
@@ -165,6 +174,7 @@ export declare class GitLab extends EnterpriseProvider implements GitProvider, I
165
174
  repo: GetRepoInput;
166
175
  pullRequestId: string;
167
176
  expectedSourceSha: string;
177
+ mergeStrategy?: GitMergeStrategy.Squash;
168
178
  }, options?: EnterpriseOptions): Promise<void>;
169
179
  setPullRequestMilestone(input: {
170
180
  repo: GetRepoInput;
@@ -42,7 +42,7 @@ export interface Issue {
42
42
  type: string | null;
43
43
  updatedDate: Date | null;
44
44
  upvoteCount: number | null;
45
- url: string;
45
+ url: string | null;
46
46
  milestone?: GitMilestone | null;
47
47
  }
48
48
  export interface IssueProvider {
@@ -5,14 +5,18 @@ import { Provider } from '../provider';
5
5
  export interface JiraResource {
6
6
  id: string;
7
7
  name: string;
8
+ url: string;
8
9
  avatarUrl: string;
9
10
  }
10
11
  export interface JiraProject {
11
12
  id: string;
13
+ key: string;
12
14
  name: string;
13
15
  resourceId: string;
14
16
  }
15
17
  export declare class Jira extends Provider {
18
+ private _resourceUrlCache;
19
+ private getResourceUrl;
16
20
  getCurrentUserForResource(input: {
17
21
  resourceId: string;
18
22
  }, options?: EnterpriseOptions): Promise<{
@@ -34,6 +38,7 @@ export declare class Jira extends Provider {
34
38
  };
35
39
  data: {
36
40
  id: string;
41
+ key: string;
37
42
  name: string;
38
43
  resourceId: string;
39
44
  }[];
@@ -41,6 +46,22 @@ export declare class Jira extends Provider {
41
46
  getJiraProjectsForResources(input: {
42
47
  resourceIds: string[];
43
48
  }, options?: EnterpriseOptions): Promise<Result<JiraProject[]>>;
49
+ getAccountsForJiraProject(input: {
50
+ resourceId: string;
51
+ projectKey: string;
52
+ } & CursorPageInput, options?: EnterpriseOptions): Promise<{
53
+ pageInfo: {
54
+ hasNextPage: boolean;
55
+ endCursor: string;
56
+ };
57
+ data: {
58
+ id: string;
59
+ name: string;
60
+ email: string;
61
+ avatarUrl: string;
62
+ username: string;
63
+ }[];
64
+ }>;
44
65
  getIssuesForProject(input: {
45
66
  project: string;
46
67
  resourceId: string;
@@ -45,6 +45,18 @@ export declare class Trello extends Provider {
45
45
  }, options?: EnterpriseOptions): Promise<{
46
46
  data: TrelloList[];
47
47
  }>;
48
+ getAccountsForTrelloBoard(input: {
49
+ appKey: string;
50
+ boardId: string;
51
+ }, options?: EnterpriseOptions): Promise<{
52
+ data: {
53
+ id: string;
54
+ name: string;
55
+ username: string;
56
+ email: null;
57
+ avatarUrl: null;
58
+ }[];
59
+ }>;
48
60
  getIssuesForBoard(input: {
49
61
  appKey: string;
50
62
  boardId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitkraken/provider-apis",
3
- "version": "0.12.3",
3
+ "version": "0.13.0",
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",
@@ -29,6 +29,7 @@
29
29
  "watch": "yarn clean && node ./scripts/build.mjs --watch & tsc -w"
30
30
  },
31
31
  "dependencies": {
32
+ "js-base64": "3.7.5",
32
33
  "node-fetch": "2.7.0"
33
34
  },
34
35
  "devDependencies": {