@gitkraken/provider-apis 0.19.0 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Lt=Object.create;var re=Object.defineProperty;var Ut=Object.getOwnPropertyDescriptor;var $t=Object.getOwnPropertyNames;var Gt=Object.getPrototypeOf,At=Object.prototype.hasOwnProperty;var O=(r,s)=>{for(var e in s)re(r,e,{get:s[e],enumerable:!0})},ut=(r,s,e,t)=>{if(s&&typeof s=="object"||typeof s=="function")for(let n of $t(s))!At.call(r,n)&&n!==e&&re(r,n,{get:()=>s[n],enumerable:!(t=Ut(s,n))||t.enumerable});return r};var Ot=(r,s,e)=>(e=r!=null?Lt(Gt(r)):{},ut(s||!r||!r.__esModule?re(e,"default",{value:r,enumerable:!0}):e,r)),Tt=r=>ut(re({},"__esModule",{value:!0}),r);var ur={};O(ur,{AzureDevOps:()=>H,AzureDevopsUtils:()=>Se,Bitbucket:()=>W,BitbucketServer:()=>J,BitbucketServerUtils:()=>ve,BitbucketUtils:()=>qe,GitHub:()=>K,GitHubUtils:()=>Ce,GitLab:()=>X,GitLabUtils:()=>De,GitProviderUtils:()=>Ee,Jira:()=>Z,JiraServer:()=>ee,JiraUtils:()=>Le,Trello:()=>te,TrelloUtils:()=>Ue,Utils:()=>ir,default:()=>ar});module.exports=Tt(ur);var v=100;var lt={APPROVED:0,COMMENTED:1,REVIEW_REQUESTED:2,CHANGES_REQUESTED:3},Q=r=>!r||r.length===0?null:r.reduce((s,e)=>lt[e.state]>lt[s]?e.state:s,"APPROVED");var pt=Ot(require("node-fetch")),dt=globalThis.fetch||pt.default;var xt=async r=>{let s=r.headers.get("content-type")||"",e=null;if(s.startsWith("application/json")){let n=await r.text();e=n.trim().length>0?JSON.parse(n):null}else if(s.startsWith("text/")||s==="")e=await r.text();else if(s.startsWith("application/vnd.github.raw+json"))e=await r.arrayBuffer();else throw new Error(`Unsupported content-type: ${s}`);let t={body:e,headers:Object.fromEntries(r.headers.entries()),status:r.status,statusText:r.statusText};if(!r.ok){let n=new Error(r.statusText);throw Object.assign(n,{response:t}),n}return t},$e=r=>async({url:s,...e})=>{let t=await r(s,e);return xt(t)};var Ge=(r,s=!1)=>r.name==="fetch"||s;var D=class{constructor(s){let e=(s==null?void 0:s.request)||dt;this.config={...s,request:Ge(e,s==null?void 0:s.forceIsFetch)?$e(e):e}}updateConfig(s){this.config={...this.config,...s,request:s.request&&Ge(s.request,(s==null?void 0:s.forceIsFetch)??this.config.forceIsFetch)?$e(s.request):this.config.request}}},$=class extends D{};var R=(r,s)=>{let e={};return r&&(e.Authorization=`${s?"Basic":"Bearer"} ${r}`),e},ct=r=>r?r.reduce((s,e)=>(s[e]=!0,s),{}):void 0,N=(r,s,e)=>!r||s.some(t=>r[t])?e:"";var P=(r,s={})=>R(s.token||r.token,s.isPAT||r.isPAT),gt=r=>r.url.replace("/_apis/git/repositories/","/_git/").replace(`/${r.repository.project.id}/`,`/${encodeURIComponent(r.repository.project.name)}/`).replace(`/${r.repository.id}/`,`/${encodeURIComponent(r.repository.name)}/`).replace("/pullRequests/","/pullrequest/");var mt="https://app.vssps.visualstudio.com/_apis",S="https://dev.azure.com",kt={active:"OPEN",completed:"MERGED",abandoned:"CLOSED"},_t={10:"APPROVED",5:"APPROVED",0:"REVIEW_REQUESTED",[-5]:"CHANGES_REQUESTED",[-10]:"CHANGES_REQUESTED"},Ae=r=>({id:r.id,name:r.displayName,username:r.uniqueName||r.displayName,email:null,avatarUrl:r.imageUrl,url:null}),oe=r=>r.startsWith("refs/heads/")?r.replace("refs/heads/",""):r,ne=(r,s)=>{var t;let e=s.reviewers.filter(n=>n.vote!==0).map(n=>({reviewer:Ae(n),state:_t[n.vote]||"REVIEW_REQUESTED"}));return{id:s.pullRequestId.toString(),title:s.title,number:s.codeReviewId,state:kt[s.status],isDraft:s.isDraft,commentCount:null,upvoteCount:null,author:Ae(s.createdBy),createdDate:new Date(s.creationDate),updatedDate:new Date(s.closedDate||s.creationDate),closedDate:s.closedDate?new Date(s.closedDate):null,mergedDate:s.closedDate&&s.status==="completed"?new Date(s.closedDate):null,repository:{id:s.repository.id,name:s.repository.name,project:s.repository.project.name,owner:{login:r},remoteInfo:null},headCommit:{buildStatuses:null},baseRef:{name:oe(s.targetRefName),oid:s.lastMergeTargetCommit.commitId},headRef:{name:oe(s.sourceRefName),oid:s.lastMergeSourceCommit.commitId},url:gt(s),assignees:s.reviewers.map(Ae),reviews:e,reviewDecision:Q(e),additions:null,deletions:null,fileCount:null,commitCount:null,headRepository:null,mergeableState:"UNKNOWN",labels:((t=s.labels)==null?void 0:t.map(n=>({color:null,description:null,id:n.id,name:n.name})))??[],permissions:null}},ht=(r,s)=>({id:s.id,name:s.name,namespace:r,project:s.project.name,webUrl:s.webUrl,httpsUrl:s.remoteUrl,sshUrl:s.sshUrl,defaultBranch:s.defaultBranch?{name:oe(s.defaultBranch)}:null,permission:null}),Qt=(r,s,e,t)=>{var l,p;let n=e.fields,o=n["System.AssignedTo"],a=n["System.State"],i=n["System.WorkItemType"],u;return a&&i&&(u=(l=t[i])==null?void 0:l[a]),{id:e.id.toString(),number:e.id.toString(),title:n["System.Title"],commentCount:n["System.CommentCount"],author:{avatarUrl:n["System.CreatedBy"]._links.avatar.href,email:null,id:n["System.CreatedBy"].id,name:n["System.CreatedBy"].uniqueName,username:n["System.CreatedBy"].displayName,url:null},closedDate:n["Microsoft.VSTS.Common.ClosedDate"]?new Date(n["Microsoft.VSTS.Common.ClosedDate"]):null,createdDate:new Date(n["System.CreatedDate"]),updatedDate:new Date(n["System.ChangedDate"]),url:e._links.html.href,assignees:o?[{avatarUrl:o._links.avatar.href,email:null,id:o.id,name:o.uniqueName,username:o.displayName,url:null}]:[],description:null,state:{name:(u==null?void 0:u.title)||a,color:null},type:n["System.WorkItemType"],repository:null,project:{namespace:r,name:s,resourceId:null},upvoteCount:0,labels:((p=e.fields["System.Tags"])==null?void 0:p.split(";").map(d=>({color:null,description:null,id:null,name:d.trim()})))??[]}},H=class extends D{async getCurrentUser(s={},e={}){if(e.isPAT||this.config.isPAT)throw new Error("Azure DevOps does not support PATs for this function.");let t=await this.config.request({url:`${mt}/profile/profiles/me`,headers:P(this.config,e)});return{data:{id:t.body.id,name:t.body.displayName,username:t.body.displayName,email:t.body.emailAddress,avatarUrl:null,url:null}}}async getCurrentUserForInstance(s,e={}){let n=(await this.config.request({url:`${S}/${encodeURIComponent(s.namespace)}/_apis/ConnectionData`,headers:P(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(s,e={}){if(!s.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let n=(await this.config.request({url:`${S}/${encodeURIComponent(s.repo.namespace)}/${encodeURIComponent(s.repo.project)}/_apis/git/repositories/${encodeURIComponent(s.repo.name)}/commits/${s.oid}`,headers:P(this.config,e)})).body.author;return{data:{name:n.name,email:n.email,avatarUrl:n.imageUrl}}}async getOrgsForUser(s,e={}){return{data:(await this.config.request({url:`${mt}/accounts?memberId=${s.userId}&api-version=6.0`,headers:P(this.config,e)})).body.value.map(n=>({id:n.accountId,name:n.accountName}))}}async getAzureProjects(s,e={}){let t=new URL(`${S}/${encodeURIComponent(s.namespace)}/_apis/projects`);t.searchParams.set("$top",v.toString()),s.cursor&&t.searchParams.set("$skip",s.cursor);let n=await this.config.request({url:t.toString(),headers:P(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:s.namespace}))}}async getAzureProjectScopeDescriptor(s,e={}){let{namespace:t,projectId:n}=s;return{data:{scope:(await this.config.request({url:`https://vssps.dev.azure.com/${encodeURIComponent(t)}/_apis/graph/descriptors/${n}?api-version=6.0`,headers:P(this.config,e)})).body.value}}}async getAzureGraphAccountsForAzureProject(s,e={}){let{namespace:t,projectScopeDescriptor:n,cursor:o}=s,a=new URL(`https://vssps.dev.azure.com/${encodeURIComponent(t)}/_apis/graph/users`);n&&a.searchParams.set("scopeDescriptor",n),o&&a.searchParams.set("continuationToken",o);let i=await this.config.request({url:a.toString(),headers:P(this.config,e)}),u=i.headers["x-ms-continuationtoken"];return{pageInfo:{endCursor:u||null,hasNextPage:!!u},data:i.body.value.map(l=>{var p;return{avatarUrl:((p=l._links.avatar)==null?void 0:p.href)??null,descriptor:l.descriptor,email:l.mailAddress,name:l.displayName,storageKeyURL:l._links.storageKey.href,username:l.displayName}})}}async getAccountFromAzureGraphAccount(s,e={}){let{azureGraphAccount:t}=s,n=await this.config.request({url:t.storageKeyURL,headers:P(this.config,e)});return{data:{avatarUrl:t.avatarUrl,email:t.email,id:n.body.value,name:t.name,username:t.username,url:null}}}async getAccountsFromAzureGraphAccounts(s,e={}){let t=[];for(let n of s.azureGraphAccounts){let o=await this.getAccountFromAzureGraphAccount({azureGraphAccount:n},e);t.push(o.data)}return{data:t}}async getRepo(s,e={}){if(!s.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let t=await this.config.request({url:`${S}/${encodeURIComponent(s.namespace)}/${encodeURIComponent(s.project)}/_apis/git/repositories/${encodeURIComponent(s.name)}`,headers:P(this.config,e)});return{data:ht(s.namespace,t.body)}}async getRepos(s,e={}){let t=[],n=[];return await Promise.all(s.map(async o=>{try{let a=await this.getRepo(o,e);t.push(a.data)}catch(a){n.push({input:o,error:a})}})),{data:t,errors:n}}async getReposForAzureProject(s,e={}){if(!s.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');return{data:(await this.config.request({url:`${S}/${encodeURIComponent(s.namespace)}/${encodeURIComponent(s.project)}/_apis/git/repositories`,headers:P(this.config,e)})).body.value.map(n=>ht(s.namespace,n))}}async getRefs(s,e,t={}){if(!e.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let n=new URL(`${S}/${encodeURIComponent(e.repo.namespace)}/${encodeURIComponent(e.repo.project)}/_apis/git/repositories/${encodeURIComponent(e.repo.name)}/refs`);n.searchParams.set("filter",s),n.searchParams.set("$top",v.toString()),e.cursor&&n.searchParams.set("continuationToken",e.cursor);let o=await this.config.request({url:n.toString(),headers:P(this.config,t)}),a=o.headers["x-ms-continuationtoken"];return{pageInfo:{hasNextPage:!!a,endCursor:a||null},data:o.body.value.map(i=>({name:oe(i.name),commit:{oid:i.objectId,authoredDate:null,committedDate:null}}))}}async getBranches(s,e={}){return this.getRefs("heads",s,e)}async getTags(s,e={}){return this.getRefs("tags",s,e)}async getPullRequestsForRepoBase(s,e={},t=100){let{page:n,repo:o,assigneeLogins:a,authorLogin:i}=s||{},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||S}/${encodeURIComponent(o.namespace)}/${encodeURIComponent(o.project||"")}/_apis/git/repositories/${encodeURIComponent(o.name)}/pullRequests?${l}&%24top=${t}&%24skip=${(u-1)*t}`,headers:P(this.config,e)})}async getPullRequestsForRepo(s,e={}){let n=s.page||1,o=await this.getPullRequestsForRepoBase(s,e,100);return{pageInfo:{hasNextPage:o.body.value.length===100,nextPage:n+1},data:o.body.value.map(a=>ne(s.repo.namespace,a))}}async getPullRequestsForRepos(s,e={}){if(!s.repos.every(o=>o.project))throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{repos:t}=s||{},n=[];return await Promise.all(t.map(async o=>{try{(await this.getPullRequestsForRepoBase({repo:o,...s},e)).body.value.forEach(i=>{n.push(ne(o.namespace,i))})}catch(a){if(a.statusCode!==404&&a.statusCode!==401)throw a}})),{data:n}}async getPullRequestsForProjectBase(s,e={},t=100){let{namespace:n,project:o,page:a,assigneeLogins:i,authorLogin:u}=s,l=a||1,p=new URL(`${e.baseUrl||S}/${encodeURIComponent(n)}/${encodeURIComponent(o)}/_apis/git/pullRequests`);return p.searchParams.set("searchCriteria.status","1"),p.searchParams.set("$top",t.toString()),p.searchParams.set("$skip",((l-1)*t).toString()),i&&i.length&&p.searchParams.set("searchCriteria.reviewerId",i[0]),u&&p.searchParams.set("searchCriteria.creatorId",u),await this.config.request({url:p.toString(),headers:P(this.config,e)})}async getPullRequestsForProject(s,e={}){let n=s.page||1,o=await this.getPullRequestsForProjectBase(s,e,100);return{pageInfo:{hasNextPage:o.body.value.length===100,nextPage:n+1},data:o.body.value.map(a=>ne(s.namespace,a))}}async getPullRequestsForProjects(s,e={}){let{projects:t}=s||{},n=[];return await Promise.all(t.map(async o=>{try{(await this.getPullRequestsForProjectBase({...o,...s},e)).body.value.forEach(i=>{n.push(ne(o.namespace,i))})}catch(a){if(a.statusCode!==404&&a.statusCode!==401)throw a}})),{data:n}}async getAzurePullRequestLastMergeStatus(s,e={}){if(!s.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{repo:{namespace:t,project:n,name:o},pullRequestId:a}=s,i=await this.config.request({url:`${e.baseUrl||S}/${encodeURIComponent(t)}/${encodeURIComponent(n||"")}/_apis/git/repositories/${o}/pullrequests/${a}?includeCommits=true?api-version=6.0`,headers:{...P(this.config,e)}});if(!i.body.mergeStatus)throw new Error("Could not fetch pull request");return{data:i.body.mergeStatus}}async updatePullRequest(s,e,t){return await this.config.request({method:"PATCH",url:`${t.baseUrl||S}/${encodeURIComponent(s.repository.owner.login)}/${encodeURIComponent(s.repository.project)}/_apis/git/repositories/${s.repository.name}/pullrequests/${s.id}?api-version=6.0`,body:e,headers:{...P(this.config,t),"Content-Type":"application/json"}})}async closePullRequest(s,e={}){let{pullRequest:t}=s,n={status:"abandoned"};if(!(await this.updatePullRequest(t,JSON.stringify(n),e)).body.status)throw new Error("Could not close pull request")}async mergePullRequest(s,e={}){var u;let{pullRequest:t,mergeStrategy:n}=s,o;switch(n){case"MERGE_COMMIT":{o="noFastForward";break}case"REBASE":{o="rebase";break}case"REBASE_THEN_MERGE_COMMIT":{o="rebaseMerge";break}case"SQUASH":{o="squash";break}}let a={completionOptions:{mergeStrategy:o},lastMergeSourceCommit:{commitId:(u=t.headRef)==null?void 0:u.oid},status:"completed"};if(!(await this.updatePullRequest(t,JSON.stringify(a),e)).body.status)throw new Error("Could not merge pull request")}async addPullRequestLabel(s,e={}){let{pullRequest:t,label:n}=s;if(!t.repository.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let o={name:n.name};if(!(await this.config.request({method:"POST",url:`${e.baseUrl||S}/${encodeURIComponent(t.repository.owner.login)}/${encodeURIComponent(t.repository.project)}/_apis/git/repositories/${t.repository.name}/pullrequests/${t.id}/labels?api-version=6.0`,body:JSON.stringify(o),headers:{...P(this.config,e),"Content-Type":"application/json"}})).body.id)throw new Error("Could not add pull request label")}async removePullRequestLabel(s,e={}){let{pullRequest:t,label:n}=s;if(!t.repository.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');await this.config.request({method:"DELETE",url:`${e.baseUrl||S}/${encodeURIComponent(t.repository.owner.login)}/${encodeURIComponent(t.repository.project)}/_apis/git/repositories/${t.repository.name}/pullrequests/${t.id}/labels/${encodeURIComponent(n.name)}?api-version=6.0`,headers:{...P(this.config,e)}})}async setPullRequestLabels(s,e={}){let{pullRequest:t,labels:n}=s;if(!t.repository.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let o=t.labels;if(!o)throw new Error('Azure DevOps requires "labels" for this function.');for(let a of n)o.find(i=>i.id===a.id)||await this.addPullRequestLabel({pullRequest:t,label:a},e);for(let a of o)n.find(i=>a.id===i.id)||await this.removePullRequestLabel({pullRequest:t,label:a},e)}async setPullRequestAsDraft(s,e={}){let{pullRequest:t,isDraft:n}=s,o={isDraft:n};if(!(await this.updatePullRequest(t,JSON.stringify(o),e)).body.status)throw new Error("Could not set the pull request as draft")}async addPullRequestReviewer(s,e={}){let{pullRequest:t,reviewer:n,isRequired:o}=s,a={id:n.id,isRequired:o};if(!(await this.config.request({method:"PUT",url:`${e.baseUrl||S}/${encodeURIComponent(t.repository.owner.login)}/${encodeURIComponent(t.repository.project)}/_apis/git/repositories/${t.repository.name}/pullrequests/${t.id}/reviewers/${n.id}?api-version=6.0`,body:JSON.stringify(a),headers:{...P(this.config,e),"Content-Type":"application/json"}})).body.id)throw new Error("Could not add pull request reviewer")}async removePullRequestReviewer(s,e={}){let{pullRequest:t,reviewer:n}=s;await this.config.request({method:"DELETE",url:`${e.baseUrl||S}/${encodeURIComponent(t.repository.owner.login)}/${encodeURIComponent(t.repository.project)}/_apis/git/repositories/${t.repository.name}/pullrequests/${t.id}/reviewers/${n.id}?api-version=6.0`,headers:{...P(this.config,e),Accept:"application/json"}})}async setPullRequestReviewers(s,e={}){let{pullRequest:t,reviewers:n}=s;for(let o of n)t.assignees.find(a=>a.id===o.id)||await this.addPullRequestReviewer({pullRequest:t,reviewer:o,isRequired:!0},e);for(let o of t.assignees)n.find(a=>o.id===a.id)||await this.removePullRequestReviewer({pullRequest:t,reviewer:o},e)}async getIssuesForAzureProject(s,e={}){let{page:t,assigneeLogins:n,authorLogin:o,mentionLogin:a,statusByWorkItemIdByStatusId:i}=s||{},u=t||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||S}/${encodeURIComponent(s.namespace)}/${encodeURIComponent(s.project)}/_apis/wit/wiql?api-version=6.0`,body:JSON.stringify({query:d}),method:"POST",headers:{...P(this.config,e),"Content-Type":"application/json"}}),g=c.body.workItems.slice((u-1)*l,l*u).map(f=>f.id);if(g.length==0)return{pageInfo:{hasNextPage:!1,nextPage:null},data:[]};let m=await this.config.request({url:`${e.baseUrl||S}/${encodeURIComponent(s.namespace)}/${encodeURIComponent(s.project)}/_apis/wit/workitemsbatch?api-version=6.0`,body:JSON.stringify({ids:g,$expand:"Links"}),method:"POST",headers:{...P(this.config,e),"Content-Type":"application/json"}});return{pageInfo:{hasNextPage:c.body.workItems.length>l*u,nextPage:u+1},data:m.body.value.map(f=>Qt(s.namespace,s.project,f,i||{}))}}async updateIssue(s,e,t={}){return await this.config.request({method:"PATCH",url:`${t.baseUrl||S}/${encodeURIComponent(s.project.namespace)}/${encodeURIComponent(s.project.name)}/_apis/wit/workitems/${s.id}?api-version=6.0`,body:JSON.stringify(e),headers:{...P(this.config,t),"Content-Type":"application/json-patch+json"}})}async setIssueStatus(s,e={}){var i;let{issue:t,status:n}=s,o=[{op:"add",path:"/fields/System.State",value:n.name}];if(!((i=(await this.updateIssue(t,o,e)).body.fields)!=null&&i["System.State"]))throw new Error("Could not set issue status")}async setIssueAssignee(s,e={}){var i;let{issue:t,assignee:n}=s,o=[{op:"add",path:"/fields/System.AssignedTo",value:(n==null?void 0:n.name)??""}];if(!((i=(await this.updateIssue(t,o,e)).body.fields)!=null&&i["System.State"]))throw new Error("Could not set issue assignee")}async setIssueLabels(s,e={}){var u;let{issue:t,labels:n}=s,a=[{op:"replace",path:"/fields/System.Tags",value:n.map(l=>l.name).join(";")}];if(!((u=(await this.updateIssue(t,a,e)).body.fields)!=null&&u["System.Tags"]))throw new Error("Could not set issue tags")}async getIssueTypesForAzureProject(s,e={}){if(!s.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{namespace:t,project:n}=s;return{data:(await this.config.request({url:`${e.baseUrl||S}/${encodeURIComponent(t)}/${encodeURIComponent(n||"")}/_apis/wit/workitemtypes?api-version=6.0`,headers:{...P(this.config,e)}})).body.value}}async getLabelsForProject(s,e={}){let{namespace:t,project:n}=s;return{data:(await this.config.request({url:`${e.baseUrl||S}/${encodeURIComponent(t)}/${encodeURIComponent(n||"")}/_apis/wit/tags?api-version=6.0`,headers:{...P(this.config,e)}})).body.value.map(a=>({color:null,description:null,id:a.id,name:a.name,url:a.url}))}}};var C=(r,s={})=>R(s.token||r.token,s.isPAT||r.isPAT);var L="https://api.bitbucket.org/2.0",Nt={OPEN:"OPEN",MERGED:"MERGED",DECLINED:"CLOSED"},Rt=r=>({id:r.uuid,name:r.display_name||r.nickname,username:r.nickname||r.display_name,email:null,avatarUrl:r.links.avatar.href,url:r.links.html.href}),ft=r=>{var s,e;return{id:r.uuid,namespace:r.workspace.slug,name:r.slug,webUrl:r.links.html.href,httpsUrl:((s=r.links.clone.find(t=>t.name==="https"))==null?void 0:s.href)??null,sshUrl:((e=r.links.clone.find(t=>t.name==="ssh"))==null?void 0:e.href)??null,defaultBranch:{name:r.mainbranch.name},permission:null}},Te=r=>{let s=r.id;return{id:s.toString(),title:r.title,number:s,state:Nt[r.state],isDraft:!1,commentCount:r.comment_count,upvoteCount:null,author:Rt(r.author),createdDate:new Date(r.created_on),updatedDate:new Date(r.updated_on),closedDate:null,mergedDate:null,repository:{id:r.destination.repository.uuid,name:r.destination.repository.name,owner:{login:r.destination.repository.full_name.split("/")[0]},remoteInfo:null},headCommit:{buildStatuses:null},baseRef:{name:r.destination.branch.name,oid:r.destination.commit.hash},headRef:{name:r.source.branch.name,oid:r.source.commit.hash},url:r.links.html.href,assignees:null,reviews:null,reviewDecision:null,additions:null,deletions:null,fileCount:null,commitCount:null,headRepository:null,mergeableState:"UNKNOWN",permissions:null}},W=class extends D{async refreshToken(s){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 ${s.base64ClientIDColonClientSecret}`},body:`grant_type=refresh_token&refresh_token=${s.refreshToken}`})).body}}async getCurrentUser(s={},e={}){let t=await this.config.request({url:`${L}/user`,headers:C(this.config,e)});return{data:Rt(t.body)}}async getUserForCommit(s,e={}){var a;let n=(await this.config.request({url:`${L}/repositories/${s.repo.namespace}/${s.repo.name}/commit/${s.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(s,e={}){let t=await this.config.request({url:`${L}/repositories/${s.namespace}/${s.name}`,headers:C(this.config,e)});return{data:ft(t.body)}}async getRepos(s,e={}){let t=[],n=[];return await Promise.all(s.map(async o=>{try{let a=await this.getRepo(o,e);t.push(a.data)}catch(a){n.push({input:o,error:a})}})),{data:t,errors:n}}async getReposForCurrentUser(s,e={}){let t=new URL(`${L}/repositories`);t.searchParams.set("role","member"),t.searchParams.set("pagelen",v.toString()),s.cursor&&t.searchParams.set("after",s.cursor);let n=await this.config.request({url:t.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(ft)}}async getBranches(s,e={}){var a;let t=new URL(`${L}/repositories/${s.repo.namespace}/${s.repo.name}/refs/branches`);t.searchParams.set("page",((a=s.page)==null?void 0:a.toString())||"1"),t.searchParams.set("pagelen",v.toString());let n=await this.config.request({url:t.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(s,e={}){let t=new URL(`${L}/repositories/${s.repo.namespace}/${s.repo.name}/refs/tags`);t.searchParams.set("pagelen",v.toString()),s.cursor&&t.searchParams.set("page",s.cursor);let n=await this.config.request({url:t.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(s,e={}){var a;let t=new URL(`${L}/pullrequests/${s.userId}`);t.searchParams.set("page",((a=s.page)==null?void 0:a.toString())||"1"),t.searchParams.set("pagelen","50");let n=await this.config.request({url:t.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(Te)}}async getPullRequestsForRepoBase(s,e={}){var n;let t=new URL(`${L}/repositories/${encodeURI(s.repo.namespace)}/${encodeURI(s.repo.name)}/pullrequests?state=OPEN`);return t.searchParams.set("page",((n=s.page)==null?void 0:n.toString())||"1"),t.searchParams.set("pagelen","50"),await this.config.request({url:t.toString(),headers:C(this.config,e)})}async getPullRequestsForRepo(s,e={}){let t=[],n=await this.getPullRequestsForRepoBase(s,e);n.body.values.forEach(a=>{if(s.authorLogin&&a.author.uuid!==s.authorLogin)return null;t.push(Te(a))});let o=!!n.body.next;return{pageInfo:{hasNextPage:o,nextPage:o?n.body.page+1:null},data:t}}async getPullRequestsForRepos(s,e={}){let t=[];return await Promise.all(s.repos.map(async n=>{try{(await this.getPullRequestsForRepoBase({repo:n,...s},e)).body.values.forEach(a=>{if(s.authorLogin&&a.author.uuid!==s.authorLogin)return null;t.push(Te(a))})}catch(o){if(o.statusCode!==404&&o.statusCode!==401)throw o}})),{data:t}}async closePullRequest(s,e={}){let{pullRequest:t}=s;if(!(await this.config.request({method:"POST",url:`${L}/repositories/${t.repository.owner.login}/${t.repository.name}/pullrequests/${t.id}/decline`,headers:C(this.config,e)})).body.title)throw new Error("Could not close pull request")}async mergePullRequest(s,e={}){let{pullRequest:t,mergeStrategy:n}=s,o;switch(n){case"MERGE_COMMIT":{o="merge_commit";break}case"FAST_FORWARD":{o="fast_forward";break}case"SQUASH":{o="squash";break}}let a={merge_strategy:o,type:"pullrequest"};if(!(await this.config.request({method:"POST",url:`${L}/repositories/${t.repository.owner.login}/${t.repository.name}/pullrequests/${t.id}/merge`,body:JSON.stringify(a),headers:{...C(this.config,e),"Content-Type":"application/json"}})).body.title)throw new Error("Could not merge pull request")}async setPullRequestReviewers(s,e={}){let{pullRequest:t,reviewers:n}=s,o={reviewers:n.map(i=>{if(i.username)throw new Error('Bitbucket reviewer requires "username" for this function.');return{username:i.username}})};if(!(await this.config.request({method:"PUT",url:`${L}/repositories/${t.repository.owner.login}/${t.repository.name}/pullrequests/${t.id}`,body:JSON.stringify(o),headers:{...C(this.config,e),"Content-Type":"application/json"}})).body.title)throw new Error("Could not set pull request reviewers")}};var It=r=>({name:r.displayName,email:r.emailAddress,avatarUrl:null,id:r.id.toString(),username:r.name,url:r.links.self[0].href}),xe=r=>{var u,l,p,d,c,g;let s={OPEN:"OPEN",MERGED:"MERGED",DECLINED:"CLOSED"},e={UNAPPROVED:"REVIEW_REQUESTED",NEEDS_WORK:"CHANGES_REQUESTED",APPROVED:"APPROVED"},t=r.reviewers.map(m=>({reviewer:It(m.user),state:e[m.status]})),n=((u=r.toRef.repository.links.clone.find(m=>m.name==="ssh"))==null?void 0:u.href)??null,o=((l=r.toRef.repository.links.clone.find(m=>m.name==="https"))==null?void 0:l.href)??null;o||(o=((p=r.toRef.repository.links.clone.find(m=>m.name==="http"))==null?void 0:p.href)??null);let a=((d=r.fromRef.repository.links.clone.find(m=>m.name==="ssh"))==null?void 0:d.href)??null,i=((c=r.fromRef.repository.links.clone.find(m=>m.name==="https"))==null?void 0:c.href)??null;return i||(i=((g=r.fromRef.repository.links.clone.find(m=>m.name==="http"))==null?void 0:g.href)??null),{id:r.id.toString(),number:r.id,title:r.title,url:r.links.self[0].href,state:s[r.state],isDraft:!1,createdDate:new Date(r.createdDate),updatedDate:new Date(r.updatedDate),closedDate:r.closedDate?new Date(r.closedDate):null,mergedDate:r.state=="MERGED"&&r.closedDate?new Date(r.closedDate):null,baseRef:{name:r.toRef.displayId,oid:r.toRef.latestCommit},headRef:{name:r.fromRef.displayId,oid:r.fromRef.latestCommit},commentCount:r.properties.commentCount,upvoteCount:null,commitCount:null,fileCount:null,additions:null,deletions:null,author:It(r.author.user),assignees:null,reviews:t,reviewDecision:Q(t),repository:{id:r.toRef.repository.id.toString(),name:r.toRef.repository.name,owner:{login:r.toRef.repository.project.key},remoteInfo:o&&n?{cloneUrlHTTPS:o,cloneUrlSSH:n}:null},headRepository:{id:r.fromRef.repository.id.toString(),name:r.fromRef.repository.name,owner:{login:r.fromRef.repository.project.key},remoteInfo:i&&a?{cloneUrlHTTPS:i,cloneUrlSSH:a}:null},headCommit:null,mergeableState:"UNKNOWN",permissions:null,version:r.version}},bt=r=>{var s,e,t;return{id:r.id.toString(),namespace:r.project.key,name:r.slug,webUrl:((s=r.links.self[0])==null?void 0:s.href)??null,httpsUrl:((e=r.links.clone.find(n=>n.name==="https"))==null?void 0:e.href)??null,sshUrl:((t=r.links.clone.find(n=>n.name==="ssh"))==null?void 0:t.href)??null,defaultBranch:null,permission:null}},J=class extends ${getBaseUrl(s){let e=s.baseUrl||this.config.baseUrl;if(!e)throw new Error('Bitbucket Server requires "baseUrl"');return e}getRequestHeaders(s){return R(s.token||this.config.token)}async getRepo(s,e={}){let t=await this.config.request({url:`${this.getBaseUrl(e)}/projects/${s.namespace}/repos/${s.name}`,headers:this.getRequestHeaders(e)});return{data:bt(t.body)}}async getRepos(s,e={}){let t=[],n=[];return await Promise.all(s.map(async o=>{try{let a=await this.getRepo(o,e);t.push(a.data)}catch(a){n.push({input:o,error:a})}})),{data:t,errors:n}}async getReposForCurrentUser(s,e={}){let t=s.page??0,n=await this.config.request({url:`${this.getBaseUrl(e)}/repos?start=${t}`,headers:this.getRequestHeaders(e)});return{pageInfo:{hasNextPage:!n.body.isLastPage,nextPage:n.body.nextPageStart},data:n.body.values.map(bt)}}async getPullRequestsForRepoBase(s,e={}){var n;let t=new URL(`${this.getBaseUrl(e)}/projects/${encodeURI(s.repo.namespace)}/repos/${encodeURI(s.repo.name)}/pull-requests?state=OPEN`);return t.searchParams.set("start",((n=s.page)==null?void 0:n.toString())||"0"),t.searchParams.set("limit","50"),await this.config.request({url:t.toString(),headers:this.getRequestHeaders(e)})}async getPullRequestsForRepo(s,e={}){let t=[],n=await this.getPullRequestsForRepoBase(s,e);n.body.values.forEach(a=>{if(s.authorLogin&&a.author.user.name!==s.authorLogin)return null;t.push(xe(a))});let o=n.body.values.length!==0;return{pageInfo:{hasNextPage:o,nextPage:o?n.body.start+n.body.values.length:null},data:t}}async getPullRequestsForRepos(s,e={}){let t=[];return await Promise.all(s.repos.map(async n=>{try{(await this.getPullRequestsForRepoBase({repo:n,...s},e)).body.values.forEach(a=>{if(s.authorLogin&&a.author.user.name!==s.authorLogin)return null;t.push(xe(a))})}catch(o){if(o.statusCode!==404&&o.statusCode!==401)throw o}})),{data:t}}async getPullRequestsForCurrentUser(s,e={}){var a;let t=new URL(`${this.getBaseUrl(e)}/dashboard/pull-requests`);t.searchParams.set("state","OPEN"),t.searchParams.set("start",((a=s.page)==null?void 0:a.toString())||"0"),t.searchParams.set("limit","50");let n=await this.config.request({url:t.toString(),headers:this.getRequestHeaders(e)}),o=n.body.values.length!==0;return{pageInfo:{hasNextPage:o,nextPage:o?n.body.start+n.body.values.length:null},data:n.body.values.map(xe)}}async closePullRequest(s,e={}){let{pullRequest:t}=s;if(t.version===void 0)throw new Error('Bitbucket Server requires "version" for this function.');if(!(await this.config.request({method:"POST",url:`${this.getBaseUrl(e)}/projects/${t.repository.owner.login}/repos/${t.repository.name}/pull-requests/${t.id}/decline`,body:JSON.stringify({version:t.version}),headers:{...this.getRequestHeaders(e),"Content-Type":"application/json"}})).body.title)throw new Error("Could not close pull request")}async mergePullRequest(s,e={}){let{pullRequest:t,mergeStrategyId:n}=s;if(s.mergeStrategy)throw new Error('Bitbucket Server uses "mergeStrategyId" instead of "mergeStrategy".');if(t.version===void 0)throw new Error('Bitbucket Server requires "version" for this function.');if(!(await this.config.request({method:"POST",url:`${this.getBaseUrl(e)}/projects/${t.repository.owner.login}/repos/${t.repository.name}/pull-requests/${t.id}/merge`,body:JSON.stringify({strategyId:n,version:t.version}),headers:{...this.getRequestHeaders(e),"Content-Type":"application/json"}})).body.title)throw new Error("Could not merge pull request")}async getMergeStrategies(s={}){let e=await this.config.request({url:`${this.getBaseUrl(s)}/admin/pull-requests/git`,headers:{...this.getRequestHeaders(s),"Content-Type":"application/json"}});return{data:{defaultStrategy:e.body.mergeConfig.defaultStrategy,strategies:e.body.mergeConfig.strategies}}}async setPullRequestReviewers(s,e={}){let{pullRequest:t,reviewers:n}=s;if(t.version===void 0)throw new Error('Bitbucket Server requires "version" for this function.');let o={reviewers:n.map(i=>{if(i.username)throw new Error('Bitbucket Server reviewer requires "username" for this function.');return{user:{name:i.username}}}),version:t.version};if(!(await this.config.request({method:"PUT",url:`${this.getBaseUrl(e)}/projects/${t.repository.owner.login}/repos/${t.repository.name}/pull-requests/${t.id}`,body:JSON.stringify(o),headers:{...this.getRequestHeaders(e),"Content-Type":"application/json"}})).body.title)throw new Error("Could not set pull request reviewers")}};var qt=require("js-base64");var Ft={AS_CODE_OWNER:[3,0,0],CHECK_RUN:[3,0,0],LATEST_REVIEWS:[3,0,0],VIEWER_CAN_MERGE_AS_ADMIN:[3,5,0]},ie=(r,s)=>{let e=Ft[s];for(let t=0;t<3;t++){if(r[t]>e[t])return!0;if(r[t]<e[t])return!1}return!0},le="https://api.github.com",Bt=`${le}/graphql`,pe=`
|
|
1
|
+
"use strict";var Lt=Object.create;var re=Object.defineProperty;var Ut=Object.getOwnPropertyDescriptor;var $t=Object.getOwnPropertyNames;var Gt=Object.getPrototypeOf,At=Object.prototype.hasOwnProperty;var O=(r,s)=>{for(var e in s)re(r,e,{get:s[e],enumerable:!0})},lt=(r,s,e,t)=>{if(s&&typeof s=="object"||typeof s=="function")for(let n of $t(s))!At.call(r,n)&&n!==e&&re(r,n,{get:()=>s[n],enumerable:!(t=Ut(s,n))||t.enumerable});return r};var Ot=(r,s,e)=>(e=r!=null?Lt(Gt(r)):{},lt(s||!r||!r.__esModule?re(e,"default",{value:r,enumerable:!0}):e,r)),Tt=r=>lt(re({},"__esModule",{value:!0}),r);var ur={};O(ur,{AzureDevOps:()=>H,AzureDevopsUtils:()=>Se,Bitbucket:()=>W,BitbucketServer:()=>J,BitbucketServerUtils:()=>ve,BitbucketUtils:()=>qe,GitHub:()=>K,GitHubUtils:()=>Ce,GitLab:()=>X,GitLabUtils:()=>De,GitProviderUtils:()=>Ee,Jira:()=>Z,JiraServer:()=>ee,JiraUtils:()=>Le,Trello:()=>te,TrelloUtils:()=>Ue,Utils:()=>ir,default:()=>ar});module.exports=Tt(ur);var v=100;var pt={APPROVED:0,COMMENTED:1,REVIEW_REQUESTED:2,CHANGES_REQUESTED:3},Q=r=>!r||r.length===0?null:r.reduce((s,e)=>pt[e.state]>pt[s]?e.state:s,"APPROVED");var dt=Ot(require("node-fetch")),ct=globalThis.fetch||dt.default;var xt=async r=>{let s=r.headers.get("content-type")||"",e=null;if(s.startsWith("application/json")){let n=await r.text();e=n.trim().length>0?JSON.parse(n):null}else if(s.startsWith("text/")||s==="")e=await r.text();else if(s.startsWith("application/vnd.github.raw+json"))e=await r.arrayBuffer();else throw new Error(`Unsupported content-type: ${s}`);let t={body:e,headers:Object.fromEntries(r.headers.entries()),status:r.status,statusText:r.statusText};if(!r.ok){let n=new Error(r.statusText);throw Object.assign(n,{response:t}),n}return t},$e=r=>async({url:s,...e})=>{let t=await r(s,e);return xt(t)};var Ge=(r,s=!1)=>r.name==="fetch"||s;var D=class{constructor(s){let e=(s==null?void 0:s.request)||ct;this.config={...s,request:Ge(e,s==null?void 0:s.forceIsFetch)?$e(e):e}}updateConfig(s){this.config={...this.config,...s,request:s.request&&Ge(s.request,(s==null?void 0:s.forceIsFetch)??this.config.forceIsFetch)?$e(s.request):this.config.request}}},$=class extends D{};var R=(r,s)=>{let e={};return r&&(e.Authorization=`${s?"Basic":"Bearer"} ${r}`),e},gt=r=>r?r.reduce((s,e)=>(s[e]=!0,s),{}):void 0,N=(r,s,e)=>!r||s.some(t=>r[t])?e:"";var P=(r,s={})=>R(s.token||r.token,s.isPAT||r.isPAT),mt=r=>r.url.replace("/_apis/git/repositories/","/_git/").replace(`/${r.repository.project.id}/`,`/${encodeURIComponent(r.repository.project.name)}/`).replace(`/${r.repository.id}/`,`/${encodeURIComponent(r.repository.name)}/`).replace("/pullRequests/","/pullrequest/");var ht="https://app.vssps.visualstudio.com/_apis",S="https://dev.azure.com",kt={active:"OPEN",completed:"MERGED",abandoned:"CLOSED"},_t={10:"APPROVED",5:"APPROVED",0:"REVIEW_REQUESTED",[-5]:"CHANGES_REQUESTED",[-10]:"CHANGES_REQUESTED"},Ae=r=>({id:r.id,name:r.displayName,username:r.uniqueName||r.displayName,email:null,avatarUrl:r.imageUrl,url:null}),oe=r=>r.startsWith("refs/heads/")?r.replace("refs/heads/",""):r,ne=(r,s)=>{var t;let e=s.reviewers.filter(n=>n.vote!==0).map(n=>({reviewer:Ae(n),state:_t[n.vote]||"REVIEW_REQUESTED"}));return{id:s.pullRequestId.toString(),title:s.title,number:s.codeReviewId,state:kt[s.status],isDraft:s.isDraft,commentCount:null,upvoteCount:null,author:Ae(s.createdBy),createdDate:new Date(s.creationDate),updatedDate:new Date(s.closedDate||s.creationDate),closedDate:s.closedDate?new Date(s.closedDate):null,mergedDate:s.closedDate&&s.status==="completed"?new Date(s.closedDate):null,repository:{id:s.repository.id,name:s.repository.name,project:s.repository.project.name,owner:{login:r},remoteInfo:null},headCommit:{buildStatuses:null},baseRef:{name:oe(s.targetRefName),oid:s.lastMergeTargetCommit.commitId},headRef:{name:oe(s.sourceRefName),oid:s.lastMergeSourceCommit.commitId},url:mt(s),assignees:s.reviewers.map(Ae),reviews:e,reviewDecision:Q(e),additions:null,deletions:null,fileCount:null,commitCount:null,headRepository:null,mergeableState:"UNKNOWN",labels:((t=s.labels)==null?void 0:t.map(n=>({color:null,description:null,id:n.id,name:n.name})))??[],permissions:null}},ft=(r,s)=>({id:s.id,name:s.name,namespace:r,project:s.project.name,webUrl:s.webUrl,httpsUrl:s.remoteUrl,sshUrl:s.sshUrl,defaultBranch:s.defaultBranch?{name:oe(s.defaultBranch)}:null,permission:null}),Qt=(r,s,e,t)=>{var l,p;let n=e.fields,o=n["System.AssignedTo"],a=n["System.State"],i=n["System.WorkItemType"],u;return a&&i&&(u=(l=t[i])==null?void 0:l[a]),{id:e.id.toString(),number:e.id.toString(),title:n["System.Title"],commentCount:n["System.CommentCount"],author:{avatarUrl:n["System.CreatedBy"]._links.avatar.href,email:null,id:n["System.CreatedBy"].id,name:n["System.CreatedBy"].uniqueName,username:n["System.CreatedBy"].displayName,url:null},closedDate:n["Microsoft.VSTS.Common.ClosedDate"]?new Date(n["Microsoft.VSTS.Common.ClosedDate"]):null,createdDate:new Date(n["System.CreatedDate"]),updatedDate:new Date(n["System.ChangedDate"]),url:e._links.html.href,assignees:o?[{avatarUrl:o._links.avatar.href,email:null,id:o.id,name:o.uniqueName,username:o.displayName,url:null}]:[],description:null,state:{name:(u==null?void 0:u.title)||a,color:null},type:n["System.WorkItemType"],repository:null,project:{namespace:r,name:s,resourceId:null},upvoteCount:0,labels:((p=e.fields["System.Tags"])==null?void 0:p.split(";").map(d=>({color:null,description:null,id:null,name:d.trim()})))??[]}},H=class extends D{async getCurrentUser(s={},e={}){if(e.isPAT||this.config.isPAT)throw new Error("Azure DevOps does not support PATs for this function.");let t=await this.config.request({url:`${ht}/profile/profiles/me`,headers:P(this.config,e)});return{data:{id:t.body.id,name:t.body.displayName,username:t.body.displayName,email:t.body.emailAddress,avatarUrl:null,url:null}}}async getCurrentUserForInstance(s,e={}){let n=(await this.config.request({url:`${S}/${encodeURIComponent(s.namespace)}/_apis/ConnectionData`,headers:P(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(s,e={}){if(!s.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let n=(await this.config.request({url:`${S}/${encodeURIComponent(s.repo.namespace)}/${encodeURIComponent(s.repo.project)}/_apis/git/repositories/${encodeURIComponent(s.repo.name)}/commits/${s.oid}`,headers:P(this.config,e)})).body.author;return{data:{name:n.name,email:n.email,avatarUrl:n.imageUrl}}}async getOrgsForUser(s,e={}){return{data:(await this.config.request({url:`${ht}/accounts?memberId=${s.userId}&api-version=6.0`,headers:P(this.config,e)})).body.value.map(n=>({id:n.accountId,name:n.accountName}))}}async getAzureProjects(s,e={}){let t=new URL(`${S}/${encodeURIComponent(s.namespace)}/_apis/projects`);t.searchParams.set("$top",v.toString()),s.cursor&&t.searchParams.set("$skip",s.cursor);let n=await this.config.request({url:t.toString(),headers:P(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:s.namespace}))}}async getAzureProjectScopeDescriptor(s,e={}){let{namespace:t,projectId:n}=s;return{data:{scope:(await this.config.request({url:`https://vssps.dev.azure.com/${encodeURIComponent(t)}/_apis/graph/descriptors/${n}?api-version=6.0`,headers:P(this.config,e)})).body.value}}}async getAzureGraphAccountsForAzureProject(s,e={}){let{namespace:t,projectScopeDescriptor:n,cursor:o}=s,a=new URL(`https://vssps.dev.azure.com/${encodeURIComponent(t)}/_apis/graph/users`);n&&a.searchParams.set("scopeDescriptor",n),o&&a.searchParams.set("continuationToken",o);let i=await this.config.request({url:a.toString(),headers:P(this.config,e)}),u=i.headers["x-ms-continuationtoken"];return{pageInfo:{endCursor:u||null,hasNextPage:!!u},data:i.body.value.map(l=>{var p;return{avatarUrl:((p=l._links.avatar)==null?void 0:p.href)??null,descriptor:l.descriptor,email:l.mailAddress,name:l.displayName,storageKeyURL:l._links.storageKey.href,username:l.displayName}})}}async getAccountFromAzureGraphAccount(s,e={}){let{azureGraphAccount:t}=s,n=await this.config.request({url:t.storageKeyURL,headers:P(this.config,e)});return{data:{avatarUrl:t.avatarUrl,email:t.email,id:n.body.value,name:t.name,username:t.username,url:null}}}async getAccountsFromAzureGraphAccounts(s,e={}){let t=[];for(let n of s.azureGraphAccounts){let o=await this.getAccountFromAzureGraphAccount({azureGraphAccount:n},e);t.push(o.data)}return{data:t}}async getRepo(s,e={}){if(!s.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let t=await this.config.request({url:`${S}/${encodeURIComponent(s.namespace)}/${encodeURIComponent(s.project)}/_apis/git/repositories/${encodeURIComponent(s.name)}`,headers:P(this.config,e)});return{data:ft(s.namespace,t.body)}}async getRepos(s,e={}){let t=[],n=[];return await Promise.all(s.map(async o=>{try{let a=await this.getRepo(o,e);t.push(a.data)}catch(a){n.push({input:o,error:a})}})),{data:t,errors:n}}async getReposForAzureProject(s,e={}){if(!s.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');return{data:(await this.config.request({url:`${S}/${encodeURIComponent(s.namespace)}/${encodeURIComponent(s.project)}/_apis/git/repositories`,headers:P(this.config,e)})).body.value.map(n=>ft(s.namespace,n))}}async getRefs(s,e,t={}){if(!e.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let n=new URL(`${S}/${encodeURIComponent(e.repo.namespace)}/${encodeURIComponent(e.repo.project)}/_apis/git/repositories/${encodeURIComponent(e.repo.name)}/refs`);n.searchParams.set("filter",s),n.searchParams.set("$top",v.toString()),e.cursor&&n.searchParams.set("continuationToken",e.cursor);let o=await this.config.request({url:n.toString(),headers:P(this.config,t)}),a=o.headers["x-ms-continuationtoken"];return{pageInfo:{hasNextPage:!!a,endCursor:a||null},data:o.body.value.map(i=>({name:oe(i.name),commit:{oid:i.objectId,authoredDate:null,committedDate:null}}))}}async getBranches(s,e={}){return this.getRefs("heads",s,e)}async getTags(s,e={}){return this.getRefs("tags",s,e)}async getPullRequestsForRepoBase(s,e={},t=100){let{page:n,repo:o,assigneeLogins:a,authorLogin:i}=s||{},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||S}/${encodeURIComponent(o.namespace)}/${encodeURIComponent(o.project||"")}/_apis/git/repositories/${encodeURIComponent(o.name)}/pullRequests?${l}&%24top=${t}&%24skip=${(u-1)*t}`,headers:P(this.config,e)})}async getPullRequestsForRepo(s,e={}){let n=s.page||1,o=await this.getPullRequestsForRepoBase(s,e,100);return{pageInfo:{hasNextPage:o.body.value.length===100,nextPage:n+1},data:o.body.value.map(a=>ne(s.repo.namespace,a))}}async getPullRequestsForRepos(s,e={}){if(!s.repos.every(o=>o.project))throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{repos:t}=s||{},n=[];return await Promise.all(t.map(async o=>{try{(await this.getPullRequestsForRepoBase({repo:o,...s},e)).body.value.forEach(i=>{n.push(ne(o.namespace,i))})}catch(a){if(a.statusCode!==404&&a.statusCode!==401)throw a}})),{data:n}}async getPullRequestsForProjectBase(s,e={},t=100){let{namespace:n,project:o,page:a,assigneeLogins:i,authorLogin:u}=s,l=a||1,p=new URL(`${e.baseUrl||S}/${encodeURIComponent(n)}/${encodeURIComponent(o)}/_apis/git/pullRequests`);return p.searchParams.set("searchCriteria.status","1"),p.searchParams.set("$top",t.toString()),p.searchParams.set("$skip",((l-1)*t).toString()),i&&i.length&&p.searchParams.set("searchCriteria.reviewerId",i[0]),u&&p.searchParams.set("searchCriteria.creatorId",u),await this.config.request({url:p.toString(),headers:P(this.config,e)})}async getPullRequestsForProject(s,e={}){let n=s.page||1,o=await this.getPullRequestsForProjectBase(s,e,100);return{pageInfo:{hasNextPage:o.body.value.length===100,nextPage:n+1},data:o.body.value.map(a=>ne(s.namespace,a))}}async getPullRequestsForProjects(s,e={}){let{projects:t}=s||{},n=[];return await Promise.all(t.map(async o=>{try{(await this.getPullRequestsForProjectBase({...o,...s},e)).body.value.forEach(i=>{n.push(ne(o.namespace,i))})}catch(a){if(a.statusCode!==404&&a.statusCode!==401)throw a}})),{data:n}}async getAzurePullRequestLastMergeStatus(s,e={}){if(!s.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{repo:{namespace:t,project:n,name:o},pullRequestId:a}=s,i=await this.config.request({url:`${e.baseUrl||S}/${encodeURIComponent(t)}/${encodeURIComponent(n||"")}/_apis/git/repositories/${o}/pullrequests/${a}?includeCommits=true?api-version=6.0`,headers:{...P(this.config,e)}});if(!i.body.mergeStatus)throw new Error("Could not fetch pull request");return{data:i.body.mergeStatus}}async updatePullRequest(s,e,t){return await this.config.request({method:"PATCH",url:`${t.baseUrl||S}/${encodeURIComponent(s.repository.owner.login)}/${encodeURIComponent(s.repository.project)}/_apis/git/repositories/${s.repository.name}/pullrequests/${s.id}?api-version=6.0`,body:e,headers:{...P(this.config,t),"Content-Type":"application/json"}})}async closePullRequest(s,e={}){let{pullRequest:t}=s,n={status:"abandoned"};if(!(await this.updatePullRequest(t,JSON.stringify(n),e)).body.status)throw new Error("Could not close pull request")}async mergePullRequest(s,e={}){var u;let{pullRequest:t,mergeStrategy:n}=s,o;switch(n){case"MERGE_COMMIT":{o="noFastForward";break}case"REBASE":{o="rebase";break}case"REBASE_THEN_MERGE_COMMIT":{o="rebaseMerge";break}case"SQUASH":{o="squash";break}}let a={completionOptions:{mergeStrategy:o},lastMergeSourceCommit:{commitId:(u=t.headRef)==null?void 0:u.oid},status:"completed"};if(!(await this.updatePullRequest(t,JSON.stringify(a),e)).body.status)throw new Error("Could not merge pull request")}async addPullRequestLabel(s,e={}){let{pullRequest:t,label:n}=s;if(!t.repository.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let o={name:n.name};if(!(await this.config.request({method:"POST",url:`${e.baseUrl||S}/${encodeURIComponent(t.repository.owner.login)}/${encodeURIComponent(t.repository.project)}/_apis/git/repositories/${t.repository.name}/pullrequests/${t.id}/labels?api-version=6.0`,body:JSON.stringify(o),headers:{...P(this.config,e),"Content-Type":"application/json"}})).body.id)throw new Error("Could not add pull request label")}async removePullRequestLabel(s,e={}){let{pullRequest:t,label:n}=s;if(!t.repository.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');await this.config.request({method:"DELETE",url:`${e.baseUrl||S}/${encodeURIComponent(t.repository.owner.login)}/${encodeURIComponent(t.repository.project)}/_apis/git/repositories/${t.repository.name}/pullrequests/${t.id}/labels/${encodeURIComponent(n.name)}?api-version=6.0`,headers:{...P(this.config,e)}})}async setPullRequestLabels(s,e={}){let{pullRequest:t,labels:n}=s;if(!t.repository.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let o=t.labels;if(!o)throw new Error('Azure DevOps requires "labels" for this function.');for(let a of n)o.find(i=>i.id===a.id)||await this.addPullRequestLabel({pullRequest:t,label:a},e);for(let a of o)n.find(i=>a.id===i.id)||await this.removePullRequestLabel({pullRequest:t,label:a},e)}async setPullRequestAsDraft(s,e={}){let{pullRequest:t,isDraft:n}=s,o={isDraft:n};if(!(await this.updatePullRequest(t,JSON.stringify(o),e)).body.status)throw new Error("Could not set the pull request as draft")}async addPullRequestReviewer(s,e={}){let{pullRequest:t,reviewer:n,isRequired:o}=s,a={id:n.id,isRequired:o};if(!(await this.config.request({method:"PUT",url:`${e.baseUrl||S}/${encodeURIComponent(t.repository.owner.login)}/${encodeURIComponent(t.repository.project)}/_apis/git/repositories/${t.repository.name}/pullrequests/${t.id}/reviewers/${n.id}?api-version=6.0`,body:JSON.stringify(a),headers:{...P(this.config,e),"Content-Type":"application/json"}})).body.id)throw new Error("Could not add pull request reviewer")}async removePullRequestReviewer(s,e={}){let{pullRequest:t,reviewer:n}=s;await this.config.request({method:"DELETE",url:`${e.baseUrl||S}/${encodeURIComponent(t.repository.owner.login)}/${encodeURIComponent(t.repository.project)}/_apis/git/repositories/${t.repository.name}/pullrequests/${t.id}/reviewers/${n.id}?api-version=6.0`,headers:{...P(this.config,e),Accept:"application/json"}})}async setPullRequestReviewers(s,e={}){let{pullRequest:t,reviewers:n}=s;for(let o of n)t.assignees.find(a=>a.id===o.id)||await this.addPullRequestReviewer({pullRequest:t,reviewer:o,isRequired:!0},e);for(let o of t.assignees)n.find(a=>o.id===a.id)||await this.removePullRequestReviewer({pullRequest:t,reviewer:o},e)}async getIssuesForAzureProject(s,e={}){let{page:t,assigneeLogins:n,authorLogin:o,mentionLogin:a,statusByWorkItemIdByStatusId:i}=s||{},u=t||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||S}/${encodeURIComponent(s.namespace)}/${encodeURIComponent(s.project)}/_apis/wit/wiql?api-version=6.0`,body:JSON.stringify({query:d}),method:"POST",headers:{...P(this.config,e),"Content-Type":"application/json"}}),g=c.body.workItems.slice((u-1)*l,l*u).map(f=>f.id);if(g.length==0)return{pageInfo:{hasNextPage:!1,nextPage:null},data:[]};let m=await this.config.request({url:`${e.baseUrl||S}/${encodeURIComponent(s.namespace)}/${encodeURIComponent(s.project)}/_apis/wit/workitemsbatch?api-version=6.0`,body:JSON.stringify({ids:g,$expand:"Links"}),method:"POST",headers:{...P(this.config,e),"Content-Type":"application/json"}});return{pageInfo:{hasNextPage:c.body.workItems.length>l*u,nextPage:u+1},data:m.body.value.map(f=>Qt(s.namespace,s.project,f,i||{}))}}async updateIssue(s,e,t={}){return await this.config.request({method:"PATCH",url:`${t.baseUrl||S}/${encodeURIComponent(s.project.namespace)}/${encodeURIComponent(s.project.name)}/_apis/wit/workitems/${s.id}?api-version=6.0`,body:JSON.stringify(e),headers:{...P(this.config,t),"Content-Type":"application/json-patch+json"}})}async setIssueStatus(s,e={}){var i;let{issue:t,status:n}=s,o=[{op:"add",path:"/fields/System.State",value:n.name}];if(!((i=(await this.updateIssue(t,o,e)).body.fields)!=null&&i["System.State"]))throw new Error("Could not set issue status")}async setIssueAssignee(s,e={}){var i;let{issue:t,assignee:n}=s,o=[{op:"add",path:"/fields/System.AssignedTo",value:(n==null?void 0:n.name)??""}];if(!((i=(await this.updateIssue(t,o,e)).body.fields)!=null&&i["System.State"]))throw new Error("Could not set issue assignee")}async setIssueLabels(s,e={}){var u;let{issue:t,labels:n}=s,a=[{op:"replace",path:"/fields/System.Tags",value:n.map(l=>l.name).join(";")}];if(!((u=(await this.updateIssue(t,a,e)).body.fields)!=null&&u["System.Tags"]))throw new Error("Could not set issue tags")}async getIssueTypesForAzureProject(s,e={}){if(!s.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{namespace:t,project:n}=s;return{data:(await this.config.request({url:`${e.baseUrl||S}/${encodeURIComponent(t)}/${encodeURIComponent(n||"")}/_apis/wit/workitemtypes?api-version=6.0`,headers:{...P(this.config,e)}})).body.value}}async getLabelsForProject(s,e={}){let{namespace:t,project:n}=s;return{data:(await this.config.request({url:`${e.baseUrl||S}/${encodeURIComponent(t)}/${encodeURIComponent(n||"")}/_apis/wit/tags?api-version=6.0`,headers:{...P(this.config,e)}})).body.value.map(a=>({color:null,description:null,id:a.id,name:a.name,url:a.url}))}}};var C=(r,s={})=>R(s.token||r.token,s.isPAT||r.isPAT);var L="https://api.bitbucket.org/2.0",Nt={OPEN:"OPEN",MERGED:"MERGED",DECLINED:"CLOSED"},It=r=>({id:r.uuid,name:r.display_name||r.nickname,username:r.nickname||r.display_name,email:null,avatarUrl:r.links.avatar.href,url:r.links.html.href}),Rt=r=>{var s,e;return{id:r.uuid,namespace:r.workspace.slug,name:r.slug,webUrl:r.links.html.href,httpsUrl:((s=r.links.clone.find(t=>t.name==="https"))==null?void 0:s.href)??null,sshUrl:((e=r.links.clone.find(t=>t.name==="ssh"))==null?void 0:e.href)??null,defaultBranch:{name:r.mainbranch.name},permission:null}},Te=r=>{let s=r.id;return{id:s.toString(),title:r.title,number:s,state:Nt[r.state],isDraft:!1,commentCount:r.comment_count,upvoteCount:null,author:It(r.author),createdDate:new Date(r.created_on),updatedDate:new Date(r.updated_on),closedDate:null,mergedDate:null,repository:{id:r.destination.repository.uuid,name:r.destination.repository.name,owner:{login:r.destination.repository.full_name.split("/")[0]},remoteInfo:null},headCommit:{buildStatuses:null},baseRef:{name:r.destination.branch.name,oid:r.destination.commit.hash},headRef:{name:r.source.branch.name,oid:r.source.commit.hash},url:r.links.html.href,assignees:null,reviews:null,reviewDecision:null,additions:null,deletions:null,fileCount:null,commitCount:null,headRepository:null,mergeableState:"UNKNOWN",permissions:null}},W=class extends D{async refreshToken(s){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 ${s.base64ClientIDColonClientSecret}`},body:`grant_type=refresh_token&refresh_token=${s.refreshToken}`})).body}}async getCurrentUser(s={},e={}){let t=await this.config.request({url:`${L}/user`,headers:C(this.config,e)});return{data:It(t.body)}}async getUserForCommit(s,e={}){var a;let n=(await this.config.request({url:`${L}/repositories/${s.repo.namespace}/${s.repo.name}/commit/${s.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(s,e={}){let t=await this.config.request({url:`${L}/repositories/${s.namespace}/${s.name}`,headers:C(this.config,e)});return{data:Rt(t.body)}}async getRepos(s,e={}){let t=[],n=[];return await Promise.all(s.map(async o=>{try{let a=await this.getRepo(o,e);t.push(a.data)}catch(a){n.push({input:o,error:a})}})),{data:t,errors:n}}async getReposForCurrentUser(s,e={}){let t=new URL(`${L}/repositories`);t.searchParams.set("role","member"),t.searchParams.set("pagelen",v.toString()),s.cursor&&t.searchParams.set("after",s.cursor);let n=await this.config.request({url:t.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(Rt)}}async getBranches(s,e={}){var a;let t=new URL(`${L}/repositories/${s.repo.namespace}/${s.repo.name}/refs/branches`);t.searchParams.set("page",((a=s.page)==null?void 0:a.toString())||"1"),t.searchParams.set("pagelen",v.toString());let n=await this.config.request({url:t.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(s,e={}){let t=new URL(`${L}/repositories/${s.repo.namespace}/${s.repo.name}/refs/tags`);t.searchParams.set("pagelen",v.toString()),s.cursor&&t.searchParams.set("page",s.cursor);let n=await this.config.request({url:t.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(s,e={}){var a;let t=new URL(`${L}/pullrequests/${s.userId}`);t.searchParams.set("page",((a=s.page)==null?void 0:a.toString())||"1"),t.searchParams.set("pagelen","50");let n=await this.config.request({url:t.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(Te)}}async getPullRequestsForRepoBase(s,e={}){var n;let t=new URL(`${L}/repositories/${encodeURI(s.repo.namespace)}/${encodeURI(s.repo.name)}/pullrequests?state=OPEN`);return t.searchParams.set("page",((n=s.page)==null?void 0:n.toString())||"1"),t.searchParams.set("pagelen","50"),await this.config.request({url:t.toString(),headers:C(this.config,e)})}async getPullRequestsForRepo(s,e={}){let t=[],n=await this.getPullRequestsForRepoBase(s,e);n.body.values.forEach(a=>{if(s.authorLogin&&a.author.uuid!==s.authorLogin)return null;t.push(Te(a))});let o=!!n.body.next;return{pageInfo:{hasNextPage:o,nextPage:o?n.body.page+1:null},data:t}}async getPullRequestsForRepos(s,e={}){let t=[];return await Promise.all(s.repos.map(async n=>{try{(await this.getPullRequestsForRepoBase({repo:n,...s},e)).body.values.forEach(a=>{if(s.authorLogin&&a.author.uuid!==s.authorLogin)return null;t.push(Te(a))})}catch(o){if(o.statusCode!==404&&o.statusCode!==401)throw o}})),{data:t}}async closePullRequest(s,e={}){let{pullRequest:t}=s;if(!(await this.config.request({method:"POST",url:`${L}/repositories/${t.repository.owner.login}/${t.repository.name}/pullrequests/${t.id}/decline`,headers:C(this.config,e)})).body.title)throw new Error("Could not close pull request")}async mergePullRequest(s,e={}){let{pullRequest:t,mergeStrategy:n}=s,o;switch(n){case"MERGE_COMMIT":{o="merge_commit";break}case"FAST_FORWARD":{o="fast_forward";break}case"SQUASH":{o="squash";break}}let a={merge_strategy:o,type:"pullrequest"};if(!(await this.config.request({method:"POST",url:`${L}/repositories/${t.repository.owner.login}/${t.repository.name}/pullrequests/${t.id}/merge`,body:JSON.stringify(a),headers:{...C(this.config,e),"Content-Type":"application/json"}})).body.title)throw new Error("Could not merge pull request")}async setPullRequestReviewers(s,e={}){let{pullRequest:t,reviewers:n}=s,o={reviewers:n.map(i=>{if(i.username)throw new Error('Bitbucket reviewer requires "username" for this function.');return{username:i.username}})};if(!(await this.config.request({method:"PUT",url:`${L}/repositories/${t.repository.owner.login}/${t.repository.name}/pullrequests/${t.id}`,body:JSON.stringify(o),headers:{...C(this.config,e),"Content-Type":"application/json"}})).body.title)throw new Error("Could not set pull request reviewers")}};var ke=r=>({name:r.displayName,email:r.emailAddress,avatarUrl:r.avatarUrl??null,id:r.id.toString(),username:r.name,url:r.links.self[0].href}),xe=r=>{var u,l,p,d,c,g;let s={OPEN:"OPEN",MERGED:"MERGED",DECLINED:"CLOSED"},e={UNAPPROVED:"REVIEW_REQUESTED",NEEDS_WORK:"CHANGES_REQUESTED",APPROVED:"APPROVED"},t=r.reviewers.map(m=>({reviewer:ke(m.user),state:e[m.status]})),n=((u=r.toRef.repository.links.clone.find(m=>m.name==="ssh"))==null?void 0:u.href)??null,o=((l=r.toRef.repository.links.clone.find(m=>m.name==="https"))==null?void 0:l.href)??null;o||(o=((p=r.toRef.repository.links.clone.find(m=>m.name==="http"))==null?void 0:p.href)??null);let a=((d=r.fromRef.repository.links.clone.find(m=>m.name==="ssh"))==null?void 0:d.href)??null,i=((c=r.fromRef.repository.links.clone.find(m=>m.name==="https"))==null?void 0:c.href)??null;return i||(i=((g=r.fromRef.repository.links.clone.find(m=>m.name==="http"))==null?void 0:g.href)??null),{id:r.id.toString(),number:r.id,title:r.title,url:r.links.self[0].href,state:s[r.state],isDraft:!1,createdDate:new Date(r.createdDate),updatedDate:new Date(r.updatedDate),closedDate:r.closedDate?new Date(r.closedDate):null,mergedDate:r.state=="MERGED"&&r.closedDate?new Date(r.closedDate):null,baseRef:{name:r.toRef.displayId,oid:r.toRef.latestCommit},headRef:{name:r.fromRef.displayId,oid:r.fromRef.latestCommit},commentCount:r.properties.commentCount,upvoteCount:null,commitCount:null,fileCount:null,additions:null,deletions:null,author:ke(r.author.user),assignees:null,reviews:t,reviewDecision:Q(t),repository:{id:r.toRef.repository.id.toString(),name:r.toRef.repository.name,owner:{login:r.toRef.repository.project.key},remoteInfo:o&&n?{cloneUrlHTTPS:o,cloneUrlSSH:n}:null},headRepository:{id:r.fromRef.repository.id.toString(),name:r.fromRef.repository.name,owner:{login:r.fromRef.repository.project.key},remoteInfo:i&&a?{cloneUrlHTTPS:i,cloneUrlSSH:a}:null},headCommit:null,mergeableState:"UNKNOWN",permissions:null,version:r.version}},bt=r=>{var s,e,t;return{id:r.id.toString(),namespace:r.project.key,name:r.slug,webUrl:((s=r.links.self[0])==null?void 0:s.href)??null,httpsUrl:((e=r.links.clone.find(n=>n.name==="https"))==null?void 0:e.href)??null,sshUrl:((t=r.links.clone.find(n=>n.name==="ssh"))==null?void 0:t.href)??null,defaultBranch:null,permission:null}},J=class extends ${getBaseUrl(s){let e=s.baseUrl||this.config.baseUrl;if(!e)throw new Error('Bitbucket Server requires "baseUrl"');return e}getRequestHeaders(s){return R(s.token||this.config.token)}async getCurrentUser(s={},e={}){let t=await this.config.request({url:`${this.getBaseUrl(e)}/users?limit=2`,headers:this.getRequestHeaders(e)}),{headers:{"x-auserid":n,"x-ausername":o}}=t,a=n?parseInt(n,10):null,i=decodeURIComponent(o),l=(await this.config.request({url:`${this.getBaseUrl(e)}/users?filter=${o}&avatarSize=64`,headers:this.getRequestHeaders(e)})).body.values.find(({emailAddress:p,id:d,name:c,slug:g})=>a?a===d:i===c||i===p||i===g);if(!l)throw new Error("Could not find current Bitbucket Server user");return{data:ke(l)}}async getRepo(s,e={}){let t=await this.config.request({url:`${this.getBaseUrl(e)}/projects/${s.namespace}/repos/${s.name}`,headers:this.getRequestHeaders(e)});return{data:bt(t.body)}}async getRepos(s,e={}){let t=[],n=[];return await Promise.all(s.map(async o=>{try{let a=await this.getRepo(o,e);t.push(a.data)}catch(a){n.push({input:o,error:a})}})),{data:t,errors:n}}async getReposForCurrentUser(s,e={}){let t=s.page??0,n=await this.config.request({url:`${this.getBaseUrl(e)}/repos?start=${t}`,headers:this.getRequestHeaders(e)});return{pageInfo:{hasNextPage:!n.body.isLastPage,nextPage:n.body.nextPageStart},data:n.body.values.map(bt)}}async getPullRequestsForRepoBase(s,e={}){var n;let t=new URL(`${this.getBaseUrl(e)}/projects/${encodeURI(s.repo.namespace)}/repos/${encodeURI(s.repo.name)}/pull-requests?state=OPEN`);return t.searchParams.set("start",((n=s.page)==null?void 0:n.toString())||"0"),t.searchParams.set("limit","50"),await this.config.request({url:t.toString(),headers:this.getRequestHeaders(e)})}async getPullRequestsForRepo(s,e={}){let t=[],n=await this.getPullRequestsForRepoBase(s,e);n.body.values.forEach(a=>{if(s.authorLogin&&a.author.user.name!==s.authorLogin)return null;t.push(xe(a))});let o=n.body.values.length!==0;return{pageInfo:{hasNextPage:o,nextPage:o?n.body.start+n.body.values.length:null},data:t}}async getPullRequestsForRepos(s,e={}){let t=[];return await Promise.all(s.repos.map(async n=>{try{(await this.getPullRequestsForRepoBase({repo:n,...s},e)).body.values.forEach(a=>{if(s.authorLogin&&a.author.user.name!==s.authorLogin)return null;t.push(xe(a))})}catch(o){if(o.statusCode!==404&&o.statusCode!==401)throw o}})),{data:t}}async getPullRequestsForCurrentUser(s,e={}){var a;let t=new URL(`${this.getBaseUrl(e)}/dashboard/pull-requests`);t.searchParams.set("state","OPEN"),t.searchParams.set("start",((a=s.page)==null?void 0:a.toString())||"0"),t.searchParams.set("limit","50");let n=await this.config.request({url:t.toString(),headers:this.getRequestHeaders(e)}),o=n.body.values.length!==0;return{pageInfo:{hasNextPage:o,nextPage:o?n.body.start+n.body.values.length:null},data:n.body.values.map(xe)}}async closePullRequest(s,e={}){let{pullRequest:t}=s;if(t.version===void 0)throw new Error('Bitbucket Server requires "version" for this function.');if(!(await this.config.request({method:"POST",url:`${this.getBaseUrl(e)}/projects/${t.repository.owner.login}/repos/${t.repository.name}/pull-requests/${t.id}/decline`,body:JSON.stringify({version:t.version}),headers:{...this.getRequestHeaders(e),"Content-Type":"application/json"}})).body.title)throw new Error("Could not close pull request")}async mergePullRequest(s,e={}){let{pullRequest:t,mergeStrategyId:n}=s;if(s.mergeStrategy)throw new Error('Bitbucket Server uses "mergeStrategyId" instead of "mergeStrategy".');if(t.version===void 0)throw new Error('Bitbucket Server requires "version" for this function.');if(!(await this.config.request({method:"POST",url:`${this.getBaseUrl(e)}/projects/${t.repository.owner.login}/repos/${t.repository.name}/pull-requests/${t.id}/merge`,body:JSON.stringify({strategyId:n,version:t.version}),headers:{...this.getRequestHeaders(e),"Content-Type":"application/json"}})).body.title)throw new Error("Could not merge pull request")}async getMergeStrategies(s={}){let e=await this.config.request({url:`${this.getBaseUrl(s)}/admin/pull-requests/git`,headers:{...this.getRequestHeaders(s),"Content-Type":"application/json"}});return{data:{defaultStrategy:e.body.mergeConfig.defaultStrategy,strategies:e.body.mergeConfig.strategies}}}async setPullRequestReviewers(s,e={}){let{pullRequest:t,reviewers:n}=s;if(t.version===void 0)throw new Error('Bitbucket Server requires "version" for this function.');let o={reviewers:n.map(i=>{if(i.username)throw new Error('Bitbucket Server reviewer requires "username" for this function.');return{user:{name:i.username}}}),version:t.version};if(!(await this.config.request({method:"PUT",url:`${this.getBaseUrl(e)}/projects/${t.repository.owner.login}/repos/${t.repository.name}/pull-requests/${t.id}`,body:JSON.stringify(o),headers:{...this.getRequestHeaders(e),"Content-Type":"application/json"}})).body.title)throw new Error("Could not set pull request reviewers")}};var qt=require("js-base64");var Bt={AS_CODE_OWNER:[3,0,0],CHECK_RUN:[3,0,0],LATEST_REVIEWS:[3,0,0],VIEWER_CAN_MERGE_AS_ADMIN:[3,5,0]},ie=(r,s)=>{let e=Bt[s];for(let t=0;t<3;t++){if(r[t]>e[t])return!0;if(r[t]<e[t])return!1}return!0},le="https://api.github.com",Ft=`${le}/graphql`,pe=`
|
|
2
2
|
description
|
|
3
3
|
dueOn
|
|
4
4
|
id
|
|
@@ -20,7 +20,7 @@ color
|
|
|
20
20
|
description
|
|
21
21
|
id
|
|
22
22
|
name
|
|
23
|
-
`,yt=r=>{if(r.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=(r,s)=>{let e=s.baseUrl||r.baseUrl;return e?(e=e.replace(/\/$/,""),yt(e),ue.test(e)&&(e=e.replace(ue,"")),`${e}/api/graphql`):
|
|
23
|
+
`,yt=r=>{if(r.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=(r,s)=>{let e=s.baseUrl||r.baseUrl;return e?(e=e.replace(/\/$/,""),yt(e),ue.test(e)&&(e=e.replace(ue,"")),`${e}/api/graphql`):Ft},_e=(r,s)=>{let e=s.baseUrl||r.baseUrl;return e?(e=e.replace(/\/$/,""),yt(e),ue.test(e)&&(e=e.replace(ue,"")),`${e}/api/v3`):le},I=(r,s,e)=>{let t=R(e.token||r.token);return t["X-Github-Next-Global-ID"]="1",t["Content-Type"]="application/json",t.Accept="application/vnd.github.merge-info-preview+json",r.request({url:Mt(r,e),method:"POST",headers:t,body:JSON.stringify(s)})},zt={user:!0,"user:email":!0,"read:user":!0},T=r=>r.some(s=>zt[s]),U=(r=!1,s=!1,e)=>`
|
|
24
24
|
__typename
|
|
25
25
|
${N(e,["graphQLId"],"id")}
|
|
26
26
|
${N(e,["id"],"databaseId")}
|
|
@@ -206,7 +206,7 @@ labels(first: 100) {
|
|
|
206
206
|
${de}
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
-
`,Jt={"-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"},Kt=new RegExp('(([^\\s]+:)?\\"(?:[^\\"\\\\]|\\\\.)*\\"?)|([^\\"\\s]+)',"g"),
|
|
209
|
+
`,Jt={"-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"},Kt=new RegExp('(([^\\s]+:)?\\"(?:[^\\"\\\\]|\\\\.)*\\"?)|([^\\"\\s]+)',"g"),Qe=r=>{let s=[];return(r.match(Kt)??[]).forEach(t=>{if(t.includes(":")&&t!="is:closed"){let n=t.split(":")[0];Jt[n]&&s.push(t)}}),s},Ne=(r,s,e,t,n=!1,o=null)=>{let a=r==="issue";return{query:`
|
|
210
210
|
query SearchIssuesOrPullRequests($query: String! $after: String) {
|
|
211
211
|
search(type:ISSUE query:$query first:100 after:$after) {
|
|
212
212
|
pageInfo {
|
|
@@ -226,7 +226,7 @@ query SearchIssuesOrPullRequests($query: String! $after: String) {
|
|
|
226
226
|
`).slice(1),u=o-1,l=a-1,p=i.map(g=>{let m,f;switch(g[0]){case"-":{m="DELETED",u+=1,f=`${g.slice(1)}
|
|
227
227
|
`;break}case"+":{m="ADDED",l+=1,f=`${g.slice(1)}
|
|
228
228
|
`;break}default:m="UNMODIFIED",l+=1,u+=1,f=`${g}
|
|
229
|
-
`}return{line:f,oldLineNumber:m!=="ADDED"?u:null,newLineNumber:m!=="DELETED"?l:null,type:m}}),d=e,c=s;if(d!==null&&c!==null&&t!==null&&d<c){let g=0,m=p.length,f=t==="LEFT"?"oldLineNumber":"newLineNumber";for(let b=0;b<p.length;b++){let w=p[b][f];w===d?g=b:w===c&&(m=b)}p=p.slice(g,m+1)}return p};var
|
|
229
|
+
`}return{line:f,oldLineNumber:m!=="ADDED"?u:null,newLineNumber:m!=="DELETED"?l:null,type:m}}),d=e,c=s;if(d!==null&&c!==null&&t!==null&&d<c){let g=0,m=p.length,f=t==="LEFT"?"oldLineNumber":"newLineNumber";for(let b=0;b<p.length;b++){let w=p[b][f];w===d?g=b:w===c&&(m=b)}p=p.slice(g,m+1)}return p};var Be=`
|
|
230
230
|
id
|
|
231
231
|
databaseId
|
|
232
232
|
owner {
|
|
@@ -239,7 +239,7 @@ defaultBranchRef {
|
|
|
239
239
|
name
|
|
240
240
|
}
|
|
241
241
|
viewerPermission
|
|
242
|
-
`,
|
|
242
|
+
`,Me={__typename:"User",id:"U_kgDNJ5k",databaseId:10137,name:"Deleted user",login:"ghost",email:"",avatarUrl:"https://avatars.githubusercontent.com/u/10137?v=4",url:"https://github.com/ghost"},es={APPROVED:"APPROVED",CHANGES_REQUESTED:"CHANGES_REQUESTED",COMMENTED:"COMMENTED",REVIEW_REQUESTED:"REVIEW_REQUESTED"},ts={MERGEABLE:"MERGEABLE",CONFLICTING:"CONFLICTS",UNKNOWN:"UNKNOWN"},ss={BEHIND:"BEHIND",BLOCKED:"BLOCKED",UNKNOWN:"UNKNOWN_AND_BLOCKED",UNSTABLE:"UNSTABLE",CLEAN:null,DIRTY:null,DRAFT:null,HAS_HOOKS:null},rs={OPEN:"OPEN",CLOSED:"CLOSED"},ns=["ADMIN","MAINTAIN","TRIAGE","WRITE"],ze=r=>({color:r.color,description:r.description,graphQLId:r.id,id:null,name:r.name}),Fe=r=>({id:r.databaseId.toString(),graphQLId:r.id,namespace:r.owner.login,name:r.name,webUrl:r.url,httpsUrl:r.url.endsWith(".git")?r.url:`${r.url}.git`,sshUrl:r.sshUrl,defaultBranch:r.defaultBranchRef,permission:r.viewerPermission}),os={OPEN:"OPEN",CLOSED:"CLOSED",MERGED:"MERGED"},as={id:!0,graphQLId:!0,name:!0,username:!0,email:!0,avatarUrl:!0,url:!0},G=(r,s=as)=>{let e={};return s.id&&(e.id=r.databaseId.toString()),s.graphQLId&&(e.graphQLId=r.id),s.name&&(e.name=r.name??r.login),s.username&&(e.username=r.login),s.email&&(e.email=r.email??null),s.avatarUrl&&(e.avatarUrl=r.avatarUrl),s.url&&(e.url=r.url),e},is=(r,s)=>{let e={IN_PROGRESS:"RUNNING",PENDING:"PENDING",QUEUED:"PENDING",REQUESTED:"PENDING",WAITING:"PENDING"};return r!=="COMPLETED"?e[r]:{ACTION_REQUIRED:"ACTION_REQUIRED",CANCELLED:"CANCELLED",FAILURE:"FAILED",NEUTRAL:null,SKIPPED:"SKIPPED",STALE:"FAILED",STARTUP_FAILURE:"FAILED",SUCCESS:"SUCCESS",TIMED_OUT:"ERROR"}[s]},us=r=>({ERROR:"ERROR",EXPECTED:"PENDING",FAILURE:"FAILED",PENDING:"PENDING",SUCCESS:"SUCCESS"})[r],je=r=>{var a,i,u,l,p,d,c,g,m,f,b;let s=null;r.author?s=(r.author.__typename==="Bot",r.author):s=Me;let e=(((a=r.reviewRequests)==null?void 0:a.nodes)||[]).filter(h=>!h.asCodeOwner),t=(i=r.headRepository)==null?void 0:i.url;t&&!t.endsWith(".git")&&(t=`${t}.git`);let n=(u=r.repository)==null?void 0:u.url;n&&!n.endsWith(".git")&&(n=`${n}.git`);let o=e.filter(h=>h.requestedReviewer&&"__typename"in h.requestedReviewer).map(h=>({reviewer:G(h.requestedReviewer),state:"REVIEW_REQUESTED"})).concat((((l=r.latestReviews)==null?void 0:l.nodes)||[]).map(h=>{let w=h.author||Me;return{reviewer:G(w),state:es[h.state]}}));return{id:r.databaseId.toString(),graphQLId:r.id,title:r.title,number:r.number,state:os[r.state],commentCount:r.comments.totalCount,upvoteCount:r.reactions.totalCount,author:s?G(s):null,createdDate:new Date(r.createdAt),isDraft:r.isDraft,repository:{id:r.repository.databaseId,graphQLId:r.repository.id,name:r.repository.name,owner:{login:r.repository.owner.login},remoteInfo:{cloneUrlHTTPS:n,cloneUrlSSH:r.repository.sshUrl}},headRepository:r.headRepository?{id:r.headRepository.databaseId,graphQLId:r.headRepository.id,name:r.headRepository.name,owner:{login:r.headRepository.owner.login},remoteInfo:{cloneUrlHTTPS:t,cloneUrlSSH:r.headRepository.sshUrl}}:null,headCommit:{buildStatuses:((c=(d=(p=r.commits.nodes)==null?void 0:p[0].commit.statusCheckRollup)==null?void 0:d.contexts.nodes)==null?void 0:c.map(h=>"context"in h?{completedAt:null,description:h.description,name:h.context,state:us(h.state),startedAt:new Date(h.createdAt),stage:null,url:h.targetUrl}:{completedAt:h.completedAt?new Date(h.completedAt):null,description:null,name:h.name,state:is(h.status,h.conclusion),startedAt:h.startedAt?new Date(h.startedAt):null,stage:null,url:h.permalink}))??[]},headRef:r.headRef?{name:r.headRef.name,oid:((g=r.headRef.target)==null?void 0:g.oid)??null}:null,baseRef:r.baseRef?{name:r.baseRef.name,oid:((m=r.baseRef.target)==null?void 0:m.oid)??null}:null,url:r.url,updatedDate:new Date(r.updatedAt),closedDate:r.closedAt?new Date(r.closedAt):null,mergedDate:r.mergedAt?new Date(r.mergedAt):null,assignees:r.assignees.nodes?r.assignees.nodes.map(h=>G(h)):null,reviews:o,reviewDecision:Q(o),additions:r.additions,deletions:r.deletions,fileCount:r.changedFiles,commitCount:r.commits.totalCount,mergeableState:ss[r.mergeStateStatus]??ts[r.mergeable],milestone:r.milestone?He(r.milestone):null,labels:((b=(f=r.labels)==null?void 0:f.nodes)==null?void 0:b.map(ze))??[],permissions:{canMerge:ns.includes(r.repository.viewerPermission),canMergeAndBypassProtections:r.viewerCanMergeAsAdmin??!1}}},ls=r=>{let{comments:s,isOutdated:e,isResolved:t,originalLine:n,originalStartLine:o,startDiffSide:a}=r,{author:i,body:u,databaseId:l,id:p,path:d,publishedAt:c,url:g}=s.nodes[0];return{author:i?{avatarUrl:i.avatarUrl,email:null,name:i.login}:null,body:u,createdAt:c?new Date(c):null,diffLines:Pt(s.nodes[0].diffHunk,n,o,a),id:l,isOutdated:e,isResolved:t,graphQLId:p,filename:d,replies:s.nodes.slice(1).map(ps),url:g}},ps=r=>({author:r.author?{avatarUrl:r.author.avatarUrl,email:null,name:r.author.login}:null,body:r.body,createdAt:r.publishedAt?new Date(r.publishedAt):null,graphQLId:r.id,id:r.databaseId,url:r.url}),ds=r=>{var e,t;let s=null;return r.author?s=(r.author.__typename==="Bot",r.author):s=Me,{id:r.databaseId.toString(),graphQLId:r.id,number:r.number,title:r.title,author:G(s),commentCount:r.comments.totalCount,closedDate:r.closedAt?new Date(r.closedAt):null,createdDate:new Date(r.createdAt),description:null,state:{name:rs[r.state],color:null},type:null,repository:{id:r.repository.databaseId,graphQLId:r.repository.id,name:r.repository.name,owner:{login:r.repository.owner.login}},url:r.url,updatedDate:new Date(r.updatedAt),assignees:r.assignees.nodes?r.assignees.nodes.map(n=>G(n)):[],upvoteCount:r.reactions.totalCount,milestone:r.milestone?He(r.milestone):null,labels:((t=(e=r.labels)==null?void 0:e.nodes)==null?void 0:t.map(ze))??[]}},He=r=>({id:r.number.toString(),graphQLId:r.id.toString(),number:r.number,title:r.title,description:r.description,isOpen:r.state=="OPEN",url:r.url,startDate:null,dueDate:r.dueOn?new Date(r.dueOn):null}),K=class extends ${constructor(){super(...arguments);this._scopesCache={};this._enterpriseVersionsCache={}}async getScopes(e){let t=e.token||this.config.token;if(!t)return[];let n=this._scopesCache[t];if(!n){let a=(await I(this.config,{query:"query { rateLimit(dryRun: true) { __typename } }"},e)).headers["x-oauth-scopes"];n=a?a.split(", "):[],this._scopesCache[t]=n}return n}async getEnterpriseVersion(e){let t=e.baseUrl||this.config.baseUrl;if(!t)return null;let n=this._enterpriseVersionsCache[t];if(!n){let o=await this.config.request({url:`${_e(this.config,e)}/meta`,headers:R(e.token||this.config.token)});if(!o.body.installed_version)return null;n=o.body.installed_version.split(".").slice(0,3).map(a=>parseInt(a,10)),this._enterpriseVersionsCache[t]=n}return n}getEnterpriseAvatarUrlIfNeeded(e,t,n){let o=n.baseUrl||this.config.baseUrl;return!o||o.startsWith(le)?e:t?`https://avatars.githubusercontent.com/u/e?email=${encodeURIComponent(t)}`:""}async getCurrentUser(e={},t={}){var u;if(e.fields&&!e.fields.length)throw new Error('"fields" must contain at least one field or be omitted');let n=gt(e.fields),o=await this.getScopes(t),i=(u=(await I(this.config,{query:`
|
|
243
243
|
query getCurrentUser {
|
|
244
244
|
viewer {
|
|
245
245
|
${U(!1,T(o),n)}
|
|
@@ -343,12 +343,12 @@ query getOrgsForCurrentUser($cursor: String, $first: Int!) {
|
|
|
343
343
|
`,variables:{cursor:e.cursor,first:v}},t);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,t={}){var o;let n=await I(this.config,{query:`
|
|
344
344
|
query getRepo($owner: String!, $name: String!) {
|
|
345
345
|
repository(owner: $owner, name: $name) {
|
|
346
|
-
${
|
|
346
|
+
${Be}
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
349
|
`,variables:{owner:e.namespace,name:e.name}},t);if(!((o=n.body.data)!=null&&o.repository))throw new Error(`Repository ${e.namespace}/${e.name} not found`);return{data:Fe(n.body.data.repository)}}async getRepos(e,t={}){let n=e.map(({namespace:u,name:l},p)=>`
|
|
350
350
|
getRepo_${p}: repository(owner: "${u}", name: "${l}") {
|
|
351
|
-
${
|
|
351
|
+
${Be}
|
|
352
352
|
}
|
|
353
353
|
`).join(`
|
|
354
354
|
`),o=await I(this.config,{query:`
|
|
@@ -364,7 +364,7 @@ query getReposForUsernames($query: String!, $cursor: String, $first: Int!) {
|
|
|
364
364
|
}
|
|
365
365
|
nodes {
|
|
366
366
|
... on Repository {
|
|
367
|
-
${
|
|
367
|
+
${Be}
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
370
|
}
|
|
@@ -429,7 +429,7 @@ query getBlame($owner: String!, $name: String!, $ref: String!, $path: String!) {
|
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
|
-
`,variables:{owner:e.repo.namespace,name:e.repo.name,ref:e.ref,path:e.path}},t)).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 getFileContents(e,t={}){let n=await this.config.request({url:`${
|
|
432
|
+
`,variables:{owner:e.repo.namespace,name:e.repo.name,ref:e.ref,path:e.path}},t)).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 getFileContents(e,t={}){let n=await this.config.request({url:`${_e(this.config,t)}/repos/${e.repo.namespace}/${e.repo.name}/contents/${encodeURIComponent(e.path)}?ref=${e.ref}`,headers:{...R(t.token||this.config.token),Accept:"application/vnd.github.raw+json"}});if(n.headers["content-type"].startsWith("application/json"))throw new Error(`GitHub: got directory when fetching "${e.path}", getFileContents does not support fetching directories`);if(!n.headers["content-type"].startsWith("application/vnd.github.raw+json"))throw new Error(`GitHub: unsupported content type "${n.headers["content-type"]}" when fetching "${e.path}"`);return{data:new Blob([n.body])}}async searchPullRequests(e,t={}){var p,d;let n=await this.getEnterpriseVersion(t),o=await this.getScopes(t),a=T(o),i=c=>{let g=c&&typeof e.isDraft=="boolean"?`${e.query} draft:${e.isDraft}`:e.query;return Ne("pr",g,e.cursor,a,c,n)},u=await I(this.config,i(!0),t);u.body.errors&&ge(u.body.errors)&&(this.config.baseUrl||t.baseUrl)&&(u=await I(this.config,i(!1),t));let{data:l}=u.body;if(!l)throw new Error(((p=u.body.errors)==null?void 0:p[0].message)||u.statusText||"Unknown error");return{pageInfo:{hasNextPage:l.search.pageInfo.hasNextPage,endCursor:l.search.pageInfo.endCursor},data:((d=l.search.nodes)==null?void 0:d.map(je))||[]}}async searchIssues(e,t={}){var u,l;let n=await this.getScopes(t),o=T(n),a=await I(this.config,Ne("issue",e.query,e.cursor,o),t),{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(ds))||[]}}async getPullRequestsAssociatedWithUser(e,t={}){return this.searchPullRequests({query:`involves:${e.username}`,cursor:e.cursor},t)}async getPullRequestsForRepos(e,t={}){let{assigneeLogins:n,updatedBefore:o,authorLogin:a,repos:i,reviewRequestedLogin:u,startQuery:l,mentionLogin:p}=e,d=Qe(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},t)}async getPullRequestForRepo(e,t={}){var d,c;let n=await this.getEnterpriseVersion(t),o=await this.getScopes(t),a=T(o),i=g=>({query:`query getPullRequest(
|
|
433
433
|
$owner: String!
|
|
434
434
|
$name: String!
|
|
435
435
|
$number: Int!
|
|
@@ -442,7 +442,7 @@ query getBlame($owner: String!, $name: String!, $ref: String!, $path: String!) {
|
|
|
442
442
|
${ce(g,a,n)}
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
|
-
}`,variables:{owner:e.repo.namespace,name:e.repo.name,number:e.number}}),u=await I(this.config,i(!0),t);u.body.errors&&ge(u.body.errors)&&(this.config.baseUrl||t.baseUrl)&&(u=await I(this.config,i(!1),t));let{data:l}=u.body;if(!l)throw new Error(((d=u.body.errors)==null?void 0:d[0].message)||u.statusText||"Unknown error");let p=(c=u.body.data)==null?void 0:c.repository.pullRequest;return{data:p?
|
|
445
|
+
}`,variables:{owner:e.repo.namespace,name:e.repo.name,number:e.number}}),u=await I(this.config,i(!0),t);u.body.errors&&ge(u.body.errors)&&(this.config.baseUrl||t.baseUrl)&&(u=await I(this.config,i(!1),t));let{data:l}=u.body;if(!l)throw new Error(((d=u.body.errors)==null?void 0:d[0].message)||u.statusText||"Unknown error");let p=(c=u.body.data)==null?void 0:c.repository.pullRequest;return{data:p?je(p):null}}async getPullRequestByGraphQLId(e,t={}){var d,c;let n=await this.getEnterpriseVersion(t),o=await this.getScopes(t),a=T(o),i=g=>({query:`query getPullRequest(
|
|
446
446
|
$graphQLId: ID!
|
|
447
447
|
) {
|
|
448
448
|
node(id: $graphQLId) {
|
|
@@ -450,7 +450,7 @@ query getBlame($owner: String!, $name: String!, $ref: String!, $path: String!) {
|
|
|
450
450
|
${ce(g,a,n)}
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
|
-
}`,variables:{graphQLId:e.graphQLId}}),u=await I(this.config,i(!0),t);u.body.errors&&ge(u.body.errors)&&(this.config.baseUrl||t.baseUrl)&&(u=await I(this.config,i(!1),t));let{data:l}=u.body;if(!l)throw new Error(((d=u.body.errors)==null?void 0:d[0].message)||u.statusText||"Unknown error");let p=(c=u.body.data)==null?void 0:c.node;return{data:p?
|
|
453
|
+
}`,variables:{graphQLId:e.graphQLId}}),u=await I(this.config,i(!0),t);u.body.errors&&ge(u.body.errors)&&(this.config.baseUrl||t.baseUrl)&&(u=await I(this.config,i(!1),t));let{data:l}=u.body;if(!l)throw new Error(((d=u.body.errors)==null?void 0:d[0].message)||u.statusText||"Unknown error");let p=(c=u.body.data)==null?void 0:c.node;return{data:p?je(p):null}}async closePullRequest(e,t={}){var i,u,l;let{pullRequest:{graphQLId:n}}=e;if(!n)throw new Error('GitHub requires "graphQLId" for this function.');let o=`mutation ClosePullRequest($pullRequestGraphQLId: ID!) {
|
|
454
454
|
closePullRequest(input: { pullRequestId: $pullRequestGraphQLId }) {
|
|
455
455
|
pullRequest {
|
|
456
456
|
id
|
|
@@ -564,7 +564,7 @@ query getBlame($owner: String!, $name: String!, $ref: String!, $path: String!) {
|
|
|
564
564
|
id
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
|
-
}`;if(!((p=(l=(u=(await I(this.config,{query:a,variables:{pullRequestGraphQLId:n.graphQLId,labelGraphQLIds:o.map(d=>{if(!d.graphQLId)throw new Error('GitHub requires label "graphQLId" for this function.');return d.graphQLId})}},t)).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,t={}){let n=
|
|
567
|
+
}`;if(!((p=(l=(u=(await I(this.config,{query:a,variables:{pullRequestGraphQLId:n.graphQLId,labelGraphQLIds:o.map(d=>{if(!d.graphQLId)throw new Error('GitHub requires label "graphQLId" for this function.');return d.graphQLId})}},t)).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,t={}){let n=Qe(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},t)}async closeIssueWithReason(e,t={}){var u,l,p;let{issue:n,reason:o}=e;if(!n.graphQLId)throw new Error('GitHub requires "graphQLId" for this function.');let a=`mutation CloseIssueWithReason($issueGraphQLId: ID!, $reason: IssueClosedStateReason!) {
|
|
568
568
|
closeIssue(input: { issueId: $issueGraphQLId, stateReason: $reason }) {
|
|
569
569
|
issue {
|
|
570
570
|
id
|
|
@@ -614,7 +614,7 @@ query getLabelsForRepo($owner: String!, $name: String! $cursor: String, $first:
|
|
|
614
614
|
}
|
|
615
615
|
}
|
|
616
616
|
}
|
|
617
|
-
`,variables:{owner:n,name:o,cursor:a,first:v}},t);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(
|
|
617
|
+
`,variables:{owner:n,name:o,cursor:a,first:v}},t);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(He))??[]}}async getLabelsForRepo(e,t={}){var u,l,p,d;let{repo:{namespace:n,name:o},cursor:a}=e,i=await I(this.config,{query:`
|
|
618
618
|
query getLabelsForRepo($owner: String!, $name: String! $cursor: String, $first: Int!) {
|
|
619
619
|
repository(owner: $owner, name: $name) {
|
|
620
620
|
labels(first: $first, after: $cursor) {
|
|
@@ -628,7 +628,7 @@ query getLabelsForRepo($owner: String!, $name: String! $cursor: String, $first:
|
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
630
|
}
|
|
631
|
-
`,variables:{owner:n,name:o,cursor:a,first:v}},t);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(
|
|
631
|
+
`,variables:{owner:n,name:o,cursor:a,first:v}},t);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(ze))??[]}}};var cs="https://gitlab.com/api/v4",gs="https://gitlab.com/api/graphql",vt=/\/api\/v\d+$/,Et=r=>{if(r.endsWith("/api/graphql"))throw new Error("The graphql endpoint is being used as the baseUrl. This package uses both GraphQL and REST APIs, and the REST version cannot be assumed. Use the REST endpoint as the baseUrl instead.")},We=(r,s)=>{let e=s.baseUrl||r.baseUrl;return e?(e=e.replace(/\/$/,""),Et(e),e):cs},ms=(r,s)=>{let e=s.baseUrl||r.baseUrl;return e?(e=e.replace(/\/$/,""),Et(e),vt.test(e)&&(e=e.replace(vt,"")),`${e}/api/graphql`):gs},y=(r,s,e)=>{let t=R(e.token||r.token);return r.request({url:ms(r,e),method:"POST",headers:{...t,"Content-Type":"application/json"},body:JSON.stringify(s)})};var et=r=>r.split("/").slice(0,-1).join("/"),tt=r=>r.split("/").at(-1)??"",V=r=>({id:r.id.replace(B,""),graphQLId:r.id,namespace:et(r.fullPath),name:tt(r.fullPath),webUrl:r.webUrl}),Ct=r=>({id:r.id.replace(B,""),graphQLId:r.id,httpsUrl:r.httpUrlToRepo,namespace:et(r.fullPath),name:tt(r.fullPath),sshUrl:r.sshUrlToRepo,webUrl:r.webUrl}),hs={assigned:"assignedMergeRequests",authored:"authoredMergeRequests",reviewRequested:"reviewRequestedMergeRequests"},fs={CAN_BE_MERGED:"MERGEABLE",CANNOT_BE_MERGED:"CONFLICTS",CANNOT_BE_MERGED_RECHECK:"UNKNOWN",UNCHECKED:"UNKNOWN",CHECKING:"UNKNOWN"},Rs="gid://gitlab/User/",B="gid://gitlab/Project/",Is="gid://gitlab/MergeRequest/",bs="gid://gitlab/Issue/",ys="gid://gitlab/ProjectLabel/",ws="gid://gitlab/Milestone/",Ps="gid://gitlab/Ci::Build/",st=`
|
|
632
632
|
description
|
|
633
633
|
dueDate
|
|
634
634
|
id
|
|
@@ -637,7 +637,7 @@ startDate
|
|
|
637
637
|
state
|
|
638
638
|
title
|
|
639
639
|
webPath
|
|
640
|
-
`,
|
|
640
|
+
`,Je=`
|
|
641
641
|
id
|
|
642
642
|
fullPath
|
|
643
643
|
webUrl
|
|
@@ -653,12 +653,12 @@ username
|
|
|
653
653
|
publicEmail
|
|
654
654
|
avatarUrl
|
|
655
655
|
webUrl
|
|
656
|
-
`,
|
|
656
|
+
`,rt=`
|
|
657
657
|
color
|
|
658
658
|
description
|
|
659
659
|
id
|
|
660
660
|
title
|
|
661
|
-
`,
|
|
661
|
+
`,Ke=`
|
|
662
662
|
author {
|
|
663
663
|
${x}
|
|
664
664
|
}
|
|
@@ -675,7 +675,7 @@ id
|
|
|
675
675
|
iid
|
|
676
676
|
labels {
|
|
677
677
|
nodes {
|
|
678
|
-
${
|
|
678
|
+
${rt}
|
|
679
679
|
}
|
|
680
680
|
}
|
|
681
681
|
state
|
|
@@ -686,7 +686,7 @@ upvotes
|
|
|
686
686
|
userNotesCount
|
|
687
687
|
webUrl
|
|
688
688
|
milestone {
|
|
689
|
-
${
|
|
689
|
+
${st}
|
|
690
690
|
}
|
|
691
691
|
`,Ss=`
|
|
692
692
|
stages {
|
|
@@ -704,7 +704,7 @@ stages {
|
|
|
704
704
|
name
|
|
705
705
|
}
|
|
706
706
|
}
|
|
707
|
-
`,
|
|
707
|
+
`,Ve=(r,s,e)=>`
|
|
708
708
|
id
|
|
709
709
|
state
|
|
710
710
|
approved
|
|
@@ -749,19 +749,19 @@ reviewers {
|
|
|
749
749
|
mergeStatusEnum
|
|
750
750
|
labels {
|
|
751
751
|
nodes {
|
|
752
|
-
${
|
|
752
|
+
${rt}
|
|
753
753
|
}
|
|
754
754
|
}
|
|
755
755
|
${r?"project { id httpUrlToRepo fullPath sshUrlToRepo webUrl } sourceProject { id httpUrlToRepo fullPath sshUrlToRepo webUrl }":""}
|
|
756
|
-
${s?`milestone { ${
|
|
756
|
+
${s?`milestone { ${st} }`:""}
|
|
757
757
|
${e?`headPipeline { ${Ss} }`:""}
|
|
758
|
-
`,
|
|
758
|
+
`,F=r=>`${r.namespace}/${r.name}`,qs=r=>`${r.namespace}/${r.name}`,Xe=r=>{var s;return{id:r.id.replace(B,""),graphQLId:r.id,namespace:et(r.fullPath),name:tt(r.fullPath),webUrl:r.webUrl,httpsUrl:r.httpUrlToRepo,sshUrl:r.sshUrlToRepo,defaultBranch:(s=r.repository)!=null&&s.rootRef?{name:r.repository.rootRef}:null,permission:null}},vs={opened:"OPEN",merged:"MERGED",closed:"CLOSED"},k=(r,s)=>{let e=r.avatarUrl;return!s&&(e!=null&&e.startsWith("/"))&&(e=`https://gitlab.com${e}`),{id:r.id.replace(Rs,""),graphQLId:r.id,name:r.name,username:r.username,email:r.publicEmail??null,avatarUrl:e,url:r.webUrl}},nt=r=>({color:r.color,description:r.description,id:r.id.replace(ys,""),graphQLId:r.id,name:r.title}),Es=(r,s)=>r?r==="FAILED"&&s?"WARNING":{CANCELED:"CANCELLED",CREATED:"PENDING",FAILED:"FAILED",MANUAL:"OPTIONAL_ACTION_REQUIRED",PENDING:"PENDING",PREPARING:"RUNNING",RUNNING:"RUNNING",SCHEDULED:"PENDING",SKIPPED:"SKIPPED",SUCCESS:"SUCCESS",WAITING_FOR_CALLBACK:"PENDING",WAITING_FOR_RESOURCE:"PENDING"}[r]:null,Ye=(r,s,e,t)=>{var o,a,i,u,l,p,d,c,g,m,f,b;let n=(o=r.reviewers)!=null&&o.nodes?r.reviewers.nodes.map(h=>{var w,q;return{reviewer:k(h,t),state:(w=h.mergeRequestInteraction)!=null&&w.approved?"APPROVED":((q=h.mergeRequestInteraction)==null?void 0:q.reviewState)==="REVIEWED"?"CHANGES_REQUESTED":"CHANGES_REQUESTED"}}):null;return{id:r.id.replace(Is,""),graphQLId:r.id,title:r.title,number:parseInt(r.iid,10),state:vs[r.state],commentCount:r.userNotesCount||0,upvoteCount:r.upvotes,author:r.author?k(r.author,t):null,createdDate:new Date(r.createdAt),isDraft:r.draft,repository:{id:s.id,graphQLId:s.graphQLId,name:s.name,owner:{login:s.namespace},remoteInfo:s.httpsUrl&&s.sshUrl?{cloneUrlHTTPS:s.httpsUrl,cloneUrlSSH:s.sshUrl}:null},headRepository:e?{id:e.id,graphQLId:e.graphQLId,name:e.name,owner:{login:e.namespace},remoteInfo:{cloneUrlHTTPS:e.httpsUrl,cloneUrlSSH:e.sshUrl}}:null,headCommit:{buildStatuses:((u=(i=(a=r.headPipeline)==null?void 0:a.stages)==null?void 0:i.nodes)==null?void 0:u.flatMap(h=>{var w,q;return((q=(w=h.jobs)==null?void 0:w.nodes)==null?void 0:q.map(E=>({completedAt:E.finishedAt?new Date(E.finishedAt):null,description:null,name:E.name??null,state:Es(E.status,E.allowFailure),stage:h.name??null,startedAt:new Date(E.createdAt),url:`${s.webUrl}/-/jobs/${E.id.replace(Ps,"")}`})))??[]}))??[]},baseRef:{name:r.targetBranch,oid:((l=r.diffRefs)==null?void 0:l.baseSha)??null},headRef:{name:r.sourceBranch,oid:((p=r.diffRefs)==null?void 0:p.headSha)??null},url:r.webUrl,updatedDate:new Date(r.updatedAt),closedDate:r.mergedAt?new Date(r.mergedAt):null,mergedDate:r.mergedAt?new Date(r.mergedAt):null,assignees:(d=r.assignees)!=null&&d.nodes?r.assignees.nodes.map(h=>k(h,t)):null,reviews:n,reviewDecision:r.approved?"APPROVED":Q(n),additions:((c=r.diffStatsSummary)==null?void 0:c.additions)||0,deletions:((g=r.diffStatsSummary)==null?void 0:g.deletions)||0,fileCount:((m=r.diffStatsSummary)==null?void 0:m.fileCount)||0,commitCount:r.commitCount||0,mergeableState:fs[r.mergeStatusEnum],milestone:r.milestone?ot(r.milestone,s.webUrl):null,labels:((b=(f=r.labels)==null?void 0:f.nodes)==null?void 0:b.map(nt))??[],permissions:null}},Ze=(r,s,e)=>{var t,n;return{author:k(r.author,e),assignees:r.assignees.nodes.map(o=>k(o,e)),commentCount:r.userNotesCount,closedDate:r.closedAt?new Date(r.closedAt):null,createdDate:new Date(r.createdAt),description:r.description,graphQLId:r.id,id:r.id.replace(bs,""),labels:((n=(t=r.labels)==null?void 0:t.nodes)==null?void 0:n.map(nt))??[],number:r.iid,repository:{id:s.id.replace(B,""),graphQLId:s.id,name:s.name,owner:{login:s.namespace}},updatedDate:new Date(r.updatedAt),upvoteCount:r.upvotes,state:{name:r.state,color:null},type:r.type,title:r.title,url:r.webUrl,milestone:r.milestone?ot(r.milestone,s.webUrl):null}},ot=(r,s)=>({id:r.id.replace(ws,""),graphQLId:r.id,number:parseInt(r.iid,10),title:r.title,description:r.description,isOpen:r.state==="active",url:`${s}/-/${r.webPath.replace(/.+?\/-\//,"")}`,startDate:r.startDate?new Date(r.startDate):null,dueDate:r.dueDate?new Date(r.dueDate):null}),X=class extends ${getIsSelfHosted(s){return!!s.baseUrl||!!this.config.baseUrl}async getCurrentUser(s={},e={}){var o;let n=(o=(await y(this.config,{query:`
|
|
759
759
|
query getCurrentUser {
|
|
760
760
|
currentUser {
|
|
761
761
|
${x}
|
|
762
762
|
}
|
|
763
763
|
}
|
|
764
|
-
`},e)).body.data)==null?void 0:o.currentUser;if(!n)throw new Error("Current user not found.");return{data:k(n,this.getIsSelfHosted(e))}}async getUserForCommit(s,e={}){var a,i,u,l;let t=
|
|
764
|
+
`},e)).body.data)==null?void 0:o.currentUser;if(!n)throw new Error("Current user not found.");return{data:k(n,this.getIsSelfHosted(e))}}async getUserForCommit(s,e={}){var a,i,u,l;let t=F(s.repo),o=(l=(u=(i=(a=(await y(this.config,{query:`
|
|
765
765
|
query getUserForCommit($fullPath: ID!, $oid: String!) {
|
|
766
766
|
project(fullPath: $fullPath) {
|
|
767
767
|
repository {
|
|
@@ -810,22 +810,22 @@ query getAccountsForRepo(
|
|
|
810
810
|
}
|
|
811
811
|
}
|
|
812
812
|
}
|
|
813
|
-
`,variables:{fullPath:`${t}/${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(f=>f.user).filter(f=>f!==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(f=>k(f,this.getIsSelfHosted(e))))??[]}}async getRepo(s,e={}){var o;let t=
|
|
813
|
+
`,variables:{fullPath:`${t}/${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(f=>f.user).filter(f=>f!==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(f=>k(f,this.getIsSelfHosted(e))))??[]}}async getRepo(s,e={}){var o;let t=F(s),n=await y(this.config,{query:`
|
|
814
814
|
query getRepo($fullPath: ID!) {
|
|
815
815
|
project(fullPath: $fullPath) {
|
|
816
|
-
${
|
|
816
|
+
${Je}
|
|
817
817
|
}
|
|
818
818
|
}
|
|
819
|
-
`,variables:{fullPath:t}},e);if(!((o=n.body.data)!=null&&o.project))throw new Error(`Repository ${t} not found`);return{data:
|
|
819
|
+
`,variables:{fullPath:t}},e);if(!((o=n.body.data)!=null&&o.project))throw new Error(`Repository ${t} not found`);return{data:Xe(n.body.data.project)}}async getRepos(s,e={}){let n=s.map(F).map((u,l)=>`
|
|
820
820
|
getRepo_${l}: project(fullPath: "${u}") {
|
|
821
|
-
${
|
|
821
|
+
${Je}
|
|
822
822
|
}
|
|
823
823
|
`).join(`
|
|
824
824
|
`),o=await y(this.config,{query:`
|
|
825
825
|
query batchGetRepos {
|
|
826
826
|
${n}
|
|
827
827
|
}
|
|
828
|
-
`},e);if(!o.body.data)throw new Error(o.statusText||"Unknown error");let a=[],i=[];return s.forEach((u,l)=>{let p=o.body.data[`getRepo_${l}`];p?a.push(
|
|
828
|
+
`},e);if(!o.body.data)throw new Error(o.statusText||"Unknown error");let a=[],i=[];return s.forEach((u,l)=>{let p=o.body.data[`getRepo_${l}`];p?a.push(Xe(p)):i.push({input:u})}),{data:a,errors:i}}async getReposForCurrentUser(s,e={}){var o,a,i,u,l,p;let t=await y(this.config,{query:`
|
|
829
829
|
query getReposForCurrentUser($after: String) {
|
|
830
830
|
projects(membership: true first: 100 after: $after) {
|
|
831
831
|
pageInfo {
|
|
@@ -833,11 +833,11 @@ query getReposForCurrentUser($after: String) {
|
|
|
833
833
|
hasNextPage
|
|
834
834
|
}
|
|
835
835
|
nodes {
|
|
836
|
-
${
|
|
836
|
+
${Je}
|
|
837
837
|
}
|
|
838
838
|
}
|
|
839
839
|
}
|
|
840
|
-
`,variables:{after:s.cursor}},e);if(!((o=t.body.data)!=null&&o.projects))throw new Error(((a=t.body.errors)==null?void 0:a[0].message)||t.statusText||"Unknown error");let n=((u=(i=t.body.data)==null?void 0:i.projects)==null?void 0:u.nodes)||[];return{pageInfo:(p=(l=t.body.data)==null?void 0:l.projects)==null?void 0:p.pageInfo,data:n.map(
|
|
840
|
+
`,variables:{after:s.cursor}},e);if(!((o=t.body.data)!=null&&o.projects))throw new Error(((a=t.body.errors)==null?void 0:a[0].message)||t.statusText||"Unknown error");let n=((u=(i=t.body.data)==null?void 0:i.projects)==null?void 0:u.nodes)||[];return{pageInfo:(p=(l=t.body.data)==null?void 0:l.projects)==null?void 0:p.pageInfo,data:n.map(Xe)}}async getRefs(s,e,t={}){var u;let n=F(e.repo),o=new URL(`${We(this.config,t)}/projects/${encodeURIComponent(n)}/repository/${s}`);o.searchParams.set("page",((u=e.page)==null?void 0:u.toString())||"1"),o.searchParams.set("per_page",v.toString());let a=await this.config.request({url:o.toString(),headers:R(t.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(s,e={}){return this.getRefs("branches",s,e)}async getTags(s,e={}){return this.getRefs("tags",s,e)}async getBlame(s,e={}){let t=F(s.repo),n=new URL(`${We(this.config,e)}/projects/${encodeURIComponent(t)}/repository/files/${encodeURIComponent(s.path)}/blame`);n.searchParams.set("ref",s.ref);let o=await this.config.request({url:n.toString(),headers:R(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(s,e={}){var a,i;let t=hs[s.association],n=await y(this.config,{query:`
|
|
841
841
|
query getPullRequestsForUser($username: String! $cursor: String) {
|
|
842
842
|
user(username: $username) {
|
|
843
843
|
${t}(state:opened first:100 after:$cursor) {
|
|
@@ -846,12 +846,12 @@ query getPullRequestsForUser($username: String! $cursor: String) {
|
|
|
846
846
|
hasNextPage
|
|
847
847
|
}
|
|
848
848
|
nodes {
|
|
849
|
-
${
|
|
849
|
+
${Ve(!0,!0,!0)}
|
|
850
850
|
}
|
|
851
851
|
}
|
|
852
852
|
}
|
|
853
853
|
}
|
|
854
|
-
`,variables:{username:s.username,cursor:s.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[t];if(!o)throw new Error("Unexpected response");return{pageInfo:o.pageInfo,data:((i=o.nodes)==null?void 0:i.map(u=>
|
|
854
|
+
`,variables:{username:s.username,cursor:s.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[t];if(!o)throw new Error("Unexpected response");return{pageInfo:o.pageInfo,data:((i=o.nodes)==null?void 0:i.map(u=>Ye(u,Ct(u.project),Ct(u.sourceProject),this.getIsSelfHosted(e))))||[]}}async getPullRequestsAssociatedWithUser(s,e={}){var c;let[t,n,o]=((c=s.cursor)==null?void 0:c.split(";"))||[void 0,void 0,void 0],[a,i,u]=await Promise.all([t==="null"?null:this.getPullRequestsForUser({username:s.username,association:"authored",cursor:t},e),n==="null"?null:this.getPullRequestsForUser({username:s.username,association:"assigned",cursor:n},e),o==="null"?null:this.getPullRequestsForUser({username:s.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(s){let{updatedBefore:e,isDraft:t,authorLogin:n,assigneeLogins:o,reviewRequestedLogin:a}=s||{},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"),t!=null&&p("draft",t,"Boolean"),a&&p("reviewerUsername",a,"String"),{variables:i,variableTypes:u,mergeRequestArguments:l}}async getPullRequestsForRepo(s,e={}){var f,b,h;let{cursor:t,repo:n}=s||{},o=F(n),{variables:a,variableTypes:i,mergeRequestArguments:u}=this.getVariablesForPullRequests(s),l={fullPath:o,...a},p=await y(this.config,{query:`
|
|
855
855
|
query getPullRequestsForRepo(
|
|
856
856
|
$fullPath: ID!
|
|
857
857
|
$after: String
|
|
@@ -875,12 +875,12 @@ query getPullRequestsForRepo(
|
|
|
875
875
|
hasNextPage
|
|
876
876
|
}
|
|
877
877
|
nodes {
|
|
878
|
-
${
|
|
878
|
+
${Ve(!1,!0,!0)}
|
|
879
879
|
}
|
|
880
880
|
}
|
|
881
881
|
}
|
|
882
882
|
}
|
|
883
|
-
`,variables:{...l,after:t}},e),d=[],c=(f=p.body.data)==null?void 0:f.project,g=V(c||{id:"",fullPath:"",webUrl:""});return(((b=c==null?void 0:c.mergeRequests)==null?void 0:b.nodes)||[]).forEach(w=>{d.push(
|
|
883
|
+
`,variables:{...l,after:t}},e),d=[],c=(f=p.body.data)==null?void 0:f.project,g=V(c||{id:"",fullPath:"",webUrl:""});return(((b=c==null?void 0:c.mergeRequests)==null?void 0:b.nodes)||[]).forEach(w=>{d.push(Ye(w,g,null,this.getIsSelfHosted(e)))}),{pageInfo:(h=c==null?void 0:c.mergeRequests)==null?void 0:h.pageInfo,data:d}}async getPullRequestsForRepos(s,e={}){var c,g,m,f,b;let{cursor:t}=s||{},n=s.repoIds.map(h=>h.toString().startsWith(B)?h:`${B}${h}`),{variables:o,variableTypes:a,mergeRequestArguments:i}=this.getVariablesForPullRequests(s),u={projectIds:n,...o},l=await y(this.config,{query:`
|
|
884
884
|
query getPullRequests(
|
|
885
885
|
$projectIds: [ID!]
|
|
886
886
|
$after: String
|
|
@@ -905,13 +905,13 @@ query getPullRequests(
|
|
|
905
905
|
${i.length?i.join(" "):""}
|
|
906
906
|
) {
|
|
907
907
|
nodes {
|
|
908
|
-
${
|
|
908
|
+
${Ve(!1,!1,!1)}
|
|
909
909
|
}
|
|
910
910
|
}
|
|
911
911
|
}
|
|
912
912
|
}
|
|
913
913
|
}
|
|
914
|
-
`,variables:{...u,after:t}},e),p=[];return(((g=(c=l.body.data)==null?void 0:c.projects)==null?void 0:g.nodes)||[]).forEach(h=>{var E;let w=V(h);(((E=h.mergeRequests)==null?void 0:E.nodes)||[]).forEach(se=>{p.push(
|
|
914
|
+
`,variables:{...u,after:t}},e),p=[];return(((g=(c=l.body.data)==null?void 0:c.projects)==null?void 0:g.nodes)||[]).forEach(h=>{var E;let w=V(h);(((E=h.mergeRequests)==null?void 0:E.nodes)||[]).forEach(se=>{p.push(Ye(se,w,null,this.getIsSelfHosted(e)))})}),{pageInfo:(b=(f=(m=l.body)==null?void 0:m.data)==null?void 0:f.projects)==null?void 0:b.pageInfo,data:p}}async closePullRequest(s,e={}){var i,u,l;let{pullRequest:t}=s,n=`mutation ClosePullRequest($fullPath: ID!, $pullRequestId: String!) {
|
|
915
915
|
mergeRequestUpdate(input: { projectPath: $fullPath, iid: $pullRequestId, state: CLOSED }) {
|
|
916
916
|
errors,
|
|
917
917
|
mergeRequest {
|
|
@@ -983,11 +983,11 @@ query GetSingleIssue($projectId: ID!, $issueNumber: String!) {
|
|
|
983
983
|
fullPath
|
|
984
984
|
webUrl
|
|
985
985
|
issue(iid: $issueNumber) {
|
|
986
|
-
${
|
|
986
|
+
${Ke}
|
|
987
987
|
}
|
|
988
988
|
}
|
|
989
989
|
}
|
|
990
|
-
`,variables:{issueNumber:s.number,projectId:t}},e);if(!((o=n.body.data)!=null&&o.project))throw new Error(`Repository ${t} not found`);if(!((i=(a=n.body.data)==null?void 0:a.project)!=null&&i.issue))throw new Error(`Issue ${s.number} not found`);return{data:
|
|
990
|
+
`,variables:{issueNumber:s.number,projectId:t}},e);if(!((o=n.body.data)!=null&&o.project))throw new Error(`Repository ${t} not found`);if(!((i=(a=n.body.data)==null?void 0:a.project)!=null&&i.issue))throw new Error(`Issue ${s.number} not found`);return{data:Ze(n.body.data.project.issue,V(n.body.data.project),this.getIsSelfHosted(e))}}getVariablesForIssues(s){let{updatedBefore:e,authorLogin:t,assigneeLogins:n}=s||{},o={},a=[],i=[],u=(l,p,d)=>{a.push(`$${l}: ${d}`),i.push(`${l}: $${l}`),o[l]=p};return e&&u("updatedBefore",e,"Time"),t&&u("authorUsername",t,"String"),n&&u("assigneeUsername",n[0],"String"),{variables:o,variableTypes:a,issueArguments:i}}async getIssuesForRepo(s,e={}){var b,h,w;let{cursor:t,repo:n}=s||{},o=F(n),{variables:a,variableTypes:i,issueArguments:u}=this.getVariablesForIssues(s),l={fullPath:o,...a},p=`
|
|
991
991
|
query GetIssuesFromProject(
|
|
992
992
|
$fullPath: ID!
|
|
993
993
|
$after: String
|
|
@@ -1007,7 +1007,7 @@ query GetSingleIssue($projectId: ID!, $issueNumber: String!) {
|
|
|
1007
1007
|
${u.length?u.join(" "):""}
|
|
1008
1008
|
) {
|
|
1009
1009
|
nodes {
|
|
1010
|
-
${
|
|
1010
|
+
${Ke}
|
|
1011
1011
|
}
|
|
1012
1012
|
pageInfo {
|
|
1013
1013
|
endCursor
|
|
@@ -1015,7 +1015,7 @@ query GetSingleIssue($projectId: ID!, $issueNumber: String!) {
|
|
|
1015
1015
|
}
|
|
1016
1016
|
}
|
|
1017
1017
|
}
|
|
1018
|
-
}`,d=await y(this.config,{query:p,variables:{...l,after:t}},e),c=[],g=(b=d.body.data)==null?void 0:b.project,m=V(g||{id:"",fullPath:"",webUrl:""});return(((h=g==null?void 0:g.issues)==null?void 0:h.nodes)||[]).forEach(q=>{c.push(
|
|
1018
|
+
}`,d=await y(this.config,{query:p,variables:{...l,after:t}},e),c=[],g=(b=d.body.data)==null?void 0:b.project,m=V(g||{id:"",fullPath:"",webUrl:""});return(((h=g==null?void 0:g.issues)==null?void 0:h.nodes)||[]).forEach(q=>{c.push(Ze(q,m,this.getIsSelfHosted(e)))}),{pageInfo:((w=g==null?void 0:g.issues)==null?void 0:w.pageInfo)??{endCursor:null,hasNextPage:!1},data:c.sort((q,E)=>(q.updatedDate||q.createdDate).getTime()-(E.updatedDate||E.createdDate).getTime())}}async getIssuesForRepos(s,e={}){var g,m,f,b,h;let{cursor:t}=s||{},n=s.repoIds.map(w=>w.toString().startsWith(B)?w:`${B}${w}`),{variables:o,variableTypes:a,mergeRequestArguments:i}=this.getVariablesForPullRequests(s),u={projectIds:n,...o},l=`
|
|
1019
1019
|
query GetIssuesFromProject(
|
|
1020
1020
|
$projectIds: [ID!]
|
|
1021
1021
|
$after: String
|
|
@@ -1040,12 +1040,12 @@ query GetSingleIssue($projectId: ID!, $issueNumber: String!) {
|
|
|
1040
1040
|
${i.length?i.join(" "):""}
|
|
1041
1041
|
) {
|
|
1042
1042
|
nodes {
|
|
1043
|
-
${
|
|
1043
|
+
${Ke}
|
|
1044
1044
|
}
|
|
1045
1045
|
}
|
|
1046
1046
|
}
|
|
1047
1047
|
}
|
|
1048
|
-
}`,p=await y(this.config,{query:l,variables:{...u,after:t}},e),d=[];return(((m=(g=p.body.data)==null?void 0:g.projects)==null?void 0:m.nodes)||[]).forEach(w=>{var se;let q=V(w);(((se=w.issues)==null?void 0:se.nodes)||[]).forEach(Dt=>d.push(
|
|
1048
|
+
}`,p=await y(this.config,{query:l,variables:{...u,after:t}},e),d=[];return(((m=(g=p.body.data)==null?void 0:g.projects)==null?void 0:m.nodes)||[]).forEach(w=>{var se;let q=V(w);(((se=w.issues)==null?void 0:se.nodes)||[]).forEach(Dt=>d.push(Ze(Dt,q,this.getIsSelfHosted(e))))}),{pageInfo:((h=(b=(f=p.body)==null?void 0:f.data)==null?void 0:b.projects)==null?void 0:h.pageInfo)??{endCursor:null,hasNextPage:!1},data:d.sort((w,q)=>(w.updatedDate||w.createdDate).getTime()-(q.updatedDate||q.createdDate).getTime())}}async setIssueState(s,e={}){var i,u,l;let{issue:t,state:n}=s;if(!t.repository)throw new Error('GitLab requires "repository" for this function.');let o=`mutation SetIssueState($fullPath: ID!, $issueId: String!, $status: IssueStateEvent!) {
|
|
1049
1049
|
updateIssue(input: { projectPath: $fullPath, iid: $issueId, stateEvent: $status }) {
|
|
1050
1050
|
issue {
|
|
1051
1051
|
id
|
|
@@ -1085,7 +1085,7 @@ query getLabelsForRepo(
|
|
|
1085
1085
|
webUrl
|
|
1086
1086
|
milestones(after: $after) {
|
|
1087
1087
|
nodes {
|
|
1088
|
-
${
|
|
1088
|
+
${st}
|
|
1089
1089
|
}
|
|
1090
1090
|
pageInfo {
|
|
1091
1091
|
endCursor
|
|
@@ -1094,7 +1094,7 @@ query getLabelsForRepo(
|
|
|
1094
1094
|
}
|
|
1095
1095
|
}
|
|
1096
1096
|
}
|
|
1097
|
-
`,variables:{fullPath:`${t}/${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 f,b;return
|
|
1097
|
+
`,variables:{fullPath:`${t}/${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 f,b;return ot(m,((b=(f=a.body.data)==null?void 0:f.project)==null?void 0:b.webUrl)||"")}))??[]}}async getLabelsForRepo(s,e={}){var i,u,l,p,d,c,g;let{repo:{namespace:t,name:n},cursor:o}=s,a=await y(this.config,{query:`
|
|
1098
1098
|
query getLabelsForRepo(
|
|
1099
1099
|
$fullPath: ID!
|
|
1100
1100
|
$after: String
|
|
@@ -1104,7 +1104,7 @@ query getLabelsForRepo(
|
|
|
1104
1104
|
) {
|
|
1105
1105
|
labels(after: $after) {
|
|
1106
1106
|
nodes {
|
|
1107
|
-
${
|
|
1107
|
+
${rt}
|
|
1108
1108
|
}
|
|
1109
1109
|
pageInfo {
|
|
1110
1110
|
endCursor
|
|
@@ -1113,5 +1113,5 @@ query getLabelsForRepo(
|
|
|
1113
1113
|
}
|
|
1114
1114
|
}
|
|
1115
1115
|
}
|
|
1116
|
-
`,variables:{fullPath:`${t}/${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(
|
|
1117
|
-
OR comment ~ currentUser() OR summary ~ currentUser() OR description ~ currentUser())`,l=(await r.request({url:`${j(r,t,o)}/rest/api/2/search?jql=${i}&startAt=${a}&maxResults=${me}&fields=${ot.join(",")}&expand=transitions`,headers:R(t.token||r.token)})).body.issues.map(d=>at(d,e,o)),p=l.length==me;return{data:l,pageInfo:{hasNextPage:p,nextPage:p?a+l.length:null}}},Ie=async(r,s,e,t={})=>{let{assigneeLogins:n,authorLogin:o,mentionLogin:a,page:i,project:u,resourceId:l}=s||{},p=i??0,d=[`project = "${u}"`,"statusCategory != Done"];o&&d.push(`creator in ("${o}")`),n&&n.length!==0&&d.push(`assignee in ("${n.join('", "')}")`),a&&d.push(`comment ~ "${a}"`);let g=(await r.request({url:`${j(r,t,l)}/rest/api/2/search?jql=${d.join(" AND ")}&startAt=${p}&maxResults=${me}&fields=${ot.join(",")}&expand=transitions`,headers:R(t.token||r.token)})).body.issues.map(f=>at(f,e,l)),m=g.length==me;return{data:g,pageInfo:{hasNextPage:m,nextPage:m?p+g.length:null}}},be=async(r,s,e={})=>{let{issue:t,labels:n}=s;if(!t.project)throw new Error('Jira requires a "project" for this function.');let o={fields:{labels:n.map(a=>a.name)}};await r.request({method:"PUT",url:`${j(r,e,t.project.resourceId??void 0)}/rest/api/2/issue/${t.id}`,body:JSON.stringify(o),headers:{...R(e.token||r.token),"Content-Type":"application/json"}})},ye=async(r,s,e={})=>{let{issue:t,components:n}=s;if(!t.project)throw new Error('Jira requires a "project" for this function.');let o={fields:{components:n.map(a=>({id:a.id}))}};await r.request({method:"PUT",url:`${j(r,e,t.project.resourceId??void 0)}/rest/api/2/issue/${t.id}`,body:JSON.stringify(o),headers:{...R(e.token||r.token),"Content-Type":"application/json"}})},we=async(r,s,e={})=>{let{issue:t,status:n}=s;if(!t.project)throw new Error('Jira requires a "project" for this function.');if(!n.id)throw new Error('Jira requires a status "id" for this function.');let o={transition:{id:n.id}};await r.request({method:"POST",url:`${j(r,e,t.project.resourceId??void 0)}/rest/api/2/issue/${t.id}/transitions`,body:JSON.stringify(o),headers:{...R(e.token||r.token),"Content-Type":"application/json"}})},Pe=async(r,s,e={})=>{let{resourceId:t,projectIdOrKey:n}=s,o=new URL(`${j(r,e,t)}/rest/api/2/project/${n}/components`);return{data:(await r.request({url:o.toString(),headers:R(e.token||r.token)})).body}};var Y="https://api.atlassian.com/ex/jira",it=100,Z=class extends D{constructor(){super(...arguments);this._resourceUrlCache={}}async getResourceUrl(e,t={}){var a;let n=t.token||this.config.token;if(!n)return null;let o=this._resourceUrlCache[n];return o?o[e.resourceId]??null:(await this.getJiraResourcesForCurrentUser(t),((a=this._resourceUrlCache[n])==null?void 0:a[e.resourceId])??null)}async getCurrentUserForResource(e,t={}){let n=await this.getResourceUrl({resourceId:e.resourceId},t),o=await this.config.request({url:`${t.baseUrl||Y}/${e.resourceId}/rest/api/2/myself`,headers:R(t.token||this.config.token)});return{data:{name:o.body.displayName,email:o.body.emailAddress,avatarUrl:o.body.avatarUrls["48x48"],id:o.body.accountId,username:o.body.displayName,url:n?`${n}/jira/people/${o.body.accountId}`:null}}}async getJiraResourcesForCurrentUser(e={}){let t=await this.config.request({url:`${e.baseUrl||"https://api.atlassian.com/"}/oauth/token/accessible-resources`,headers:R(e.token||this.config.token)}),n=e.token||this.config.token,o=n?this._resourceUrlCache[n]||{}:void 0,a=t.body.map(i=>(o&&(o[i.id]=i.url),{avatarUrl:i.avatarUrl,id:i.id,name:i.name,url:i.url}));return n&&(this._resourceUrlCache[n]=o),{data:a}}async getJiraProjectsForResource(e,t={}){let n=new URL(`${t.baseUrl||Y}/${e.resourceId}/rest/api/2/project/search`);n.searchParams.set("maxResults",it.toString()),e.cursor&&n.searchParams.set("startAt",e.cursor);let o=await this.config.request({url:n.toString(),headers:R(t.token||this.config.token)});return{pageInfo:{hasNextPage:o.body.values.length!==0,endCursor:(o.body.startAt+o.body.values.length).toString()},data:o.body.values.map(a=>({id:a.id,key:a.key,name:a.name,resourceId:e.resourceId}))}}async getJiraProjectsForResources(e,t={}){let n=[];return await Promise.all(e.resourceIds.map(async o=>{let a=await this.getJiraProjectsForResource({resourceId:o},t);n.push(...a.data)})),{data:n}}async getAccountsForJiraProject(e,t={}){let{resourceId:n,projectKey:o,cursor:a}=e,i=await this.getResourceUrl({resourceId:n},t),u=new URL(`${t.baseUrl||Y}/${n}/rest/api/2/user/assignable/search`);u.searchParams.set("maxResults",it.toString()),a&&u.searchParams.set("startAt",a),u.searchParams.set("project",o);let l=await this.config.request({url:u.toString(),headers:R(t.token||this.config.token)});return{pageInfo:{hasNextPage:l.body.length!==0,endCursor:((a?parseInt(a):0)+l.body.length).toString()},data:l.body.filter(p=>p.accountType!=="app"&&p.active).map(p=>he(p,i,!1))}}async getComponentsForJiraProject(e,t={}){return await Pe(this.config,e,t)}async getIssue(e,t={}){let n=await this.getResourceUrl({resourceId:e.resourceId},t);return await fe(this.config,e,n,t)}async getIssuesForProject(e,t={}){let n=await this.getResourceUrl({resourceId:e.resourceId},t);return await Ie(this.config,e,n,t)}async getIssuesForResourceForCurrentUser(e,t={}){let n=await this.getResourceUrl({resourceId:e.resourceId},t);return await Re(this.config,e,n,t)}async setIssueStatus(e,t={}){await we(this.config,e,t)}async setIssueAssignee(e,t={}){let{issue:n,assignee:o}=e;if(!n.project)throw new Error('Jira Cloud requires a "project" for this function.');if(!n.project.resourceId)throw new Error('Jira Cloud requires a project "resourceId" for this function.');let a={accountId:o==null?void 0:o.id};await this.config.request({method:"PUT",url:`${t.baseUrl||Y}/${n.project.resourceId}/rest/api/2/issue/${n.id}/assignee`,body:JSON.stringify(a),headers:{...R(t.token||this.config.token),"Content-Type":"application/json"}})}async setIssueComponents(e,t={}){await ye(this.config,e,t)}async setIssueLabels(e,t={}){await be(this.config,e,t)}async getLabelsForResource(e,t={}){let{resourceId:n,cursor:o}=e,a=new URL(`${t.baseUrl||Y}/${n}/rest/api/2/label`);a.searchParams.set("maxResults",it.toString()),o&&a.searchParams.set("startAt",o);let i=await this.config.request({url:a.toString(),headers:R(t.token||this.config.token)});return{pageInfo:{hasNextPage:!i.body.isLast,endCursor:(i.body.startAt+i.body.values.length).toString()},data:i.body.values.map(u=>({color:null,description:null,id:null,name:u}))}}};var ee=class extends ${async getCurrentUser(s={}){let e=await this.config.request({url:`${(s==null?void 0:s.baseUrl)||this.config.baseUrl}/rest/api/2/myself`,headers:R((s==null?void 0:s.token)||this.config.token)});return{data:{name:e.body.displayName,email:e.body.emailAddress,avatarUrl:e.body.avatarUrls["48x48"],id:e.body.key,username:e.body.displayName,url:null}}}async getJiraProjects(s={}){return{data:(await this.config.request({url:`${(s==null?void 0:s.baseUrl)||this.config.baseUrl}/rest/api/2/project`,headers:R((s==null?void 0:s.token)||this.config.token)})).body.map(t=>({id:t.id,name:t.name}))}}async getIssue(s,e={}){if(!e.baseUrl)throw new Error('Jira Server requires a "baseUrl" for this function.');return await fe(this.config,s,e.baseUrl,e)}async getIssuesForProject(s,e={}){if(!e.baseUrl)throw new Error('Jira Server requires a "baseUrl" for this function.');return await Ie(this.config,s,e.baseUrl,e)}async getIssuesForResourceForCurrentUser(s,e={}){if(!e.baseUrl)throw new Error('Jira Server requires a "baseUrl" for this function.');return await Re(this.config,s,e.baseUrl,e)}async setIssueStatus(s,e={}){await we(this.config,s,e)}async setIssueLabels(s,e={}){await be(this.config,s,e)}async setIssueComponents(s,e={}){await ye(this.config,s,e)}async getLabels(s={}){return{data:(await this.config.request({url:`${(s==null?void 0:s.baseUrl)||this.config.baseUrl}/rest/api/2/jql/autocompletedata/suggestions?fieldName=labels`,headers:R(s.token||this.config.token)})).body.results.map(({displayName:t})=>({color:null,description:null,id:null,name:t}))}}async getComponentsForJiraProject(s,e={}){return await Pe(this.config,s,e)}};var _="https://api.trello.com",Gs=1e3,As=(r,s)=>{let e=new Date(1e3*parseInt(r.id.substring(0,8),16));return{id:r.id,commentCount:r.badges.comments,number:r.idShort.toString(),title:r.name,url:r.url,closedDate:null,createdDate:new Date(e.toISOString()),author:null,updatedDate:new Date(r.dateLastActivity),assignees:r.idMembers.map(t=>({id:t,username:null,name:null,email:null,avatarUrl:null,url:null})),description:null,state:s[r.idList??""]?{id:r.idList,name:s[r.idList].name,color:null}:null,type:null,repository:null,upvoteCount:r.badges.votes,labels:r.labels.map(t=>({color:t.color,description:null,id:t.id,name:t.name}))}},te=class extends D{async getCurrentUser(s,e={}){let t=await this.config.request({url:`${e.baseUrl||_}/1/members/me?key=${s.appKey}&token=${e.token||this.config.token}`,headers:R(e.token||this.config.token)});return{data:{name:t.body.fullName,email:t.body.email,avatarUrl:t.body.avatarHash?`https://trello-members.s3.amazonaws.com/${t.body.id}/${t.body.avatarHash}/50.png`:null,id:t.body.id,username:t.body.username,url:t.body.url}}}async getBoardsForCurrentUser(s,e={}){return{data:(await this.config.request({url:`${e.baseUrl||_}/1/members/me/boards?fields=name&key=${s.appKey}&token=${e.token||this.config.token}&filter=open`,headers:R(e.token||this.config.token)})).body.map(n=>({id:n.id,name:n.name}))}}async getListsForTrelloBoard(s,e={}){let{appKey:t,boardId:n}=s;return{data:(await this.config.request({url:`${e.baseUrl||_}/1/boards/${n}/lists?key=${t}&token=${e.token||this.config.token}`,headers:R(e.token||this.config.token)})).body}}async getAccountsForTrelloBoard(s,e={}){let{appKey:t,boardId:n}=s;return{data:(await this.config.request({url:`${e.baseUrl||_}/1/boards/${n}/members?key=${t}&token=${e.token||this.config.token}`,headers:R(e.token||this.config.token)})).body.map(a=>({id:a.id,name:a.fullName,username:a.username,email:null,avatarUrl:null,url:null}))}}async getIssuesForBoard(s,e={}){let t=["-is:archived","sort:edited"],{appKey:n,boardId:o,filterText:a,assigneeLogins:i,trelloBoardListsById:u}=s||{};i&&t.push("@me");let l=`${a?`${a}`:""}${t.join(" ")} board:${o}`;return{data:(await this.config.request({url:`${e.baseUrl||_}/1/search?key=${n}&query=${l}&cards_limit=${Gs}&token=${e.token||this.config.token}`,headers:R(e.token||this.config.token)})).body.cards.map(d=>As(d,u||{}))}}async updateIssue(s,e,t,n){return await this.config.request({method:"PUT",url:`${n.baseUrl||_}/1/cards/${e.id}?key=${s}&token=${n.token||this.config.token}&${t}`,headers:R(n.token||this.config.token)})}async setIssueStatus(s,e={}){let{appKey:t,issue:n,status:o}=s;if(!o.id)throw new Error('Trello requires a status "id" for this function.');let a=`idList=${o.id}`;if(!(await this.updateIssue(t,n,a,e)).body.id)throw new Error("Could not set issue status")}async setIssueAssignees(s,e={}){let{appKey:t,issue:n,assignees:o}=s,a=o.map(l=>l.id),i=`idMembers=${encodeURIComponent(a.join(","))}`;if(!(await this.updateIssue(t,n,i,e)).body.id)throw new Error("Could not set issue status")}async setIssueLabels(s,e={}){let{appKey:t,issue:n,labels:o}=s,a=o.map(u=>u.id).join(",");if(!(await this.config.request({method:"PUT",url:`${e.baseUrl||_}/1/cards/${n.id}?key=${t}&token=${e.token||this.config.token}&idLabels=${encodeURIComponent(a)}`,headers:R(e.token||this.config.token)})).body.id)throw new Error("Could not set issue status")}async setIssueArchived(s,e={}){let{appKey:t,issue:n,archived:o}=s;if(!(await this.config.request({method:"PUT",url:`${e.baseUrl||_}/1/cards/${n.id}?key=${t}&token=${e.token||this.config.token}&closed=${o}`,headers:R(e.token||this.config.token)})).body.id)throw new Error("Could not update issue archived status")}async archiveIssue(s,e={}){await this.setIssueArchived({...s,archived:!0},e)}async unArchiveIssue(s,e={}){await this.setIssueArchived({...s,archived:!1},e)}async getLabelsForBoard(s,e={}){let{appKey:t,boardId:n}=s;return{data:(await this.config.request({url:`${e.baseUrl||_}/1/boards/${n}/labels?key=${t}&token=${e.token||this.config.token}`,headers:R(e.token||this.config.token)})).body.map(a=>({color:a.color,description:null,id:a.id,name:a.name}))}}};var Se={};O(Se,{getIssueUniqueId:()=>Os,getPullRequestUniqueId:()=>Ts});var Os=(r,s,e,t="")=>{let n=[];return n.push(t),n.push(r),n.push(s),n.push(e),JSON.stringify(n)},Ts=(r,s,e,t,n="")=>{let o=[];return o.push(n),o.push(r),o.push(s),o.push(e),o.push(t),JSON.stringify(o)};var qe={};O(qe,{getIssueUniqueId:()=>xs,getPullRequestUniqueId:()=>ks});var xs=(r,s)=>JSON.stringify(["",r,s]),ks=(r,s)=>JSON.stringify(["",r,s]);var ve={};O(ve,{getIssueUniqueId:()=>_s,getPullRequestUniqueId:()=>Qs});var _s=(r,s,e)=>JSON.stringify([e,r,s]),Qs=(r,s,e)=>JSON.stringify([e,r,s]);var Ee={};O(Ee,{CHANGES_REQUESTED_BUCKET_ID:()=>zs,CONFLICTS_BUCKET_ID:()=>js,DRAFT_BUCKET_ID:()=>Js,FAILING_CI_BUCKET_ID:()=>Bs,NEEDS_MY_REVIEW_BUCKET_ID:()=>Ms,OTHER_BUCKET_ID:()=>Ks,READY_TO_MERGE_BUCKET_ID:()=>Ns,REVIEWER_COMMENTED_BUCKET_ID:()=>Hs,UNASSIGNED_REVIEWERS_BUCKET_ID:()=>Fs,WAITING_FOR_REVIEW_BUCKET_ID:()=>Ws,groupPullRequestsIntoBuckets:()=>Vs});var A=(r,s,e,t)=>({id:r,faIconName:e,name:s,priority:t,pullRequests:[]}),Ns="readyToMerge",Fs="unassignedReviewers",Bs="failingCI",js="conflicts",Ms="needsMyReview",zs="changesRequested",Hs="reviewerCommented",Ws="waitingForReview",Js="draft",Ks="other",Vs=(r,s)=>{let e={readyToMerge:A("readyToMerge","Ready to Merge","code-merge",0),unassignedReviewers:A("unassignedReviewers","Unassigned Reviewers","user-plus",1),failingCI:A("failingCI","Failing CI","circle-x",2),conflicts:A("conflicts","Resolve Conflicts","triangle-exclamation",3),needsMyReview:A("needsMyReview","Needs My Review","eye",4),changesRequested:A("changesRequested","Suggested Changes","file-plus",5),reviewerCommented:A("reviewerCommented","Reviewer Commented","comment",6),waitingForReview:A("waitingForReview","Waiting for Review","circle-pause",7),draft:A("draft","Draft","compass-drafting",8),other:A("other","Other","ellipsis",9)};return r.forEach(t=>{var u,l,p,d,c,g,m,f;let n=!0,o=((u=t.author)==null?void 0:u.id)===s.id,a=((l=t.assignees)==null?void 0:l.some(b=>b.id===s.id))??!1,i=((p=t.reviews)==null?void 0:p.some(b=>b.reviewer.id===s.id))??!1;(o||a&&!i)&&t.mergeableState==="MERGEABLE"&&(!t.reviewDecision||t.reviewDecision==="APPROVED")&&(((d=t.permissions)==null?void 0:d.canMerge)??!0)&&(e.readyToMerge.pullRequests.push(t),n=!1),o&&!((c=t.reviews)!=null&&c.length)&&(e.unassignedReviewers.pullRequests.push(t),n=!1),o&&((m=(g=t.headCommit)==null?void 0:g.buildStatuses)!=null&&m.some(b=>b.state==="ERROR"||b.state==="FAILED"))&&(e.failingCI.pullRequests.push(t),n=!1),o&&t.mergeableState==="CONFLICTS"&&(e.conflicts.pullRequests.push(t),n=!1),(f=t.reviews)!=null&&f.some(b=>b.reviewer.id===s.id&&b.state==="REVIEW_REQUESTED")&&(e.needsMyReview.pullRequests.push(t),n=!1),o&&t.reviewDecision==="CHANGES_REQUESTED"&&(e.changesRequested.pullRequests.push(t),n=!1),o&&t.reviewDecision==="COMMENTED"&&(e.reviewerCommented.pullRequests.push(t),n=!1),o&&t.reviewDecision==="REVIEW_REQUESTED"&&(e.waitingForReview.pullRequests.push(t),n=!1),o&&t.isDraft&&(e.draft.pullRequests.push(t),n=!1),n&&e.other.pullRequests.push(t)}),e};var Ce={};O(Ce,{getIssueUniqueId:()=>Xs,getPullRequestRank:()=>Zs,getPullRequestUniqueId:()=>Ys});var Xs=(r,s="")=>{let e=[];return e.push(s),e.push(r),JSON.stringify(e)},Ys=(r,s="")=>{let e=[];return e.push(s),e.push(r),JSON.stringify(e)},Zs=(r,s,e)=>{var a,i,u;let t=0,n,o;return(a=r.reviews)==null||a.forEach(l=>{l.reviewer.id===s&&(n=l.state),l.state==="CHANGES_REQUESTED"?o="CHANGES_REQUESTED":l.state==="APPROVED"&&o!=="CHANGES_REQUESTED"&&(o="APPROVED")}),o||(o="REVIEW_REQUESTED"),((i=r.author)==null?void 0:i.id)===s?t+=1e3:(u=r.assignees)!=null&&u.find(l=>l.id===s)?t+=900:n==="REVIEW_REQUESTED"?t+=800:e&&(t+=700),o==="APPROVED"?r.mergeableState==="MERGEABLE"?t+=100:r.mergeableState==="CONFLICTS"?t+=90:t+=80:o=="CHANGES_REQUESTED"&&(t+=70),t};var De={};O(De,{getIssueUniqueId:()=>er,getPullRequestUniqueId:()=>tr});var er=(r,s="")=>{let e=[];return e.push(s),e.push(r),JSON.stringify(e)},tr=(r,s="")=>{let e=[];return e.push(s),e.push(r),JSON.stringify(e)};var Le={};O(Le,{getIssueUniqueId:()=>sr,getJiraServerIssueUniqueId:()=>rr});var sr=(r,s,e)=>{let t=[];return t.push(""),t.push(r),t.push(s),t.push(e),JSON.stringify(t)},rr=(r,s,e)=>{let t=[];return t.push(e),t.push(""),t.push(r),t.push(s),JSON.stringify(t)};var Ue={};O(Ue,{getIssueUniqueId:()=>nr});var nr=(r,s,e,t="")=>{let n=[];return n.push(t),n.push(r),n.push(s),n.push(e),JSON.stringify(n)};var or=r=>{let s={request:r==null?void 0:r.request};return{azureDevOps:new H({...s,...r==null?void 0:r.azureDevOps}),bitbucket:new W({...s,...r==null?void 0:r.bitbucket}),bitbucketServer:new J({...s,...r==null?void 0:r.bitbucketServer}),github:new K({...s,...r==null?void 0:r.github}),gitlab:new X({...s,...r==null?void 0:r.gitlab}),jira:new Z({...s,...r==null?void 0:r.jira}),jiraServer:new ee({...s,...r==null?void 0:r.jiraServer}),trello:new te({...s,...r==null?void 0:r.trello})}},ar=or;var ir={azureDevOps:Se,bitbucket:qe,bitbucketServer:ve,github:Ce,gitlab:De,gitProvider:Ee,jira:Le,trello:Ue};
|
|
1116
|
+
`,variables:{fullPath:`${t}/${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(nt))??[]}}};var Cs="https://api.atlassian.com/ex/jira",me=10,at=["assignee","comment","summary","created","creator","updated","votes","issuetype","status","labels","components","project"],it=(r,s,e)=>{var o,a,i,u;let t=r.fields.assignee,n=!e;return{id:r.id,commentCount:r.fields.comment.comments.length,number:r.key,title:r.fields.summary,url:s?`${s}/browse/${r.key}`:null,closedDate:null,createdDate:new Date(r.fields.created),author:he(r.fields.creator,s,n),updatedDate:new Date(r.fields.updated),assignees:t?[he(t,s,n)]:[],description:null,repository:null,project:{name:r.fields.project.name,resourceId:e??null,namespace:null},state:$s(r.fields.status),statusTransitions:((o=r.transitions)==null?void 0:o.map(Ds))??[],components:((a=r.fields.components)==null?void 0:a.map(Ls))??[],type:r.fields.issuetype.name,upvoteCount:((i=r.fields.votes)==null?void 0:i.votes)||0,labels:((u=r.fields.labels)==null?void 0:u.map(l=>({color:null,description:null,id:null,name:l})))??[]}},Ds=r=>{let s;switch(r.to.statusCategory.name){case"To Do":s="TO_DO";break;case"In Progress":s="IN_PROGRESS";break;default:s="DONE";break}return{name:r.name,id:r.id,to:{id:r.to.id,name:r.to.name,color:r.to.statusCategory.colorName,category:s}}},Ls=r=>({description:r.description??null,id:r.id,name:r.name}),Us=(r,s,e)=>e&&r.name?`${s}/secure/ViewProfile.jspa?name=${encodeURIComponent(r.name)}`:`${s}/jira/people/${r.accountId}`,he=(r,s,e)=>({id:(e?r.key:r.accountId)??"",name:r.displayName,email:r.emailAddress,avatarUrl:r.avatarUrls["48x48"],username:r.displayName,url:Us(r,s,e)}),$s=r=>{let s;switch(r.statusCategory.name){case"To Do":s="TO_DO";break;case"In Progress":s="IN_PROGRESS";break;default:s="DONE";break}return{id:r.id,name:r.name,color:r.statusCategory.colorName,category:s}},j=(r,s,e)=>e?`${s.baseUrl||Cs}/${e}`:`${(s==null?void 0:s.baseUrl)||r.baseUrl}`,fe=async(r,s,e,t={})=>{let{number:n,resourceId:o}=s||{},a=await r.request({url:`${j(r,t,o)}/rest/api/2/issue/${n}?fields=${at.join(",")}&expand=transitions`,headers:R(t.token||r.token)});return{data:it(a.body,e,o)}},Re=async(r,s,e,t={})=>{let{page:n,resourceId:o}=s||{},a=n??0,i=`statusCategory != Done AND (creator = currentUser() OR assignee = currentUser()
|
|
1117
|
+
OR comment ~ currentUser() OR summary ~ currentUser() OR description ~ currentUser())`,l=(await r.request({url:`${j(r,t,o)}/rest/api/2/search?jql=${i}&startAt=${a}&maxResults=${me}&fields=${at.join(",")}&expand=transitions`,headers:R(t.token||r.token)})).body.issues.map(d=>it(d,e,o)),p=l.length==me;return{data:l,pageInfo:{hasNextPage:p,nextPage:p?a+l.length:null}}},Ie=async(r,s,e,t={})=>{let{assigneeLogins:n,authorLogin:o,mentionLogin:a,page:i,project:u,resourceId:l}=s||{},p=i??0,d=[`project = "${u}"`,"statusCategory != Done"];o&&d.push(`creator in ("${o}")`),n&&n.length!==0&&d.push(`assignee in ("${n.join('", "')}")`),a&&d.push(`comment ~ "${a}"`);let g=(await r.request({url:`${j(r,t,l)}/rest/api/2/search?jql=${d.join(" AND ")}&startAt=${p}&maxResults=${me}&fields=${at.join(",")}&expand=transitions`,headers:R(t.token||r.token)})).body.issues.map(f=>it(f,e,l)),m=g.length==me;return{data:g,pageInfo:{hasNextPage:m,nextPage:m?p+g.length:null}}},be=async(r,s,e={})=>{let{issue:t,labels:n}=s;if(!t.project)throw new Error('Jira requires a "project" for this function.');let o={fields:{labels:n.map(a=>a.name)}};await r.request({method:"PUT",url:`${j(r,e,t.project.resourceId??void 0)}/rest/api/2/issue/${t.id}`,body:JSON.stringify(o),headers:{...R(e.token||r.token),"Content-Type":"application/json"}})},ye=async(r,s,e={})=>{let{issue:t,components:n}=s;if(!t.project)throw new Error('Jira requires a "project" for this function.');let o={fields:{components:n.map(a=>({id:a.id}))}};await r.request({method:"PUT",url:`${j(r,e,t.project.resourceId??void 0)}/rest/api/2/issue/${t.id}`,body:JSON.stringify(o),headers:{...R(e.token||r.token),"Content-Type":"application/json"}})},we=async(r,s,e={})=>{let{issue:t,status:n}=s;if(!t.project)throw new Error('Jira requires a "project" for this function.');if(!n.id)throw new Error('Jira requires a status "id" for this function.');let o={transition:{id:n.id}};await r.request({method:"POST",url:`${j(r,e,t.project.resourceId??void 0)}/rest/api/2/issue/${t.id}/transitions`,body:JSON.stringify(o),headers:{...R(e.token||r.token),"Content-Type":"application/json"}})},Pe=async(r,s,e={})=>{let{resourceId:t,projectIdOrKey:n}=s,o=new URL(`${j(r,e,t)}/rest/api/2/project/${n}/components`);return{data:(await r.request({url:o.toString(),headers:R(e.token||r.token)})).body}};var Y="https://api.atlassian.com/ex/jira",ut=100,Z=class extends D{constructor(){super(...arguments);this._resourceUrlCache={}}async getResourceUrl(e,t={}){var a;let n=t.token||this.config.token;if(!n)return null;let o=this._resourceUrlCache[n];return o?o[e.resourceId]??null:(await this.getJiraResourcesForCurrentUser(t),((a=this._resourceUrlCache[n])==null?void 0:a[e.resourceId])??null)}async getCurrentUserForResource(e,t={}){let n=await this.getResourceUrl({resourceId:e.resourceId},t),o=await this.config.request({url:`${t.baseUrl||Y}/${e.resourceId}/rest/api/2/myself`,headers:R(t.token||this.config.token)});return{data:{name:o.body.displayName,email:o.body.emailAddress,avatarUrl:o.body.avatarUrls["48x48"],id:o.body.accountId,username:o.body.displayName,url:n?`${n}/jira/people/${o.body.accountId}`:null}}}async getJiraResourcesForCurrentUser(e={}){let t=await this.config.request({url:`${e.baseUrl||"https://api.atlassian.com/"}/oauth/token/accessible-resources`,headers:R(e.token||this.config.token)}),n=e.token||this.config.token,o=n?this._resourceUrlCache[n]||{}:void 0,a=t.body.map(i=>(o&&(o[i.id]=i.url),{avatarUrl:i.avatarUrl,id:i.id,name:i.name,url:i.url}));return n&&(this._resourceUrlCache[n]=o),{data:a}}async getJiraProjectsForResource(e,t={}){let n=new URL(`${t.baseUrl||Y}/${e.resourceId}/rest/api/2/project/search`);n.searchParams.set("maxResults",ut.toString()),e.cursor&&n.searchParams.set("startAt",e.cursor);let o=await this.config.request({url:n.toString(),headers:R(t.token||this.config.token)});return{pageInfo:{hasNextPage:o.body.values.length!==0,endCursor:(o.body.startAt+o.body.values.length).toString()},data:o.body.values.map(a=>({id:a.id,key:a.key,name:a.name,resourceId:e.resourceId}))}}async getJiraProjectsForResources(e,t={}){let n=[];return await Promise.all(e.resourceIds.map(async o=>{let a=await this.getJiraProjectsForResource({resourceId:o},t);n.push(...a.data)})),{data:n}}async getAccountsForJiraProject(e,t={}){let{resourceId:n,projectKey:o,cursor:a}=e,i=await this.getResourceUrl({resourceId:n},t),u=new URL(`${t.baseUrl||Y}/${n}/rest/api/2/user/assignable/search`);u.searchParams.set("maxResults",ut.toString()),a&&u.searchParams.set("startAt",a),u.searchParams.set("project",o);let l=await this.config.request({url:u.toString(),headers:R(t.token||this.config.token)});return{pageInfo:{hasNextPage:l.body.length!==0,endCursor:((a?parseInt(a):0)+l.body.length).toString()},data:l.body.filter(p=>p.accountType!=="app"&&p.active).map(p=>he(p,i,!1))}}async getComponentsForJiraProject(e,t={}){return await Pe(this.config,e,t)}async getIssue(e,t={}){let n=await this.getResourceUrl({resourceId:e.resourceId},t);return await fe(this.config,e,n,t)}async getIssuesForProject(e,t={}){let n=await this.getResourceUrl({resourceId:e.resourceId},t);return await Ie(this.config,e,n,t)}async getIssuesForResourceForCurrentUser(e,t={}){let n=await this.getResourceUrl({resourceId:e.resourceId},t);return await Re(this.config,e,n,t)}async setIssueStatus(e,t={}){await we(this.config,e,t)}async setIssueAssignee(e,t={}){let{issue:n,assignee:o}=e;if(!n.project)throw new Error('Jira Cloud requires a "project" for this function.');if(!n.project.resourceId)throw new Error('Jira Cloud requires a project "resourceId" for this function.');let a={accountId:o==null?void 0:o.id};await this.config.request({method:"PUT",url:`${t.baseUrl||Y}/${n.project.resourceId}/rest/api/2/issue/${n.id}/assignee`,body:JSON.stringify(a),headers:{...R(t.token||this.config.token),"Content-Type":"application/json"}})}async setIssueComponents(e,t={}){await ye(this.config,e,t)}async setIssueLabels(e,t={}){await be(this.config,e,t)}async getLabelsForResource(e,t={}){let{resourceId:n,cursor:o}=e,a=new URL(`${t.baseUrl||Y}/${n}/rest/api/2/label`);a.searchParams.set("maxResults",ut.toString()),o&&a.searchParams.set("startAt",o);let i=await this.config.request({url:a.toString(),headers:R(t.token||this.config.token)});return{pageInfo:{hasNextPage:!i.body.isLast,endCursor:(i.body.startAt+i.body.values.length).toString()},data:i.body.values.map(u=>({color:null,description:null,id:null,name:u}))}}};var ee=class extends ${async getCurrentUser(s={}){let e=await this.config.request({url:`${(s==null?void 0:s.baseUrl)||this.config.baseUrl}/rest/api/2/myself`,headers:R((s==null?void 0:s.token)||this.config.token)});return{data:{name:e.body.displayName,email:e.body.emailAddress,avatarUrl:e.body.avatarUrls["48x48"],id:e.body.key,username:e.body.displayName,url:null}}}async getJiraProjects(s={}){return{data:(await this.config.request({url:`${(s==null?void 0:s.baseUrl)||this.config.baseUrl}/rest/api/2/project`,headers:R((s==null?void 0:s.token)||this.config.token)})).body.map(t=>({id:t.id,name:t.name}))}}async getIssue(s,e={}){if(!e.baseUrl)throw new Error('Jira Server requires a "baseUrl" for this function.');return await fe(this.config,s,e.baseUrl,e)}async getIssuesForProject(s,e={}){if(!e.baseUrl)throw new Error('Jira Server requires a "baseUrl" for this function.');return await Ie(this.config,s,e.baseUrl,e)}async getIssuesForResourceForCurrentUser(s,e={}){if(!e.baseUrl)throw new Error('Jira Server requires a "baseUrl" for this function.');return await Re(this.config,s,e.baseUrl,e)}async setIssueStatus(s,e={}){await we(this.config,s,e)}async setIssueLabels(s,e={}){await be(this.config,s,e)}async setIssueComponents(s,e={}){await ye(this.config,s,e)}async getLabels(s={}){return{data:(await this.config.request({url:`${(s==null?void 0:s.baseUrl)||this.config.baseUrl}/rest/api/2/jql/autocompletedata/suggestions?fieldName=labels`,headers:R(s.token||this.config.token)})).body.results.map(({displayName:t})=>({color:null,description:null,id:null,name:t}))}}async getComponentsForJiraProject(s,e={}){return await Pe(this.config,s,e)}};var _="https://api.trello.com",Gs=1e3,As=(r,s)=>{let e=new Date(1e3*parseInt(r.id.substring(0,8),16));return{id:r.id,commentCount:r.badges.comments,number:r.idShort.toString(),title:r.name,url:r.url,closedDate:null,createdDate:new Date(e.toISOString()),author:null,updatedDate:new Date(r.dateLastActivity),assignees:r.idMembers.map(t=>({id:t,username:null,name:null,email:null,avatarUrl:null,url:null})),description:null,state:s[r.idList??""]?{id:r.idList,name:s[r.idList].name,color:null}:null,type:null,repository:null,upvoteCount:r.badges.votes,labels:r.labels.map(t=>({color:t.color,description:null,id:t.id,name:t.name}))}},te=class extends D{async getCurrentUser(s,e={}){let t=await this.config.request({url:`${e.baseUrl||_}/1/members/me?key=${s.appKey}&token=${e.token||this.config.token}`,headers:R(e.token||this.config.token)});return{data:{name:t.body.fullName,email:t.body.email,avatarUrl:t.body.avatarHash?`https://trello-members.s3.amazonaws.com/${t.body.id}/${t.body.avatarHash}/50.png`:null,id:t.body.id,username:t.body.username,url:t.body.url}}}async getBoardsForCurrentUser(s,e={}){return{data:(await this.config.request({url:`${e.baseUrl||_}/1/members/me/boards?fields=name&key=${s.appKey}&token=${e.token||this.config.token}&filter=open`,headers:R(e.token||this.config.token)})).body.map(n=>({id:n.id,name:n.name}))}}async getListsForTrelloBoard(s,e={}){let{appKey:t,boardId:n}=s;return{data:(await this.config.request({url:`${e.baseUrl||_}/1/boards/${n}/lists?key=${t}&token=${e.token||this.config.token}`,headers:R(e.token||this.config.token)})).body}}async getAccountsForTrelloBoard(s,e={}){let{appKey:t,boardId:n}=s;return{data:(await this.config.request({url:`${e.baseUrl||_}/1/boards/${n}/members?key=${t}&token=${e.token||this.config.token}`,headers:R(e.token||this.config.token)})).body.map(a=>({id:a.id,name:a.fullName,username:a.username,email:null,avatarUrl:null,url:null}))}}async getIssuesForBoard(s,e={}){let t=["-is:archived","sort:edited"],{appKey:n,boardId:o,filterText:a,assigneeLogins:i,trelloBoardListsById:u}=s||{};i&&t.push("@me");let l=`${a?`${a}`:""}${t.join(" ")} board:${o}`;return{data:(await this.config.request({url:`${e.baseUrl||_}/1/search?key=${n}&query=${l}&cards_limit=${Gs}&token=${e.token||this.config.token}`,headers:R(e.token||this.config.token)})).body.cards.map(d=>As(d,u||{}))}}async updateIssue(s,e,t,n){return await this.config.request({method:"PUT",url:`${n.baseUrl||_}/1/cards/${e.id}?key=${s}&token=${n.token||this.config.token}&${t}`,headers:R(n.token||this.config.token)})}async setIssueStatus(s,e={}){let{appKey:t,issue:n,status:o}=s;if(!o.id)throw new Error('Trello requires a status "id" for this function.');let a=`idList=${o.id}`;if(!(await this.updateIssue(t,n,a,e)).body.id)throw new Error("Could not set issue status")}async setIssueAssignees(s,e={}){let{appKey:t,issue:n,assignees:o}=s,a=o.map(l=>l.id),i=`idMembers=${encodeURIComponent(a.join(","))}`;if(!(await this.updateIssue(t,n,i,e)).body.id)throw new Error("Could not set issue status")}async setIssueLabels(s,e={}){let{appKey:t,issue:n,labels:o}=s,a=o.map(u=>u.id).join(",");if(!(await this.config.request({method:"PUT",url:`${e.baseUrl||_}/1/cards/${n.id}?key=${t}&token=${e.token||this.config.token}&idLabels=${encodeURIComponent(a)}`,headers:R(e.token||this.config.token)})).body.id)throw new Error("Could not set issue status")}async setIssueArchived(s,e={}){let{appKey:t,issue:n,archived:o}=s;if(!(await this.config.request({method:"PUT",url:`${e.baseUrl||_}/1/cards/${n.id}?key=${t}&token=${e.token||this.config.token}&closed=${o}`,headers:R(e.token||this.config.token)})).body.id)throw new Error("Could not update issue archived status")}async archiveIssue(s,e={}){await this.setIssueArchived({...s,archived:!0},e)}async unArchiveIssue(s,e={}){await this.setIssueArchived({...s,archived:!1},e)}async getLabelsForBoard(s,e={}){let{appKey:t,boardId:n}=s;return{data:(await this.config.request({url:`${e.baseUrl||_}/1/boards/${n}/labels?key=${t}&token=${e.token||this.config.token}`,headers:R(e.token||this.config.token)})).body.map(a=>({color:a.color,description:null,id:a.id,name:a.name}))}}};var Se={};O(Se,{getIssueUniqueId:()=>Os,getPullRequestUniqueId:()=>Ts});var Os=(r,s,e,t="")=>{let n=[];return n.push(t),n.push(r),n.push(s),n.push(e),JSON.stringify(n)},Ts=(r,s,e,t,n="")=>{let o=[];return o.push(n),o.push(r),o.push(s),o.push(e),o.push(t),JSON.stringify(o)};var qe={};O(qe,{getIssueUniqueId:()=>xs,getPullRequestUniqueId:()=>ks});var xs=(r,s)=>JSON.stringify(["",r,s]),ks=(r,s)=>JSON.stringify(["",r,s]);var ve={};O(ve,{getIssueUniqueId:()=>_s,getPullRequestUniqueId:()=>Qs});var _s=(r,s,e)=>JSON.stringify([e,r,s]),Qs=(r,s,e)=>JSON.stringify([e,r,s]);var Ee={};O(Ee,{CHANGES_REQUESTED_BUCKET_ID:()=>zs,CONFLICTS_BUCKET_ID:()=>js,DRAFT_BUCKET_ID:()=>Js,FAILING_CI_BUCKET_ID:()=>Fs,NEEDS_MY_REVIEW_BUCKET_ID:()=>Ms,OTHER_BUCKET_ID:()=>Ks,READY_TO_MERGE_BUCKET_ID:()=>Ns,REVIEWER_COMMENTED_BUCKET_ID:()=>Hs,UNASSIGNED_REVIEWERS_BUCKET_ID:()=>Bs,WAITING_FOR_REVIEW_BUCKET_ID:()=>Ws,groupPullRequestsIntoBuckets:()=>Vs});var A=(r,s,e,t)=>({id:r,faIconName:e,name:s,priority:t,pullRequests:[]}),Ns="readyToMerge",Bs="unassignedReviewers",Fs="failingCI",js="conflicts",Ms="needsMyReview",zs="changesRequested",Hs="reviewerCommented",Ws="waitingForReview",Js="draft",Ks="other",Vs=(r,s)=>{let e={readyToMerge:A("readyToMerge","Ready to Merge","code-merge",0),unassignedReviewers:A("unassignedReviewers","Unassigned Reviewers","user-plus",1),failingCI:A("failingCI","Failing CI","circle-x",2),conflicts:A("conflicts","Resolve Conflicts","triangle-exclamation",3),needsMyReview:A("needsMyReview","Needs My Review","eye",4),changesRequested:A("changesRequested","Suggested Changes","file-plus",5),reviewerCommented:A("reviewerCommented","Reviewer Commented","comment",6),waitingForReview:A("waitingForReview","Waiting for Review","circle-pause",7),draft:A("draft","Draft","compass-drafting",8),other:A("other","Other","ellipsis",9)};return r.forEach(t=>{var u,l,p,d,c,g,m,f;let n=!0,o=((u=t.author)==null?void 0:u.id)===s.id,a=((l=t.assignees)==null?void 0:l.some(b=>b.id===s.id))??!1,i=((p=t.reviews)==null?void 0:p.some(b=>b.reviewer.id===s.id))??!1;(o||a&&!i)&&t.mergeableState==="MERGEABLE"&&(!t.reviewDecision||t.reviewDecision==="APPROVED")&&(((d=t.permissions)==null?void 0:d.canMerge)??!0)&&(e.readyToMerge.pullRequests.push(t),n=!1),o&&!((c=t.reviews)!=null&&c.length)&&(e.unassignedReviewers.pullRequests.push(t),n=!1),o&&((m=(g=t.headCommit)==null?void 0:g.buildStatuses)!=null&&m.some(b=>b.state==="ERROR"||b.state==="FAILED"))&&(e.failingCI.pullRequests.push(t),n=!1),o&&t.mergeableState==="CONFLICTS"&&(e.conflicts.pullRequests.push(t),n=!1),(f=t.reviews)!=null&&f.some(b=>b.reviewer.id===s.id&&b.state==="REVIEW_REQUESTED")&&(e.needsMyReview.pullRequests.push(t),n=!1),o&&t.reviewDecision==="CHANGES_REQUESTED"&&(e.changesRequested.pullRequests.push(t),n=!1),o&&t.reviewDecision==="COMMENTED"&&(e.reviewerCommented.pullRequests.push(t),n=!1),o&&t.reviewDecision==="REVIEW_REQUESTED"&&(e.waitingForReview.pullRequests.push(t),n=!1),o&&t.isDraft&&(e.draft.pullRequests.push(t),n=!1),n&&e.other.pullRequests.push(t)}),e};var Ce={};O(Ce,{getIssueUniqueId:()=>Xs,getPullRequestRank:()=>Zs,getPullRequestUniqueId:()=>Ys});var Xs=(r,s="")=>{let e=[];return e.push(s),e.push(r),JSON.stringify(e)},Ys=(r,s="")=>{let e=[];return e.push(s),e.push(r),JSON.stringify(e)},Zs=(r,s,e)=>{var a,i,u;let t=0,n,o;return(a=r.reviews)==null||a.forEach(l=>{l.reviewer.id===s&&(n=l.state),l.state==="CHANGES_REQUESTED"?o="CHANGES_REQUESTED":l.state==="APPROVED"&&o!=="CHANGES_REQUESTED"&&(o="APPROVED")}),o||(o="REVIEW_REQUESTED"),((i=r.author)==null?void 0:i.id)===s?t+=1e3:(u=r.assignees)!=null&&u.find(l=>l.id===s)?t+=900:n==="REVIEW_REQUESTED"?t+=800:e&&(t+=700),o==="APPROVED"?r.mergeableState==="MERGEABLE"?t+=100:r.mergeableState==="CONFLICTS"?t+=90:t+=80:o=="CHANGES_REQUESTED"&&(t+=70),t};var De={};O(De,{getIssueUniqueId:()=>er,getPullRequestUniqueId:()=>tr});var er=(r,s="")=>{let e=[];return e.push(s),e.push(r),JSON.stringify(e)},tr=(r,s="")=>{let e=[];return e.push(s),e.push(r),JSON.stringify(e)};var Le={};O(Le,{getIssueUniqueId:()=>sr,getJiraServerIssueUniqueId:()=>rr});var sr=(r,s,e)=>{let t=[];return t.push(""),t.push(r),t.push(s),t.push(e),JSON.stringify(t)},rr=(r,s,e)=>{let t=[];return t.push(e),t.push(""),t.push(r),t.push(s),JSON.stringify(t)};var Ue={};O(Ue,{getIssueUniqueId:()=>nr});var nr=(r,s,e,t="")=>{let n=[];return n.push(t),n.push(r),n.push(s),n.push(e),JSON.stringify(n)};var or=r=>{let s={request:r==null?void 0:r.request};return{azureDevOps:new H({...s,...r==null?void 0:r.azureDevOps}),bitbucket:new W({...s,...r==null?void 0:r.bitbucket}),bitbucketServer:new J({...s,...r==null?void 0:r.bitbucketServer}),github:new K({...s,...r==null?void 0:r.github}),gitlab:new X({...s,...r==null?void 0:r.gitlab}),jira:new Z({...s,...r==null?void 0:r.jira}),jiraServer:new ee({...s,...r==null?void 0:r.jiraServer}),trello:new te({...s,...r==null?void 0:r.trello})}},ar=or;var ir={azureDevOps:Se,bitbucket:qe,bitbucketServer:ve,github:Ce,gitlab:De,gitProvider:Ee,jira:Le,trello:Ue};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { EnterpriseOptions, GetRepoErrorData, GetRepoInput, GitProvider, GitPullRequest, GitRepository, NumberedPageInput, SetPullRequestInput } from '../gitProvider';
|
|
1
|
+
import { Account, EnterpriseOptions, GetRepoErrorData, GetRepoInput, GitProvider, GitPullRequest, GitRepository, NumberedPageInput, SetPullRequestInput } from '../gitProvider';
|
|
2
2
|
import { EnterpriseProvider } from '../provider';
|
|
3
3
|
import { BitbucketServerMergeStrategy } from './bitbucketServerTypes';
|
|
4
4
|
export declare class BitbucketServer extends EnterpriseProvider implements GitProvider {
|
|
5
5
|
private getBaseUrl;
|
|
6
6
|
private getRequestHeaders;
|
|
7
|
+
getCurrentUser(input?: Record<string, never>, options?: EnterpriseOptions): Promise<{
|
|
8
|
+
data: Account;
|
|
9
|
+
}>;
|
|
7
10
|
getRepo(input: GetRepoInput, options?: EnterpriseOptions): Promise<{
|
|
8
11
|
data: GitRepository;
|
|
9
12
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitkraken/provider-apis",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.1",
|
|
4
4
|
"description": "An SDK around different third-party APIs that accepts and returns data in a common format.",
|
|
5
5
|
"author": "Axosoft, LLC dba GitKraken",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|