@gitkraken/provider-apis 0.13.2 → 0.14.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 +16 -0
- package/dist/index.js +177 -103
- package/dist/providers/azureDevops/azureDevOps.d.ts +34 -0
- package/dist/providers/bitbucket/bitbucket.d.ts +5 -0
- package/dist/providers/bitbucketServer/bitbucketServer.d.ts +24 -0
- package/dist/providers/bitbucketServer/bitbucketServerTypes.d.ts +7 -0
- package/dist/providers/gitProvider.d.ts +43 -6
- package/dist/providers/github/github.d.ts +16 -0
- package/dist/providers/github/githubTypes.d.ts +18 -9
- package/dist/providers/gitlab/gitlab.d.ts +20 -0
- package/dist/providers/issueProvider.d.ts +6 -0
- package/dist/providers/jira/jira.d.ts +55 -0
- package/dist/providers/trello/trello.d.ts +11 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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})},Te=(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)):{},Te(r||!e||!e.__esModule?K(t,"default",{value:e,enumerable:!0}):t,e)),ot=e=>Te(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 U=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}}},O=class extends U{};var m=(e,r)=>{let t={};return e&&(t.Authorization=`${r?"Basic":"Bearer"} ${e}`),t};var y=(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",C="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 U{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:y(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:`${C}/${encodeURIComponent(r.namespace)}/_apis/ConnectionData`,headers:y(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:`${C}/${encodeURIComponent(r.repo.namespace)}/${encodeURIComponent(r.repo.project)}/_apis/git/repositories/${encodeURIComponent(r.repo.name)}/commits/${r.oid}`,headers:y(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:y(this.config,t)})).body.value.map(n=>({id:n.accountId,name:n.accountName}))}}async getAzureProjects(r,t={}){let s=new URL(`${C}/${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:y(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:y(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:y(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:`${C}/${encodeURIComponent(r.namespace)}/${encodeURIComponent(r.project)}/_apis/git/repositories/${encodeURIComponent(r.name)}`,headers:y(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:`${C}/${encodeURIComponent(r.namespace)}/${encodeURIComponent(r.project)}/_apis/git/repositories`,headers:y(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(`${C}/${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:y(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||C}/${encodeURIComponent(o.namespace)}/${encodeURIComponent(o.project||"")}/_apis/git/repositories/${encodeURIComponent(o.name)}/pullRequests?${l}&%24top=${s}&%24skip=${(u-1)*s}`,headers:y(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 getAzurePullRequestLastMergeStatus(r,t={}){if(!r.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{repo:{namespace:s,project:n,name:o},pullRequestId:a}=r,i=await this.config.request({url:`${t.baseUrl||C}/${encodeURIComponent(s)}/${encodeURIComponent(n||"")}/_apis/git/repositories/${o}/pullrequests/${a}?includeCommits=true?api-version=6.0`,headers:{...y(this.config,t)}});if(!i.body.mergeStatus)throw new Error("Could not fetch pull request");return{data:i.body.mergeStatus}}async updatePullRequest(r,t,s,n){let{namespace:o,project:a,name:i}=r;return await this.config.request({method:"PATCH",url:`${n.baseUrl||C}/${encodeURIComponent(o)}/${encodeURIComponent(a||"")}/_apis/git/repositories/${i}/pullrequests/${t}?api-version=6.0`,body:s,headers:{...y(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||C}/${encodeURIComponent(r.namespace)}/${encodeURIComponent(r.project)}/_apis/wit/wiql?api-version=6.0`,body:JSON.stringify({query:d}),method:"POST",headers:{...y(this.config,t),"Content-Type":"application/json"}}),g=c.body.workItems.slice((u-1)*l,l*u).map(R=>R.id);if(g.length==0)return{pageInfo:{hasNextPage:!1,nextPage:null},data:[]};let I=await this.config.request({url:`${t.baseUrl||C}/${encodeURIComponent(r.namespace)}/${encodeURIComponent(r.project)}/_apis/wit/workitemsbatch?api-version=6.0`,body:JSON.stringify({ids:g,$expand:"Links"}),method:"POST",headers:{...y(this.config,t),"Content-Type":"application/json"}});return{pageInfo:{hasNextPage:c.body.workItems.length>l*u,nextPage:u+1},data:I.body.value.map(R=>pt(R,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||C}/${encodeURIComponent(s)}/${encodeURIComponent(n||"")}/_apis/wit/workitems/${o}?api-version=6.0`,body:JSON.stringify(i),headers:{...y(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||C}/${encodeURIComponent(s)}/${encodeURIComponent(n||"")}/_apis/wit/workitemtypes?api-version=6.0`,headers:{...y(this.config,t)}})).body.value}}async getLabelsForProject(r,t={}){let{namespace:s,project:n}=r;return{data:(await this.config.request({url:`${t.baseUrl||C}/${encodeURIComponent(s)}/${encodeURIComponent(n||"")}/_apis/wit/tags?api-version=6.0`,headers:{...y(this.config,t)}})).body.value.map(a=>({color:null,description:null,id:a.id,name:a.name}))}}};var v=(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 U{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:v(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:v(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:v(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:v(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:v(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:v(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:v(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:v(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:v(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:{...v(this.config,t),"Content-Type":"application/json"}})).body.title)throw new Error("Could not merge pull request")}};var M=class extends O{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=`
|
|
1
|
+
"use strict";var et=Object.create;var K=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var st=Object.getOwnPropertyNames;var rt=Object.getPrototypeOf,nt=Object.prototype.hasOwnProperty;var A=(t,r)=>{for(var e in r)K(t,e,{get:r[e],enumerable:!0})},Te=(t,r,e,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of st(r))!nt.call(t,n)&&n!==e&&K(t,n,{get:()=>r[n],enumerable:!(s=tt(r,n))||s.enumerable});return t};var at=(t,r,e)=>(e=t!=null?et(rt(t)):{},Te(r||!t||!t.__esModule?K(e,"default",{value:t,enumerable:!0}):e,t)),ot=t=>Te(K({},"__esModule",{value:!0}),t);var us={};A(us,{AzureDevOps:()=>j,AzureDevopsUtils:()=>se,Bitbucket:()=>B,BitbucketServer:()=>F,BitbucketServerUtils:()=>ne,BitbucketUtils:()=>re,GitHub:()=>M,GitHubUtils:()=>ae,GitLab:()=>W,GitLabUtils:()=>oe,Jira:()=>J,JiraUtils:()=>ie,Trello:()=>H,TrelloUtils:()=>ue,Utils:()=>is,default:()=>os});module.exports=ot(us);var Fe=require("js-base64");var $=100;var xe=at(require("node-fetch")),ke=globalThis.fetch||xe.default;var _e=t=>t.name==="fetch";var it=async t=>{let r=t.headers.get("content-type")||"",e=null;if(r.startsWith("application/json")){let n=await t.text();e=n.trim().length>0?JSON.parse(n):null}else if(r.startsWith("text/")||r==="")e=await t.text();else throw new Error(`Unsupported content-type: ${r}`);let s={body:e,headers:Object.fromEntries(t.headers.entries()),status:t.status,statusText:t.statusText};if(!t.ok){let n=new Error(t.statusText);throw Object.assign(n,{response:s}),n}return s},le=t=>_e(t)?async({url:r,...e})=>{let s=await t(r,e);return it(s)}:t;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 h=(t,r)=>{let e={};return t&&(e.Authorization=`${r?"Basic":"Bearer"} ${t}`),e};var y=(t,r={})=>h(r.token||t.token,r.isPAT||t.isPAT),Qe=t=>t.url.replace("/_apis/git/repositories/","/_git/").replace(`/${t.repository.project.id}/`,`/${encodeURIComponent(t.repository.project.name)}/`).replace(`/${t.repository.id}/`,`/${encodeURIComponent(t.repository.name)}/`).replace("/pullRequests/","/pullrequest/");var Ne="https://app.vssps.visualstudio.com/_apis",w="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"},pe=t=>({id:t.id,name:t.displayName,username:t.uniqueName||t.displayName,email:null,avatarUrl:t.imageUrl}),X=t=>t.startsWith("refs/heads/")?t.replace("refs/heads/",""):t,je=t=>{var r;return{id:t.pullRequestId.toString(),title:t.title,number:t.codeReviewId,state:ut[t.status],isDraft:t.isDraft,commentCount:null,upvoteCount:null,author:pe(t.createdBy),createdDate:new Date(t.creationDate),updatedDate:new Date(t.closedDate||t.creationDate),closedDate:t.closedDate?new Date(t.closedDate):null,repository:{name:t.repository.name,owner:{login:void 0}},headCommit:{buildStatuses:null},baseRef:{name:X(t.targetRefName),oid:t.lastMergeTargetCommit.commitId},headRef:{name:X(t.sourceRefName),oid:t.lastMergeSourceCommit.commitId},url:Qe(t),assignees:t.reviewers.map(pe),reviews:t.reviewers.filter(e=>e.vote!==0).map(e=>({reviewer:pe(e),state:lt[e.vote]||"REVIEW_REQUESTED"})),additions:null,deletions:null,fileCount:null,commitCount:null,headRepository:null,mergeableState:"UNKNOWN",labels:((r=t.labels)==null?void 0:r.map(e=>({color:null,description:null,id:e.id,name:e.name})))??[]}},Be=(t,r)=>({id:r.id,name:r.name,namespace:t,project:r.project.name,webUrl:r.webUrl,httpsUrl:r.remoteUrl,sshUrl:r.sshUrl,defaultBranch:r.defaultBranch?{name:X(r.defaultBranch)}:null,permission:null}),pt=(t,r)=>{var i,u;let e=t.fields,s=e["System.AssignedTo"],n=e["System.State"],o=e["System.WorkItemType"],a;return n&&o&&(a=(i=r[o])==null?void 0:i[n]),{id:t.id.toString(),number:t.id.toString(),title:e["System.Title"],commentCount:e["System.CommentCount"],author:{avatarUrl:e["System.CreatedBy"]._links.avatar.href,email:null,id:e["System.CreatedBy"].id,name:e["System.CreatedBy"].uniqueName,username:e["System.CreatedBy"].displayName},createdDate:new Date(e["System.CreatedDate"]),updatedDate:new Date(e["System.ChangedDate"]),url:t._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:e["System.WorkItemType"],repository:null,upvoteCount:0,labels:((u=t.fields["System.Tags"])==null?void 0:u.split(";").map(l=>({color:null,description:null,id:null,name:l.trim()})))??[]}},j=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 e=await this.config.request({url:`${Ne}/profile/profiles/me`,headers:y(this.config,r)});return{data:{id:e.body.id,name:e.body.displayName,username:e.body.displayName,email:e.body.emailAddress,avatarUrl:null}}}async getCurrentUserForInstance(r,e={}){let n=(await this.config.request({url:`${w}/${encodeURIComponent(r.namespace)}/_apis/ConnectionData`,headers:y(this.config,e)})).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,e={}){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:`${w}/${encodeURIComponent(r.repo.namespace)}/${encodeURIComponent(r.repo.project)}/_apis/git/repositories/${encodeURIComponent(r.repo.name)}/commits/${r.oid}`,headers:y(this.config,e)})).body.author;return{data:{name:n.name,email:n.email,avatarUrl:n.imageUrl}}}async getOrgsForUser(r,e={}){return{data:(await this.config.request({url:`${Ne}/accounts?memberId=${r.userId}&api-version=6.0`,headers:y(this.config,e)})).body.value.map(n=>({id:n.accountId,name:n.accountName}))}}async getAzureProjects(r,e={}){let s=new URL(`${w}/${encodeURIComponent(r.namespace)}/_apis/projects`);s.searchParams.set("$top",$.toString()),r.cursor&&s.searchParams.set("$skip",r.cursor);let n=await this.config.request({url:s.toString(),headers:y(this.config,e)}),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,e={}){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:y(this.config,e)})).body.value}}}async getAccountsForAzureProject(r,e={}){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:y(this.config,e)})).body.value.map(i=>{var u;return{id:Fe.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,e={}){if(!r.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let s=await this.config.request({url:`${w}/${encodeURIComponent(r.namespace)}/${encodeURIComponent(r.project)}/_apis/git/repositories/${encodeURIComponent(r.name)}`,headers:y(this.config,e)});return{data:Be(r.namespace,s.body)}}async getRepos(r,e={}){let s=[],n=[];return await Promise.all(r.map(async o=>{try{let a=await this.getRepo(o,e);s.push(a.data)}catch(a){n.push({input:o,error:a})}})),{data:s,errors:n}}async getReposForAzureProject(r,e={}){if(!r.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');return{data:(await this.config.request({url:`${w}/${encodeURIComponent(r.namespace)}/${encodeURIComponent(r.project)}/_apis/git/repositories`,headers:y(this.config,e)})).body.value.map(n=>Be(r.namespace,n))}}async getRefs(r,e,s={}){if(!e.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let n=new URL(`${w}/${encodeURIComponent(e.repo.namespace)}/${encodeURIComponent(e.repo.project)}/_apis/git/repositories/${encodeURIComponent(e.repo.name)}/refs`);n.searchParams.set("filter",r),n.searchParams.set("$top",$.toString()),e.cursor&&n.searchParams.set("continuationToken",e.cursor);let o=await this.config.request({url:n.toString(),headers:y(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,e={}){return this.getRefs("heads",r,e)}async getTags(r,e={}){return this.getRefs("tags",r,e)}async getPullRequestsForRepoBase(r,e={},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:`${e.baseUrl||w}/${encodeURIComponent(o.namespace)}/${encodeURIComponent(o.project||"")}/_apis/git/repositories/${encodeURIComponent(o.name)}/pullRequests?${l}&%24top=${s}&%24skip=${(u-1)*s}`,headers:y(this.config,e)})}async getPullRequestsForRepo(r,e={}){let n=r.page||1,o=await this.getPullRequestsForRepoBase(r,e,100);return{pageInfo:{hasNextPage:o.body.value.length===100,nextPage:n+1},data:o.body.value.map(je)}}async getPullRequestsForRepos(r,e={}){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},e)).body.value.forEach(i=>{n.push(je(i))})}catch(a){if(a.statusCode!==404&&a.statusCode!==401)throw a}})),{data:n}}async getAzurePullRequestLastMergeStatus(r,e={}){if(!r.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{repo:{namespace:s,project:n,name:o},pullRequestId:a}=r,i=await this.config.request({url:`${e.baseUrl||w}/${encodeURIComponent(s)}/${encodeURIComponent(n||"")}/_apis/git/repositories/${o}/pullrequests/${a}?includeCommits=true?api-version=6.0`,headers:{...y(this.config,e)}});if(!i.body.mergeStatus)throw new Error("Could not fetch pull request");return{data:i.body.mergeStatus}}async updatePullRequest(r,e,s,n){let{namespace:o,project:a,name:i}=r;return await this.config.request({method:"PATCH",url:`${n.baseUrl||w}/${encodeURIComponent(o)}/${encodeURIComponent(a||"")}/_apis/git/repositories/${i}/pullrequests/${e}?api-version=6.0`,body:s,headers:{...y(this.config,n),"Content-Type":"application/json"}})}async closePullRequest(r,e={}){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),e)).body.status)throw new Error("Could not close pull request")}async mergePullRequest(r,e={}){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),e)).body.status)throw new Error("Could not merge pull request")}async addPullRequestLabel(r,e={}){let{repo:{namespace:s,project:n,name:o},pullRequestId:a,labelName:i}=r;if(!n)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let u={name:i};if(!(await this.config.request({method:"POST",url:`${e.baseUrl||w}/${encodeURIComponent(s)}/${encodeURIComponent(n||"")}/_apis/git/repositories/${o}/pullrequests/${a}/labels?api-version=6.0`,body:JSON.stringify(u),headers:{...y(this.config,e),"Content-Type":"application/json"}})).body.id)throw new Error("Could not add pull request label")}async removePullRequestLabel(r,e={}){let{repo:{namespace:s,project:n,name:o},pullRequestId:a,labelNameOrId:i}=r;if(!n)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');await this.config.request({method:"DELETE",url:`${e.baseUrl||w}/${encodeURIComponent(s)}/${encodeURIComponent(n||"")}/_apis/git/repositories/${o}/pullrequests/${a}/labels/${encodeURIComponent(i)}?api-version=6.0`,headers:{...y(this.config,e)}})}async setPullRequestAsDraft(r,e={}){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),e)).body.status)throw new Error("Could not set the pull request as draft")}async addPullRequestReviewer(r,e={}){if(!r.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{repo:{namespace:s,project:n,name:o},pullRequestId:a,reviewerId:i,isRequired:u}=r,l={id:i,isRequired:u};if(!(await this.config.request({method:"PUT",url:`${e.baseUrl||w}/${encodeURIComponent(s)}/${encodeURIComponent(n||"")}/_apis/git/repositories/${o}/pullrequests/${a}/reviewers/${i}?api-version=6.0`,body:JSON.stringify(l),headers:{...y(this.config,e),"Content-Type":"application/json"}})).body.id)throw new Error("Could not add pull request reviewer")}async removePullRequestReviewer(r,e={}){if(!r.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{repo:{namespace:s,project:n,name:o},pullRequestId:a,reviewerId:i}=r;await this.config.request({method:"DELETE",url:`${e.baseUrl||w}/${encodeURIComponent(s)}/${encodeURIComponent(n||"")}/_apis/git/repositories/${o}/pullrequests/${a}/reviewers/${i}?api-version=6.0`,headers:{...y(this.config,e),Accept:"application/json"}})}async getIssuesForAzureProject(r,e={}){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:`${e.baseUrl||w}/${encodeURIComponent(r.namespace)}/${encodeURIComponent(r.project)}/_apis/wit/wiql?api-version=6.0`,body:JSON.stringify({query:d}),method:"POST",headers:{...y(this.config,e),"Content-Type":"application/json"}}),g=c.body.workItems.slice((u-1)*l,l*u).map(R=>R.id);if(g.length==0)return{pageInfo:{hasNextPage:!1,nextPage:null},data:[]};let m=await this.config.request({url:`${e.baseUrl||w}/${encodeURIComponent(r.namespace)}/${encodeURIComponent(r.project)}/_apis/wit/workitemsbatch?api-version=6.0`,body:JSON.stringify({ids:g,$expand:"Links"}),method:"POST",headers:{...y(this.config,e),"Content-Type":"application/json"}});return{pageInfo:{hasNextPage:c.body.workItems.length>l*u,nextPage:u+1},data:m.body.value.map(R=>pt(R,i||{}))}}async updateIssue(r,e,s,n,o={}){return await this.config.request({method:"PATCH",url:`${o.baseUrl||w}/${encodeURIComponent(r)}/${encodeURIComponent(e||"")}/_apis/wit/workitems/${s}?api-version=6.0`,body:JSON.stringify(n),headers:{...y(this.config,o),"Content-Type":"application/json-patch+json"}})}async setIssueStatus(r,e={}){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.updateIssue(s,n,o,i,e)).body.fields)!=null&&l["System.State"]))throw new Error("Could not set issue status")}async setIssueAssignee(r,e={}){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,assigneeNameOrEmail:a}=r,i=[{op:"add",path:"/fields/System.AssignedTo",value:a??""}];if(!((l=(await this.updateIssue(s,n,o,i,e)).body.fields)!=null&&l["System.State"]))throw new Error("Could not set issue assignee")}async setIssueLabels(r,e={}){var l;let{namespace:s,project:n,issueId:o,tagNames:a}=r,i=[{op:"replace",path:"/fields/System.Tags",value:a.join(";")}];if(!((l=(await this.updateIssue(s,n,o,i,e)).body.fields)!=null&&l["System.Tags"]))throw new Error("Could not set issue tags")}async getIssueTypesForAzureProject(r,e={}){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:`${e.baseUrl||w}/${encodeURIComponent(s)}/${encodeURIComponent(n||"")}/_apis/wit/workitemtypes?api-version=6.0`,headers:{...y(this.config,e)}})).body.value}}async getLabelsForProject(r,e={}){let{namespace:s,project:n}=r;return{data:(await this.config.request({url:`${e.baseUrl||w}/${encodeURIComponent(s)}/${encodeURIComponent(n||"")}/_apis/wit/tags?api-version=6.0`,headers:{...y(this.config,e)}})).body.value.map(a=>({color:null,description:null,id:a.id,name:a.name}))}}};var C=(t,r={})=>h(r.token||t.token,r.isPAT||t.isPAT);var S="https://api.bitbucket.org/2.0",dt={OPEN:"OPEN",MERGED:"MERGED",DECLINED:"CLOSED"},ze=t=>({id:t.uuid,name:t.display_name||t.nickname,username:t.nickname||t.display_name,email:null,avatarUrl:t.links.avatar.href}),Me=t=>{var r,e;return{id:t.uuid,namespace:t.workspace.slug,name:t.slug,webUrl:t.links.html.href,httpsUrl:((r=t.links.clone.find(s=>s.name==="https"))==null?void 0:r.href)??null,sshUrl:((e=t.links.clone.find(s=>s.name==="ssh"))==null?void 0:e.href)??null,defaultBranch:{name:t.mainbranch.name},permission:null}},me=t=>{let r=t.id;return{id:r.toString(),title:t.title,number:r,state:dt[t.state],isDraft:!1,commentCount:t.comment_count,upvoteCount:null,author:ze(t.author),createdDate:new Date(t.created_on),updatedDate:new Date(t.updated_on),closedDate:null,repository:{name:t.source.repository.name,owner:{login:void 0}},headCommit:{buildStatuses:null},baseRef:{name:t.destination.branch.name,oid:t.destination.commit.hash},headRef:{name:t.source.branch.name,oid:t.source.commit.hash},url:t.links.html.href,assignees:null,reviews:null,additions:null,deletions:null,fileCount:null,commitCount:null,headRepository:null,mergeableState:"UNKNOWN"}},B=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 e=await this.config.request({url:`${S}/user`,headers:C(this.config,r)});return{data:ze(e.body)}}async getUserForCommit(r,e={}){var a;let n=(await this.config.request({url:`${S}/repositories/${r.repo.namespace}/${r.repo.name}/commit/${r.oid}`,headers:C(this.config,e)})).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,e={}){let s=await this.config.request({url:`${S}/repositories/${r.namespace}/${r.name}`,headers:C(this.config,e)});return{data:Me(s.body)}}async getRepos(r,e={}){let s=[],n=[];return await Promise.all(r.map(async o=>{try{let a=await this.getRepo(o,e);s.push(a.data)}catch(a){n.push({input:o,error:a})}})),{data:s,errors:n}}async getReposForCurrentUser(r={},e={}){let s=new URL(`${S}/repositories`);s.searchParams.set("role","member"),s.searchParams.set("pagelen",$.toString()),r.cursor&&s.searchParams.set("after",r.cursor);let n=await this.config.request({url:s.toString(),headers:C(this.config,e)}),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(Me)}}async getBranches(r,e={}){var a;let s=new URL(`${S}/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",$.toString());let n=await this.config.request({url:s.toString(),headers:C(this.config,e)}),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,e={}){let s=new URL(`${S}/repositories/${r.repo.namespace}/${r.repo.name}/refs/tags`);s.searchParams.set("pagelen",$.toString()),r.cursor&&s.searchParams.set("page",r.cursor);let n=await this.config.request({url:s.toString(),headers:C(this.config,e)}),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,e={}){var a;let s=new URL(`${S}/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:`${S}/pullrequests/${r.userId}`,headers:C(this.config,e)}),o=!!n.body.next;return{pageInfo:{hasNextPage:o,nextPage:o?n.body.page+1:null},data:n.body.values.map(me)}}async getPullRequestsForRepoBase(r,e={}){var n;let s=new URL(`${S}/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:C(this.config,e)})}async getPullRequestsForRepo(r,e={}){let s=[],n=await this.getPullRequestsForRepoBase(r,e);n.body.values.forEach(a=>{if(r.authorLogin&&a.author.uuid!==r.authorLogin)return null;s.push(me(a))});let o=!!n.body.next;return{pageInfo:{hasNextPage:o,nextPage:o?n.body.page+1:null},data:s}}async getPullRequestsForRepos(r,e={}){let s=[];return await Promise.all(r.repos.map(async n=>{try{(await this.getPullRequestsForRepoBase({repo:n,...r},e)).body.values.forEach(a=>{if(r.authorLogin&&a.author.uuid!==r.authorLogin)return null;s.push(me(a))})}catch(o){if(o.statusCode!==404&&o.statusCode!==401)throw o}})),{data:s}}async closePullRequest(r,e={}){let{repo:{namespace:s,name:n},pullRequestId:o}=r;if(!(await this.config.request({method:"POST",url:`${S}/repositories/${s}/${n}/pullrequests/${o}/decline`,headers:C(this.config,e)})).body.title)throw new Error("Could not close pull request")}async mergePullRequest(r,e={}){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:`${S}/repositories/${s}/${n}/pullrequests/${o}/merge`,body:JSON.stringify(u),headers:{...C(this.config,e),"Content-Type":"application/json"}})).body.title)throw new Error("Could not merge pull request")}async setPullRequestReviewers(r,e={}){let{repo:{namespace:s,name:n},pullRequestId:o,reviewerUsernames:a}=r,i={reviewers:a.map(l=>({username:l}))};if(!(await this.config.request({method:"PUT",url:`${S}/repositories/${s}/${n}/pullrequests/${o}`,body:JSON.stringify(i),headers:{...C(this.config,e),"Content-Type":"application/json"}})).body.title)throw new Error("Could not set pull request reviewers")}};var F=class extends T{getBaseUrl(r){let e=r.baseUrl||this.config.baseUrl;if(!e)throw new Error('Bitbucket Server requires "baseUrl"');return e}getRequestHeaders(r){return h(r.token||this.config.token)}async getRepo(r,e={}){var n,o,a;let s=await this.config.request({url:`${this.getBaseUrl(e)}/projects/${r.namespace}/repos/${r.name}`,headers:this.getRequestHeaders(e)});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,e={}){let s=[],n=[];return await Promise.all(r.map(async o=>{try{let a=await this.getRepo(o,e);s.push(a.data)}catch(a){n.push({input:o,error:a})}})),{data:s,errors:n}}async closePullRequest(r,e){let{repo:{namespace:s,name:n},pullRequestId:o,version:a}=r;if(!(await this.config.request({method:"POST",url:`${this.getBaseUrl(e)}/projects/${s}/repos/${n}/pull-requests/${o}/decline`,body:JSON.stringify({version:a}),headers:{...this.getRequestHeaders(e),"Content-Type":"application/json"}})).body.title)throw new Error("Could not close pull request")}async mergePullRequest(r,e){let{repo:{namespace:s,name:n},pullRequestId:o,mergeStrategyId:a,version:i}=r;if(!(await this.config.request({method:"POST",url:`${this.getBaseUrl(e)}/projects/${s}/repos/${n}/pull-requests/${o}/merge`,body:JSON.stringify({strategyId:a,version:i}),headers:{...this.getRequestHeaders(e),"Content-Type":"application/json"}})).body.title)throw new Error("Could not merge pull request")}async getMergeStrategies(r){let e=await this.config.request({url:`${this.getBaseUrl(r)}/admin/pull-requests/git`,headers:{...this.getRequestHeaders(r),"Content-Type":"application/json"}});return{data:{defaultStrategy:e.body.mergeConfig.defaultStrategy,strategies:e.body.mergeConfig.strategies}}}async setPullRequestReviewers(r,e={}){let{repo:{namespace:s,name:n},pullRequestId:o,reviewerUsernames:a,version:i}=r,u={reviewers:a.map(p=>({user:{name:p}})),version:i};if(!(await this.config.request({method:"PUT",url:`${this.getBaseUrl(e)}/projects/${s}/repos/${n}/pull-requests/${o}`,body:JSON.stringify(u),headers:{...this.getRequestHeaders(e),"Content-Type":"application/json"}})).body.title)throw new Error("Could not set pull request reviewers")}};var he="https://api.github.com",ct=`${he}/graphql`,Y=`
|
|
2
2
|
description
|
|
3
3
|
dueOn
|
|
4
4
|
id
|
|
@@ -6,26 +6,26 @@ number
|
|
|
6
6
|
state
|
|
7
7
|
title
|
|
8
8
|
url
|
|
9
|
-
`,
|
|
9
|
+
`,We=/\/api\/v\d+$/,ee=`
|
|
10
10
|
color
|
|
11
11
|
description
|
|
12
12
|
id
|
|
13
13
|
name
|
|
14
|
-
`,gt=
|
|
14
|
+
`,gt=t=>{if(t.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=(t,r)=>{let e=r.baseUrl||t.baseUrl;return e?(e=e.replace(/\/$/,""),gt(e),We.test(e)&&(e=e.replace(We,"")),`${e}/api/graphql`):ct},f=(t,r,e)=>{let s=h(e.token||t.token);return s["X-Github-Next-Global-ID"]="1",s["Content-Type"]="application/json",t.request({url:mt(t,e),method:"POST",headers:s,body:JSON.stringify(r)})},ht={user:!0,"user:email":!0,"read:user":!0},x=t=>t.some(r=>ht[r]),D=(t=!1,r=!1)=>`
|
|
15
15
|
__typename
|
|
16
16
|
id
|
|
17
17
|
databaseId
|
|
18
18
|
name
|
|
19
19
|
login
|
|
20
20
|
${r?"email":""}
|
|
21
|
-
avatarUrl${
|
|
22
|
-
`,Je=(
|
|
21
|
+
avatarUrl${t?"(size: $avatarSize)":""}
|
|
22
|
+
`,Je=(t=!1)=>`
|
|
23
23
|
__typename
|
|
24
24
|
id
|
|
25
25
|
databaseId
|
|
26
26
|
login
|
|
27
|
-
avatarUrl${
|
|
28
|
-
`,ft=(
|
|
27
|
+
avatarUrl${t?"(size: $avatarSize)":""}
|
|
28
|
+
`,ft=(t,r=!1)=>`
|
|
29
29
|
id
|
|
30
30
|
databaseId
|
|
31
31
|
number
|
|
@@ -33,7 +33,7 @@ title
|
|
|
33
33
|
state
|
|
34
34
|
author {
|
|
35
35
|
... on User {
|
|
36
|
-
${
|
|
36
|
+
${D(!1,r)}
|
|
37
37
|
}
|
|
38
38
|
... on Bot {
|
|
39
39
|
${Je(!1)}
|
|
@@ -45,12 +45,22 @@ commits(last: 1) {
|
|
|
45
45
|
commit {
|
|
46
46
|
... on Commit {
|
|
47
47
|
oid
|
|
48
|
-
|
|
49
|
-
contexts {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
statusCheckRollup {
|
|
49
|
+
contexts(first: 100) {
|
|
50
|
+
totalCount
|
|
51
|
+
nodes {
|
|
52
|
+
... on CheckRun {
|
|
53
|
+
name
|
|
54
|
+
status
|
|
55
|
+
permalink
|
|
56
|
+
}
|
|
57
|
+
... on StatusContext {
|
|
58
|
+
context
|
|
59
|
+
description
|
|
60
|
+
state
|
|
61
|
+
targetUrl
|
|
62
|
+
}
|
|
63
|
+
}
|
|
54
64
|
}
|
|
55
65
|
}
|
|
56
66
|
}
|
|
@@ -83,7 +93,7 @@ headRepository {
|
|
|
83
93
|
url
|
|
84
94
|
sshUrl
|
|
85
95
|
}
|
|
86
|
-
${
|
|
96
|
+
${t?"isDraft":""}
|
|
87
97
|
url
|
|
88
98
|
createdAt
|
|
89
99
|
comments {
|
|
@@ -96,7 +106,7 @@ updatedAt
|
|
|
96
106
|
closedAt
|
|
97
107
|
assignees(first: 100) {
|
|
98
108
|
nodes {
|
|
99
|
-
${
|
|
109
|
+
${D(!1,r)}
|
|
100
110
|
}
|
|
101
111
|
}
|
|
102
112
|
reviewRequests(first: 100) {
|
|
@@ -104,7 +114,7 @@ reviewRequests(first: 100) {
|
|
|
104
114
|
asCodeOwner
|
|
105
115
|
requestedReviewer {
|
|
106
116
|
... on User {
|
|
107
|
-
${
|
|
117
|
+
${D(!1,r)}
|
|
108
118
|
}
|
|
109
119
|
}
|
|
110
120
|
}
|
|
@@ -113,7 +123,7 @@ latestReviews(first: 100) {
|
|
|
113
123
|
nodes {
|
|
114
124
|
author {
|
|
115
125
|
... on User {
|
|
116
|
-
${
|
|
126
|
+
${D(!1,r)}
|
|
117
127
|
}
|
|
118
128
|
}
|
|
119
129
|
state
|
|
@@ -131,13 +141,13 @@ labels(first: 100) {
|
|
|
131
141
|
${ee}
|
|
132
142
|
}
|
|
133
143
|
}
|
|
134
|
-
`,Rt=(
|
|
144
|
+
`,Rt=(t=!1)=>`
|
|
135
145
|
id
|
|
136
146
|
databaseId
|
|
137
147
|
title
|
|
138
148
|
author {
|
|
139
149
|
... on User {
|
|
140
|
-
${
|
|
150
|
+
${D(!1,t)}
|
|
141
151
|
}
|
|
142
152
|
... on Bot {
|
|
143
153
|
${Je(!1)}
|
|
@@ -161,7 +171,7 @@ comments {
|
|
|
161
171
|
}
|
|
162
172
|
assignees(first: 100) {
|
|
163
173
|
nodes {
|
|
164
|
-
${
|
|
174
|
+
${D(!1,t)}
|
|
165
175
|
}
|
|
166
176
|
}
|
|
167
177
|
state
|
|
@@ -173,7 +183,7 @@ labels(first: 100) {
|
|
|
173
183
|
${ee}
|
|
174
184
|
}
|
|
175
185
|
}
|
|
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"},
|
|
186
|
+
`,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"},yt=new RegExp('(([^\\s]+:)?\\"(?:[^\\"\\\\]|\\\\.)*\\"?)|([^\\"\\s]+)',"g"),fe=t=>{let r=[];return(t.match(yt)??[]).forEach(s=>{if(s.includes(":")&&s!="is:closed"){let n=s.split(":")[0];It[n]&&r.push(s)}}),r},Re=(t,r,e,s,n=!1)=>{let o=t==="issue";return{query:`
|
|
177
187
|
query SearchIssuesOrPullRequests($query: String! $after: String) {
|
|
178
188
|
search(type:ISSUE query:$query first:100 after:$after) {
|
|
179
189
|
pageInfo {
|
|
@@ -186,7 +196,7 @@ query SearchIssuesOrPullRequests($query: String! $after: String) {
|
|
|
186
196
|
}
|
|
187
197
|
}
|
|
188
198
|
}
|
|
189
|
-
}`,variables:{query:`is:${
|
|
199
|
+
}`,variables:{query:`is:${t} is:open ${r}`,after:e}}},bt="Field 'isDraft' doesn't exist on type 'PullRequest'",He=(t=[])=>t.some(r=>(r==null?void 0:r.message)===bt);var Ie=`
|
|
190
200
|
id
|
|
191
201
|
databaseId
|
|
192
202
|
owner {
|
|
@@ -199,18 +209,18 @@ defaultBranchRef {
|
|
|
199
209
|
name
|
|
200
210
|
}
|
|
201
211
|
viewerPermission
|
|
202
|
-
`,
|
|
212
|
+
`,be={__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"},qt={OPEN:"OPEN",CLOSED:"CLOSED"},Pe=t=>({color:t.color,description:t.description,graphQLId:t.id,id:null,name:t.name}),ye=t=>({id:t.databaseId.toString(),graphQLId:t.id,namespace:t.owner.login,name:t.name,webUrl:t.url,httpsUrl:t.url.endsWith(".git")?t.url:`${t.url}.git`,sshUrl:t.sshUrl,defaultBranch:t.defaultBranchRef,permission:t.viewerPermission}),$t={OPEN:"OPEN",CLOSED:"CLOSED",MERGED:"MERGED"},v=t=>({id:t.databaseId.toString(),graphQLId:t.id,name:t.name??t.login,username:t.login,email:t.email??null,avatarUrl:t.avatarUrl}),Ct=t=>{var n,o,a,i,u,l,p,d,c,g;let r=null;t.author?r=(t.author.__typename==="Bot",t.author):r=be;let e=(((n=t.reviewRequests)==null?void 0:n.nodes)||[]).filter(m=>!m.asCodeOwner),s=(o=t.headRepository)==null?void 0:o.url;return s&&!s.endsWith(".git")&&(s=`${s}.git`),{id:t.databaseId.toString(),graphQLId:t.id,title:t.title,number:t.number,state:$t[t.state],commentCount:t.comments.totalCount,upvoteCount:t.reactions.totalCount,author:r?v(r):null,createdDate:new Date(t.createdAt),isDraft:t.isDraft,repository:{name:t.repository.name,owner:{login:t.repository.owner.login}},headRepository:t.headRepository?{name:t.headRepository.name,owner:{login:t.headRepository.owner.login},remoteInfo:{cloneUrlHTTPS:s,cloneUrlSSH:t.headRepository.sshUrl}}:null,headCommit:{buildStatuses:((u=(i=(a=t.commits.nodes)==null?void 0:a[0].commit.statusCheckRollup)==null?void 0:i.contexts.nodes)==null?void 0:u.map(m=>"context"in m?{description:m.description,name:m.context,state:m.state,stage:null,url:m.targetUrl}:{description:null,name:m.name,state:m.status,stage:null,url:m.permalink}))??[]},headRef:t.headRef?{name:t.headRef.name,oid:((l=t.headRef.target)==null?void 0:l.oid)??null}:null,baseRef:t.baseRef?{name:t.baseRef.name,oid:((p=t.baseRef.target)==null?void 0:p.oid)??null}:null,url:t.url,updatedDate:new Date(t.updatedAt),closedDate:t.closedAt?new Date(t.closedAt):null,assignees:t.assignees.nodes?t.assignees.nodes.map(v):null,reviews:e.map(m=>({reviewer:v(m.requestedReviewer),state:"REVIEW_REQUESTED"})).concat((((d=t.latestReviews)==null?void 0:d.nodes)||[]).map(m=>{let R=m.author||be;return{reviewer:v(R),state:Pt[m.state]}})),additions:t.additions,deletions:t.deletions,fileCount:t.changedFiles,commitCount:t.commits.totalCount,mergeableState:wt[t.mergeable],milestone:t.milestone?we(t.milestone):null,labels:((g=(c=t.labels)==null?void 0:c.nodes)==null?void 0:g.map(Pe))??[]}},St=t=>{var e,s;let r=null;return t.author?r=(t.author.__typename==="Bot",t.author):r=be,{id:t.databaseId.toString(),graphQLId:t.id,number:t.number,title:t.title,author:v(r),commentCount:t.comments.totalCount,createdDate:new Date(t.createdAt),description:null,state:{name:qt[t.state],color:null},type:null,repository:{name:t.repository.name,owner:{login:t.repository.owner.login}},url:t.url,updatedDate:new Date(t.updatedAt),assignees:t.assignees.nodes?t.assignees.nodes.map(v):[],upvoteCount:t.reactions.totalCount,milestone:t.milestone?we(t.milestone):null,labels:((s=(e=t.labels)==null?void 0:e.nodes)==null?void 0:s.map(Pe))??[]}},we=t=>({id:t.number.toString(),graphQLId:t.id.toString(),number:t.number,title:t.title,description:t.description,isOpen:t.state=="OPEN",url:t.url,startDate:null,dueDate:t.dueOn?new Date(t.dueOn):null}),M=class extends T{constructor(){super(...arguments);this._scopesCache={}}async getScopes(e){let s=e.token||this.config.token;if(!s)return[];let n=this._scopesCache[s];if(!n){let a=(await f(this.config,{query:"query { rateLimit(dryRun: true) { __typename } }"},e)).headers["x-oauth-scopes"];n=a?a.split(", "):[],this._scopesCache[s]=n}return n}getEnterpriseAvatarUrlIfNeeded(e,s,n){let o=n.baseUrl||this.config.baseUrl;return!o||o.startsWith(he)?e:s?`https://avatars.githubusercontent.com/u/e?email=${encodeURIComponent(s)}`:""}async getCurrentUser(e={}){var a;let s=await this.getScopes(e),o=(a=(await f(this.config,{query:`
|
|
203
213
|
query getCurrentUser {
|
|
204
214
|
viewer {
|
|
205
|
-
${
|
|
215
|
+
${D(!1,x(s))}
|
|
206
216
|
}
|
|
207
217
|
}
|
|
208
|
-
`},
|
|
218
|
+
`},e)).body.data)==null?void 0:a.viewer;if(!o)throw new Error("Current user not found.");return{data:v(o)}}async getAccountsForRepo(e,s={}){var l,p,d,c,g,m;let n=await this.getScopes(s),{repo:{namespace:o,name:a},cursor:i}=e,u=await f(this.config,{query:`
|
|
209
219
|
query getAccountsForRepo($owner: String!, $name: String! $cursor: String, $first: Int!) {
|
|
210
220
|
repository(owner: $owner, name: $name) {
|
|
211
221
|
assignableUsers(first: $first, after: $cursor) {
|
|
212
222
|
nodes {
|
|
213
|
-
${
|
|
223
|
+
${D(!1,x(n))}
|
|
214
224
|
}
|
|
215
225
|
pageInfo {
|
|
216
226
|
endCursor
|
|
@@ -219,7 +229,7 @@ query getAccountsForRepo($owner: String!, $name: String! $cursor: String, $first
|
|
|
219
229
|
}
|
|
220
230
|
}
|
|
221
231
|
}
|
|
222
|
-
`,variables:{owner:o,name:a,cursor:i,first
|
|
232
|
+
`,variables:{owner:o,name:a,cursor:i,first:$}},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:((m=(g=(c=u.body.data.repository)==null?void 0:c.assignableUsers)==null?void 0:g.nodes)==null?void 0:m.map(v))??[]}}async getUserForCommit(e,s={}){var i,u;let o=(i=(await f(this.config,{query:`
|
|
223
233
|
query getUserForCommit(
|
|
224
234
|
$owner: String!
|
|
225
235
|
$name: String!
|
|
@@ -238,23 +248,23 @@ query getUserForCommit(
|
|
|
238
248
|
}
|
|
239
249
|
}
|
|
240
250
|
}
|
|
241
|
-
`,variables:{owner:
|
|
251
|
+
`,variables:{owner:e.repo.namespace,name:e.repo.name,oid:e.oid,avatarSize:e.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(e,s={}){var i,u,l;let n=await this.getScopes(s),a=(l=(u=(i=(await f(this.config,{query:`
|
|
242
252
|
query getAccountForEmail($query: String! $avatarSize: Int) {
|
|
243
253
|
search(query: $query, type: USER, first: 1) {
|
|
244
254
|
nodes {
|
|
245
255
|
... on User {
|
|
246
|
-
${
|
|
256
|
+
${D(!0,x(n))}
|
|
247
257
|
}
|
|
248
258
|
}
|
|
249
259
|
}
|
|
250
260
|
}
|
|
251
|
-
`,variables:{query:`in:email ${
|
|
261
|
+
`,variables:{query:`in:email ${e.email}`,avatarSize:e.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:v({...a,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(a.avatarUrl,a.email,s)})}}async getAccountForUsername(e,s={}){var i;let n=await this.getScopes(s),a=(i=(await f(this.config,{query:`
|
|
252
262
|
query getUserForUsername($login: String! $avatarSize: Int) {
|
|
253
263
|
user(login: $login) {
|
|
254
|
-
${
|
|
264
|
+
${D(!0,x(n))}
|
|
255
265
|
}
|
|
256
266
|
}
|
|
257
|
-
`,variables:{login:
|
|
267
|
+
`,variables:{login:e.username,avatarSize:e.avatarSize}},s)).body.data)==null?void 0:i.user;if(!a)throw new Error("User not found.");return{data:v({...a,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(a.avatarUrl,a.email,s)})}}async getOrgsForCurrentUser(e={},s={}){var a,i;let n=await f(this.config,{query:`
|
|
258
268
|
query getOrgsForCurrentUser($cursor: String, $first: Int!) {
|
|
259
269
|
viewer {
|
|
260
270
|
organizations(first: $first after: $cursor) {
|
|
@@ -273,22 +283,22 @@ query getOrgsForCurrentUser($cursor: String, $first: Int!) {
|
|
|
273
283
|
}
|
|
274
284
|
}
|
|
275
285
|
}
|
|
276
|
-
`,variables:{cursor:
|
|
286
|
+
`,variables:{cursor:e.cursor,first:$}},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(e,s={}){var o;let n=await f(this.config,{query:`
|
|
277
287
|
query getRepo($owner: String!, $name: String!) {
|
|
278
288
|
repository(owner: $owner, name: $name) {
|
|
279
|
-
${
|
|
289
|
+
${Ie}
|
|
280
290
|
}
|
|
281
291
|
}
|
|
282
|
-
`,variables:{owner:
|
|
292
|
+
`,variables:{owner:e.namespace,name:e.name}},s);if(!((o=n.body.data)!=null&&o.repository))throw new Error(`Repository ${e.namespace}/${e.name} not found`);return{data:ye(n.body.data.repository)}}async getRepos(e,s={}){let n=e.map(({namespace:u,name:l},p)=>`
|
|
283
293
|
getRepo_${p}: repository(owner: "${u}", name: "${l}") {
|
|
284
|
-
${
|
|
294
|
+
${Ie}
|
|
285
295
|
}
|
|
286
296
|
`).join(`
|
|
287
|
-
`),o=await
|
|
297
|
+
`),o=await f(this.config,{query:`
|
|
288
298
|
query batchGetRepos {
|
|
289
299
|
${n}
|
|
290
300
|
}
|
|
291
|
-
`},s);if(!o.body.data)throw new Error(o.statusText||"Unknown error");let a=[],i=[];return
|
|
301
|
+
`},s);if(!o.body.data)throw new Error(o.statusText||"Unknown error");let a=[],i=[];return e.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(e,s={}){var a;if(!e.usernames.length)return{pageInfo:{endCursor:null,hasNextPage:!1},data:[]};let n=await f(this.config,{query:`
|
|
292
302
|
query getReposForUsernames($query: String!, $cursor: String, $first: Int!) {
|
|
293
303
|
search(query: $query, type: REPOSITORY, first: $first, after: $cursor) {
|
|
294
304
|
pageInfo {
|
|
@@ -297,12 +307,12 @@ query getReposForUsernames($query: String!, $cursor: String, $first: Int!) {
|
|
|
297
307
|
}
|
|
298
308
|
nodes {
|
|
299
309
|
... on Repository {
|
|
300
|
-
${
|
|
310
|
+
${Ie}
|
|
301
311
|
}
|
|
302
312
|
}
|
|
303
313
|
}
|
|
304
314
|
}
|
|
305
|
-
`,variables:{query:`fork:true ${
|
|
315
|
+
`,variables:{query:`fork:true ${e.usernames.map(i=>`user:${i}`).join(" ")}`,cursor:e.cursor,first:$}},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(e,s={}){return this.getReposForUsernames({usernames:e.owners.filter(n=>n.username).map(n=>n.username),cursor:e.cursor},s)}async getRefs(e,s,n={}){var u;let a=(u=(await f(this.config,{query:`
|
|
306
316
|
query getRefs($owner: String!, $name: String!, $refPrefix: String!, $cursor: String, $first: Int!) {
|
|
307
317
|
repository(owner: $owner, name: $name) {
|
|
308
318
|
refs(refPrefix: $refPrefix first: $first after: $cursor) {
|
|
@@ -323,7 +333,7 @@ query getRefs($owner: String!, $name: String!, $refPrefix: String!, $cursor: Str
|
|
|
323
333
|
}
|
|
324
334
|
}
|
|
325
335
|
}
|
|
326
|
-
`,variables:{owner:s.repo.namespace,name:s.repo.name,refPrefix:
|
|
336
|
+
`,variables:{owner:s.repo.namespace,name:s.repo.name,refPrefix:e,cursor:s.cursor,first:$}},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(e,s={}){return this.getRefs("refs/heads/",e,s)}async getTags(e,s={}){return this.getRefs("refs/tags/",e,s)}async getBlame(e,s={}){var i;let o=(i=(await f(this.config,{query:`
|
|
327
337
|
query getBlame($owner: String!, $name: String!, $ref: String!, $path: String!) {
|
|
328
338
|
repository(owner: $owner, name: $name) {
|
|
329
339
|
object(expression: $ref) {
|
|
@@ -362,13 +372,13 @@ query getBlame($owner: String!, $name: String!, $ref: String!, $path: String!) {
|
|
|
362
372
|
}
|
|
363
373
|
}
|
|
364
374
|
}
|
|
365
|
-
`,variables:{owner:
|
|
375
|
+
`,variables:{owner:e.repo.namespace,name:e.repo.name,ref:e.ref,path:e.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(e,s={}){var l,p;let n=await this.getScopes(s),o=x(n),a=d=>{let c=d&&typeof e.isDraft=="boolean"?`${e.query} draft:${e.isDraft}`:e.query;return Re("pr",c,e.cursor,o,d)},i=await f(this.config,a(!0),s);i.body.errors&&He(i.body.errors)&&(this.config.baseUrl||s.baseUrl)&&(i=await f(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(Ct))||[]}}async searchIssues(e,s={}){var u,l;let n=await this.getScopes(s),o=x(n),a=await f(this.config,Re("issue",e.query,e.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(St))||[]}}async getPullRequestsAssociatedWithUser(e,s={}){return this.searchPullRequests({query:`involves:${e.username}`,cursor:e.cursor},s)}async getPullRequestsForRepos(e,s={}){let{assigneeLogins:n,updatedBefore:o,authorLogin:a,repos:i,reviewRequestedLogin:u,startQuery:l,mentionLogin:p}=e,d=fe(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:e.isDraft,cursor:e.cursor},s)}async closePullRequest(e,s={}){var i,u,l;let{pullRequestGraphQLId:n}=e,o=`mutation ClosePullRequest($pullRequestGraphQLId: ID!) {
|
|
366
376
|
closePullRequest(input: { pullRequestId: $pullRequestGraphQLId }) {
|
|
367
377
|
pullRequest {
|
|
368
378
|
id
|
|
369
379
|
}
|
|
370
380
|
}
|
|
371
|
-
}`;if(!((l=(u=(i=(await
|
|
381
|
+
}`;if(!((l=(u=(i=(await f(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(e,s={}){var p,d,c;let{pullRequestGraphQLId:n,expectedSourceSha:o,mergeStrategy:a}=e,i;switch(a){case"MERGE_COMMIT":{i="MERGE";break}case"REBASE":{i="REBASE";break}case"SQUASH":{i="SQUASH";break}}let u=`mutation MergePullRequest(
|
|
372
382
|
$pullRequestGraphQLId: ID!,
|
|
373
383
|
$expectedSourceSha: GitObjectID!,
|
|
374
384
|
$mergeStrategy: PullRequestMergeMethod,
|
|
@@ -382,55 +392,79 @@ query getBlame($owner: String!, $name: String!, $ref: String!, $path: String!) {
|
|
|
382
392
|
id
|
|
383
393
|
}
|
|
384
394
|
}
|
|
385
|
-
}`;if(!((c=(d=(p=(await
|
|
395
|
+
}`;if(!((c=(d=(p=(await f(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(e,s={}){var u,l,p;let{pullRequestGraphQLId:n,milestoneGraphQLId:o}=e,a=`mutation SetPullRequestMilestone($pullRequestGraphQLId: ID!, $milestoneGraphQLId: ID) {
|
|
386
396
|
updatePullRequest(input: { pullRequestId: $pullRequestGraphQLId, milestoneId: $milestoneGraphQLId }) {
|
|
387
397
|
pullRequest {
|
|
388
398
|
id
|
|
389
399
|
}
|
|
390
400
|
}
|
|
391
|
-
}`;if(!((p=(l=(u=(await
|
|
401
|
+
}`;if(!((p=(l=(u=(await f(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(e,s){var a,i,u;let n=`mutation MarkReadyToReview($pullRequestGraphQLId: ID!) {
|
|
392
402
|
markPullRequestReadyForReview(input: { pullRequestId: $pullRequestGraphQLId }) {
|
|
393
403
|
pullRequest {
|
|
394
404
|
id
|
|
395
405
|
}
|
|
396
406
|
}
|
|
397
|
-
}`;if(!((u=(i=(a=(await
|
|
407
|
+
}`;if(!((u=(i=(a=(await f(this.config,{query:n,variables:{pullRequestGraphQLId:e}},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(e,s){var a,i,u;let n=`mutation ConvertToDraft($pullRequestGraphQLId: ID!) {
|
|
398
408
|
convertPullRequestToDraft(input: { pullRequestId: $pullRequestGraphQLId }) {
|
|
399
409
|
pullRequest {
|
|
400
410
|
id
|
|
401
411
|
}
|
|
402
412
|
}
|
|
403
|
-
}`;if(!((u=(i=(a=(await
|
|
413
|
+
}`;if(!((u=(i=(a=(await f(this.config,{query:n,variables:{pullRequestGraphQLId:e}},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(e,s={}){let{pullRequestGraphQLId:n,isDraft:o}=e;if(o){await this.convertPullRequestToDraft(n,s);return}await this.markPullRequestReadyForReview(n,s)}async setPullRequestReviewers(e,s={}){var u,l,p;let{pullRequestGraphQLId:n,reviewerGraphQLIds:o}=e,a=`mutation SetPullRequestReviewers($pullRequestGraphQLId: ID!, $reviewerGraphQLIds: [ID!]!) {
|
|
414
|
+
requestReviews(input: { pullRequestId: $pullRequestGraphQLId, userIds: $reviewerGraphQLIds }) {
|
|
415
|
+
pullRequest {
|
|
416
|
+
id
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}`;if(!((p=(l=(u=(await f(this.config,{query:a,variables:{pullRequestGraphQLId:n,reviewerGraphQLIds:o}},s)).body.data)==null?void 0:u.requestReviews)==null?void 0:l.pullRequest)!=null&&p.id))throw new Error("Could not set pull request reviewers")}async setPullRequestAssignees(e,s={}){var u,l,p;let{pullRequestGraphQLId:n,assigneeGraphQLIds:o}=e,a=`mutation SetPullRequestAssignees($pullRequestGraphQLId: ID!, $assigneeGraphQLIds: [ID!]!) {
|
|
404
420
|
updatePullRequest(input: { pullRequestId: $pullRequestGraphQLId, assigneeIds: $assigneeGraphQLIds }) {
|
|
405
421
|
pullRequest {
|
|
406
422
|
id
|
|
407
423
|
}
|
|
408
424
|
}
|
|
409
|
-
}`;if(!((p=(l=(u=(await
|
|
425
|
+
}`;if(!((p=(l=(u=(await f(this.config,{query:a,variables:{pullRequestGraphQLId:n,assigneeGraphQLIds:o}},s)).body.data)==null?void 0:u.updatePullRequest)==null?void 0:l.pullRequest)!=null&&p.id))throw new Error("Could not set pull request assignees")}async getIssuesAssociatedWithUser(e,s={}){var d;let[n,o]=((d=e.cursor)==null?void 0:d.split(";"))||[void 0,void 0],[a,i]=await Promise.all([n==="null"?null:this.searchIssues({query:`author:${e.username}`,cursor:n},s),o==="null"?null:this.searchIssues({query:`assignee:${e.username}`,cursor:o},s)]),u={},l=[],p=c=>{u[c.id]||(u[c.id]=!0,l.push(c))};return a==null||a.data.forEach(p),i==null||i.data.forEach(p),{pageInfo:{hasNextPage:(a==null?void 0:a.pageInfo.hasNextPage)||(i==null?void 0:i.pageInfo.hasNextPage)||!1,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 setPullRequestLabels(e,s={}){var u,l,p;let{pullRequestGraphQLId:n,labelGraphQLIds:o}=e,a=`mutation SetPullRequestLabels($pullRequestGraphQLId: ID!, $labelGraphQLIds: [ID!]) {
|
|
426
|
+
updatePullRequest(input: { pullRequestId: $pullRequestGraphQLId, labelIds: $labelGraphQLIds }) {
|
|
427
|
+
pullRequest {
|
|
428
|
+
id
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}`;if(!((p=(l=(u=(await f(this.config,{query:a,variables:{pullRequestGraphQLId:n,labelGraphQLIds:o}},s)).body.data)==null?void 0:u.updatePullRequest)==null?void 0:l.pullRequest)!=null&&p.id))throw new Error("Could not set pull request labels")}async getIssuesForRepos(e,s={}){let n=fe(e.startQuery||""),{cursor:o,assigneeLogins:a,updatedBefore:i,authorLogin:u,mentionLogin:l}=e;return e.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(e,s,n){var i,u,l;let o=`mutation CloseIssueWithReason($issueGraphQLId: ID!, $closeReason: IssueClosedStateReason!) {
|
|
410
432
|
closeIssue(input: { issueId: $issueGraphQLId, stateReason: $closeReason }) {
|
|
411
433
|
issue {
|
|
412
434
|
id
|
|
413
435
|
}
|
|
414
436
|
}
|
|
415
|
-
}`;if(!((l=(u=(i=(await
|
|
437
|
+
}`;if(!((l=(u=(i=(await f(this.config,{query:o,variables:{issueGraphQLId:e,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(e,s){var a,i,u;let n=`mutation SetIssueState($issueGraphQLId: ID!) {
|
|
416
438
|
updateIssue(input: { id: $issueGraphQLId, state: CLOSED }) {
|
|
417
439
|
issue {
|
|
418
440
|
id
|
|
419
441
|
}
|
|
420
442
|
}
|
|
421
|
-
}`;if(!((u=(i=(a=(await
|
|
443
|
+
}`;if(!((u=(i=(a=(await f(this.config,{query:n,variables:{issueGraphQLId:e}},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(e,s){var a,i,u;let n=`mutation ReOpenIssue($issueGraphQLId: ID!) {
|
|
422
444
|
reopenIssue(input: { issueId: $issueGraphQLId }) {
|
|
423
445
|
issue {
|
|
424
446
|
id
|
|
425
447
|
}
|
|
426
448
|
}
|
|
427
|
-
}`;if(!((u=(i=(a=(await
|
|
449
|
+
}`;if(!((u=(i=(a=(await f(this.config,{query:n,variables:{issueGraphQLId:e}},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(e,s={}){let{issueGraphQLId:n,status:o,closeReason:a}=e;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 setIssueLabels(e,s={}){var u,l,p;let{issueGraphQLId:n,labelGraphQLIds:o}=e,a=`mutation SetIssueLabels($issueGraphQLId: ID!, $labelGraphQLIds: [ID!]) {
|
|
450
|
+
updateIssue(input: { id: $issueGraphQLId, labelIds: $labelGraphQLIds }) {
|
|
451
|
+
issue {
|
|
452
|
+
id
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}`;if(!((p=(l=(u=(await f(this.config,{query:a,variables:{issueGraphQLId:n,labelGraphQLIds:o}},s)).body.data)==null?void 0:u.updateIssue)==null?void 0:l.issue)!=null&&p.id))throw new Error("Could not set issue labels")}async setIssueMilestone(e,s={}){var u,l,p;let{issueGraphQLId:n,milestoneGraphQLId:o}=e,a=`mutation SetIssueMilestone($issueGraphQLId: ID!, $milestoneGraphQLId: ID) {
|
|
428
456
|
updateIssue(input: { id: $issueGraphQLId, milestoneId: $milestoneGraphQLId }) {
|
|
429
457
|
issue {
|
|
430
458
|
id
|
|
431
459
|
}
|
|
432
460
|
}
|
|
433
|
-
}`;if(!((p=(l=(u=(await
|
|
461
|
+
}`;if(!((p=(l=(u=(await f(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 setIssueAssignees(e,s={}){var u,l,p;let{issueGraphQLId:n,assigneeGraphQLIds:o}=e,a=`mutation SetIssueAssignees($issueGraphQLId: ID!, $assigneeGraphQLIds: [ID!]!) {
|
|
462
|
+
updateIssue(input: { id: $issueGraphQLId, assigneeIds: $assigneeGraphQLIds }) {
|
|
463
|
+
issue {
|
|
464
|
+
id
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}`;if(!((p=(l=(u=(await f(this.config,{query:a,variables:{issueGraphQLId:n,assigneeGraphQLIds:o}},s)).body.data)==null?void 0:u.updateIssue)==null?void 0:l.issue)!=null&&p.id))throw new Error("Could not set issue assignees")}async getMilestonesForRepo(e,s={}){var u,l,p,d;let{repo:{namespace:n,name:o},cursor:a}=e,i=await f(this.config,{query:`
|
|
434
468
|
query getLabelsForRepo($owner: String!, $name: String! $cursor: String, $first: Int!) {
|
|
435
469
|
repository(owner: $owner, name: $name) {
|
|
436
470
|
milestones(first: $first, after: $cursor) {
|
|
@@ -444,7 +478,7 @@ query getLabelsForRepo($owner: String!, $name: String! $cursor: String, $first:
|
|
|
444
478
|
}
|
|
445
479
|
}
|
|
446
480
|
}
|
|
447
|
-
`,variables:{owner:n,name:o,cursor:a,first
|
|
481
|
+
`,variables:{owner:n,name:o,cursor:a,first:$}},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(we))??[]}}async getLabelsForRepo(e,s={}){var u,l,p,d;let{repo:{namespace:n,name:o},cursor:a}=e,i=await f(this.config,{query:`
|
|
448
482
|
query getLabelsForRepo($owner: String!, $name: String! $cursor: String, $first: Int!) {
|
|
449
483
|
repository(owner: $owner, name: $name) {
|
|
450
484
|
labels(first: $first, after: $cursor) {
|
|
@@ -458,7 +492,7 @@ query getLabelsForRepo($owner: String!, $name: String! $cursor: String, $first:
|
|
|
458
492
|
}
|
|
459
493
|
}
|
|
460
494
|
}
|
|
461
|
-
`,variables:{owner:n,name:o,cursor:a,first
|
|
495
|
+
`,variables:{owner:n,name:o,cursor:a,first:$}},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(Pe))??[]}}};var Et="https://gitlab.com/api/v4",Dt="https://gitlab.com/api/graphql",Ve=/\/api\/v\d+$/,Ke=t=>{if(t.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.")},qe=(t,r)=>{let e=r.baseUrl||t.baseUrl;return e?(e=e.replace(/\/$/,""),Ke(e),e):Et},Ut=(t,r)=>{let e=r.baseUrl||t.baseUrl;return e?(e=e.replace(/\/$/,""),Ke(e),Ve.test(e)&&(e=e.replace(Ve,"")),`${e}/api/graphql`):Dt},I=(t,r,e)=>{let s=h(e.token||t.token);return t.request({url:Ut(t,e),method:"POST",headers:{...s,"Content-Type":"application/json"},body:JSON.stringify(r)})};var Xe=t=>t.split("/").slice(0,-1).join("/"),N=t=>({namespace:Xe(t.fullPath),name:t.path,webUrl:t.webUrl}),vt={assigned:"assignedMergeRequests",authored:"authoredMergeRequests",reviewRequested:"reviewRequestedMergeRequests"},Lt={CAN_BE_MERGED:"MERGEABLE",CANNOT_BE_MERGED:"CONFLICTS",CANNOT_BE_MERGED_RECHECK:"UNKNOWN",UNCHECKED:"UNKNOWN",CHECKING:"UNKNOWN"},ve="gid://gitlab/User/",z="gid://gitlab/Project/",Gt="gid://gitlab/MergeRequest/",Ot="gid://gitlab/Issue/",At="gid://gitlab/ProjectLabel/",Ze="gid://gitlab/Milestone/",Tt="gid://gitlab/Ci::Build/",Le=`
|
|
462
496
|
description
|
|
463
497
|
dueDate
|
|
464
498
|
id
|
|
@@ -477,24 +511,24 @@ sshUrlToRepo
|
|
|
477
511
|
repository {
|
|
478
512
|
rootRef
|
|
479
513
|
}
|
|
480
|
-
`,
|
|
514
|
+
`,G=`
|
|
481
515
|
id
|
|
482
516
|
name
|
|
483
517
|
username
|
|
484
518
|
publicEmail
|
|
485
519
|
avatarUrl
|
|
486
|
-
`,
|
|
520
|
+
`,Ge=`
|
|
487
521
|
color
|
|
488
522
|
description
|
|
489
523
|
id
|
|
490
524
|
title
|
|
491
|
-
`,
|
|
525
|
+
`,Ce=`
|
|
492
526
|
author {
|
|
493
|
-
${
|
|
527
|
+
${G}
|
|
494
528
|
}
|
|
495
529
|
assignees {
|
|
496
530
|
nodes {
|
|
497
|
-
${
|
|
531
|
+
${G}
|
|
498
532
|
}
|
|
499
533
|
}
|
|
500
534
|
createdAt
|
|
@@ -504,7 +538,7 @@ id
|
|
|
504
538
|
iid
|
|
505
539
|
labels {
|
|
506
540
|
nodes {
|
|
507
|
-
${
|
|
541
|
+
${Ge}
|
|
508
542
|
}
|
|
509
543
|
}
|
|
510
544
|
state
|
|
@@ -517,11 +551,24 @@ webUrl
|
|
|
517
551
|
milestone {
|
|
518
552
|
${Le}
|
|
519
553
|
}
|
|
520
|
-
`,
|
|
554
|
+
`,xt=`
|
|
555
|
+
stages {
|
|
556
|
+
nodes {
|
|
557
|
+
jobs {
|
|
558
|
+
nodes {
|
|
559
|
+
id
|
|
560
|
+
name
|
|
561
|
+
status
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
name
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
`,Se=(t,r,e)=>`
|
|
521
568
|
id
|
|
522
569
|
state
|
|
523
570
|
author {
|
|
524
|
-
${
|
|
571
|
+
${G}
|
|
525
572
|
}
|
|
526
573
|
diffRefs {
|
|
527
574
|
baseSha
|
|
@@ -546,12 +593,12 @@ targetBranch
|
|
|
546
593
|
sourceBranch
|
|
547
594
|
assignees {
|
|
548
595
|
nodes {
|
|
549
|
-
${
|
|
596
|
+
${G}
|
|
550
597
|
}
|
|
551
598
|
}
|
|
552
599
|
reviewers {
|
|
553
600
|
nodes {
|
|
554
|
-
${
|
|
601
|
+
${G}
|
|
555
602
|
mergeRequestInteraction {
|
|
556
603
|
approved
|
|
557
604
|
reviewState
|
|
@@ -561,18 +608,19 @@ reviewers {
|
|
|
561
608
|
mergeStatusEnum
|
|
562
609
|
labels {
|
|
563
610
|
nodes {
|
|
564
|
-
${
|
|
611
|
+
${Ge}
|
|
565
612
|
}
|
|
566
613
|
}
|
|
567
|
-
${
|
|
614
|
+
${t?"project { path fullPath webUrl }":""}
|
|
568
615
|
${r?`milestone { ${Le} }`:""}
|
|
569
|
-
|
|
616
|
+
${e?`headPipeline { ${xt} }`:""}
|
|
617
|
+
`,k=t=>`${t.namespace}/${t.name}`,kt=t=>`${t.namespace}/${t.name}`,Ee=t=>{var r;return{id:t.id.replace(z,""),graphQLId:t.id,namespace:Xe(t.fullPath),name:t.path,webUrl:t.webUrl,httpsUrl:t.httpUrlToRepo,sshUrl:t.sshUrlToRepo,defaultBranch:(r=t.repository)!=null&&r.rootRef?{name:t.repository.rootRef}:null,permission:null}},_t={opened:"OPEN",merged:"MERGED",closed:"CLOSED"},_=t=>({id:t.id.replace(ve,""),graphQLId:t.id,name:t.name,username:t.username,email:t.publicEmail,avatarUrl:t.avatarUrl}),Oe=t=>({color:t.color,description:t.description,id:t.id.replace(At,""),graphQLId:t.id,name:t.title}),De=(t,r)=>{var e,s,n,o,a,i,u,l,p,d,c,g;return{id:t.id.replace(Gt,""),graphQLId:t.id,title:t.title,number:parseInt(t.iid,10),state:_t[t.state],commentCount:t.userNotesCount||0,upvoteCount:t.upvotes,author:t.author?_(t.author):null,createdDate:new Date(t.createdAt),isDraft:t.draft,repository:{name:r.name,owner:{login:r.namespace}},headRepository:null,headCommit:{buildStatuses:((n=(s=(e=t.headPipeline)==null?void 0:e.stages)==null?void 0:s.nodes)==null?void 0:n.flatMap(m=>{var R,b;return((b=(R=m.jobs)==null?void 0:R.nodes)==null?void 0:b.map(P=>({description:null,name:P.name??null,state:P.status??null,stage:m.name??null,url:`${r.webUrl}/-/jobs/${P.id.replace(Tt,"")}`})))??[]}))??[]},baseRef:{name:t.targetBranch,oid:((o=t.diffRefs)==null?void 0:o.baseSha)??null},headRef:{name:t.sourceBranch,oid:((a=t.diffRefs)==null?void 0:a.headSha)??null},url:t.webUrl,updatedDate:new Date(t.updatedAt),closedDate:t.mergedAt?new Date(t.mergedAt):null,assignees:(i=t.assignees)!=null&&i.nodes?t.assignees.nodes.map(_):null,reviews:(u=t.reviewers)!=null&&u.nodes?t.reviewers.nodes.map(m=>{var R,b;return{reviewer:_(m),state:(R=m.mergeRequestInteraction)!=null&&R.approved?"APPROVED":((b=m.mergeRequestInteraction)==null?void 0:b.reviewState)==="REVIEWED"?"CHANGES_REQUESTED":"CHANGES_REQUESTED"}}):null,additions:((l=t.diffStatsSummary)==null?void 0:l.additions)||0,deletions:((p=t.diffStatsSummary)==null?void 0:p.deletions)||0,fileCount:((d=t.diffStatsSummary)==null?void 0:d.fileCount)||0,commitCount:t.commitCount||0,mergeableState:Lt[t.mergeStatusEnum],milestone:t.milestone?Ae(t.milestone,r.webUrl):null,labels:((g=(c=t.labels)==null?void 0:c.nodes)==null?void 0:g.map(Oe))??[]}},Ue=(t,r)=>{var e,s;return{author:{avatarUrl:t.author.avatarUrl,email:null,graphQLId:t.author.id,id:t.author.id.replace(ve,""),name:t.author.name,username:t.author.username},assignees:t.assignees.nodes.map(n=>({avatarUrl:n.avatarUrl,email:null,graphQLId:n.id,id:n.id.replace(ve,""),name:n.name,username:n.username})),commentCount:t.userNotesCount,createdDate:new Date(t.createdAt),description:t.description,graphQLId:t.id,id:t.id.replace(Ot,""),labels:((s=(e=t.labels)==null?void 0:e.nodes)==null?void 0:s.map(Oe))??[],number:t.iid,repository:{name:r.name,owner:{login:r.namespace}},updatedDate:new Date(t.updatedAt),upvoteCount:t.upvotes,state:{name:t.state,color:null},type:t.type,title:t.title,url:t.webUrl,milestone:t.milestone?Ae(t.milestone,r.webUrl):null}},Ae=(t,r)=>({id:t.id.replace(Ze,""),graphQLId:t.id,number:parseInt(t.iid,10),title:t.title,description:t.description,isOpen:t.state==="active",url:`${r}/-/${t.webPath.replace(/.+?\/-\//,"")}`,startDate:t.startDate?new Date(t.startDate):null,dueDate:t.dueDate?new Date(t.dueDate):null}),W=class extends T{async getCurrentUser(r={}){var n;let s=(n=(await I(this.config,{query:`
|
|
570
618
|
query getCurrentUser {
|
|
571
619
|
currentUser {
|
|
572
|
-
${
|
|
620
|
+
${G}
|
|
573
621
|
}
|
|
574
622
|
}
|
|
575
|
-
`},r)).body.data)==null?void 0:n.currentUser;if(!s)throw new Error("Current user not found.");return{data:
|
|
623
|
+
`},r)).body.data)==null?void 0:n.currentUser;if(!s)throw new Error("Current user not found.");return{data:_(s)}}async getUserForCommit(r,e={}){var a,i,u,l;let s=k(r.repo),o=(l=(u=(i=(a=(await I(this.config,{query:`
|
|
576
624
|
query getUserForCommit($fullPath: ID!, $oid: String!) {
|
|
577
625
|
project(fullPath: $fullPath) {
|
|
578
626
|
repository {
|
|
@@ -586,21 +634,21 @@ query getUserForCommit($fullPath: ID!, $oid: String!) {
|
|
|
586
634
|
}
|
|
587
635
|
}
|
|
588
636
|
}
|
|
589
|
-
`,variables:{fullPath:s,oid:r.oid}},
|
|
637
|
+
`,variables:{fullPath:s,oid:r.oid}},e)).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,e={}){var o,a,i;let n=(i=(a=(o=(await I(this.config,{query:`
|
|
590
638
|
query getAccountForEmail($email: String!) {
|
|
591
639
|
users(search: $email) {
|
|
592
640
|
nodes {
|
|
593
|
-
${
|
|
641
|
+
${G}
|
|
594
642
|
}
|
|
595
643
|
}
|
|
596
644
|
}
|
|
597
|
-
`,variables:{email:r.email}},
|
|
645
|
+
`,variables:{email:r.email}},e)).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,e={}){var o;let n=(o=(await I(this.config,{query:`
|
|
598
646
|
query getAccountForUsername($username: String!) {
|
|
599
647
|
user(username: $username) {
|
|
600
|
-
${
|
|
648
|
+
${G}
|
|
601
649
|
}
|
|
602
650
|
}
|
|
603
|
-
`,variables:{username:r.username}},
|
|
651
|
+
`,variables:{username:r.username}},e)).body.data)==null?void 0:o.user;if(!n)throw new Error("User not found.");return{data:_(n)}}async getAccountsForRepo(r,e={}){var u,l,p,d,c,g,m;let{repo:{namespace:s,name:n},cursor:o}=r,a=await I(this.config,{query:`
|
|
604
652
|
query getAccountsForRepo(
|
|
605
653
|
$fullPath: ID!
|
|
606
654
|
$after: String
|
|
@@ -611,7 +659,7 @@ query getAccountsForRepo(
|
|
|
611
659
|
projectMembers(after: $after) {
|
|
612
660
|
nodes {
|
|
613
661
|
user {
|
|
614
|
-
${
|
|
662
|
+
${G}
|
|
615
663
|
}
|
|
616
664
|
}
|
|
617
665
|
pageInfo {
|
|
@@ -621,22 +669,22 @@ query getAccountsForRepo(
|
|
|
621
669
|
}
|
|
622
670
|
}
|
|
623
671
|
}
|
|
624
|
-
`,variables:{fullPath:`${s}/${n}`,after:o}},
|
|
672
|
+
`,variables:{fullPath:`${s}/${n}`,after:o}},e),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(R=>R.user).filter(R=>R!==null);return{pageInfo:((m=(g=(c=a.body.data)==null?void 0:c.project)==null?void 0:g.projectMembers)==null?void 0:m.pageInfo)??{endCursor:null,hasNextPage:!1},data:(i==null?void 0:i.map(_))??[]}}async getRepo(r,e={}){var o;let s=k(r),n=await I(this.config,{query:`
|
|
625
673
|
query getRepo($fullPath: ID!) {
|
|
626
674
|
project(fullPath: $fullPath) {
|
|
627
675
|
${$e}
|
|
628
676
|
}
|
|
629
677
|
}
|
|
630
|
-
`,variables:{fullPath:s}},
|
|
678
|
+
`,variables:{fullPath:s}},e);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,e={}){let n=r.map(k).map((u,l)=>`
|
|
631
679
|
getRepo_${l}: project(fullPath: "${u}") {
|
|
632
680
|
${$e}
|
|
633
681
|
}
|
|
634
682
|
`).join(`
|
|
635
|
-
`),o=await
|
|
683
|
+
`),o=await I(this.config,{query:`
|
|
636
684
|
query batchGetRepos {
|
|
637
685
|
${n}
|
|
638
686
|
}
|
|
639
|
-
`},
|
|
687
|
+
`},e);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={},e={}){var o,a,i,u,l,p;let s=await I(this.config,{query:`
|
|
640
688
|
query getReposForCurrentUser($after: String) {
|
|
641
689
|
projects(membership: true first: 100 after: $after) {
|
|
642
690
|
pageInfo {
|
|
@@ -648,7 +696,7 @@ query getReposForCurrentUser($after: String) {
|
|
|
648
696
|
}
|
|
649
697
|
}
|
|
650
698
|
}
|
|
651
|
-
`,variables:{after:r.cursor}},
|
|
699
|
+
`,variables:{after:r.cursor}},e);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,e,s={}){var u;let n=k(e.repo),o=new URL(`${qe(this.config,s)}/projects/${encodeURIComponent(n)}/repository/${r}`);o.searchParams.set("page",((u=e.page)==null?void 0:u.toString())||"1"),o.searchParams.set("per_page",$.toString());let a=await this.config.request({url:o.toString(),headers:h(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,e={}){return this.getRefs("branches",r,e)}async getTags(r,e={}){return this.getRefs("tags",r,e)}async getBlame(r,e={}){let s=k(r.repo),n=new URL(`${qe(this.config,e)}/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:h(e.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,e={}){var a,i;let s=vt[r.association],n=await I(this.config,{query:`
|
|
652
700
|
query getPullRequestsForUser($username: String! $cursor: String) {
|
|
653
701
|
user(username: $username) {
|
|
654
702
|
${s}(state:opened first:100 after:$cursor) {
|
|
@@ -657,12 +705,12 @@ query getPullRequestsForUser($username: String! $cursor: String) {
|
|
|
657
705
|
hasNextPage
|
|
658
706
|
}
|
|
659
707
|
nodes {
|
|
660
|
-
${
|
|
708
|
+
${Se(!0,!0,!0)}
|
|
661
709
|
}
|
|
662
710
|
}
|
|
663
711
|
}
|
|
664
712
|
}
|
|
665
|
-
`,variables:{username:r.username,cursor:r.cursor}},
|
|
713
|
+
`,variables:{username:r.username,cursor:r.cursor}},e);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,N(u.project))))||[]}}async getPullRequestsAssociatedWithUser(r,e={}){var c;let[s,n,o]=((c=r.cursor)==null?void 0:c.split(";"))||[void 0,void 0,void 0],[a,i,u]=await Promise.all([s==="null"?null:this.getPullRequestsForUser({username:r.username,association:"authored",cursor:s},e),n==="null"?null:this.getPullRequestsForUser({username:r.username,association:"assigned",cursor:n},e),o==="null"?null:this.getPullRequestsForUser({username:r.username,association:"reviewRequested",cursor:o},e)]),l={},p=[],d=g=>{l[g.id]||(l[g.id]=!0,p.push(g))};return a==null||a.data.forEach(d),i==null||i.data.forEach(d),u==null||u.data.forEach(d),{pageInfo:{hasNextPage:(a==null?void 0:a.pageInfo.hasNextPage)||(i==null?void 0:i.pageInfo.hasNextPage)||(u==null?void 0:u.pageInfo.hasNextPage)||!1,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:e,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 e&&p("updatedBefore",e,"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,e={}){var R,b,P;let{cursor:s,repo:n}=r||{},o=k(n),{variables:a,variableTypes:i,mergeRequestArguments:u}=this.getVariablesForPullRequests(r),l={fullPath:o,...a},p=await I(this.config,{query:`
|
|
666
714
|
query getPullRequestsForRepo(
|
|
667
715
|
$fullPath: ID!
|
|
668
716
|
$after: String
|
|
@@ -686,12 +734,12 @@ query getPullRequestsForRepo(
|
|
|
686
734
|
hasNextPage
|
|
687
735
|
}
|
|
688
736
|
nodes {
|
|
689
|
-
${
|
|
737
|
+
${Se(!1,!0,!0)}
|
|
690
738
|
}
|
|
691
739
|
}
|
|
692
740
|
}
|
|
693
741
|
}
|
|
694
|
-
`,variables:{...l,after:s}},
|
|
742
|
+
`,variables:{...l,after:s}},e),d=[],c=(R=p.body.data)==null?void 0:R.project,g=N(c||{fullPath:"",path:"",webUrl:""});return(((b=c==null?void 0:c.mergeRequests)==null?void 0:b.nodes)||[]).forEach(q=>{d.push(De(q,g))}),{pageInfo:(P=c==null?void 0:c.mergeRequests)==null?void 0:P.pageInfo,data:d}}async getPullRequestsForRepos(r,e={}){var c,g,m,R,b;let{cursor:s}=r||{},n=r.repoIds.map(P=>P.toString().startsWith(z)?P:`${z}${P}`),{variables:o,variableTypes:a,mergeRequestArguments:i}=this.getVariablesForPullRequests(r),u={projectIds:n,...o},l=await I(this.config,{query:`
|
|
695
743
|
query getPullRequests(
|
|
696
744
|
$projectIds: [ID!]
|
|
697
745
|
$after: String
|
|
@@ -716,20 +764,20 @@ query getPullRequests(
|
|
|
716
764
|
${i.length?i.join(" "):""}
|
|
717
765
|
) {
|
|
718
766
|
nodes {
|
|
719
|
-
${
|
|
767
|
+
${Se(!1,!1,!1)}
|
|
720
768
|
}
|
|
721
769
|
}
|
|
722
770
|
}
|
|
723
771
|
}
|
|
724
772
|
}
|
|
725
|
-
`,variables:{...u,after:s}},
|
|
773
|
+
`,variables:{...u,after:s}},e),p=[];return(((g=(c=l.body.data)==null?void 0:c.projects)==null?void 0:g.nodes)||[]).forEach(P=>{var Q;let q=N(P);(((Q=P.mergeRequests)==null?void 0:Q.nodes)||[]).forEach(V=>{p.push(De(V,q))})}),{pageInfo:(b=(R=(m=l.body)==null?void 0:m.data)==null?void 0:R.projects)==null?void 0:b.pageInfo,data:p}}async closePullRequest(r,e={}){var l,p,d;let{repo:{namespace:s,name:n},pullRequestId:o}=r,a=`mutation ClosePullRequest($fullPath: ID!, $pullRequestId: String!) {
|
|
726
774
|
mergeRequestUpdate(input: { projectPath: $fullPath, iid: $pullRequestId, state: CLOSED }) {
|
|
727
775
|
errors,
|
|
728
776
|
mergeRequest {
|
|
729
777
|
id
|
|
730
778
|
}
|
|
731
779
|
}
|
|
732
|
-
}`,u=(l=(await
|
|
780
|
+
}`,u=(l=(await I(this.config,{query:a,variables:{fullPath:`${s}/${n}`,pullRequestId:o}},e)).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,e={}){var d,c,g;let{repo:{namespace:s,name:n},pullRequestId:o,expectedSourceSha:a,mergeStrategy:i}=r,u=`mutation MergePullRequest(
|
|
733
781
|
$fullPath: ID!,
|
|
734
782
|
$pullRequestId: String!,
|
|
735
783
|
$expectedSourceSha: String!,
|
|
@@ -746,39 +794,52 @@ query getPullRequests(
|
|
|
746
794
|
id
|
|
747
795
|
}
|
|
748
796
|
}
|
|
749
|
-
}`,p=(d=(await
|
|
797
|
+
}`,p=(d=(await I(this.config,{query:u,variables:{fullPath:`${s}/${n}`,pullRequestId:o,expectedSourceSha:a,squash:i==="SQUASH"}},e)).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,e={}){var p,d,c;let{repo:{namespace:s,name:n},pullRequestId:o,milestoneGraphQLId:a}=r,i=`mutation SetPullRequestMilestone($fullPath: ID!, $pullRequestId: String!, $milestoneGraphQLId: MilestoneID) {
|
|
750
798
|
mergeRequestSetMilestone(input: { projectPath: $fullPath, iid: $pullRequestId, milestoneId: $milestoneGraphQLId }) {
|
|
751
799
|
errors,
|
|
752
800
|
mergeRequest {
|
|
753
801
|
id
|
|
754
802
|
}
|
|
755
803
|
}
|
|
756
|
-
}`,u=await
|
|
804
|
+
}`,u=await I(this.config,{query:i,variables:{fullPath:`${s}/${n}`,pullRequestId:o,milestoneGraphQLId:a}},e),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,e={}){var p,d,c;let{repo:{namespace:s,name:n},pullRequestId:o,isDraft:a}=r,i=`mutation MergeRequestSetDraft($fullPath: ID!, $pullRequestId: String!, $isDraft: Boolean!) {
|
|
757
805
|
mergeRequestSetDraft(input: { projectPath: $fullPath, iid: $pullRequestId, draft: $isDraft }) {
|
|
758
806
|
errors,
|
|
759
807
|
mergeRequest {
|
|
760
808
|
id
|
|
761
809
|
}
|
|
762
810
|
}
|
|
763
|
-
}`,l=(p=(await
|
|
811
|
+
}`,l=(p=(await I(this.config,{query:i,variables:{fullPath:`${s}/${n}`,pullRequestId:o,isDraft:a}},e)).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 setPullRequestReviewers(r,e={}){var p,d,c;let{repo:{namespace:s,name:n},pullRequestId:o,reviewerUsernames:a}=r,i=`mutation MergeRequestSetReviewers($fullPath: ID!, $pullRequestId: String!, $reviewerUsernames: [String!]!) {
|
|
812
|
+
mergeRequestSetReviewers(input: { projectPath: $fullPath, iid: $pullRequestId, reviewerUsernames: $reviewerUsernames }) {
|
|
813
|
+
errors,
|
|
814
|
+
mergeRequest {
|
|
815
|
+
id
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}`,l=(p=(await I(this.config,{query:i,variables:{fullPath:`${s}/${n}`,pullRequestId:o,reviewerUsernames:a}},e)).body.data)==null?void 0:p.mergeRequestSetReviewers;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 reviewers")}async setPullRequestAssignees(r,e={}){var p,d,c;let{repo:{namespace:s,name:n},pullRequestId:o,assigneeUsernames:a}=r,i=`mutation MergeRequestSetAssignees($fullPath: ID!, $pullRequestId: String!, $assigneeUsernames: [String!]!) {
|
|
764
819
|
mergeRequestSetAssignees(input: { projectPath: $fullPath, iid: $pullRequestId, assigneeUsernames: $assigneeUsernames }) {
|
|
765
820
|
errors,
|
|
766
821
|
mergeRequest {
|
|
767
822
|
id
|
|
768
823
|
}
|
|
769
824
|
}
|
|
770
|
-
}`,l=(p=(await
|
|
825
|
+
}`,l=(p=(await I(this.config,{query:i,variables:{fullPath:`${s}/${n}`,pullRequestId:o,assigneeUsernames:a}},e)).body.data)==null?void 0:p.mergeRequestSetAssignees;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 assignees")}async setPullRequestLabels(r,e={}){var l,p,d;let{repo:{namespace:s,name:n},pullRequestId:o,labelGraphQLIds:a}=r,i=`mutation SetPullRequestLabels($fullPath: ID!, $pullRequestId: String!, $labelGraphQLIds: [LabelID!]!) {
|
|
826
|
+
mergeRequestSetLabels(input: { projectPath: $fullPath, iid: $pullRequestId, labelIds: $labelGraphQLIds }) {
|
|
827
|
+
mergeRequest {
|
|
828
|
+
id
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
}`;if(!((d=(p=(l=(await I(this.config,{query:i,variables:{fullPath:`${s}/${n}`,pullRequestId:o,labelGraphQLIds:a}},e)).body.data)==null?void 0:l.mergeRequestSetLabels)==null?void 0:p.mergeRequest)!=null&&d.id))throw new Error("Could not set pull request labels")}async getIssue(r,e={}){var o,a,i;let s=kt(r),n=await I(this.config,{query:`
|
|
771
832
|
query GetSingleIssue($projectId: ID!, $issueId: String!) {
|
|
772
833
|
project(fullPath: $projectId) {
|
|
773
834
|
path
|
|
774
835
|
fullPath
|
|
775
836
|
webUrl
|
|
776
837
|
issue(iid: $issueId) {
|
|
777
|
-
${
|
|
838
|
+
${Ce}
|
|
778
839
|
}
|
|
779
840
|
}
|
|
780
841
|
}
|
|
781
|
-
`,variables:{issueId:r.id,projectId:s}},
|
|
842
|
+
`,variables:{issueId:r.id,projectId:s}},e);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:Ue(n.body.data.project.issue,N(n.body.data.project))}}getVariablesForIssues(r){let{updatedBefore:e,authorLogin:s,assigneeLogins:n}=r||{},o={},a=[],i=[],u=(l,p,d)=>{a.push(`$${l}: ${d}`),i.push(`${l}: $${l}`),o[l]=p};return e&&u("updatedBefore",e,"Time"),s&&u("authorUsername",s,"String"),n&&u("assigneeUsername",n[0],"String"),{variables:o,variableTypes:a,issueArguments:i}}async getIssuesForRepo(r,e={}){var b,P,q;let{cursor:s,repo:n}=r||{},o=k(n),{variables:a,variableTypes:i,issueArguments:u}=this.getVariablesForIssues(r),l={fullPath:o,...a},p=`
|
|
782
843
|
query GetIssuesFromProject(
|
|
783
844
|
$fullPath: ID!
|
|
784
845
|
$after: String
|
|
@@ -798,7 +859,7 @@ query GetSingleIssue($projectId: ID!, $issueId: String!) {
|
|
|
798
859
|
${u.length?u.join(" "):""}
|
|
799
860
|
) {
|
|
800
861
|
nodes {
|
|
801
|
-
${
|
|
862
|
+
${Ce}
|
|
802
863
|
}
|
|
803
864
|
pageInfo {
|
|
804
865
|
endCursor
|
|
@@ -806,7 +867,7 @@ query GetSingleIssue($projectId: ID!, $issueId: String!) {
|
|
|
806
867
|
}
|
|
807
868
|
}
|
|
808
869
|
}
|
|
809
|
-
}`,d=await
|
|
870
|
+
}`,d=await I(this.config,{query:p,variables:{...l,after:s}},e),c=[],g=(b=d.body.data)==null?void 0:b.project,m=N(g||{fullPath:"",path:"",webUrl:""});return(((P=g==null?void 0:g.issues)==null?void 0:P.nodes)||[]).forEach(U=>{c.push(Ue(U,m))}),{pageInfo:(q=g==null?void 0:g.issues)==null?void 0:q.pageInfo,data:c.sort((U,Q)=>(U.updatedDate||U.createdDate).getTime()-(Q.updatedDate||Q.createdDate).getTime())}}async getIssuesForRepos(r,e={}){var g,m,R,b,P;let{cursor:s}=r||{},n=r.repoIds.map(q=>q.toString().startsWith(z)?q:`${z}${q}`),{variables:o,variableTypes:a,mergeRequestArguments:i}=this.getVariablesForPullRequests(r),u={projectIds:n,...o},l=`
|
|
810
871
|
query GetIssuesFromProject(
|
|
811
872
|
$projectIds: [ID!]
|
|
812
873
|
$after: String
|
|
@@ -831,18 +892,24 @@ query GetSingleIssue($projectId: ID!, $issueId: String!) {
|
|
|
831
892
|
${i.length?i.join(" "):""}
|
|
832
893
|
) {
|
|
833
894
|
nodes {
|
|
834
|
-
${
|
|
895
|
+
${Ce}
|
|
835
896
|
}
|
|
836
897
|
}
|
|
837
898
|
}
|
|
838
899
|
}
|
|
839
|
-
}`,p=await
|
|
900
|
+
}`,p=await I(this.config,{query:l,variables:{...u,after:s}},e),d=[];return(((m=(g=p.body.data)==null?void 0:g.projects)==null?void 0:m.nodes)||[]).forEach(q=>{var V;let U=N(q);(((V=q.issues)==null?void 0:V.nodes)||[]).forEach(Ye=>d.push(Ue(Ye,U)))}),{pageInfo:(P=(b=(R=p.body)==null?void 0:R.data)==null?void 0:b.projects)==null?void 0:P.pageInfo,data:d.sort((q,U)=>(q.updatedDate||q.createdDate).getTime()-(U.updatedDate||U.createdDate).getTime())}}async setIssueStatus(r,e={}){var l,p,d;let{repo:{namespace:s,name:n},issueId:o,status:a}=r,i=`mutation SetIssueState($fullPath: ID!, $issueId: String!, $status: IssueStateEvent!) {
|
|
840
901
|
updateIssue(input: { projectPath: $fullPath, iid: $issueId, stateEvent: $status }) {
|
|
841
902
|
issue {
|
|
842
903
|
id
|
|
843
904
|
}
|
|
844
905
|
}
|
|
845
|
-
}`;if(!((d=(p=(l=(await
|
|
906
|
+
}`;if(!((d=(p=(l=(await I(this.config,{query:i,variables:{fullPath:`${s}/${n}`,issueId:o,status:a}},e)).body.data)==null?void 0:l.updateIssue)==null?void 0:p.issue)!=null&&d.id))throw new Error("Could not set issue status")}async setIssueLabels(r,e={}){var l,p,d;let{repo:{namespace:s,name:n},issueId:o,labelGraphQLIds:a}=r,i=`mutation SetIssueLabels($fullPath: ID!, $issueId: String!, $labelGraphQLIds: [ID!]) {
|
|
907
|
+
updateIssue(input: { projectPath: $fullPath, iid: $issueId, labelIds: $labelGraphQLIds }) {
|
|
908
|
+
issue {
|
|
909
|
+
id
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
}`;if(!((d=(p=(l=(await I(this.config,{query:i,variables:{fullPath:`${s}/${n}`,issueId:o,labelGraphQLIds:a}},e)).body.data)==null?void 0:l.updateIssue)==null?void 0:p.issue)!=null&&d.id))throw new Error("Could not set issue labels")}async setIssueMilestone(r,e={}){var p,d,c,g;let{repo:{namespace:s,name:n},issueId:o}=r,a=((p=r.milestoneGraphQLId)==null?void 0:p.replace(Ze,""))??"",i=`mutation SetIssueMilestone($fullPath: ID!, $issueId: String!, $milestoneGraphQLId: ID) {
|
|
846
913
|
updateIssue(input: { projectPath: $fullPath, iid: $issueId, milestoneId: $milestoneGraphQLId }) {
|
|
847
914
|
errors
|
|
848
915
|
issue {
|
|
@@ -852,7 +919,14 @@ query GetSingleIssue($projectId: ID!, $issueId: String!) {
|
|
|
852
919
|
}
|
|
853
920
|
}
|
|
854
921
|
}
|
|
855
|
-
}`,u=await
|
|
922
|
+
}`,u=await I(this.config,{query:i,variables:{fullPath:`${s}/${n}`,issueId:o,milestoneGraphQLId:a}},e),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 setIssueAssignees(r,e={}){var p,d,c;let{repo:{namespace:s,name:n},issueId:o,assigneeUsernames:a}=r,i=`mutation SetIssueAssignees($fullPath: ID!, $issueId: String!, $assigneeUsernames: [String!]!) {
|
|
923
|
+
issueSetAssignees(input: { projectPath: $fullPath, iid: $issueId, assigneeUsernames: $assigneeUsernames }) {
|
|
924
|
+
errors,
|
|
925
|
+
issue {
|
|
926
|
+
id
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
}`,l=(p=(await I(this.config,{query:i,variables:{fullPath:`${s}/${n}`,issueId:o,assigneeUsernames:a}},e)).body.data)==null?void 0:p.issueSetAssignees;if(!((d=l==null?void 0:l.issue)!=null&&d.id)||((c=l==null?void 0:l.errors)==null?void 0:c.length)!==0)throw new Error("Could not set issue assignees")}async getMilestonesForRepo(r,e={}){var i,u,l,p,d,c,g;let{repo:{namespace:s,name:n},cursor:o}=r,a=await I(this.config,{query:`
|
|
856
930
|
query getLabelsForRepo(
|
|
857
931
|
$fullPath: ID!
|
|
858
932
|
$after: String
|
|
@@ -872,7 +946,7 @@ query getLabelsForRepo(
|
|
|
872
946
|
}
|
|
873
947
|
}
|
|
874
948
|
}
|
|
875
|
-
`,variables:{fullPath:`${s}/${n}`,after:o}},
|
|
949
|
+
`,variables:{fullPath:`${s}/${n}`,after:o}},e);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(m=>{var R,b;return Ae(m,((b=(R=a.body.data)==null?void 0:R.project)==null?void 0:b.webUrl)||"")}))??[]}}async getLabelsForRepo(r,e={}){var i,u,l,p,d,c,g;let{repo:{namespace:s,name:n},cursor:o}=r,a=await I(this.config,{query:`
|
|
876
950
|
query getLabelsForRepo(
|
|
877
951
|
$fullPath: ID!
|
|
878
952
|
$after: String
|
|
@@ -882,7 +956,7 @@ query getLabelsForRepo(
|
|
|
882
956
|
) {
|
|
883
957
|
labels(after: $after) {
|
|
884
958
|
nodes {
|
|
885
|
-
${
|
|
959
|
+
${Ge}
|
|
886
960
|
}
|
|
887
961
|
pageInfo {
|
|
888
962
|
endCursor
|
|
@@ -891,4 +965,4 @@ query getLabelsForRepo(
|
|
|
891
965
|
}
|
|
892
966
|
}
|
|
893
967
|
}
|
|
894
|
-
`,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 U{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}"`,"statusCategory != Done"];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 T="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 U{async getCurrentUser(r,t={}){let s=await this.config.request({url:`${t.baseUrl||T}/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||T}/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||T}/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||T}/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||T}/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||T}/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 setIssueArchived(r,t={}){let{appKey:s,cardId:n,archived:o}=r;if(!(await this.config.request({method:"PUT",url:`${t.baseUrl||T}/1/cards/${n}?key=${s}&token=${t.token||this.config.token}&closed=${o}`,headers:m(t.token||this.config.token)})).body.id)throw new Error("Could not update issue archived status")}async getLabelsForBoard(r,t={}){let{appKey:s,boardId:n}=r;return{data:(await this.config.request({url:`${t.baseUrl||T}/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};
|
|
968
|
+
`,variables:{fullPath:`${s}/${n}`,after:o}},e);return{pageInfo:((l=(u=(i=a.body.data)==null?void 0:i.project)==null?void 0:u.labels)==null?void 0:l.pageInfo)??{endCursor:null,hasNextPage:!1},data:((g=(c=(d=(p=a.body.data)==null?void 0:p.project)==null?void 0:d.labels)==null?void 0:c.nodes)==null?void 0:g.map(Oe))??[]}}};var L="https://api.atlassian.com/ex/jira",te=100,Qt=(t,r)=>{var s,n,o,a,i,u,l;let e=t.fields.assignee;return{id:t.id,commentCount:t.fields.comment.comments.length,number:t.key,title:t.fields.summary,url:r?`${r}/browse/${t.key}`:null,createdDate:new Date(t.fields.created),author:{id:t.fields.creator.accountId,name:t.fields.creator.displayName,email:t.fields.creator.emailAddress,avatarUrl:t.fields.creator.avatarUrls["32x32"],username:t.fields.creator.displayName},updatedDate:new Date(t.fields.updated),assignees:e?[{id:e.accountId,name:e.displayName,email:e.emailAddress,avatarUrl:e.avatarUrls["32x32"],username:e.displayName}]:[],description:null,repository:null,state:{name:(s=t.fields.status)==null?void 0:s.name,color:(o=(n=t.fields.status)==null?void 0:n.statusCategory)==null?void 0:o.colorName},statusTransitions:((a=t.transitions)==null?void 0:a.map(Nt))??[],components:((i=t.fields.components)==null?void 0:i.map(jt))??[],type:t.fields.issuetype.name,upvoteCount:((u=t.fields.votes)==null?void 0:u.votes)||0,labels:((l=t.fields.labels)==null?void 0:l.map(p=>({color:null,description:null,id:null,name:p})))??[]}},Nt=t=>({name:t.name,id:t.id}),jt=t=>({description:t.description??null,id:t.id,name:t.name}),Bt=t=>({id:t.accountId,name:t.displayName,email:t.emailAddress,avatarUrl:t.avatarUrls["48x48"],username:t.displayName}),J=class extends E{constructor(){super(...arguments);this._resourceUrlCache={}}async getResourceUrl(e,s={}){var a;let n=s.token||this.config.token;if(!n)return null;let o=this._resourceUrlCache[n];return o?o[e.resourceId]??null:(await this.getJiraResourcesForCurrentUser(s),((a=this._resourceUrlCache[n])==null?void 0:a[e.resourceId])??null)}async getCurrentUserForResource(e,s={}){let n=await this.config.request({url:`${s.baseUrl||L}/${e.resourceId}/rest/api/2/myself`,headers:h(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(e={}){let s=await this.config.request({url:`${e.baseUrl||"https://api.atlassian.com/"}/oauth/token/accessible-resources`,headers:h(e.token||this.config.token)}),n=e.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(e,s={}){let n=new URL(`${s.baseUrl||L}/${e.resourceId}/rest/api/2/project/search`);n.searchParams.set("maxResults",te.toString()),e.cursor&&n.searchParams.set("startAt",e.cursor);let o=await this.config.request({url:n.toString(),headers:h(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:e.resourceId}))}}async getJiraProjectsForResources(e,s={}){let n=[];return await Promise.all(e.resourceIds.map(async o=>{let a=await this.getJiraProjectsForResource({resourceId:o},s);n.push(...a.data)})),{data:n}}async getAccountsForJiraProject(e,s={}){let{resourceId:n,projectKey:o,cursor:a}=e,i=new URL(`${s.baseUrl||L}/${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:h(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(Bt)}}async getComponentsForJiraProject(e,s={}){let{resourceId:n,projectIdOrKey:o}=e,a=new URL(`${s.baseUrl||L}/${n}/rest/api/2/project/${o}/components`);return{data:(await this.config.request({url:a.toString(),headers:h(s.token||this.config.token)})).body}}async getIssuesForProject(e,s={}){let{assigneeLogins:n,authorLogin:o,mentionLogin:a,project:i}=e||{},u=[`project = "${i}"`,"statusCategory != Done"];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||L}/${e.resourceId}/rest/api/2/search?jql=${u.join(" AND ")}&startAt=0&maxResults=${te}&fields=${["assignee","comment","summary","created","creator","updated","votes","issuetype","status","labels","components"].join(",")}&expand=transitions`,headers:h(s.token||this.config.token)}),p=await this.getResourceUrl({resourceId:e.resourceId},s);return{data:l.body.issues.map(d=>Qt(d,p))}}async setIssueStatus(e,s={}){let{resourceId:n,issueId:o,status:a}=e,i={transition:{id:a}};await this.config.request({method:"POST",url:`${s.baseUrl||L}/${n}/rest/api/2/issue/${o}/transitions`,body:JSON.stringify(i),headers:{...h(s.token||this.config.token),"Content-Type":"application/json"}})}async setIssueAssignee(e,s={}){let{resourceId:n,issueId:o,assigneeId:a}=e,i={accountId:a};await this.config.request({method:"PUT",url:`${s.baseUrl||L}/${n}/rest/api/2/issue/${o}/assignee`,body:JSON.stringify(i),headers:{...h(s.token||this.config.token),"Content-Type":"application/json"}})}async setIssueComponents(e,s={}){let{resourceId:n,issueId:o,componentIds:a}=e,i={fields:{components:a.map(u=>({id:u}))}};await this.config.request({method:"PUT",url:`${s.baseUrl||L}/${n}/rest/api/2/issue/${o}`,body:JSON.stringify(i),headers:{...h(s.token||this.config.token),"Content-Type":"application/json"}})}async setIssueLabels(e,s={}){let{resourceId:n,issueId:o,labelNames:a}=e,i={fields:{labels:a}};if(!(await this.config.request({method:"PUT",url:`${s.baseUrl||L}/${n}/rest/api/2/issue/${o}?returnIssue=true`,body:JSON.stringify(i),headers:{...h(s.token||this.config.token),"Content-Type":"application/json"}})).body.id)throw new Error("Could not set issue labels")}async getLabelsForResource(e,s={}){let{resourceId:n,cursor:o}=e,a=new URL(`${s.baseUrl||L}/${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:h(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 O="https://api.trello.com",Ft=1e3,Mt=(t,r)=>{let e=new Date(1e3*parseInt(t.id.substring(0,8),16));return{id:t.id,commentCount:t.badges.comments,number:t.idShort.toString(),title:t.name,url:t.url,createdDate:new Date(e.toISOString()),author:null,updatedDate:new Date(t.dateLastActivity),assignees:t.idMembers.map(s=>({id:s,username:null,name:null,email:null,avatarUrl:null})),description:null,state:r[t.idList??""]?{name:r[t.idList].name,color:null}:null,type:null,repository:null,upvoteCount:t.badges.votes,labels:t.labels.map(s=>({color:s.color,description:null,id:s.id,name:s.name}))}},H=class extends E{async getCurrentUser(r,e={}){let s=await this.config.request({url:`${e.baseUrl||O}/1/members/me?key=${r.appKey}&token=${e.token||this.config.token}`,headers:h(e.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,e={}){return{data:(await this.config.request({url:`${e.baseUrl||O}/1/members/me/boards?fields=name&key=${r.appKey}&token=${e.token||this.config.token}&filter=open`,headers:h(e.token||this.config.token)})).body.map(n=>({id:n.id,name:n.name}))}}async getListsForTrelloBoard(r,e={}){let{appKey:s,boardId:n}=r;return{data:(await this.config.request({url:`${e.baseUrl||O}/1/boards/${n}/lists?key=${s}&token=${e.token||this.config.token}`,headers:h(e.token||this.config.token)})).body}}async getAccountsForTrelloBoard(r,e={}){let{appKey:s,boardId:n}=r;return{data:(await this.config.request({url:`${e.baseUrl||O}/1/boards/${n}/members?key=${s}&token=${e.token||this.config.token}`,headers:h(e.token||this.config.token)})).body.map(a=>({id:a.id,name:a.fullName,username:a.username,email:null,avatarUrl:null}))}}async getIssuesForBoard(r,e={}){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:`${e.baseUrl||O}/1/search?key=${n}&query=${l}&cards_limit=${Ft}&token=${e.token||this.config.token}`,headers:h(e.token||this.config.token)})).body.cards.map(d=>Mt(d,u||{}))}}async updateIssue(r,e,s,n){return await this.config.request({method:"PUT",url:`${n.baseUrl||O}/1/cards/${e}?key=${r}&token=${n.token||this.config.token}&${s}`,headers:h(n.token||this.config.token)})}async setIssueStatus(r,e={}){let{appKey:s,cardId:n,status:o}=r,a=`idList=${o}`;if(!(await this.updateIssue(s,n,a,e)).body.id)throw new Error("Could not set issue status")}async setIssueAssignees(r,e={}){let{appKey:s,cardId:n,assigneeIds:o}=r,a=`idMembers=${encodeURIComponent(o.join(","))}`;if(!(await this.updateIssue(s,n,a,e)).body.id)throw new Error("Could not set issue status")}async setIssueLabels(r,e={}){let{appKey:s,cardId:n,labelIds:o}=r;if(!(await this.config.request({method:"PUT",url:`${e.baseUrl||O}/1/cards/${n}?key=${s}&token=${e.token||this.config.token}&idLabels=${encodeURIComponent(o.join(","))}`,headers:h(e.token||this.config.token)})).body.id)throw new Error("Could not set issue status")}async setIssueArchived(r,e={}){let{appKey:s,cardId:n,archived:o}=r;if(!(await this.config.request({method:"PUT",url:`${e.baseUrl||O}/1/cards/${n}?key=${s}&token=${e.token||this.config.token}&closed=${o}`,headers:h(e.token||this.config.token)})).body.id)throw new Error("Could not update issue archived status")}async getLabelsForBoard(r,e={}){let{appKey:s,boardId:n}=r;return{data:(await this.config.request({url:`${e.baseUrl||O}/1/boards/${n}/labels?key=${s}&token=${e.token||this.config.token}`,headers:h(e.token||this.config.token)})).body.map(a=>({color:a.color,description:null,id:a.id,name:a.name}))}}};var se={};A(se,{getIssueUniqueId:()=>zt,getPullRequestUniqueId:()=>Wt});var zt=(t,r,e,s="")=>{let n=[];return n.push(s),n.push(t),n.push(r),n.push(e),JSON.stringify(n)},Wt=(t,r,e,s,n="")=>{let o=[];return o.push(n),o.push(t),o.push(r),o.push(e),o.push(s),JSON.stringify(o)};var re={};A(re,{getIssueUniqueId:()=>Jt,getPullRequestUniqueId:()=>Ht});var Jt=(t,r)=>JSON.stringify(["",t,r]),Ht=(t,r)=>JSON.stringify(["",t,r]);var ne={};A(ne,{getIssueUniqueId:()=>Vt,getPullRequestUniqueId:()=>Kt});var Vt=(t,r,e)=>JSON.stringify([e,t,r]),Kt=(t,r,e)=>JSON.stringify([e,t,r]);var ae={};A(ae,{getIssueUniqueId:()=>Xt,getPullRequestRank:()=>Yt,getPullRequestUniqueId:()=>Zt});var Xt=(t,r="")=>{let e=[];return e.push(r),e.push(t),JSON.stringify(e)},Zt=(t,r="")=>{let e=[];return e.push(r),e.push(t),JSON.stringify(e)},Yt=(t,r,e)=>{var a,i,u;let s=0,n,o;return(a=t.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=t.author)==null?void 0:i.id)===r?s+=1e3:(u=t.assignees)!=null&&u.find(l=>l.id===r)?s+=900:n==="REVIEW_REQUESTED"?s+=800:e&&(s+=700),o==="APPROVED"?t.mergeableState==="MERGEABLE"?s+=100:t.mergeableState==="CONFLICTS"?s+=90:s+=80:o=="CHANGES_REQUESTED"&&(s+=70),s};var oe={};A(oe,{getIssueUniqueId:()=>es,getPullRequestUniqueId:()=>ts});var es=(t,r="")=>{let e=[];return e.push(r),e.push(t),JSON.stringify(e)},ts=(t,r="")=>{let e=[];return e.push(r),e.push(t),JSON.stringify(e)};var ie={};A(ie,{getIssueUniqueId:()=>ss,getJiraServerIssueUniqueId:()=>rs});var ss=(t,r,e)=>{let s=[];return s.push(""),s.push(t),s.push(r),s.push(e),JSON.stringify(s)},rs=(t,r,e)=>{let s=[];return s.push(e),s.push(""),s.push(t),s.push(r),JSON.stringify(s)};var ue={};A(ue,{getIssueUniqueId:()=>ns});var ns=(t,r,e,s="")=>{let n=[];return n.push(s),n.push(t),n.push(r),n.push(e),JSON.stringify(n)};var as=t=>{let r={request:t==null?void 0:t.request};return{azureDevOps:new j({...r,...t==null?void 0:t.azureDevOps}),bitbucket:new B({...r,...t==null?void 0:t.bitbucket}),bitbucketServer:new F({...r,...t==null?void 0:t.bitbucketServer}),github:new M({...r,...t==null?void 0:t.github}),gitlab:new W({...r,...t==null?void 0:t.gitlab}),jira:new J({...r,...t==null?void 0:t.jira}),trello:new H({...r,...t==null?void 0:t.trello})}},os=as;var is={azureDevOps:se,bitbucket:re,bitbucketServer:ne,github:ae,gitlab:oe,jira:ie,trello:ue};
|