@gitkraken/provider-apis 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.0
4
+
5
+ - added `searchPullRequests` (GitHub)
6
+ - added `getPullRequestsAssociatedWithUser` (GitHub)
7
+ - added `closePullRequest` (GitHub, GitLab, Bitbucket, and Azure DevOps)
8
+ - added `mergePullRequest` (GitHub, GitLab, Bitbucket, and Azure DevOps)
9
+ - added `setIssueStatus` (GitHub, GitLab, Azure DevOps, Jira, and Trello)
10
+ - added `getJiraServerIssueUniqueId` (JiraUtils)
11
+
12
+ ### ⚠️ Breaking Changes
13
+
14
+ - Jira's `getIssueUniqueId` no longer supports a `domain` parameter. Use `getJiraServerIssueUniqueId` instead.
15
+ - `getRepos` no longer throws if any of the repositories fail to fetch, meaning the index of the returned repositories may not match the index the inputs. It now also returns an `errors` property containing the inputs that failed. (GitHub, GitLab, Bitbucket, and Azure DevOps)
16
+
3
17
  ## 0.9.0
4
18
 
5
19
  - Azure DevOps `GitPullRequest` objects now include `url`
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var je=Object.create;var W=Object.defineProperty;var Ne=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var Qe=Object.getPrototypeOf,ze=Object.prototype.hasOwnProperty;var L=(e,t)=>{for(var r in t)W(e,r,{get:t[r],enumerable:!0})},Ie=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Fe(t))!ze.call(e,n)&&n!==r&&W(e,n,{get:()=>t[n],enumerable:!(s=Ne(t,n))||s.enumerable});return e};var Me=(e,t,r)=>(r=e!=null?je(Qe(e)):{},Ie(t||!e||!e.__esModule?W(r,"default",{value:e,enumerable:!0}):r,e)),He=e=>Ie(W({},"__esModule",{value:!0}),e);var kt={};L(kt,{AzureDevOps:()=>B,AzureDevopsUtils:()=>X,Bitbucket:()=>j,BitbucketServer:()=>N,BitbucketServerUtils:()=>Z,BitbucketUtils:()=>K,GitHub:()=>F,GitHubUtils:()=>Y,GitLab:()=>z,GitLabUtils:()=>ee,Jira:()=>M,JiraUtils:()=>te,Trello:()=>H,TrelloUtils:()=>re,Utils:()=>_t,default:()=>qt});module.exports=He(kt);var v=100;var Pe=Me(require("node-fetch")),ve=globalThis.fetch||Pe.default;var Ue=e=>e.name==="fetch";var We=async e=>{let t=e.headers.get("content-type")||"",r=null;if(t.startsWith("application/json"))r=await e.json();else if(t.startsWith("text/"))r=await e.text();else throw new Error(`Unsupported content-type: ${t}`);let s={body:r,headers:Object.fromEntries(e.headers.entries()),status:e.status,statusText:e.statusText};if(!e.ok){let n=new Error(e.statusText);throw Object.assign(n,{response:s}),n}return s},se=e=>Ue(e)?async({url:t,...r})=>{let s=await e(t,r);return We(s)}:e;var w=class{constructor(t){this.config={...t,request:se((t==null?void 0:t.request)||ve)}}updateConfig(t){this.config={...this.config,...t,request:t.request?se(t.request):this.config.request}}},A=class extends w{};var y=(e,t)=>{let r={};return e&&(r.Authorization=`${t?"Basic":"Bearer"} ${e}`),r};var C=(e,t={})=>y(t.token||e.token,t.isPAT||e.isPAT),Ce=e=>e.url.replace("/_apis/git/repositories/","/_git/").replace(`/${e.repository.project.id}/`,`/${encodeURIComponent(e.repository.project.name)}/`).replace(`/${e.repository.id}/`,`/${encodeURIComponent(e.repository.name)}/`).replace("/pullRequests/","/pullrequest/");var we="https://app.vssps.visualstudio.com/_apis",D="https://dev.azure.com",Je={active:"OPEN",completed:"MERGED",abandoned:"CLOSED"},Ve={10:"APPROVED",5:"APPROVED",0:"REVIEW_REQUESTED",[-5]:"CHANGES_REQUESTED",[-10]:"CHANGES_REQUESTED"},ne=e=>({id:e.id,name:e.displayName,username:e.uniqueName||e.displayName,email:null,avatarUrl:e.imageUrl}),J=e=>e.startsWith("refs/heads/")?e.replace("refs/heads/",""):e,Se=e=>({id:e.pullRequestId.toString(),title:e.title,number:e.codeReviewId,state:Je[e.status],isDraft:e.isDraft,commentCount:null,upvoteCount:null,author:ne(e.createdBy),createdDate:new Date(e.creationDate),updatedDate:new Date(e.closedDate||e.creationDate),closedDate:e.closedDate?new Date(e.closedDate):null,repository:{name:e.repository.name,owner:{login:void 0}},headCommit:{buildStatus:null},baseRef:{name:J(e.targetRefName)},headRef:{name:J(e.sourceRefName)},url:Ce(e),assignees:e.reviewers.map(ne),reviews:e.reviewers.filter(t=>t.vote!==0).map(t=>({reviewer:ne(t),state:Ve[t.vote]||"REVIEW_REQUESTED"})),additions:null,deletions:null,fileCount:null,commitCount:null,headRepository:null,mergeableState:"UNKNOWN"}),Ee=(e,t)=>({id:t.id,name:t.name,namespace:e,project:t.project.name,webUrl:t.webUrl,httpsUrl:t.remoteUrl,sshUrl:t.sshUrl,defaultBranch:t.defaultBranch?{name:J(t.defaultBranch)}:null,permission:null}),Xe=e=>{let t=e.fields,r=t["System.AssignedTo"];return{id:e.id.toString(),number:e.id.toString(),title:t["System.Title"],commentCount:t["System.CommentCount"],author:{avatarUrl:t["System.CreatedBy"]._links.avatar.href,email:null,id:t["System.CreatedBy"].id,name:t["System.CreatedBy"].uniqueName,username:t["System.CreatedBy"].displayName},createdDate:new Date(t["System.CreatedDate"]),updatedDate:new Date(t["System.ChangedDate"]),url:e._links.html.href,assignees:r?[{avatarUrl:r._links.avatar.href,email:null,id:r.id,name:r.uniqueName,username:r.displayName}]:[],description:null,state:null,type:t["System.WorkItemType"],repository:null,upvoteCount:0}},B=class extends w{async getCurrentUser(t={}){if(t.isPAT||this.config.isPAT)throw new Error("Azure DevOps does not support PATs for this function.");let r=await this.config.request({url:`${we}/profile/profiles/me`,headers:C(this.config,t)});return{data:{id:r.body.id,name:r.body.displayName,username:r.body.displayName,email:r.body.emailAddress,avatarUrl:null}}}async getCurrentUserForInstance(t,r={}){let n=(await this.config.request({url:`${D}/${encodeURIComponent(t.namespace)}/_apis/ConnectionData`,headers:C(this.config,r)})).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(t,r={}){if(!t.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let n=(await this.config.request({url:`${D}/${encodeURIComponent(t.repo.namespace)}/${encodeURIComponent(t.repo.project)}/_apis/git/repositories/${encodeURIComponent(t.repo.name)}/commits/${t.oid}`,headers:C(this.config,r)})).body.author;return{data:{name:n.name,email:n.email,avatarUrl:n.imageUrl}}}async getOrgsForUser(t,r={}){return{data:(await this.config.request({url:`${we}/accounts?memberId=${t.userId}&api-version=6.0`,headers:C(this.config,r)})).body.value.map(n=>({id:n.accountId,name:n.accountName}))}}async getAzureProjects(t,r={}){let s=new URL(`${D}/${encodeURIComponent(t.namespace)}/_apis/projects`);s.searchParams.set("$top",v.toString()),t.cursor&&s.searchParams.set("$skip",t.cursor);let n=await this.config.request({url:s.toString(),headers:C(this.config,r)}),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:t.namespace}))}}async getRepo(t,r={}){if(!t.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let s=await this.config.request({url:`${D}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/git/repositories/${encodeURIComponent(t.name)}`,headers:C(this.config,r)});return{data:Ee(t.namespace,s.body)}}async getRepos(t,r={}){return{data:(await Promise.all(t.map(n=>this.getRepo(n,r)))).map(n=>n.data)}}async getReposForAzureProject(t,r={}){if(!t.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');return{data:(await this.config.request({url:`${D}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/git/repositories`,headers:C(this.config,r)})).body.value.map(n=>Ee(t.namespace,n))}}async getRefs(t,r,s={}){if(!r.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let n=new URL(`${D}/${encodeURIComponent(r.repo.namespace)}/${encodeURIComponent(r.repo.project)}/_apis/git/repositories/${encodeURIComponent(r.repo.name)}/refs`);n.searchParams.set("filter",t),n.searchParams.set("$top",v.toString()),r.cursor&&n.searchParams.set("continuationToken",r.cursor);let o=await this.config.request({url:n.toString(),headers:C(this.config,s)}),a=o.headers["x-ms-continuationtoken"];return{pageInfo:{hasNextPage:!!a,endCursor:a||null},data:o.body.value.map(i=>({name:J(i.name),commit:{oid:i.objectId,authoredDate:null,committedDate:null}}))}}async getBranches(t,r={}){return this.getRefs("heads",t,r)}async getTags(t,r={}){return this.getRefs("tags",t,r)}async getPullRequestsForRepoBase(t,r={},s=100){let{page:n,repo:o,assigneeLogins:a,authorLogin:i}=t||{},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:`${r.baseUrl||D}/${encodeURIComponent(o.namespace)}/${encodeURIComponent(o.project||"")}/_apis/git/repositories/${encodeURIComponent(o.name)}/pullRequests?${l}&%24top=${s}&%24skip=${(u-1)*s}`,headers:C(this.config,r)})}async getPullRequestsForRepo(t,r={}){let n=t.page||1,o=await this.getPullRequestsForRepoBase(t,r,100);return{pageInfo:{hasNextPage:o.body.value.length===100,nextPage:n+1},data:o.body.value.map(Se)}}async getPullRequestsForRepos(t,r={}){if(!t.repos.every(o=>o.project))throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{repos:s}=t||{},n=[];return await Promise.all(s.map(async o=>{try{(await this.getPullRequestsForRepoBase({repo:o,...t},r)).body.value.forEach(i=>{n.push(Se(i))})}catch(a){if(a.statusCode!==404&&a.statusCode!==401)throw a}})),{data:n}}async getIssuesForAzureProject(t,r={}){let{page:s,assigneeLogins:n,authorLogin:o,mentionLogin:a}=t||{},i=s||1,u=200,l=["[Microsoft.VSTS.Common.ClosedDate] = ''","[System.TeamProject] = @project","[Microsoft.VSTS.Common.ResolvedDate] = ''"];o&&l.push(`[System.CreatedBy] = '${o.replace("'","''")}'`),n&&n[0]&&l.push(`[System.AssignedTo] = '${n[0].replace("'","''")}'`),a&&l.push("[System.Id] IN (@recentMentions)");let p=`Select [Microsoft.VSTS.Common.ClosedDate], [Microsoft.VSTS.Common.ResolvedDate] From WorkItems Where ${l.join(" AND ")} order by [System.CreatedDate] desc`,g=await this.config.request({url:`${r.baseUrl||D}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/wit/wiql?api-version=6.0`,body:JSON.stringify({query:p}),method:"POST",headers:{...C(this.config,r),"Content-Type":"application/json"}}),m=g.body.workItems.slice((i-1)*u,u*i).map(c=>c.id);if(m.length==0)return{pageInfo:{hasNextPage:!1,nextPage:null},data:[]};let d=await this.config.request({url:`${r.baseUrl||D}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/wit/workitemsbatch?api-version=6.0`,body:JSON.stringify({ids:m,$expand:"Links"}),method:"POST",headers:{...C(this.config,r),"Content-Type":"application/json"}});return{pageInfo:{hasNextPage:g.body.workItems.length>u*i,nextPage:i+1},data:d.body.value.map(Xe)}}};var x=(e,t={})=>y(t.token||e.token,t.isPAT||e.isPAT);var q="https://api.bitbucket.org/2.0",Ke={OPEN:"OPEN",MERGED:"MERGED",DECLINED:"CLOSED"},Ge=e=>({id:e.uuid,name:e.display_name||e.nickname,username:e.nickname||e.display_name,email:null,avatarUrl:e.links.avatar.href}),$e=e=>{var t,r;return{id:e.uuid,namespace:e.workspace.slug,name:e.slug,webUrl:e.links.html.href,httpsUrl:((t=e.links.clone.find(s=>s.name==="https"))==null?void 0:t.href)??null,sshUrl:((r=e.links.clone.find(s=>s.name==="ssh"))==null?void 0:r.href)??null,defaultBranch:{name:e.mainbranch.name},permission:null}},De=e=>{let t=e.id;return{id:t.toString(),title:e.title,number:t,state:Ke[e.state],isDraft:!1,commentCount:e.comment_count,upvoteCount:null,author:Ge(e.author),createdDate:new Date(e.created_on),updatedDate:new Date(e.updated_on),closedDate:null,repository:{name:e.source.repository.name,owner:{login:void 0}},headCommit:{buildStatus:null},baseRef:{name:e.destination.branch.name},headRef:{name:e.source.branch.name},url:e.links.html.href,assignees:null,reviews:null,additions:null,deletions:null,fileCount:null,commitCount:null,headRepository:null,mergeableState:"UNKNOWN"}},j=class extends w{async refreshToken(t){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 ${t.base64ClientIDColonClientSecret}`},body:`grant_type=refresh_token&refresh_token=${t.refreshToken}`})).body}}async getCurrentUser(t={}){let r=await this.config.request({url:`${q}/user`,headers:x(this.config,t)});return{data:Ge(r.body)}}async getUserForCommit(t,r={}){var a;let n=(await this.config.request({url:`${q}/repositories/${t.repo.namespace}/${t.repo.name}/commit/${t.oid}`,headers:x(this.config,r)})).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(t,r={}){let s=await this.config.request({url:`${q}/repositories/${t.namespace}/${t.name}`,headers:x(this.config,r)});return{data:$e(s.body)}}async getRepos(t,r={}){return{data:(await Promise.all(t.map(n=>this.getRepo(n,r)))).map(n=>n.data)}}async getReposForCurrentUser(t={},r={}){let s=new URL(`${q}/repositories`);s.searchParams.set("role","member"),s.searchParams.set("pagelen",v.toString()),t.cursor&&s.searchParams.set("after",t.cursor);let n=await this.config.request({url:s.toString(),headers:x(this.config,r)}),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($e)}}async getBranches(t,r={}){var a;let s=new URL(`${q}/repositories/${t.repo.namespace}/${t.repo.name}/refs/branches`);s.searchParams.set("page",((a=t.page)==null?void 0:a.toString())||"1"),s.searchParams.set("pagelen",v.toString());let n=await this.config.request({url:s.toString(),headers:x(this.config,r)}),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(t,r={}){let s=new URL(`${q}/repositories/${t.repo.namespace}/${t.repo.name}/refs/tags`);s.searchParams.set("pagelen",v.toString()),t.cursor&&s.searchParams.set("page",t.cursor);let n=await this.config.request({url:s.toString(),headers:x(this.config,r)}),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 getPullRequestsForRepoBase(t,r={}){var n;let s=new URL(`${q}/repositories/${encodeURI(t.repo.namespace)}/${encodeURI(t.repo.name)}/pullrequests?state=OPEN`);return s.searchParams.set("page",((n=t.page)==null?void 0:n.toString())||"1"),s.searchParams.set("pagelen","50"),await this.config.request({url:s.toString(),headers:x(this.config,r)})}async getPullRequestsForRepo(t,r={}){let s=[],n=await this.getPullRequestsForRepoBase(t,r);n.body.values.forEach(a=>{if(t.authorLogin&&a.author.uuid!==t.authorLogin)return null;s.push(De(a))});let o=!!n.body.next;return{pageInfo:{hasNextPage:o,nextPage:o?n.body.page+1:null},data:s}}async getPullRequestsForRepos(t,r={}){let s=[];return await Promise.all(t.repos.map(async n=>{try{(await this.getPullRequestsForRepoBase({repo:n,...t},r)).body.values.forEach(a=>{if(t.authorLogin&&a.author.uuid!==t.authorLogin)return null;s.push(De(a))})}catch(o){if(o.statusCode!==404&&o.statusCode!==401)throw o}})),{data:s}}};var N=class extends A{getBaseUrl(t){let r=t.baseUrl||this.config.baseUrl;if(!r)throw new Error('Bitbucket Server requires "baseUrl"');return r}getRequestHeaders(t){return y(t.token||this.config.token)}async getRepo(t,r={}){var n,o,a;let s=await this.config.request({url:`${this.getBaseUrl(r)}/projects/${t.namespace}/repos/${t.name}`,headers:this.getRequestHeaders(r)});return{data:{id:s.body.id.toString(),namespace:s.body.project.key,name:s.body.slug,webUrl:((n=s.body.links.self[0])==null?void 0:n.href)??null,httpsUrl:((o=s.body.links.clone.find(i=>i.name==="https"))==null?void 0:o.href)??null,sshUrl:((a=s.body.links.clone.find(i=>i.name==="ssh"))==null?void 0:a.href)??null,defaultBranch:null,permission:null}}}async getRepos(t,r={}){return{data:(await Promise.all(t.map(n=>this.getRepo(n,r)))).map(n=>n.data)}}};var ie="https://api.github.com",Ze=`${ie}/graphql`,Le=/\/api\/v\d+$/,Ye=e=>{if(e.endsWith("/api/graphql"))throw new Error("The graphql endpoint is being used as the baseUrl. This package uses both GraphQL and REST APIs, and the REST version cannot be assumed. Use the REST endpoint as the baseUrl instead.")},et=(e,t)=>{let r=t.baseUrl||e.baseUrl;return r?(r=r.replace(/\/$/,""),Ye(r),Le.test(r)&&(r=r.replace(Le,"")),`${r}/api/graphql`):Ze},I=(e,t,r)=>{let s=y(r.token||e.token);return s["X-Github-Next-Global-ID"]="1",s["Content-Type"]="application/json",e.request({url:et(e,r),method:"POST",headers:s,body:JSON.stringify(t)})},tt={user:!0,"user:email":!0,"read:user":!0},k=e=>e.some(t=>tt[t]),S=(e=!1,t=!1)=>`
1
+ "use strict";var Ne=Object.create;var W=Object.defineProperty;var Qe=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var ze=Object.getPrototypeOf,Me=Object.prototype.hasOwnProperty;var x=(e,t)=>{for(var r in t)W(e,r,{get:t[r],enumerable:!0})},Pe=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Fe(t))!Me.call(e,n)&&n!==r&&W(e,n,{get:()=>t[n],enumerable:!(s=Qe(t,n))||s.enumerable});return e};var He=(e,t,r)=>(r=e!=null?Ne(ze(e)):{},Pe(t||!e||!e.__esModule?W(r,"default",{value:e,enumerable:!0}):r,e)),We=e=>Pe(W({},"__esModule",{value:!0}),e);var Bt={};x(Bt,{AzureDevOps:()=>j,AzureDevopsUtils:()=>X,Bitbucket:()=>B,BitbucketServer:()=>N,BitbucketServerUtils:()=>Z,BitbucketUtils:()=>K,GitHub:()=>Q,GitHubUtils:()=>Y,GitLab:()=>z,GitLabUtils:()=>ee,Jira:()=>M,JiraUtils:()=>te,Trello:()=>H,TrelloUtils:()=>re,Utils:()=>jt,default:()=>kt});module.exports=We(Bt);var v=100;var we=He(require("node-fetch")),Ce=globalThis.fetch||we.default;var ve=e=>e.name==="fetch";var Je=async e=>{let t=e.headers.get("content-type")||"",r=null;if(t.startsWith("application/json"))r=await e.json();else if(t.startsWith("text/"))r=await e.text();else throw new Error(`Unsupported content-type: ${t}`);let s={body:r,headers:Object.fromEntries(e.headers.entries()),status:e.status,statusText:e.statusText};if(!e.ok){let n=new Error(e.statusText);throw Object.assign(n,{response:s}),n}return s},se=e=>ve(e)?async({url:t,...r})=>{let s=await e(t,r);return Je(s)}:e;var E=class{constructor(t){this.config={...t,request:se((t==null?void 0:t.request)||Ce)}}updateConfig(t){this.config={...this.config,...t,request:t.request?se(t.request):this.config.request}}},A=class extends E{};var f=(e,t)=>{let r={};return e&&(r.Authorization=`${t?"Basic":"Bearer"} ${e}`),r};var w=(e,t={})=>f(t.token||e.token,t.isPAT||e.isPAT),Ue=e=>e.url.replace("/_apis/git/repositories/","/_git/").replace(`/${e.repository.project.id}/`,`/${encodeURIComponent(e.repository.project.name)}/`).replace(`/${e.repository.id}/`,`/${encodeURIComponent(e.repository.name)}/`).replace("/pullRequests/","/pullrequest/");var Ee="https://app.vssps.visualstudio.com/_apis",U="https://dev.azure.com",Ve={active:"OPEN",completed:"MERGED",abandoned:"CLOSED"},Xe={10:"APPROVED",5:"APPROVED",0:"REVIEW_REQUESTED",[-5]:"CHANGES_REQUESTED",[-10]:"CHANGES_REQUESTED"},ne=e=>({id:e.id,name:e.displayName,username:e.uniqueName||e.displayName,email:null,avatarUrl:e.imageUrl}),J=e=>e.startsWith("refs/heads/")?e.replace("refs/heads/",""):e,Se=e=>({id:e.pullRequestId.toString(),title:e.title,number:e.codeReviewId,state:Ve[e.status],isDraft:e.isDraft,commentCount:null,upvoteCount:null,author:ne(e.createdBy),createdDate:new Date(e.creationDate),updatedDate:new Date(e.closedDate||e.creationDate),closedDate:e.closedDate?new Date(e.closedDate):null,repository:{name:e.repository.name,owner:{login:void 0}},headCommit:{buildStatus:null},baseRef:{name:J(e.targetRefName)},headRef:{name:J(e.sourceRefName)},url:Ue(e),assignees:e.reviewers.map(ne),reviews:e.reviewers.filter(t=>t.vote!==0).map(t=>({reviewer:ne(t),state:Xe[t.vote]||"REVIEW_REQUESTED"})),additions:null,deletions:null,fileCount:null,commitCount:null,headRepository:null,mergeableState:"UNKNOWN"}),$e=(e,t)=>({id:t.id,name:t.name,namespace:e,project:t.project.name,webUrl:t.webUrl,httpsUrl:t.remoteUrl,sshUrl:t.sshUrl,defaultBranch:t.defaultBranch?{name:J(t.defaultBranch)}:null,permission:null}),Ke=e=>{let t=e.fields,r=t["System.AssignedTo"];return{id:e.id.toString(),number:e.id.toString(),title:t["System.Title"],commentCount:t["System.CommentCount"],author:{avatarUrl:t["System.CreatedBy"]._links.avatar.href,email:null,id:t["System.CreatedBy"].id,name:t["System.CreatedBy"].uniqueName,username:t["System.CreatedBy"].displayName},createdDate:new Date(t["System.CreatedDate"]),updatedDate:new Date(t["System.ChangedDate"]),url:e._links.html.href,assignees:r?[{avatarUrl:r._links.avatar.href,email:null,id:r.id,name:r.uniqueName,username:r.displayName}]:[],description:null,state:null,type:t["System.WorkItemType"],repository:null,upvoteCount:0}},j=class extends E{async getCurrentUser(t={}){if(t.isPAT||this.config.isPAT)throw new Error("Azure DevOps does not support PATs for this function.");let r=await this.config.request({url:`${Ee}/profile/profiles/me`,headers:w(this.config,t)});return{data:{id:r.body.id,name:r.body.displayName,username:r.body.displayName,email:r.body.emailAddress,avatarUrl:null}}}async getCurrentUserForInstance(t,r={}){let n=(await this.config.request({url:`${U}/${encodeURIComponent(t.namespace)}/_apis/ConnectionData`,headers:w(this.config,r)})).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(t,r={}){if(!t.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let n=(await this.config.request({url:`${U}/${encodeURIComponent(t.repo.namespace)}/${encodeURIComponent(t.repo.project)}/_apis/git/repositories/${encodeURIComponent(t.repo.name)}/commits/${t.oid}`,headers:w(this.config,r)})).body.author;return{data:{name:n.name,email:n.email,avatarUrl:n.imageUrl}}}async getOrgsForUser(t,r={}){return{data:(await this.config.request({url:`${Ee}/accounts?memberId=${t.userId}&api-version=6.0`,headers:w(this.config,r)})).body.value.map(n=>({id:n.accountId,name:n.accountName}))}}async getAzureProjects(t,r={}){let s=new URL(`${U}/${encodeURIComponent(t.namespace)}/_apis/projects`);s.searchParams.set("$top",v.toString()),t.cursor&&s.searchParams.set("$skip",t.cursor);let n=await this.config.request({url:s.toString(),headers:w(this.config,r)}),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:t.namespace}))}}async getRepo(t,r={}){if(!t.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let s=await this.config.request({url:`${U}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/git/repositories/${encodeURIComponent(t.name)}`,headers:w(this.config,r)});return{data:$e(t.namespace,s.body)}}async getRepos(t,r={}){let s=[],n=[];return await Promise.all(t.map(async o=>{try{let a=await this.getRepo(o,r);s.push(a.data)}catch(a){n.push({input:o,error:a})}})),{data:s,errors:n}}async getReposForAzureProject(t,r={}){if(!t.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');return{data:(await this.config.request({url:`${U}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/git/repositories`,headers:w(this.config,r)})).body.value.map(n=>$e(t.namespace,n))}}async getRefs(t,r,s={}){if(!r.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let n=new URL(`${U}/${encodeURIComponent(r.repo.namespace)}/${encodeURIComponent(r.repo.project)}/_apis/git/repositories/${encodeURIComponent(r.repo.name)}/refs`);n.searchParams.set("filter",t),n.searchParams.set("$top",v.toString()),r.cursor&&n.searchParams.set("continuationToken",r.cursor);let o=await this.config.request({url:n.toString(),headers:w(this.config,s)}),a=o.headers["x-ms-continuationtoken"];return{pageInfo:{hasNextPage:!!a,endCursor:a||null},data:o.body.value.map(i=>({name:J(i.name),commit:{oid:i.objectId,authoredDate:null,committedDate:null}}))}}async getBranches(t,r={}){return this.getRefs("heads",t,r)}async getTags(t,r={}){return this.getRefs("tags",t,r)}async getPullRequestsForRepoBase(t,r={},s=100){let{page:n,repo:o,assigneeLogins:a,authorLogin:i}=t||{},u=n||1;if(!o.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let p="searchCriteria.status=1";return a&&a.length&&(p+=`&searchCriteria.reviewerId=${a[0]}`),i&&(p+=`&searchCriteria.creatorId=${i}`),await this.config.request({url:`${r.baseUrl||U}/${encodeURIComponent(o.namespace)}/${encodeURIComponent(o.project||"")}/_apis/git/repositories/${encodeURIComponent(o.name)}/pullRequests?${p}&%24top=${s}&%24skip=${(u-1)*s}`,headers:w(this.config,r)})}async getPullRequestsForRepo(t,r={}){let n=t.page||1,o=await this.getPullRequestsForRepoBase(t,r,100);return{pageInfo:{hasNextPage:o.body.value.length===100,nextPage:n+1},data:o.body.value.map(Se)}}async getPullRequestsForRepos(t,r={}){if(!t.repos.every(o=>o.project))throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{repos:s}=t||{},n=[];return await Promise.all(s.map(async o=>{try{(await this.getPullRequestsForRepoBase({repo:o,...t},r)).body.value.forEach(i=>{n.push(Se(i))})}catch(a){if(a.statusCode!==404&&a.statusCode!==401)throw a}})),{data:n}}async closePullRequest(t,r={}){if(!t.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{repo:{namespace:s,name:n,project:o},pullRequestId:a}=t,i={status:"abandoned"};if(!(await this.config.request({method:"PATCH",url:`${r.baseUrl||U}/${encodeURIComponent(s)}/${encodeURIComponent(o||"")}/_apis/git/repositories/${n}/pullrequests/${a}?api-version=6.0`,body:JSON.stringify(i),headers:{...w(this.config,r),"Content-Type":"application/json"}})).body.status)throw new Error("Could not close pull request")}async mergePullRequest(t,r={}){if(!t.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{repo:{namespace:s,name:n,project:o},pullRequestId:a,expectedSourceSha:i}=t,u={lastMergeSourceCommit:{commitId:i},status:"completed"};if(!(await this.config.request({method:"PATCH",url:`${r.baseUrl||U}/${encodeURIComponent(s)}/${encodeURIComponent(o||"")}/_apis/git/repositories/${n}/pullrequests/${a}?api-version=6.0`,body:JSON.stringify(u),headers:{...w(this.config,r),"Content-Type":"application/json"}})).body.status)throw new Error("Could not merge pull request")}async getIssuesForAzureProject(t,r={}){let{page:s,assigneeLogins:n,authorLogin:o,mentionLogin:a}=t||{},i=s||1,u=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 l=`Select [Microsoft.VSTS.Common.ClosedDate], [Microsoft.VSTS.Common.ResolvedDate] From WorkItems Where ${p.join(" AND ")} order by [System.CreatedDate] desc`,d=await this.config.request({url:`${r.baseUrl||U}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/wit/wiql?api-version=6.0`,body:JSON.stringify({query:l}),method:"POST",headers:{...w(this.config,r),"Content-Type":"application/json"}}),c=d.body.workItems.slice((i-1)*u,u*i).map(I=>I.id);if(c.length==0)return{pageInfo:{hasNextPage:!1,nextPage:null},data:[]};let g=await this.config.request({url:`${r.baseUrl||U}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/wit/workitemsbatch?api-version=6.0`,body:JSON.stringify({ids:c,$expand:"Links"}),method:"POST",headers:{...w(this.config,r),"Content-Type":"application/json"}});return{pageInfo:{hasNextPage:d.body.workItems.length>u*i,nextPage:i+1},data:g.body.value.map(Ke)}}async setIssueStatus(t,r={}){var p;if(!t.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{namespace:s,project:n,issueId:o,status:a}=t,i=[{op:"add",path:"/fields/System.State",value:a}];if(!((p=(await this.config.request({method:"PATCH",url:`${r.baseUrl||U}/${encodeURIComponent(s)}/${encodeURIComponent(n||"")}/_apis/wit/workitems/${o}?api-version=6.0`,body:JSON.stringify(i),headers:{...w(this.config,r),"Content-Type":"application/json-patch+json"}})).body.fields)!=null&&p["System.State"]))throw new Error("Could not set issue status")}};var S=(e,t={})=>f(t.token||e.token,t.isPAT||e.isPAT);var G="https://api.bitbucket.org/2.0",Ze={OPEN:"OPEN",MERGED:"MERGED",DECLINED:"CLOSED"},Ge=e=>({id:e.uuid,name:e.display_name||e.nickname,username:e.nickname||e.display_name,email:null,avatarUrl:e.links.avatar.href}),De=e=>{var t,r;return{id:e.uuid,namespace:e.workspace.slug,name:e.slug,webUrl:e.links.html.href,httpsUrl:((t=e.links.clone.find(s=>s.name==="https"))==null?void 0:t.href)??null,sshUrl:((r=e.links.clone.find(s=>s.name==="ssh"))==null?void 0:r.href)??null,defaultBranch:{name:e.mainbranch.name},permission:null}},qe=e=>{let t=e.id;return{id:t.toString(),title:e.title,number:t,state:Ze[e.state],isDraft:!1,commentCount:e.comment_count,upvoteCount:null,author:Ge(e.author),createdDate:new Date(e.created_on),updatedDate:new Date(e.updated_on),closedDate:null,repository:{name:e.source.repository.name,owner:{login:void 0}},headCommit:{buildStatus:null},baseRef:{name:e.destination.branch.name},headRef:{name:e.source.branch.name},url:e.links.html.href,assignees:null,reviews:null,additions:null,deletions:null,fileCount:null,commitCount:null,headRepository:null,mergeableState:"UNKNOWN"}},B=class extends E{async refreshToken(t){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 ${t.base64ClientIDColonClientSecret}`},body:`grant_type=refresh_token&refresh_token=${t.refreshToken}`})).body}}async getCurrentUser(t={}){let r=await this.config.request({url:`${G}/user`,headers:S(this.config,t)});return{data:Ge(r.body)}}async getUserForCommit(t,r={}){var a;let n=(await this.config.request({url:`${G}/repositories/${t.repo.namespace}/${t.repo.name}/commit/${t.oid}`,headers:S(this.config,r)})).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(t,r={}){let s=await this.config.request({url:`${G}/repositories/${t.namespace}/${t.name}`,headers:S(this.config,r)});return{data:De(s.body)}}async getRepos(t,r={}){let s=[],n=[];return await Promise.all(t.map(async o=>{try{let a=await this.getRepo(o,r);s.push(a.data)}catch(a){n.push({input:o,error:a})}})),{data:s,errors:n}}async getReposForCurrentUser(t={},r={}){let s=new URL(`${G}/repositories`);s.searchParams.set("role","member"),s.searchParams.set("pagelen",v.toString()),t.cursor&&s.searchParams.set("after",t.cursor);let n=await this.config.request({url:s.toString(),headers:S(this.config,r)}),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(De)}}async getBranches(t,r={}){var a;let s=new URL(`${G}/repositories/${t.repo.namespace}/${t.repo.name}/refs/branches`);s.searchParams.set("page",((a=t.page)==null?void 0:a.toString())||"1"),s.searchParams.set("pagelen",v.toString());let n=await this.config.request({url:s.toString(),headers:S(this.config,r)}),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(t,r={}){let s=new URL(`${G}/repositories/${t.repo.namespace}/${t.repo.name}/refs/tags`);s.searchParams.set("pagelen",v.toString()),t.cursor&&s.searchParams.set("page",t.cursor);let n=await this.config.request({url:s.toString(),headers:S(this.config,r)}),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 getPullRequestsForRepoBase(t,r={}){var n;let s=new URL(`${G}/repositories/${encodeURI(t.repo.namespace)}/${encodeURI(t.repo.name)}/pullrequests?state=OPEN`);return s.searchParams.set("page",((n=t.page)==null?void 0:n.toString())||"1"),s.searchParams.set("pagelen","50"),await this.config.request({url:s.toString(),headers:S(this.config,r)})}async getPullRequestsForRepo(t,r={}){let s=[],n=await this.getPullRequestsForRepoBase(t,r);n.body.values.forEach(a=>{if(t.authorLogin&&a.author.uuid!==t.authorLogin)return null;s.push(qe(a))});let o=!!n.body.next;return{pageInfo:{hasNextPage:o,nextPage:o?n.body.page+1:null},data:s}}async getPullRequestsForRepos(t,r={}){let s=[];return await Promise.all(t.repos.map(async n=>{try{(await this.getPullRequestsForRepoBase({repo:n,...t},r)).body.values.forEach(a=>{if(t.authorLogin&&a.author.uuid!==t.authorLogin)return null;s.push(qe(a))})}catch(o){if(o.statusCode!==404&&o.statusCode!==401)throw o}})),{data:s}}async closePullRequest(t,r={}){let{repo:{namespace:s,name:n},pullRequestId:o}=t;if(!(await this.config.request({method:"POST",url:`${G}/repositories/${s}/${n}/pullrequests/${o}/decline`,headers:S(this.config,r)})).body.title)throw new Error("Could not close pull request")}async mergePullRequest(t,r={}){let{repo:{namespace:s,name:n},pullRequestId:o}=t;if(!(await this.config.request({method:"POST",url:`${G}/repositories/${s}/${n}/pullrequests/${o}/merge`,headers:S(this.config,r)})).body.title)throw new Error("Could not merge pull request")}};var N=class extends A{getBaseUrl(t){let r=t.baseUrl||this.config.baseUrl;if(!r)throw new Error('Bitbucket Server requires "baseUrl"');return r}getRequestHeaders(t){return f(t.token||this.config.token)}async getRepo(t,r={}){var n,o,a;let s=await this.config.request({url:`${this.getBaseUrl(r)}/projects/${t.namespace}/repos/${t.name}`,headers:this.getRequestHeaders(r)});return{data:{id:s.body.id.toString(),namespace:s.body.project.key,name:s.body.slug,webUrl:((n=s.body.links.self[0])==null?void 0:n.href)??null,httpsUrl:((o=s.body.links.clone.find(i=>i.name==="https"))==null?void 0:o.href)??null,sshUrl:((a=s.body.links.clone.find(i=>i.name==="ssh"))==null?void 0:a.href)??null,defaultBranch:null,permission:null}}}async getRepos(t,r={}){return{data:(await Promise.all(t.map(n=>this.getRepo(n,r)))).map(n=>n.data)}}};var ie="https://api.github.com",Ye=`${ie}/graphql`,Le=/\/api\/v\d+$/,et=e=>{if(e.endsWith("/api/graphql"))throw new Error("The graphql endpoint is being used as the baseUrl. This package uses both GraphQL and REST APIs, and the REST version cannot be assumed. Use the REST endpoint as the baseUrl instead.")},tt=(e,t)=>{let r=t.baseUrl||e.baseUrl;return r?(r=r.replace(/\/$/,""),et(r),Le.test(r)&&(r=r.replace(Le,"")),`${r}/api/graphql`):Ye},R=(e,t,r)=>{let s=f(r.token||e.token);return s["X-Github-Next-Global-ID"]="1",s["Content-Type"]="application/json",e.request({url:tt(e,r),method:"POST",headers:s,body:JSON.stringify(t)})},rt={user:!0,"user:email":!0,"read:user":!0},_=e=>e.some(t=>rt[t]),$=(e=!1,t=!1)=>`
2
2
  __typename
3
3
  id
4
4
  databaseId
@@ -12,7 +12,7 @@ id
12
12
  databaseId
13
13
  login
14
14
  avatarUrl${e?"(size: $avatarSize)":""}
15
- `,rt=(e,t=!1)=>`
15
+ `,st=(e,t=!1)=>`
16
16
  id
17
17
  databaseId
18
18
  number
@@ -20,7 +20,7 @@ title
20
20
  state
21
21
  author {
22
22
  ... on User {
23
- ${S(!1,t)}
23
+ ${$(!1,t)}
24
24
  }
25
25
  ... on Bot {
26
26
  ${ue(!1)}
@@ -83,7 +83,7 @@ updatedAt
83
83
  closedAt
84
84
  assignees(first: 100) {
85
85
  nodes {
86
- ${S(!1,t)}
86
+ ${$(!1,t)}
87
87
  }
88
88
  }
89
89
  reviewRequests(first: 100) {
@@ -91,7 +91,7 @@ reviewRequests(first: 100) {
91
91
  asCodeOwner
92
92
  requestedReviewer {
93
93
  ... on User {
94
- ${S(!1,t)}
94
+ ${$(!1,t)}
95
95
  }
96
96
  }
97
97
  }
@@ -100,7 +100,7 @@ latestReviews(first: 100) {
100
100
  nodes {
101
101
  author {
102
102
  ... on User {
103
- ${S(!1,t)}
103
+ ${$(!1,t)}
104
104
  }
105
105
  }
106
106
  state
@@ -110,30 +110,20 @@ additions
110
110
  deletions
111
111
  changedFiles
112
112
  mergeable
113
- `,st={"-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"},nt=new RegExp('(([^\\s]+:)?\\"(?:[^\\"\\\\]|\\\\.)*\\"?)|([^\\"\\s]+)',"g"),le=e=>{let t=[];return(e.match(nt)??[]).forEach(s=>{if(s.includes(":")&&s!="is:closed"){let n=s.split(":")[0];st[n]&&t.push(s)}}),t},pe=async(e,t,r,s=!0,n=!1)=>{let{cursor:o,assigneeLogins:a,updatedBefore:i,isDraft:u,authorLogin:l,repos:p,reviewRequestedLogin:g,startQuery:m,mentionLogin:d}=t||{},c=le(m||"");p.forEach(f=>{c.push(`repo:${f.namespace}/${f.name}`)}),a&&a.forEach(f=>{c.push(`assignee:${f}`)}),i&&c.push(`updated:<${i}`),s&&u!=null&&u!=null&&c.push(`draft:${String(u)}`),l&&c.push(`author:${l}`),g&&c.push(`review-requested:${g}`),d&&c.push(`mentions:${d}`);let b=`
114
- query (
115
- $after: String
116
- $search: String!
117
- ) {
118
- search(
119
- type: ISSUE
120
- first: 100
121
- after: $after
122
- query: $search
123
- ) {
113
+ `,nt={"-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"},ot=new RegExp('(([^\\s]+:)?\\"(?:[^\\"\\\\]|\\\\.)*\\"?)|([^\\"\\s]+)',"g"),pe=e=>{let t=[];return(e.match(ot)??[]).forEach(s=>{if(s.includes(":")&&s!="is:closed"){let n=s.split(":")[0];nt[n]&&t.push(s)}}),t},xe=(e,t,r,s)=>({query:`
114
+ query SearchPullRequests($query: String! $after: String) {
115
+ search(type:ISSUE query:$query first:100 after:$after) {
116
+ pageInfo {
117
+ hasNextPage
118
+ endCursor
119
+ }
124
120
  nodes {
125
121
  ... on PullRequest {
126
- ${rt(s,n)}
122
+ ${st(r,s)}
127
123
  }
128
124
  }
129
- pageInfo {
130
- endCursor
131
- hasNextPage
132
- startCursor
133
- }
134
125
  }
135
- }
136
- `;return I(e,{query:`${b}`,variables:{after:o??null,search:`sort:updated type:pr state:open ${c.join(" ")}`}},r)};var de=`
126
+ }`,variables:{query:`is:pr is:open ${e}`,after:t}}),at="Field 'isDraft' doesn't exist on type 'PullRequest'",Ae=(e=[])=>e.some(t=>(t==null?void 0:t.message)===at);var le=`
137
127
  id
138
128
  databaseId
139
129
  owner {
@@ -146,13 +136,13 @@ defaultBranchRef {
146
136
  name
147
137
  }
148
138
  viewerPermission
149
- `,me={__typename:"User",id:"U_kgDNJ5k",databaseId:10137,name:"Deleted user",login:"ghost",email:"",avatarUrl:"https://avatars.githubusercontent.com/u/10137?v=4"},ot={APPROVED:"APPROVED",CHANGES_REQUESTED:"CHANGES_REQUESTED",COMMENTED:"COMMENTED",REVIEW_REQUESTED:"REVIEW_REQUESTED"},at={MERGEABLE:"MERGEABLE",CONFLICTING:"CONFLICTS",UNKNOWN:"UNKNOWN"},ge=e=>({id:e.databaseId.toString(),graphQLId:e.id,namespace:e.owner.login,name:e.name,webUrl:e.url,httpsUrl:e.url.endsWith(".git")?e.url:`${e.url}.git`,sshUrl:e.sshUrl,defaultBranch:e.defaultBranchRef,permission:e.viewerPermission}),it={OPEN:"OPEN",CLOSED:"CLOSED",MERGED:"MERGED"},G=e=>({id:e.databaseId.toString(),graphQLId:e.id,name:e.name??e.login,username:e.login,email:e.email??null,avatarUrl:e.avatarUrl}),ut=e=>{var l,p,g,m,d,c,b,f;let t=null;e.author?t=(e.author.__typename==="Bot",e.author):t=me;let r=(p=(l=e.commits.nodes)==null?void 0:l[0])==null?void 0:p.commit,s=((g=e.headRef)==null?void 0:g.target)||r,n=s==null?void 0:s.oid,o=r==null?void 0:r.oid,a=n===o?(d=(m=r==null?void 0:r.status)==null?void 0:m.contexts)==null?void 0:d[0]:null,i=(((c=e.reviewRequests)==null?void 0:c.nodes)||[]).filter(h=>!h.asCodeOwner),u=(b=e.headRepository)==null?void 0:b.url;return u&&!u.endsWith(".git")&&(u=`${u}.git`),{id:e.databaseId.toString(),graphQLId:e.id,title:e.title,number:e.number,state:it[e.state],commentCount:e.comments.totalCount,upvoteCount:e.reactions.totalCount,author:t?G(t):null,createdDate:new Date(e.createdAt),isDraft:e.isDraft,repository:{name:e.repository.name,owner:{login:e.repository.owner.login}},headRepository:e.headRepository?{name:e.headRepository.name,owner:{login:e.headRepository.owner.login},remoteInfo:{cloneUrlHTTPS:u,cloneUrlSSH:e.headRepository.sshUrl}}:null,headCommit:{buildStatus:a||null},headRef:e.headRef?{name:e.headRef.name}:null,baseRef:e.baseRef?{name:e.baseRef.name}:null,url:e.url,updatedDate:new Date(e.updatedAt),closedDate:e.closedAt?new Date(e.closedAt):null,assignees:e.assignees.nodes?e.assignees.nodes.map(G):null,reviews:i.map(h=>({reviewer:G(h.requestedReviewer),state:"REVIEW_REQUESTED"})).concat((((f=e.latestReviews)==null?void 0:f.nodes)||[]).map(h=>{let R=h.author||me;return{reviewer:G(R),state:ot[h.state]}})),additions:e.additions,deletions:e.deletions,fileCount:e.changedFiles,commitCount:e.commits.totalCount,mergeableState:at[e.mergeable]}},lt=e=>{let t=null;return e.author?t=(e.author.__typename==="Bot",e.author):t=me,{id:e.databaseId.toString(),graphQLId:e.id,number:e.number,title:e.title,author:G(t),commentCount:e.comments.totalCount,createdDate:new Date(e.createdAt),description:null,state:null,type:null,repository:{name:e.repository.name,owner:{login:e.repository.owner.login}},url:e.url,updatedDate:new Date(e.updatedAt),assignees:e.assignees.nodes?e.assignees.nodes.map(G):[],upvoteCount:e.reactions.totalCount}},F=class extends A{constructor(){super(...arguments);this._scopesCache={}}async getScopes(r){let s=r.token||this.config.token;if(!s)return[];let n=this._scopesCache[s];if(!n){let a=(await I(this.config,{query:"query { rateLimit(dryRun: true) { __typename } }"},r)).headers["x-oauth-scopes"];n=a?a.split(", "):[],this._scopesCache[s]=n}return n}getEnterpriseAvatarUrlIfNeeded(r,s,n){let o=n.baseUrl||this.config.baseUrl;return!o||o.startsWith(ie)?r:s?`https://avatars.githubusercontent.com/u/e?email=${encodeURIComponent(s)}`:""}async getCurrentUser(r={}){var a;let s=await this.getScopes(r),o=(a=(await I(this.config,{query:`
139
+ `,ce={__typename:"User",id:"U_kgDNJ5k",databaseId:10137,name:"Deleted user",login:"ghost",email:"",avatarUrl:"https://avatars.githubusercontent.com/u/10137?v=4"},it={APPROVED:"APPROVED",CHANGES_REQUESTED:"CHANGES_REQUESTED",COMMENTED:"COMMENTED",REVIEW_REQUESTED:"REVIEW_REQUESTED"},ut={MERGEABLE:"MERGEABLE",CONFLICTING:"CONFLICTS",UNKNOWN:"UNKNOWN"},de=e=>({id:e.databaseId.toString(),graphQLId:e.id,namespace:e.owner.login,name:e.name,webUrl:e.url,httpsUrl:e.url.endsWith(".git")?e.url:`${e.url}.git`,sshUrl:e.sshUrl,defaultBranch:e.defaultBranchRef,permission:e.viewerPermission}),pt={OPEN:"OPEN",CLOSED:"CLOSED",MERGED:"MERGED"},L=e=>({id:e.databaseId.toString(),graphQLId:e.id,name:e.name??e.login,username:e.login,email:e.email??null,avatarUrl:e.avatarUrl}),lt=e=>{var p,l,d,c,g,I,P,y;let t=null;e.author?t=(e.author.__typename==="Bot",e.author):t=ce;let r=(l=(p=e.commits.nodes)==null?void 0:p[0])==null?void 0:l.commit,s=((d=e.headRef)==null?void 0:d.target)||r,n=s==null?void 0:s.oid,o=r==null?void 0:r.oid,a=n===o?(g=(c=r==null?void 0:r.status)==null?void 0:c.contexts)==null?void 0:g[0]:null,i=(((I=e.reviewRequests)==null?void 0:I.nodes)||[]).filter(m=>!m.asCodeOwner),u=(P=e.headRepository)==null?void 0:P.url;return u&&!u.endsWith(".git")&&(u=`${u}.git`),{id:e.databaseId.toString(),graphQLId:e.id,title:e.title,number:e.number,state:pt[e.state],commentCount:e.comments.totalCount,upvoteCount:e.reactions.totalCount,author:t?L(t):null,createdDate:new Date(e.createdAt),isDraft:e.isDraft,repository:{name:e.repository.name,owner:{login:e.repository.owner.login}},headRepository:e.headRepository?{name:e.headRepository.name,owner:{login:e.headRepository.owner.login},remoteInfo:{cloneUrlHTTPS:u,cloneUrlSSH:e.headRepository.sshUrl}}:null,headCommit:{buildStatus:a||null},headRef:e.headRef?{name:e.headRef.name}:null,baseRef:e.baseRef?{name:e.baseRef.name}:null,url:e.url,updatedDate:new Date(e.updatedAt),closedDate:e.closedAt?new Date(e.closedAt):null,assignees:e.assignees.nodes?e.assignees.nodes.map(L):null,reviews:i.map(m=>({reviewer:L(m.requestedReviewer),state:"REVIEW_REQUESTED"})).concat((((y=e.latestReviews)==null?void 0:y.nodes)||[]).map(m=>{let h=m.author||ce;return{reviewer:L(h),state:it[m.state]}})),additions:e.additions,deletions:e.deletions,fileCount:e.changedFiles,commitCount:e.commits.totalCount,mergeableState:ut[e.mergeable]}},dt=e=>{let t=null;return e.author?t=(e.author.__typename==="Bot",e.author):t=ce,{id:e.databaseId.toString(),graphQLId:e.id,number:e.number,title:e.title,author:L(t),commentCount:e.comments.totalCount,createdDate:new Date(e.createdAt),description:null,state:null,type:null,repository:{name:e.repository.name,owner:{login:e.repository.owner.login}},url:e.url,updatedDate:new Date(e.updatedAt),assignees:e.assignees.nodes?e.assignees.nodes.map(L):[],upvoteCount:e.reactions.totalCount}},Q=class extends A{constructor(){super(...arguments);this._scopesCache={}}async getScopes(r){let s=r.token||this.config.token;if(!s)return[];let n=this._scopesCache[s];if(!n){let a=(await R(this.config,{query:"query { rateLimit(dryRun: true) { __typename } }"},r)).headers["x-oauth-scopes"];n=a?a.split(", "):[],this._scopesCache[s]=n}return n}getEnterpriseAvatarUrlIfNeeded(r,s,n){let o=n.baseUrl||this.config.baseUrl;return!o||o.startsWith(ie)?r:s?`https://avatars.githubusercontent.com/u/e?email=${encodeURIComponent(s)}`:""}async getCurrentUser(r={}){var a;let s=await this.getScopes(r),o=(a=(await R(this.config,{query:`
150
140
  query getCurrentUser {
151
141
  viewer {
152
- ${S(!1,k(s))}
142
+ ${$(!1,_(s))}
153
143
  }
154
144
  }
155
- `},r)).body.data)==null?void 0:a.viewer;if(!o)throw new Error("Current user not found.");return{data:G(o)}}async getUserForCommit(r,s={}){var i,u;let o=(i=(await I(this.config,{query:`
145
+ `},r)).body.data)==null?void 0:a.viewer;if(!o)throw new Error("Current user not found.");return{data:L(o)}}async getUserForCommit(r,s={}){var i,u;let o=(i=(await R(this.config,{query:`
156
146
  query getUserForCommit(
157
147
  $owner: String!
158
148
  $name: String!
@@ -171,23 +161,23 @@ query getUserForCommit(
171
161
  }
172
162
  }
173
163
  }
174
- `,variables:{owner:r.repo.namespace,name:r.repo.name,oid:r.oid,avatarSize:r.avatarSize}},s)).body.data)==null?void 0:i.repository;if(!o)throw new Error("Repository not found.");let a=(u=o.object)==null?void 0:u.author;if(!a)throw new Error("Commit not found.");return{data:{name:a.name,email:a.email,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(a.avatarUrl,a.email,s)}}}async getAccountForEmail(r,s={}){var i,u,l;let n=await this.getScopes(s),a=(l=(u=(i=(await I(this.config,{query:`
164
+ `,variables:{owner:r.repo.namespace,name:r.repo.name,oid:r.oid,avatarSize:r.avatarSize}},s)).body.data)==null?void 0:i.repository;if(!o)throw new Error("Repository not found.");let a=(u=o.object)==null?void 0:u.author;if(!a)throw new Error("Commit not found.");return{data:{name:a.name,email:a.email,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(a.avatarUrl,a.email,s)}}}async getAccountForEmail(r,s={}){var i,u,p;let n=await this.getScopes(s),a=(p=(u=(i=(await R(this.config,{query:`
175
165
  query getAccountForEmail($query: String! $avatarSize: Int) {
176
166
  search(query: $query, type: USER, first: 1) {
177
167
  nodes {
178
168
  ... on User {
179
- ${S(!0,k(n))}
169
+ ${$(!0,_(n))}
180
170
  }
181
171
  }
182
172
  }
183
173
  }
184
- `,variables:{query:`in:email ${r.email}`,avatarSize:r.avatarSize}},s)).body.data)==null?void 0:i.search)==null?void 0:u.nodes)==null?void 0:l[0];if(!a)throw new Error("User not found.");return{data:G({...a,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(a.avatarUrl,a.email,s)})}}async getAccountForUsername(r,s={}){var i;let n=await this.getScopes(s),a=(i=(await I(this.config,{query:`
174
+ `,variables:{query:`in:email ${r.email}`,avatarSize:r.avatarSize}},s)).body.data)==null?void 0:i.search)==null?void 0:u.nodes)==null?void 0:p[0];if(!a)throw new Error("User not found.");return{data:L({...a,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(a.avatarUrl,a.email,s)})}}async getAccountForUsername(r,s={}){var i;let n=await this.getScopes(s),a=(i=(await R(this.config,{query:`
185
175
  query getUserForUsername($login: String! $avatarSize: Int) {
186
176
  user(login: $login) {
187
- ${S(!0,k(n))}
177
+ ${$(!0,_(n))}
188
178
  }
189
179
  }
190
- `,variables:{login:r.username,avatarSize:r.avatarSize}},s)).body.data)==null?void 0:i.user;if(!a)throw new Error("User not found.");return{data:G({...a,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(a.avatarUrl,a.email,s)})}}async getOrgsForCurrentUser(r={},s={}){var a,i;let n=await I(this.config,{query:`
180
+ `,variables:{login:r.username,avatarSize:r.avatarSize}},s)).body.data)==null?void 0:i.user;if(!a)throw new Error("User not found.");return{data:L({...a,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(a.avatarUrl,a.email,s)})}}async getOrgsForCurrentUser(r={},s={}){var a,i;let n=await R(this.config,{query:`
191
181
  query getOrgsForCurrentUser($cursor: String, $first: Int!) {
192
182
  viewer {
193
183
  organizations(first: $first after: $cursor) {
@@ -206,22 +196,22 @@ query getOrgsForCurrentUser($cursor: String, $first: Int!) {
206
196
  }
207
197
  }
208
198
  }
209
- `,variables:{cursor:r.cursor,first:v}},s);if(!((a=n.body.data)!=null&&a.viewer.organizations))throw new Error(((i=n.body.errors)==null?void 0:i[0].message)||n.statusText||"Unknown error");let o=n.body.data.viewer.organizations.nodes||[];return{pageInfo:n.body.data.viewer.organizations.pageInfo,data:o.map(u=>({id:u.databaseId.toString(),graphQLId:u.id,username:u.login,name:u.name||null,email:u.email||null,avatarUrl:u.avatarUrl}))}}async getRepo(r,s={}){var o;let n=await I(this.config,{query:`
199
+ `,variables:{cursor:r.cursor,first:v}},s);if(!((a=n.body.data)!=null&&a.viewer.organizations))throw new Error(((i=n.body.errors)==null?void 0:i[0].message)||n.statusText||"Unknown error");let o=n.body.data.viewer.organizations.nodes||[];return{pageInfo:n.body.data.viewer.organizations.pageInfo,data:o.map(u=>({id:u.databaseId.toString(),graphQLId:u.id,username:u.login,name:u.name||null,email:u.email||null,avatarUrl:u.avatarUrl}))}}async getRepo(r,s={}){var o;let n=await R(this.config,{query:`
210
200
  query getRepo($owner: String!, $name: String!) {
211
201
  repository(owner: $owner, name: $name) {
212
- ${de}
202
+ ${le}
213
203
  }
214
204
  }
215
- `,variables:{owner:r.namespace,name:r.name}},s);if(!((o=n.body.data)!=null&&o.repository))throw new Error(`Repository ${r.namespace}/${r.name} not found`);return{data:ge(n.body.data.repository)}}async getRepos(r,s={}){let n=r.map(({namespace:a,name:i},u)=>`
216
- getRepo_${u}: repository(owner: "${a}", name: "${i}") {
217
- ${de}
205
+ `,variables:{owner:r.namespace,name:r.name}},s);if(!((o=n.body.data)!=null&&o.repository))throw new Error(`Repository ${r.namespace}/${r.name} not found`);return{data:de(n.body.data.repository)}}async getRepos(r,s={}){let n=r.map(({namespace:u,name:p},l)=>`
206
+ getRepo_${l}: repository(owner: "${u}", name: "${p}") {
207
+ ${le}
218
208
  }
219
209
  `).join(`
220
- `),o=await I(this.config,{query:`
210
+ `),o=await R(this.config,{query:`
221
211
  query batchGetRepos {
222
212
  ${n}
223
213
  }
224
- `},s);if(!o.body.data)throw new Error(o.statusText||"Unknown error");return{data:r.map(({namespace:a,name:i},u)=>{let l=o.body.data[`getRepo_${u}`];if(!l)throw new Error(`Repository ${a}/${i} not found`);return ge(l)})}}async getReposForUsernames(r,s={}){var a;if(!r.usernames.length)return{pageInfo:{endCursor:null,hasNextPage:!1},data:[]};let n=await I(this.config,{query:`
214
+ `},s);if(!o.body.data)throw new Error(o.statusText||"Unknown error");let a=[],i=[];return r.forEach((u,p)=>{let l=o.body.data[`getRepo_${p}`];l?a.push(de(l)):i.push({input:u})}),{data:a,errors:i}}async getReposForUsernames(r,s={}){var a;if(!r.usernames.length)return{pageInfo:{endCursor:null,hasNextPage:!1},data:[]};let n=await R(this.config,{query:`
225
215
  query getReposForUsernames($query: String!, $cursor: String, $first: Int!) {
226
216
  search(query: $query, type: REPOSITORY, first: $first, after: $cursor) {
227
217
  pageInfo {
@@ -230,12 +220,12 @@ query getReposForUsernames($query: String!, $cursor: String, $first: Int!) {
230
220
  }
231
221
  nodes {
232
222
  ... on Repository {
233
- ${de}
223
+ ${le}
234
224
  }
235
225
  }
236
226
  }
237
227
  }
238
- `,variables:{query:`fork:true ${r.usernames.map(i=>`user:${i}`).join(" ")}`,cursor:r.cursor,first:v}},s);if(!n.body.data)throw new Error(((a=n.body.errors)==null?void 0:a[0].message)||n.statusText||"Unknown error");let o=n.body.data.search.nodes||[];return{pageInfo:n.body.data.search.pageInfo,data:o.map(ge)}}async getReposForOwners(r,s={}){return this.getReposForUsernames({usernames:r.owners.filter(n=>n.username).map(n=>n.username),cursor:r.cursor},s)}async getRefs(r,s,n={}){var u;let a=(u=(await I(this.config,{query:`
228
+ `,variables:{query:`fork:true ${r.usernames.map(i=>`user:${i}`).join(" ")}`,cursor:r.cursor,first:v}},s);if(!n.body.data)throw new Error(((a=n.body.errors)==null?void 0:a[0].message)||n.statusText||"Unknown error");let o=n.body.data.search.nodes||[];return{pageInfo:n.body.data.search.pageInfo,data:o.map(de)}}async getReposForOwners(r,s={}){return this.getReposForUsernames({usernames:r.owners.filter(n=>n.username).map(n=>n.username),cursor:r.cursor},s)}async getRefs(r,s,n={}){var u;let a=(u=(await R(this.config,{query:`
239
229
  query getRefs($owner: String!, $name: String!, $refPrefix: String!, $cursor: String, $first: Int!) {
240
230
  repository(owner: $owner, name: $name) {
241
231
  refs(refPrefix: $refPrefix first: $first after: $cursor) {
@@ -256,7 +246,7 @@ query getRefs($owner: String!, $name: String!, $refPrefix: String!, $cursor: Str
256
246
  }
257
247
  }
258
248
  }
259
- `,variables:{owner:s.repo.namespace,name:s.repo.name,refPrefix:r,cursor:s.cursor,first:v}},n)).body.data)==null?void 0:u.repository;if(!a)throw new Error("Repository not found.");let i=a.refs;return i?{pageInfo:i.pageInfo,data:(i.nodes||[]).map(l=>{var g;let p=(g=l.target)!=null&&g.oid?l.target:null;return{name:l.name,commit:p?{oid:p.oid,authoredDate:new Date(p.authoredDate),committedDate:new Date(p.committedDate)}:null}})}:{pageInfo:{endCursor:null,hasNextPage:!1},data:[]}}async getBranches(r,s={}){return this.getRefs("refs/heads/",r,s)}async getTags(r,s={}){return this.getRefs("refs/tags/",r,s)}async getBlame(r,s={}){var i;let o=(i=(await I(this.config,{query:`
249
+ `,variables:{owner:s.repo.namespace,name:s.repo.name,refPrefix:r,cursor:s.cursor,first:v}},n)).body.data)==null?void 0:u.repository;if(!a)throw new Error("Repository not found.");let i=a.refs;return i?{pageInfo:i.pageInfo,data:(i.nodes||[]).map(p=>{var d;let l=(d=p.target)!=null&&d.oid?p.target:null;return{name:p.name,commit:l?{oid:l.oid,authoredDate:new Date(l.authoredDate),committedDate:new Date(l.committedDate)}:null}})}:{pageInfo:{endCursor:null,hasNextPage:!1},data:[]}}async getBranches(r,s={}){return this.getRefs("refs/heads/",r,s)}async getTags(r,s={}){return this.getRefs("refs/tags/",r,s)}async getBlame(r,s={}){var i;let o=(i=(await R(this.config,{query:`
260
250
  query getBlame($owner: String!, $name: String!, $ref: String!, $path: String!) {
261
251
  repository(owner: $owner, name: $name) {
262
252
  object(expression: $ref) {
@@ -295,7 +285,19 @@ query getBlame($owner: String!, $name: String!, $ref: String!, $path: String!) {
295
285
  }
296
286
  }
297
287
  }
298
- `,variables:{owner:r.repo.namespace,name:r.repo.name,ref:r.ref,path:r.path}},s)).body.data)==null?void 0:i.repository;if(!o)throw new Error("Repository not found.");let a=o.object;if(!a||!("blame"in a))throw new Error("Ref not found.");if(a.blame.ranges.length===0)throw new Error("File not found.");return{data:{ranges:a.blame.ranges.map(u=>{var l;return{startingLine:u.startingLine,endingLine:u.endingLine,commit:{oid:u.commit.oid,parentOids:((l=u.commit.parents.nodes)==null?void 0:l.map(p=>p.oid))||[],authoredDate:new Date(u.commit.authoredDate),author:u.commit.author?{name:u.commit.author.name,email:u.commit.author.email,avatarUrl:u.commit.author.avatarUrl}:null,committedDate:new Date(u.commit.committedDate),committer:u.commit.committer?{name:u.commit.committer.name,email:u.commit.committer.email,avatarUrl:u.commit.committer.avatarUrl}:null,message:u.commit.message,fileCount:u.commit.changedFilesIfAvailable,additions:u.commit.additions,deletions:u.commit.deletions}}})}}}async getPullRequestsForRepos(r,s={}){var l,p,g,m,d,c,b,f;let n=await this.getScopes(s),o=k(n),a="Field 'isDraft' doesn't exist on type 'PullRequest'",i=await pe(this.config,r,s,!0,o);if(i.body.errors){let R=((p=(l=i==null?void 0:i.body.errors)==null?void 0:l[0])==null?void 0:p.message)===a;s.baseUrl&&R&&(i=await pe(this.config,r,s,!1,o))}let u=((d=(m=(g=i.body)==null?void 0:g.data)==null?void 0:m.search)==null?void 0:d.nodes)||[];return{pageInfo:(f=(b=(c=i.body)==null?void 0:c.data)==null?void 0:b.search)==null?void 0:f.pageInfo,data:u.map(ut)}}async getIssuesForRepos(r,s={}){var b,f,h,R,P,E;let n=await this.getScopes(s),o=k(n),a=le(r.startQuery||""),{cursor:i,assigneeLogins:u,updatedBefore:l,authorLogin:p,mentionLogin:g}=r||{};r.repos.forEach($=>{a.push(`repo:${$.namespace}/${$.name}`)}),u&&u.forEach($=>{a.push(`assignee:${$}`)}),l&&a.push(`updated:<${l}`),p&&a.push(`author:${p}`),g&&a.push(`mentions:${g}`);let m=`
288
+ `,variables:{owner:r.repo.namespace,name:r.repo.name,ref:r.ref,path:r.path}},s)).body.data)==null?void 0:i.repository;if(!o)throw new Error("Repository not found.");let a=o.object;if(!a||!("blame"in a))throw new Error("Ref not found.");if(a.blame.ranges.length===0)throw new Error("File not found.");return{data:{ranges:a.blame.ranges.map(u=>{var p;return{startingLine:u.startingLine,endingLine:u.endingLine,commit:{oid:u.commit.oid,parentOids:((p=u.commit.parents.nodes)==null?void 0:p.map(l=>l.oid))||[],authoredDate:new Date(u.commit.authoredDate),author:u.commit.author?{name:u.commit.author.name,email:u.commit.author.email,avatarUrl:u.commit.author.avatarUrl}:null,committedDate:new Date(u.commit.committedDate),committer:u.commit.committer?{name:u.commit.committer.name,email:u.commit.committer.email,avatarUrl:u.commit.committer.avatarUrl}:null,message:u.commit.message,fileCount:u.commit.changedFilesIfAvailable,additions:u.commit.additions,deletions:u.commit.deletions}}})}}}async searchPullRequests(r,s={}){var p,l;let n=await this.getScopes(s),o=_(n),a=d=>{let c=d&&typeof r.isDraft=="boolean"?`${r.query} draft:${r.isDraft}`:r.query;return xe(c,r.cursor,d,o)},i=await R(this.config,a(!0),s);i.body.errors&&Ae(i.body.errors)&&(this.config.baseUrl||s.baseUrl)&&(i=await R(this.config,a(!1),s));let{data:u}=i.body;if(!u)throw new Error(((p=i.body.errors)==null?void 0:p[0].message)||i.statusText||"Unknown error");return{pageInfo:{hasNextPage:u.search.pageInfo.hasNextPage,endCursor:u.search.pageInfo.endCursor},data:((l=u.search.nodes)==null?void 0:l.map(lt))||[]}}async getPullRequestsAssociatedWithUser(r,s={}){var g;let[n,o,a]=((g=r.cursor)==null?void 0:g.split(";"))||[void 0,void 0,void 0];if(r.cursor&&n==="null"&&o==="null"&&a==="null")return{pageInfo:{hasNextPage:!1,endCursor:"null;null;null"},data:[]};let[i,u,p]=await Promise.all([this.searchPullRequests({query:`author:${r.username}`,cursor:n},s),this.searchPullRequests({query:`assignee:${r.username}`,cursor:o},s),this.searchPullRequests({query:`review-requested:${r.username}`,cursor:a},s)]),l={},d=[],c=I=>{l[I.id]||(l[I.id]=!0,d.push(I))};return i.data.forEach(c),u.data.forEach(c),p.data.forEach(c),{pageInfo:{hasNextPage:i.pageInfo.hasNextPage||u.pageInfo.hasNextPage||p.pageInfo.hasNextPage,endCursor:`${(i==null?void 0:i.pageInfo.hasNextPage)&&(i==null?void 0:i.pageInfo.endCursor)||"null"};${(u==null?void 0:u.pageInfo.hasNextPage)&&(u==null?void 0:u.pageInfo.endCursor)||"null"};${(p==null?void 0:p.pageInfo.hasNextPage)&&(p==null?void 0:p.pageInfo.endCursor)||"null"}`},data:d}}async getPullRequestsForRepos(r,s={}){let{assigneeLogins:n,updatedBefore:o,authorLogin:a,repos:i,reviewRequestedLogin:u,startQuery:p,mentionLogin:l}=r,d=pe(p||"");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}`),l&&d.push(`mentions:${l}`),await this.searchPullRequests({query:`sort:updated ${d.join(" ")}`,isDraft:r.isDraft,cursor:r.cursor},s)}async closePullRequest(r,s={}){var i,u,p;let{pullRequestGraphQLId:n}=r,o=`mutation ClosePullRequest($pullRequestGraphQLId: ID!) {
289
+ closePullRequest(input: { pullRequestId: $pullRequestGraphQLId }) {
290
+ pullRequest {
291
+ id
292
+ }
293
+ }
294
+ }`;if(!((p=(u=(i=(await R(this.config,{query:`${o}`,variables:{pullRequestGraphQLId:n}},s)).body.data)==null?void 0:i.closePullRequest)==null?void 0:u.pullRequest)!=null&&p.id))throw new Error("Could not close pull request")}async mergePullRequest(r,s={}){var u,p,l;let{pullRequestGraphQLId:n,expectedSourceSha:o}=r,a=`mutation MergePullRequest($pullRequestGraphQLId: ID!, $expectedSourceSha: GitObjectID!) {
295
+ mergePullRequest(input: { pullRequestId: $pullRequestGraphQLId, expectedHeadOid: $expectedSourceSha }) {
296
+ pullRequest {
297
+ id
298
+ }
299
+ }
300
+ }`;if(!((l=(p=(u=(await R(this.config,{query:`${a}`,variables:{pullRequestGraphQLId:n,expectedSourceSha:o}},s)).body.data)==null?void 0:u.mergePullRequest)==null?void 0:p.pullRequest)!=null&&l.id))throw new Error("Could not merge pull request")}async getIssuesForRepos(r,s={}){var P,y,m,h,C,D;let n=await this.getScopes(s),o=_(n),a=pe(r.startQuery||""),{cursor:i,assigneeLogins:u,updatedBefore:p,authorLogin:l,mentionLogin:d}=r;r.repos.forEach(q=>{a.push(`repo:${q.namespace}/${q.name}`)}),u&&u.forEach(q=>{a.push(`assignee:${q}`)}),p&&a.push(`updated:<${p}`),l&&a.push(`author:${l}`),d&&a.push(`mentions:${d}`);let c=`
299
301
  query (
300
302
  $after: String
301
303
  $search: String!
@@ -313,7 +315,7 @@ query (
313
315
  title
314
316
  author {
315
317
  ... on User {
316
- ${S(!1,o)}
318
+ ${$(!1,o)}
317
319
  }
318
320
  ... on Bot {
319
321
  ${ue(!1)}
@@ -337,7 +339,7 @@ query (
337
339
  }
338
340
  assignees(first: 100) {
339
341
  nodes {
340
- ${S(!1,o)}
342
+ ${$(!1,o)}
341
343
  }
342
344
  }
343
345
  }
@@ -345,11 +347,28 @@ query (
345
347
  pageInfo {
346
348
  endCursor
347
349
  hasNextPage
348
- startCursor
349
350
  }
350
351
  }
351
352
  }
352
- `,d=await I(this.config,{query:`${m}`,variables:{after:i??null,search:`sort:updated type:issue state:open ${a.join(" ")}`}},s);if(!d.body.data)throw new Error(d.statusText||"Unknown error");let c=((h=(f=(b=d.body)==null?void 0:b.data)==null?void 0:f.search)==null?void 0:h.nodes)||[];return{pageInfo:(E=(P=(R=d.body)==null?void 0:R.data)==null?void 0:P.search)==null?void 0:E.pageInfo,data:c.map(lt)}}};var pt="https://gitlab.com/api/v4",dt="https://gitlab.com/api/graphql",Ae=/\/api\/v\d+$/,xe=e=>{if(e.endsWith("/api/graphql"))throw new Error("The graphql endpoint is being used as the baseUrl. This package uses both GraphQL and REST APIs, and the REST version cannot be assumed. Use the REST endpoint as the baseUrl instead.")},ce=(e,t)=>{let r=t.baseUrl||e.baseUrl;return r?(r=r.replace(/\/$/,""),xe(r),r):pt},gt=(e,t)=>{let r=t.baseUrl||e.baseUrl;return r?(r=r.replace(/\/$/,""),xe(r),Ae.test(r)&&(r=r.replace(Ae,"")),`${r}/api/graphql`):dt},U=(e,t,r)=>{let s=y(r.token||e.token);return e.request({url:gt(e,r),method:"POST",headers:{...s,"Content-Type":"application/json"},body:JSON.stringify(t)})};var mt={CAN_BE_MERGED:"MERGEABLE",CANNOT_BE_MERGED:"CONFLICTS",CANNOT_BE_MERGED_RECHECK:"UNKNOWN",UNCHECKED:"UNKNOWN",CHECKING:"UNKNOWN"},ye="gid://gitlab/User/",Q="gid://gitlab/Project/",ct="gid://gitlab/MergeRequest/",ht="gid://gitlab/Issue/",he=`
353
+ `,g=await R(this.config,{query:`${c}`,variables:{after:i??null,search:`sort:updated type:issue state:open ${a.join(" ")}`}},s);if(!g.body.data)throw new Error(g.statusText||"Unknown error");let I=((m=(y=(P=g.body)==null?void 0:P.data)==null?void 0:y.search)==null?void 0:m.nodes)||[];return{pageInfo:(D=(C=(h=g.body)==null?void 0:h.data)==null?void 0:C.search)==null?void 0:D.pageInfo,data:I.map(dt)}}async closeIssueWithReason(r,s,n){var i,u,p;let o=`mutation CloseIssueWithReason($issueGraphQLId: ID!, $closeReason: IssueClosedStateReason!) {
354
+ closeIssue(input: { issueId: $issueGraphQLId, stateReason: $closeReason }) {
355
+ issue {
356
+ id
357
+ }
358
+ }
359
+ }`;if(!((p=(u=(i=(await R(this.config,{query:o,variables:{issueGraphQLId:r,closeReason:s}},n)).body.data)==null?void 0:i.closeIssue)==null?void 0:u.issue)!=null&&p.id))throw new Error("Could not close issue with reason")}async closeIssueWithoutReason(r,s){var a,i,u;let n=`mutation SetIssueState($issueGraphQLId: ID!) {
360
+ updateIssue(input: { id: $issueGraphQLId, state: CLOSED }) {
361
+ issue {
362
+ id
363
+ }
364
+ }
365
+ }`;if(!((u=(i=(a=(await R(this.config,{query:n,variables:{issueGraphQLId:r}},s)).body.data)==null?void 0:a.updateIssue)==null?void 0:i.issue)!=null&&u.id))throw new Error("Could not close issue")}async reopenIssue(r,s){var a,i,u;let n=`mutation ReOpenIssue($issueGraphQLId: ID!) {
366
+ reopenIssue(input: { issueId: $issueGraphQLId }) {
367
+ issue {
368
+ id
369
+ }
370
+ }
371
+ }`;if(!((u=(i=(a=(await R(this.config,{query:n,variables:{issueGraphQLId:r}},s)).body.data)==null?void 0:a.reopenIssue)==null?void 0:i.issue)!=null&&u.id))throw new Error("Could not reopen issue")}async setIssueStatus(r,s={}){let{issueGraphQLId:n,status:o,closeReason:a}=r;if(a&&o=="OPEN")throw new Error("Did not expect closeReason to be set when trying to reopen issue");o=="OPEN"?await this.reopenIssue(n,s):o=="CLOSED"&&!a?await this.closeIssueWithoutReason(n,s):a&&await this.closeIssueWithReason(n,a,s)}};var ct="https://gitlab.com/api/v4",gt="https://gitlab.com/api/graphql",Te=/\/api\/v\d+$/,Oe=e=>{if(e.endsWith("/api/graphql"))throw new Error("The graphql endpoint is being used as the baseUrl. This package uses both GraphQL and REST APIs, and the REST version cannot be assumed. Use the REST endpoint as the baseUrl instead.")},ge=(e,t)=>{let r=t.baseUrl||e.baseUrl;return r?(r=r.replace(/\/$/,""),Oe(r),r):ct},mt=(e,t)=>{let r=t.baseUrl||e.baseUrl;return r?(r=r.replace(/\/$/,""),Oe(r),Te.test(r)&&(r=r.replace(Te,"")),`${r}/api/graphql`):gt},b=(e,t,r)=>{let s=f(r.token||e.token);return e.request({url:mt(e,r),method:"POST",headers:{...s,"Content-Type":"application/json"},body:JSON.stringify(t)})};var ht={CAN_BE_MERGED:"MERGEABLE",CANNOT_BE_MERGED:"CONFLICTS",CANNOT_BE_MERGED_RECHECK:"UNKNOWN",UNCHECKED:"UNKNOWN",CHECKING:"UNKNOWN"},Ie="gid://gitlab/User/",F="gid://gitlab/Project/",ft="gid://gitlab/MergeRequest/",Rt="gid://gitlab/Issue/",me=`
353
372
  id
354
373
  path
355
374
  fullPath
@@ -365,7 +384,7 @@ name
365
384
  username
366
385
  publicEmail
367
386
  avatarUrl
368
- `,fe=`
387
+ `,he=`
369
388
  author {
370
389
  ${T}
371
390
  }
@@ -386,7 +405,7 @@ updatedAt
386
405
  upvotes
387
406
  userNotesCount
388
407
  webUrl
389
- `,Te=`
408
+ `,_e=`
390
409
  id
391
410
  state
392
411
  author {
@@ -423,13 +442,13 @@ reviewers {
423
442
  }
424
443
  }
425
444
  }
426
- mergeStatusEnum`,_=e=>`${e.namespace}/${e.name}`,ft=e=>`${e.namespace}/${e.name}`,Re=e=>{var t;return{id:e.id.replace(Q,""),graphQLId:e.id,namespace:e.fullPath.split("/").slice(0,-1).join("/"),name:e.path,webUrl:e.webUrl,httpsUrl:e.httpUrlToRepo,sshUrl:e.sshUrlToRepo,defaultBranch:(t=e.repository)!=null&&t.rootRef?{name:e.repository.rootRef}:null,permission:null}},Rt={opened:"OPEN",merged:"MERGED",closed:"CLOSED"},O=e=>({id:e.id.replace(ye,""),graphQLId:e.id,name:e.name,username:e.username,email:e.publicEmail,avatarUrl:e.avatarUrl}),qe=(e,t)=>{var r,s,n,o,a;return{id:e.id.replace(ct,""),graphQLId:e.id,title:e.title,number:parseInt(e.iid,10),state:Rt[e.state],commentCount:e.userNotesCount||0,upvoteCount:e.upvotes,author:e.author?O(e.author):null,createdDate:new Date(e.createdAt),isDraft:e.draft,repository:{name:t.name,owner:{login:t.owner}},headRepository:null,headCommit:{buildStatus:null},baseRef:{name:e.targetBranch},headRef:{name:e.sourceBranch},url:e.webUrl,updatedDate:new Date(e.updatedAt),closedDate:e.mergedAt?new Date(e.mergedAt):null,assignees:(r=e.assignees)!=null&&r.nodes?e.assignees.nodes.map(O):null,reviews:(s=e.reviewers)!=null&&s.nodes?e.reviewers.nodes.map(i=>{var u,l;return{reviewer:O(i),state:(u=i.mergeRequestInteraction)!=null&&u.approved?"APPROVED":((l=i.mergeRequestInteraction)==null?void 0:l.reviewState)==="REVIEWED"?"CHANGES_REQUESTED":"CHANGES_REQUESTED"}}):null,additions:((n=e.diffStatsSummary)==null?void 0:n.additions)||0,deletions:((o=e.diffStatsSummary)==null?void 0:o.deletions)||0,fileCount:((a=e.diffStatsSummary)==null?void 0:a.fileCount)||0,commitCount:e.commitCount||0,mergeableState:mt[e.mergeStatusEnum]}},be=(e,t)=>({author:{avatarUrl:e.author.avatarUrl,email:null,graphQLId:e.author.id,id:e.author.id.replace(ye,""),name:e.author.name,username:e.author.username},assignees:e.assignees.nodes.map(r=>({avatarUrl:r.avatarUrl,email:null,graphQLId:r.id,id:r.id.replace(ye,""),name:r.name,username:r.username})),commentCount:e.userNotesCount,createdDate:new Date(e.createdAt),description:e.description,graphQLId:e.id,id:e.id.replace(ht,""),number:e.iid,repository:{name:t.name,owner:{login:t.owner}},updatedDate:new Date(e.updatedAt),upvoteCount:e.upvotes,state:e.state,type:e.type,title:e.title,url:e.webUrl}),z=class extends A{async getCurrentUser(t={}){var n;let s=(n=(await U(this.config,{query:`
445
+ mergeStatusEnum`,O=e=>`${e.namespace}/${e.name}`,It=e=>`${e.namespace}/${e.name}`,fe=e=>{var t;return{id:e.id.replace(F,""),graphQLId:e.id,namespace:e.fullPath.split("/").slice(0,-1).join("/"),name:e.path,webUrl:e.webUrl,httpsUrl:e.httpUrlToRepo,sshUrl:e.sshUrlToRepo,defaultBranch:(t=e.repository)!=null&&t.rootRef?{name:e.repository.rootRef}:null,permission:null}},yt={opened:"OPEN",merged:"MERGED",closed:"CLOSED"},k=e=>({id:e.id.replace(Ie,""),graphQLId:e.id,name:e.name,username:e.username,email:e.publicEmail,avatarUrl:e.avatarUrl}),ke=(e,t)=>{var r,s,n,o,a;return{id:e.id.replace(ft,""),graphQLId:e.id,title:e.title,number:parseInt(e.iid,10),state:yt[e.state],commentCount:e.userNotesCount||0,upvoteCount:e.upvotes,author:e.author?k(e.author):null,createdDate:new Date(e.createdAt),isDraft:e.draft,repository:{name:t.name,owner:{login:t.owner}},headRepository:null,headCommit:{buildStatus:null},baseRef:{name:e.targetBranch},headRef:{name:e.sourceBranch},url:e.webUrl,updatedDate:new Date(e.updatedAt),closedDate:e.mergedAt?new Date(e.mergedAt):null,assignees:(r=e.assignees)!=null&&r.nodes?e.assignees.nodes.map(k):null,reviews:(s=e.reviewers)!=null&&s.nodes?e.reviewers.nodes.map(i=>{var u,p;return{reviewer:k(i),state:(u=i.mergeRequestInteraction)!=null&&u.approved?"APPROVED":((p=i.mergeRequestInteraction)==null?void 0:p.reviewState)==="REVIEWED"?"CHANGES_REQUESTED":"CHANGES_REQUESTED"}}):null,additions:((n=e.diffStatsSummary)==null?void 0:n.additions)||0,deletions:((o=e.diffStatsSummary)==null?void 0:o.deletions)||0,fileCount:((a=e.diffStatsSummary)==null?void 0:a.fileCount)||0,commitCount:e.commitCount||0,mergeableState:ht[e.mergeStatusEnum]}},Re=(e,t)=>({author:{avatarUrl:e.author.avatarUrl,email:null,graphQLId:e.author.id,id:e.author.id.replace(Ie,""),name:e.author.name,username:e.author.username},assignees:e.assignees.nodes.map(r=>({avatarUrl:r.avatarUrl,email:null,graphQLId:r.id,id:r.id.replace(Ie,""),name:r.name,username:r.username})),commentCount:e.userNotesCount,createdDate:new Date(e.createdAt),description:e.description,graphQLId:e.id,id:e.id.replace(Rt,""),number:e.iid,repository:{name:t.name,owner:{login:t.owner}},updatedDate:new Date(e.updatedAt),upvoteCount:e.upvotes,state:e.state,type:e.type,title:e.title,url:e.webUrl}),z=class extends A{async getCurrentUser(t={}){var n;let s=(n=(await b(this.config,{query:`
427
446
  query getCurrentUser {
428
447
  currentUser {
429
448
  ${T}
430
449
  }
431
450
  }
432
- `},t)).body.data)==null?void 0:n.currentUser;if(!s)throw new Error("Current user not found.");return{data:O(s)}}async getUserForCommit(t,r={}){var a,i,u,l;let s=_(t.repo),o=(l=(u=(i=(a=(await U(this.config,{query:`
451
+ `},t)).body.data)==null?void 0:n.currentUser;if(!s)throw new Error("Current user not found.");return{data:k(s)}}async getUserForCommit(t,r={}){var a,i,u,p;let s=O(t.repo),o=(p=(u=(i=(a=(await b(this.config,{query:`
433
452
  query getUserForCommit($fullPath: ID!, $oid: String!) {
434
453
  project(fullPath: $fullPath) {
435
454
  repository {
@@ -443,7 +462,7 @@ query getUserForCommit($fullPath: ID!, $oid: String!) {
443
462
  }
444
463
  }
445
464
  }
446
- `,variables:{fullPath:s,oid:t.oid}},r)).body.data)==null?void 0:a.project)==null?void 0:i.repository)==null?void 0:u.tree)==null?void 0:l.lastCommit;if(!o)throw new Error("Commit not found.");return{data:{name:o.authorName,email:o.authorEmail,avatarUrl:o.authorGravatar}}}async getAccountForEmail(t,r={}){var o,a,i;let n=(i=(a=(o=(await U(this.config,{query:`
465
+ `,variables:{fullPath:s,oid:t.oid}},r)).body.data)==null?void 0:a.project)==null?void 0:i.repository)==null?void 0:u.tree)==null?void 0:p.lastCommit;if(!o)throw new Error("Commit not found.");return{data:{name:o.authorName,email:o.authorEmail,avatarUrl:o.authorGravatar}}}async getAccountForEmail(t,r={}){var o,a,i;let n=(i=(a=(o=(await b(this.config,{query:`
447
466
  query getAccountForEmail($email: String!) {
448
467
  users(search: $email) {
449
468
  nodes {
@@ -451,28 +470,28 @@ query getAccountForEmail($email: String!) {
451
470
  }
452
471
  }
453
472
  }
454
- `,variables:{email:t.email}},r)).body.data)==null?void 0:o.users)==null?void 0:a.nodes)==null?void 0:i[0];if(!n)throw new Error("User not found.");return{data:O(n)}}async getAccountForUsername(t,r={}){var o;let n=(o=(await U(this.config,{query:`
473
+ `,variables:{email:t.email}},r)).body.data)==null?void 0:o.users)==null?void 0:a.nodes)==null?void 0:i[0];if(!n)throw new Error("User not found.");return{data:k(n)}}async getAccountForUsername(t,r={}){var o;let n=(o=(await b(this.config,{query:`
455
474
  query getAccountForUsername($username: String!) {
456
475
  user(username: $username) {
457
476
  ${T}
458
477
  }
459
478
  }
460
- `,variables:{username:t.username}},r)).body.data)==null?void 0:o.user;if(!n)throw new Error("User not found.");return{data:O(n)}}async getRepo(t,r={}){var o;let s=_(t),n=await U(this.config,{query:`
479
+ `,variables:{username:t.username}},r)).body.data)==null?void 0:o.user;if(!n)throw new Error("User not found.");return{data:k(n)}}async getRepo(t,r={}){var o;let s=O(t),n=await b(this.config,{query:`
461
480
  query getRepo($fullPath: ID!) {
462
481
  project(fullPath: $fullPath) {
463
- ${he}
482
+ ${me}
464
483
  }
465
484
  }
466
- `,variables:{fullPath:s}},r);if(!((o=n.body.data)!=null&&o.project))throw new Error(`Repository ${s} not found`);return{data:Re(n.body.data.project)}}async getRepos(t,r={}){let s=t.map(_),n=s.map((a,i)=>`
467
- getRepo_${i}: project(fullPath: "${a}") {
468
- ${he}
485
+ `,variables:{fullPath:s}},r);if(!((o=n.body.data)!=null&&o.project))throw new Error(`Repository ${s} not found`);return{data:fe(n.body.data.project)}}async getRepos(t,r={}){let n=t.map(O).map((u,p)=>`
486
+ getRepo_${p}: project(fullPath: "${u}") {
487
+ ${me}
469
488
  }
470
489
  `).join(`
471
- `),o=await U(this.config,{query:`
490
+ `),o=await b(this.config,{query:`
472
491
  query batchGetRepos {
473
492
  ${n}
474
493
  }
475
- `},r);if(!o.body.data)throw new Error(o.statusText||"Unknown error");return{data:s.map((a,i)=>{let u=o.body.data[`getRepo_${i}`];if(!u)throw new Error(`Repository ${a} not found`);return Re(u)})}}async getReposForCurrentUser(t={},r={}){var o,a,i,u,l,p;let s=await U(this.config,{query:`
494
+ `},r);if(!o.body.data)throw new Error(o.statusText||"Unknown error");let a=[],i=[];return t.forEach((u,p)=>{let l=o.body.data[`getRepo_${p}`];l?a.push(fe(l)):i.push({input:u})}),{data:a,errors:i}}async getReposForCurrentUser(t={},r={}){var o,a,i,u,p,l;let s=await b(this.config,{query:`
476
495
  query getReposForCurrentUser($after: String) {
477
496
  projects(membership: true first: 100 after: $after) {
478
497
  pageInfo {
@@ -480,11 +499,11 @@ query getReposForCurrentUser($after: String) {
480
499
  hasNextPage
481
500
  }
482
501
  nodes {
483
- ${he}
502
+ ${me}
484
503
  }
485
504
  }
486
505
  }
487
- `,variables:{after:t.cursor}},r);if(!((o=s.body.data)!=null&&o.projects))throw new Error(((a=s.body.errors)==null?void 0:a[0].message)||s.statusText||"Unknown error");let n=((u=(i=s.body.data)==null?void 0:i.projects)==null?void 0:u.nodes)||[];return{pageInfo:(p=(l=s.body.data)==null?void 0:l.projects)==null?void 0:p.pageInfo,data:n.map(Re)}}async getRefs(t,r,s={}){var u;let n=_(r.repo),o=new URL(`${ce(this.config,s)}/projects/${encodeURIComponent(n)}/repository/${t}`);o.searchParams.set("page",((u=r.page)==null?void 0:u.toString())||"1"),o.searchParams.set("per_page",v.toString());let a=await this.config.request({url:o.toString(),headers:y(s.token||this.config.token)}),i=a.headers["x-next-page"];return{pageInfo:{hasNextPage:!!i,nextPage:i?parseInt(i,10):null},data:a.body.map(l=>({name:l.name,commit:{oid:l.commit.id,authoredDate:new Date(l.commit.authored_date),committedDate:new Date(l.commit.committed_date)}}))}}async getBranches(t,r={}){return this.getRefs("branches",t,r)}async getTags(t,r={}){return this.getRefs("tags",t,r)}async getBlame(t,r={}){let s=_(t.repo),n=new URL(`${ce(this.config,r)}/projects/${encodeURIComponent(s)}/repository/files/${encodeURIComponent(t.path)}/blame`);n.searchParams.set("ref",t.ref);let o=await this.config.request({url:n.toString(),headers:y(r.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}}})}}}getVariablesForPullRequests(t){let{updatedBefore:r,isDraft:s,authorLogin:n,assigneeLogins:o,reviewRequestedLogin:a}=t||{},i={},u=[],l=[],p=(g,m,d)=>{u.push(`$${g}: ${d}`),l.push(`${g}: $${g}`),i[g]=m};return r&&p("updatedBefore",r,"Time"),n&&p("authorUsername",n,"String"),o&&p("assigneeUsername",o[0],"String"),s!=null&&p("draft",s,"Boolean"),a&&p("reviewerUsername",a,"String"),{variables:i,variableTypes:u,mergeRequestArguments:l}}async getPullRequestsForRepo(t,r={}){var b,f,h;let{cursor:s,repo:n}=t||{},o=_(n),{variables:a,variableTypes:i,mergeRequestArguments:u}=this.getVariablesForPullRequests(t),l={fullPath:o,...a},p=await U(this.config,{query:`
506
+ `,variables:{after:t.cursor}},r);if(!((o=s.body.data)!=null&&o.projects))throw new Error(((a=s.body.errors)==null?void 0:a[0].message)||s.statusText||"Unknown error");let n=((u=(i=s.body.data)==null?void 0:i.projects)==null?void 0:u.nodes)||[];return{pageInfo:(l=(p=s.body.data)==null?void 0:p.projects)==null?void 0:l.pageInfo,data:n.map(fe)}}async getRefs(t,r,s={}){var u;let n=O(r.repo),o=new URL(`${ge(this.config,s)}/projects/${encodeURIComponent(n)}/repository/${t}`);o.searchParams.set("page",((u=r.page)==null?void 0:u.toString())||"1"),o.searchParams.set("per_page",v.toString());let a=await this.config.request({url:o.toString(),headers:f(s.token||this.config.token)}),i=a.headers["x-next-page"];return{pageInfo:{hasNextPage:!!i,nextPage:i?parseInt(i,10):null},data:a.body.map(p=>({name:p.name,commit:{oid:p.commit.id,authoredDate:new Date(p.commit.authored_date),committedDate:new Date(p.commit.committed_date)}}))}}async getBranches(t,r={}){return this.getRefs("branches",t,r)}async getTags(t,r={}){return this.getRefs("tags",t,r)}async getBlame(t,r={}){let s=O(t.repo),n=new URL(`${ge(this.config,r)}/projects/${encodeURIComponent(s)}/repository/files/${encodeURIComponent(t.path)}/blame`);n.searchParams.set("ref",t.ref);let o=await this.config.request({url:n.toString(),headers:f(r.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}}})}}}getVariablesForPullRequests(t){let{updatedBefore:r,isDraft:s,authorLogin:n,assigneeLogins:o,reviewRequestedLogin:a}=t||{},i={},u=[],p=[],l=(d,c,g)=>{u.push(`$${d}: ${g}`),p.push(`${d}: $${d}`),i[d]=c};return r&&l("updatedBefore",r,"Time"),n&&l("authorUsername",n,"String"),o&&l("assigneeUsername",o[0],"String"),s!=null&&l("draft",s,"Boolean"),a&&l("reviewerUsername",a,"String"),{variables:i,variableTypes:u,mergeRequestArguments:p}}async getPullRequestsForRepo(t,r={}){var P,y,m;let{cursor:s,repo:n}=t||{},o=O(n),{variables:a,variableTypes:i,mergeRequestArguments:u}=this.getVariablesForPullRequests(t),p={fullPath:o,...a},l=await b(this.config,{query:`
488
507
  query getPullRequestsForRepo(
489
508
  $fullPath: ID!
490
509
  $after: String
@@ -507,12 +526,12 @@ query getPullRequestsForRepo(
507
526
  hasNextPage
508
527
  }
509
528
  nodes {
510
- ${Te}
529
+ ${_e}
511
530
  }
512
531
  }
513
532
  }
514
533
  }
515
- `,variables:{...l,after:s}},r),g=[],m=(b=p.body.data)==null?void 0:b.project,d={name:(m==null?void 0:m.name)||"",owner:((m==null?void 0:m.fullPath)||"").split("/").slice(0,-1).join("/")};return(((f=m==null?void 0:m.mergeRequests)==null?void 0:f.nodes)||[]).forEach(R=>{g.push(qe(R,d))}),{pageInfo:(h=m==null?void 0:m.mergeRequests)==null?void 0:h.pageInfo,data:g}}async getPullRequestsForRepos(t,r={}){var m,d,c,b,f;let{cursor:s}=t||{},n=t.repoIds.map(h=>h.toString().startsWith(Q)?h:`${Q}${h}`),{variables:o,variableTypes:a,mergeRequestArguments:i}=this.getVariablesForPullRequests(t),u={projectIds:n,...o},l=await U(this.config,{query:`
534
+ `,variables:{...p,after:s}},r),d=[],c=(P=l.body.data)==null?void 0:P.project,g={name:(c==null?void 0:c.name)||"",owner:((c==null?void 0:c.fullPath)||"").split("/").slice(0,-1).join("/")};return(((y=c==null?void 0:c.mergeRequests)==null?void 0:y.nodes)||[]).forEach(h=>{d.push(ke(h,g))}),{pageInfo:(m=c==null?void 0:c.mergeRequests)==null?void 0:m.pageInfo,data:d}}async getPullRequestsForRepos(t,r={}){var c,g,I,P,y;let{cursor:s}=t||{},n=t.repoIds.map(m=>m.toString().startsWith(F)?m:`${F}${m}`),{variables:o,variableTypes:a,mergeRequestArguments:i}=this.getVariablesForPullRequests(t),u={projectIds:n,...o},p=await b(this.config,{query:`
516
535
  query getPullRequests(
517
536
  $projectIds: [ID!]
518
537
  $after: String
@@ -536,23 +555,37 @@ query getPullRequests(
536
555
  ${i.length?i.join(" "):""}
537
556
  ) {
538
557
  nodes {
539
- ${Te}
558
+ ${_e}
540
559
  }
541
560
  }
542
561
  }
543
562
  }
544
563
  }
545
- `,variables:{...u,after:s}},r),p=[];return(((d=(m=l.body.data)==null?void 0:m.projects)==null?void 0:d.nodes)||[]).forEach(h=>{var E;let R={name:h.name,owner:h.fullPath.split("/").slice(0,-1).join("/")};(((E=h.mergeRequests)==null?void 0:E.nodes)||[]).forEach($=>{p.push(qe($,R))})}),{pageInfo:(f=(b=(c=l.body)==null?void 0:c.data)==null?void 0:b.projects)==null?void 0:f.pageInfo,data:p}}async getIssue(t,r={}){var o,a,i,u,l,p,g;let s=ft(t),n=await U(this.config,{query:`
564
+ `,variables:{...u,after:s}},r),l=[];return(((g=(c=p.body.data)==null?void 0:c.projects)==null?void 0:g.nodes)||[]).forEach(m=>{var D;let h={name:m.name,owner:m.fullPath.split("/").slice(0,-1).join("/")};(((D=m.mergeRequests)==null?void 0:D.nodes)||[]).forEach(q=>{l.push(ke(q,h))})}),{pageInfo:(y=(P=(I=p.body)==null?void 0:I.data)==null?void 0:P.projects)==null?void 0:y.pageInfo,data:l}}async closePullRequest(t,r={}){var p,l,d;let{repo:{namespace:s,name:n},pullRequestId:o}=t,a=`mutation ClosePullRequest($fullPath: ID!, $pullRequestId: String!) {
565
+ mergeRequestUpdate(input: { projectPath: $fullPath, iid: $pullRequestId, state: CLOSED }) {
566
+ errors,
567
+ mergeRequest {
568
+ id
569
+ }
570
+ }
571
+ }`,u=(p=(await b(this.config,{query:a,variables:{fullPath:`${s}/${n}`,pullRequestId:o}},r)).body.data)==null?void 0:p.mergeRequestUpdate;if(!((l=u==null?void 0:u.mergeRequest)!=null&&l.id)||((d=u==null?void 0:u.errors)==null?void 0:d.length)!==0)throw new Error("Could not close pull request")}async mergePullRequest(t,r={}){var l,d,c;let{repo:{namespace:s,name:n},pullRequestId:o,expectedSourceSha:a}=t,i=`mutation MergePullRequest($fullPath: ID!, $pullRequestId: String!, $expectedSourceSha: String!) {
572
+ mergeRequestAccept(input: { projectPath: $fullPath, iid: $pullRequestId, sha: $expectedSourceSha }) {
573
+ errors,
574
+ mergeRequest {
575
+ id
576
+ }
577
+ }
578
+ }`,p=(l=(await b(this.config,{query:i,variables:{fullPath:`${s}/${n}`,pullRequestId:o,expectedSourceSha:a}},r)).body.data)==null?void 0:l.mergeRequestAccept;if(!((d=p==null?void 0:p.mergeRequest)!=null&&d.id)||((c=p==null?void 0:p.errors)==null?void 0:c.length)!==0)throw new Error("Could not merge pull request")}async getIssue(t,r={}){var o,a,i,u,p,l,d;let s=It(t),n=await b(this.config,{query:`
546
579
  query GetSingleIssue($projectId: ID!, $issueId: String!) {
547
580
  project(fullPath: $projectId) {
548
581
  name
549
582
  fullPath
550
583
  issue(iid: $issueId) {
551
- ${fe}
584
+ ${he}
552
585
  }
553
586
  }
554
587
  }
555
- `,variables:{issueId:t.id,projectId:s}},r);if(!((o=n.body.data)!=null&&o.project))throw new Error(`Repository ${s} not found`);if(!((i=(a=n.body.data)==null?void 0:a.project)!=null&&i.issue))throw new Error(`Issue ${t.id} not found`);return{data:be((l=(u=n.body.data)==null?void 0:u.project)==null?void 0:l.issue,{name:(p=n.body.data)==null?void 0:p.project.name,owner:(g=n.body.data)==null?void 0:g.project.fullPath.split("/").slice(0,-1).join("/")})}}getVariablesForIssues(t){let{updatedBefore:r,authorLogin:s,assigneeLogins:n}=t||{},o={},a=[],i=[],u=(l,p,g)=>{a.push(`$${l}: ${g}`),i.push(`${l}: $${l}`),o[l]=p};return r&&u("updatedBefore",r,"Time"),s&&u("authorUsername",s,"String"),n&&u("assigneeUsername",n[0],"String"),{variables:o,variableTypes:a,issueArguments:i}}async getIssuesForRepo(t,r={}){var f,h,R;let{cursor:s,repo:n}=t||{},o=_(n),{variables:a,variableTypes:i,issueArguments:u}=this.getVariablesForIssues(t),l={fullPath:o,...a},p=`
588
+ `,variables:{issueId:t.id,projectId:s}},r);if(!((o=n.body.data)!=null&&o.project))throw new Error(`Repository ${s} not found`);if(!((i=(a=n.body.data)==null?void 0:a.project)!=null&&i.issue))throw new Error(`Issue ${t.id} not found`);return{data:Re((p=(u=n.body.data)==null?void 0:u.project)==null?void 0:p.issue,{name:(l=n.body.data)==null?void 0:l.project.name,owner:(d=n.body.data)==null?void 0:d.project.fullPath.split("/").slice(0,-1).join("/")})}}getVariablesForIssues(t){let{updatedBefore:r,authorLogin:s,assigneeLogins:n}=t||{},o={},a=[],i=[],u=(p,l,d)=>{a.push(`$${p}: ${d}`),i.push(`${p}: $${p}`),o[p]=l};return r&&u("updatedBefore",r,"Time"),s&&u("authorUsername",s,"String"),n&&u("assigneeUsername",n[0],"String"),{variables:o,variableTypes:a,issueArguments:i}}async getIssuesForRepo(t,r={}){var y,m,h;let{cursor:s,repo:n}=t||{},o=O(n),{variables:a,variableTypes:i,issueArguments:u}=this.getVariablesForIssues(t),p={fullPath:o,...a},l=`
556
589
  query GetIssuesFromProject(
557
590
  $fullPath: ID!
558
591
  $after: String
@@ -571,7 +604,7 @@ query GetSingleIssue($projectId: ID!, $issueId: String!) {
571
604
  ${u.length?u.join(" "):""}
572
605
  ) {
573
606
  nodes {
574
- ${fe}
607
+ ${he}
575
608
  }
576
609
  pageInfo {
577
610
  endCursor
@@ -579,7 +612,7 @@ query GetSingleIssue($projectId: ID!, $issueId: String!) {
579
612
  }
580
613
  }
581
614
  }
582
- }`,g=await U(this.config,{query:p,variables:{...l,after:s}},r),m=[],d=(f=g.body.data)==null?void 0:f.project,c={name:(d==null?void 0:d.name)||"",owner:((d==null?void 0:d.fullPath)||"").split("/").slice(0,-1).join("/")};return(((h=d==null?void 0:d.issues)==null?void 0:h.nodes)||[]).forEach(P=>{m.push(be(P,c))}),{pageInfo:(R=d==null?void 0:d.issues)==null?void 0:R.pageInfo,data:m.sort((P,E)=>(P.updatedDate||P.createdDate).getTime()-(E.updatedDate||E.createdDate).getTime())}}async getIssuesForRepos(t,r={}){var d,c,b,f,h;let{cursor:s}=t||{},n=t.repoIds.map(R=>R.toString().startsWith(Q)?R:`${Q}${R}`),{variables:o,variableTypes:a,mergeRequestArguments:i}=this.getVariablesForPullRequests(t),u={projectIds:n,...o},l=`
615
+ }`,d=await b(this.config,{query:l,variables:{...p,after:s}},r),c=[],g=(y=d.body.data)==null?void 0:y.project,I={name:(g==null?void 0:g.name)||"",owner:((g==null?void 0:g.fullPath)||"").split("/").slice(0,-1).join("/")};return(((m=g==null?void 0:g.issues)==null?void 0:m.nodes)||[]).forEach(C=>{c.push(Re(C,I))}),{pageInfo:(h=g==null?void 0:g.issues)==null?void 0:h.pageInfo,data:c.sort((C,D)=>(C.updatedDate||C.createdDate).getTime()-(D.updatedDate||D.createdDate).getTime())}}async getIssuesForRepos(t,r={}){var g,I,P,y,m;let{cursor:s}=t||{},n=t.repoIds.map(h=>h.toString().startsWith(F)?h:`${F}${h}`),{variables:o,variableTypes:a,mergeRequestArguments:i}=this.getVariablesForPullRequests(t),u={projectIds:n,...o},p=`
583
616
  query GetIssuesFromProject(
584
617
  $projectIds: [ID!]
585
618
  $after: String
@@ -603,9 +636,15 @@ query GetSingleIssue($projectId: ID!, $issueId: String!) {
603
636
  ${i.length?i.join(" "):""}
604
637
  ) {
605
638
  nodes {
606
- ${fe}
639
+ ${he}
607
640
  }
608
641
  }
609
642
  }
610
643
  }
611
- }`,p=await U(this.config,{query:l,variables:{...u,after:s}},r),g=[];return(((c=(d=p.body.data)==null?void 0:d.projects)==null?void 0:c.nodes)||[]).forEach(R=>{var $;let P={name:R.name,owner:R.fullPath.split("/").slice(0,-1).join("/")};((($=R.issues)==null?void 0:$.nodes)||[]).forEach(Be=>g.push(be(Be,P)))}),{pageInfo:(h=(f=(b=p.body)==null?void 0:b.data)==null?void 0:f.projects)==null?void 0:h.pageInfo,data:g.sort((R,P)=>(R.updatedDate||R.createdDate).getTime()-(P.updatedDate||P.createdDate).getTime())}}};var _e="https://api.atlassian.com/ex/jira",ke=100,bt=e=>{var r;let t=e.fields.assignee;return{id:e.id,commentCount:e.fields.comment.comments.length,number:e.key,title:e.fields.summary,url:e.self,createdDate:new Date(e.fields.created),author:{id:e.fields.creator.accountId,name:e.fields.creator.displayName,email:e.fields.creator.emailAddress,avatarUrl:e.fields.creator.avatarUrls["32x32"],username:e.fields.creator.displayName},updatedDate:new Date(e.fields.updated),assignees:t?[{id:t.accountId,name:t.displayName,email:t.emailAddress,avatarUrl:t.avatarUrls["32x32"],username:t.displayName}]:[],description:null,repository:null,state:null,type:e.fields.issuetype.name,upvoteCount:((r=e.fields.votes)==null?void 0:r.votes)||0}},M=class extends w{async getJiraResourcesForCurrentUser(t={}){return{data:(await this.config.request({url:`${t.baseUrl||"https://api.atlassian.com/"}/oauth/token/accessible-resources`,headers:y(t.token||this.config.token)})).body.map(s=>({avatarUrl:s.avatarUrl,id:s.id,name:s.name}))}}async getJiraProjectsForResource(t,r={}){let s=new URL(`${r.baseUrl||_e}/${t.resourceId}/rest/api/2/project/search`);s.searchParams.set("maxResults",ke.toString()),t.cursor&&s.searchParams.set("startAt",t.cursor);let n=await this.config.request({url:s.toString(),headers:y(r.token||this.config.token)});return{pageInfo:{hasNextPage:n.body.values.length!==0,endCursor:(n.body.startAt+n.body.values.length).toString()},data:n.body.values.map(o=>({name:o.name,resourceId:t.resourceId}))}}async getJiraProjectsForResources(t,r={}){let s=[];return await Promise.all(t.resourceIds.map(async n=>{let o=await this.getJiraProjectsForResource({resourceId:n},r);s.push(...o.data)})),{data:s}}async getIssuesForProject(t,r={}){let{assigneeLogins:s,authorLogin:n,mentionLogin:o,project:a}=t||{},i=[`project = "${a}"`];return n&&i.push(`creator in (${n})`),s&&i.push(`assignee in (${s.join(", ")})`),o&&i.push(`comment ~ ${o}`),{data:(await this.config.request({url:`${r.baseUrl||_e}/${t.resourceId}/rest/api/2/search?jql=${i.join(" AND ")}&startAt=0&maxResults=${ke}&fields=${["assignee","comment","summary","created","creator","updated","votes","issuetype"].join(",")}`,headers:y(r.token||this.config.token)})).body.issues.map(bt)}}};var Oe="https://api.trello.com",yt=1e3,It=e=>{let t=new Date(1e3*parseInt(e.id.substring(0,8),16));return{id:e.id,commentCount:e.badges.comments,number:e.idShort.toString(),title:e.name,url:e.url,createdDate:new Date(t.toISOString()),author:null,updatedDate:new Date(e.dateLastActivity),assignees:e.idMembers.map(r=>({id:r,username:null,name:null,email:null,avatarUrl:null})),description:null,state:null,type:null,repository:null,upvoteCount:e.badges.votes}},H=class extends w{async getBoardsForCurrentUser(t,r={}){return{data:(await this.config.request({url:`${r.baseUrl||Oe}/1/members/me/boards?fields=name&key=${t.appKey}&token=${r.token||this.config.token}&filter=open`,headers:y(r.token||this.config.token)})).body.map(n=>({id:n.id,name:n.name}))}}async getIssuesForBoard(t,r={}){let s=["-is:archived","sort:edited"],{appKey:n,boardId:o,filterText:a,assigneeLogins:i}=t||{};i&&s.push("@me");let u=`${a?`${a}`:""}${s.join(" ")} board:${o}`;return{data:(await this.config.request({url:`${r.baseUrl||Oe}/1/search?key=${n}&query=${u}&cards_limit=${yt}&token=${r.token||this.config.token}`,headers:y(r.token||this.config.token)})).body.cards.map(It)}}};var X={};L(X,{getIssueUniqueId:()=>Pt,getPullRequestUniqueId:()=>vt});var Pt=(e,t,r,s="")=>{let n=[];return n.push(s),n.push(e),n.push(t),n.push(r),JSON.stringify(n)},vt=(e,t,r,s,n="")=>{let o=[];return o.push(n),o.push(e),o.push(t),o.push(r),o.push(s),JSON.stringify(o)};var K={};L(K,{getIssueUniqueId:()=>Ut,getPullRequestUniqueId:()=>Ct});var Ut=(e,t)=>JSON.stringify(["",e,t]),Ct=(e,t)=>JSON.stringify(["",e,t]);var Z={};L(Z,{getIssueUniqueId:()=>wt,getPullRequestUniqueId:()=>St});var wt=(e,t,r)=>JSON.stringify([r,e,t]),St=(e,t,r)=>JSON.stringify([r,e,t]);var Y={};L(Y,{getIssueUniqueId:()=>Et,getPullRequestRank:()=>Dt,getPullRequestUniqueId:()=>$t});var Et=(e,t="")=>{let r=[];return r.push(t),r.push(e),JSON.stringify(r)},$t=(e,t="")=>{let r=[];return r.push(t),r.push(e),JSON.stringify(r)},Dt=(e,t,r)=>{var a,i,u;let s=0,n,o;return(a=e.reviews)==null||a.forEach(l=>{l.reviewer.id===t&&(n=l.state),l.state==="CHANGES_REQUESTED"?o="CHANGES_REQUESTED":l.state==="APPROVED"&&o!=="CHANGES_REQUESTED"&&(o="APPROVED")}),o||(o="REVIEW_REQUESTED"),((i=e.author)==null?void 0:i.id)===t?s+=1e3:(u=e.assignees)!=null&&u.find(l=>l.id===t)?s+=900:n==="REVIEW_REQUESTED"?s+=800:r&&(s+=700),o==="APPROVED"?e.mergeableState==="MERGEABLE"?s+=100:e.mergeableState==="CONFLICTS"?s+=90:s+=80:o=="CHANGES_REQUESTED"&&(s+=70),s};var ee={};L(ee,{getIssueUniqueId:()=>Gt,getPullRequestUniqueId:()=>Lt});var Gt=(e,t="")=>{let r=[];return r.push(t),r.push(e),JSON.stringify(r)},Lt=(e,t="")=>{let r=[];return r.push(t),r.push(e),JSON.stringify(r)};var te={};L(te,{getIssueUniqueId:()=>At});var At=(e,t,r,s="")=>{let n=[];return n.push(s),n.push(e),n.push(t),n.push(r),JSON.stringify(n)};var re={};L(re,{getIssueUniqueId:()=>xt});var xt=(e,t,r,s="")=>{let n=[];return n.push(s),n.push(e),n.push(t),n.push(r),JSON.stringify(n)};var Tt=e=>{let t={request:e==null?void 0:e.request};return{azureDevOps:new B({...t,...e==null?void 0:e.azureDevOps}),bitbucket:new j({...t,...e==null?void 0:e.bitbucket}),bitbucketServer:new N({...t,...e==null?void 0:e.bitbucketServer}),github:new F({...t,...e==null?void 0:e.github}),gitlab:new z({...t,...e==null?void 0:e.gitlab}),jira:new M({...t,...e==null?void 0:e.jira}),trello:new H({...t,...e==null?void 0:e.trello})}},qt=Tt;var _t={azureDevOps:X,bitbucket:K,bitbucketServer:Z,github:Y,gitlab:ee,jira:te,trello:re};
644
+ }`,l=await b(this.config,{query:p,variables:{...u,after:s}},r),d=[];return(((I=(g=l.body.data)==null?void 0:g.projects)==null?void 0:I.nodes)||[]).forEach(h=>{var q;let C={name:h.name,owner:h.fullPath.split("/").slice(0,-1).join("/")};(((q=h.issues)==null?void 0:q.nodes)||[]).forEach(Be=>d.push(Re(Be,C)))}),{pageInfo:(m=(y=(P=l.body)==null?void 0:P.data)==null?void 0:y.projects)==null?void 0:m.pageInfo,data:d.sort((h,C)=>(h.updatedDate||h.createdDate).getTime()-(C.updatedDate||C.createdDate).getTime())}}async setIssueStatus(t,r={}){var p,l,d;let{repo:{namespace:s,name:n},issueId:o,status:a}=t,i=`mutation SetIssueState($fullPath: ID!, $issueId: String!, $status: IssueStateEvent!) {
645
+ updateIssue(input: { projectPath: $fullPath, iid: $issueId, stateEvent: $status }) {
646
+ issue {
647
+ id
648
+ }
649
+ }
650
+ }`;if(!((d=(l=(p=(await b(this.config,{query:i,variables:{fullPath:`${s}/${n}`,issueId:o,status:a}},r)).body.data)==null?void 0:p.updateIssue)==null?void 0:l.issue)!=null&&d.id))throw new Error("Could not set issue status")}};var ye="https://api.atlassian.com/ex/jira",je=100,bt=e=>{var r;let t=e.fields.assignee;return{id:e.id,commentCount:e.fields.comment.comments.length,number:e.key,title:e.fields.summary,url:e.self,createdDate:new Date(e.fields.created),author:{id:e.fields.creator.accountId,name:e.fields.creator.displayName,email:e.fields.creator.emailAddress,avatarUrl:e.fields.creator.avatarUrls["32x32"],username:e.fields.creator.displayName},updatedDate:new Date(e.fields.updated),assignees:t?[{id:t.accountId,name:t.displayName,email:t.emailAddress,avatarUrl:t.avatarUrls["32x32"],username:t.displayName}]:[],description:null,repository:null,state:null,type:e.fields.issuetype.name,upvoteCount:((r=e.fields.votes)==null?void 0:r.votes)||0}},M=class extends E{async getJiraResourcesForCurrentUser(t={}){return{data:(await this.config.request({url:`${t.baseUrl||"https://api.atlassian.com/"}/oauth/token/accessible-resources`,headers:f(t.token||this.config.token)})).body.map(s=>({avatarUrl:s.avatarUrl,id:s.id,name:s.name}))}}async getJiraProjectsForResource(t,r={}){let s=new URL(`${r.baseUrl||ye}/${t.resourceId}/rest/api/2/project/search`);s.searchParams.set("maxResults",je.toString()),t.cursor&&s.searchParams.set("startAt",t.cursor);let n=await this.config.request({url:s.toString(),headers:f(r.token||this.config.token)});return{pageInfo:{hasNextPage:n.body.values.length!==0,endCursor:(n.body.startAt+n.body.values.length).toString()},data:n.body.values.map(o=>({name:o.name,resourceId:t.resourceId}))}}async getJiraProjectsForResources(t,r={}){let s=[];return await Promise.all(t.resourceIds.map(async n=>{let o=await this.getJiraProjectsForResource({resourceId:n},r);s.push(...o.data)})),{data:s}}async getIssuesForProject(t,r={}){let{assigneeLogins:s,authorLogin:n,mentionLogin:o,project:a}=t||{},i=[`project = "${a}"`];return n&&i.push(`creator in (${n})`),s&&i.push(`assignee in (${s.join(", ")})`),o&&i.push(`comment ~ ${o}`),{data:(await this.config.request({url:`${r.baseUrl||ye}/${t.resourceId}/rest/api/2/search?jql=${i.join(" AND ")}&startAt=0&maxResults=${je}&fields=${["assignee","comment","summary","created","creator","updated","votes","issuetype"].join(",")}`,headers:f(r.token||this.config.token)})).body.issues.map(bt)}}async setIssueStatus(t,r={}){let{resourceId:s,issueId:n,status:o}=t,a={transition:{id:o}};try{await this.config.request({method:"POST",url:`${r.baseUrl||ye}/${s}/rest/api/2/issue/${n}/transitions`,body:JSON.stringify(a),headers:{...f(r.token||this.config.token),"Content-Type":"application/json"}})}catch(i){if(i.message=="Unexpected end of JSON input")return;throw new Error("Could not set issue status")}}};var be="https://api.trello.com",Pt=1e3,wt=e=>{let t=new Date(1e3*parseInt(e.id.substring(0,8),16));return{id:e.id,commentCount:e.badges.comments,number:e.idShort.toString(),title:e.name,url:e.url,createdDate:new Date(t.toISOString()),author:null,updatedDate:new Date(e.dateLastActivity),assignees:e.idMembers.map(r=>({id:r,username:null,name:null,email:null,avatarUrl:null})),description:null,state:null,type:null,repository:null,upvoteCount:e.badges.votes}},H=class extends E{async getBoardsForCurrentUser(t,r={}){return{data:(await this.config.request({url:`${r.baseUrl||be}/1/members/me/boards?fields=name&key=${t.appKey}&token=${r.token||this.config.token}&filter=open`,headers:f(r.token||this.config.token)})).body.map(n=>({id:n.id,name:n.name}))}}async getIssuesForBoard(t,r={}){let s=["-is:archived","sort:edited"],{appKey:n,boardId:o,filterText:a,assigneeLogins:i}=t||{};i&&s.push("@me");let u=`${a?`${a}`:""}${s.join(" ")} board:${o}`;return{data:(await this.config.request({url:`${r.baseUrl||be}/1/search?key=${n}&query=${u}&cards_limit=${Pt}&token=${r.token||this.config.token}`,headers:f(r.token||this.config.token)})).body.cards.map(wt)}}async setIssueStatus(t,r={}){let{appKey:s,cardId:n,status:o}=t;if(!(await this.config.request({method:"PUT",url:`${r.baseUrl||be}/1/cards/${n}?key=${s}&token=${r.token||this.config.token}&idList=${o}`,headers:f(r.token||this.config.token)})).body.id)throw new Error("Could not set issue status")}};var X={};x(X,{getIssueUniqueId:()=>Ct,getPullRequestUniqueId:()=>vt});var Ct=(e,t,r,s="")=>{let n=[];return n.push(s),n.push(e),n.push(t),n.push(r),JSON.stringify(n)},vt=(e,t,r,s,n="")=>{let o=[];return o.push(n),o.push(e),o.push(t),o.push(r),o.push(s),JSON.stringify(o)};var K={};x(K,{getIssueUniqueId:()=>Ut,getPullRequestUniqueId:()=>Et});var Ut=(e,t)=>JSON.stringify(["",e,t]),Et=(e,t)=>JSON.stringify(["",e,t]);var Z={};x(Z,{getIssueUniqueId:()=>St,getPullRequestUniqueId:()=>$t});var St=(e,t,r)=>JSON.stringify([r,e,t]),$t=(e,t,r)=>JSON.stringify([r,e,t]);var Y={};x(Y,{getIssueUniqueId:()=>Dt,getPullRequestRank:()=>Gt,getPullRequestUniqueId:()=>qt});var Dt=(e,t="")=>{let r=[];return r.push(t),r.push(e),JSON.stringify(r)},qt=(e,t="")=>{let r=[];return r.push(t),r.push(e),JSON.stringify(r)},Gt=(e,t,r)=>{var a,i,u;let s=0,n,o;return(a=e.reviews)==null||a.forEach(p=>{p.reviewer.id===t&&(n=p.state),p.state==="CHANGES_REQUESTED"?o="CHANGES_REQUESTED":p.state==="APPROVED"&&o!=="CHANGES_REQUESTED"&&(o="APPROVED")}),o||(o="REVIEW_REQUESTED"),((i=e.author)==null?void 0:i.id)===t?s+=1e3:(u=e.assignees)!=null&&u.find(p=>p.id===t)?s+=900:n==="REVIEW_REQUESTED"?s+=800:r&&(s+=700),o==="APPROVED"?e.mergeableState==="MERGEABLE"?s+=100:e.mergeableState==="CONFLICTS"?s+=90:s+=80:o=="CHANGES_REQUESTED"&&(s+=70),s};var ee={};x(ee,{getIssueUniqueId:()=>Lt,getPullRequestUniqueId:()=>xt});var Lt=(e,t="")=>{let r=[];return r.push(t),r.push(e),JSON.stringify(r)},xt=(e,t="")=>{let r=[];return r.push(t),r.push(e),JSON.stringify(r)};var te={};x(te,{getIssueUniqueId:()=>At,getJiraServerIssueUniqueId:()=>Tt});var At=(e,t,r)=>{let s=[];return s.push(""),s.push(e),s.push(t),s.push(r),JSON.stringify(s)},Tt=(e,t,r)=>{let s=[];return s.push(r),s.push(""),s.push(e),s.push(t),JSON.stringify(s)};var re={};x(re,{getIssueUniqueId:()=>Ot});var Ot=(e,t,r,s="")=>{let n=[];return n.push(s),n.push(e),n.push(t),n.push(r),JSON.stringify(n)};var _t=e=>{let t={request:e==null?void 0:e.request};return{azureDevOps:new j({...t,...e==null?void 0:e.azureDevOps}),bitbucket:new B({...t,...e==null?void 0:e.bitbucket}),bitbucketServer:new N({...t,...e==null?void 0:e.bitbucketServer}),github:new Q({...t,...e==null?void 0:e.github}),gitlab:new z({...t,...e==null?void 0:e.gitlab}),jira:new M({...t,...e==null?void 0:e.jira}),trello:new H({...t,...e==null?void 0:e.trello})}},kt=_t;var jt={azureDevOps:X,bitbucket:K,bitbucketServer:Z,github:Y,gitlab:ee,jira:te,trello:re};
@@ -1 +1,2 @@
1
- export declare const getIssueUniqueId: (resourceId: string, projectId: string, issueId: string, domain?: string) => string;
1
+ export declare const getIssueUniqueId: (resourceId: string, projectId: string, issueId: string) => string;
2
+ export declare const getJiraServerIssueUniqueId: (projectId: string, issueId: string, domain: string) => string;
@@ -1,5 +1,5 @@
1
1
  import { PagedResult, Result } from '../../types';
2
- import { CursorPageInput, EnterpriseOptions, GetRepoInput, GitProvider, GitPullRequest, GitRepository, NumberedPageInput, Options } from '../gitProvider';
2
+ import { CursorPageInput, EnterpriseOptions, GetRepoErrorData, GetRepoInput, GitProvider, GitPullRequest, GitRepository, NumberedPageInput, Options } from '../gitProvider';
3
3
  import { Issue } from '../issueProvider';
4
4
  import { Provider } from '../provider';
5
5
  export interface AzureGetRepoInput extends GetRepoInput {
@@ -61,6 +61,7 @@ export declare class AzureDevOps extends Provider implements GitProvider {
61
61
  }>;
62
62
  getRepos(inputs: AzureGetRepoInput[], options?: Options): Promise<{
63
63
  data: GitRepository[];
64
+ errors: GetRepoErrorData[];
64
65
  }>;
65
66
  getReposForAzureProject(input: AzureGetReposInput, options?: Options): Promise<{
66
67
  data: GitRepository[];
@@ -117,6 +118,15 @@ export declare class AzureDevOps extends Provider implements GitProvider {
117
118
  }, options?: EnterpriseOptions): Promise<{
118
119
  data: GitPullRequest[];
119
120
  }>;
121
+ closePullRequest(input: {
122
+ repo: GetRepoInput;
123
+ pullRequestId: string;
124
+ }, options?: EnterpriseOptions): Promise<void>;
125
+ mergePullRequest(input: {
126
+ repo: GetRepoInput;
127
+ pullRequestId: string;
128
+ expectedSourceSha: string;
129
+ }, options?: EnterpriseOptions): Promise<void>;
120
130
  getIssuesForAzureProject(input: {
121
131
  namespace: string;
122
132
  project: string;
@@ -136,4 +146,10 @@ export declare class AzureDevOps extends Provider implements GitProvider {
136
146
  };
137
147
  data: Issue[];
138
148
  }>;
149
+ setIssueStatus(input: {
150
+ namespace: string;
151
+ project: string;
152
+ issueId: string;
153
+ status: string;
154
+ }, options?: EnterpriseOptions): Promise<void>;
139
155
  }
@@ -1,4 +1,4 @@
1
- import { Account, CursorPageInput, GetRepoInput, GitProvider, GitPullRequest, GitRepository, NumberedPageInput, Options } from '../gitProvider';
1
+ import { Account, CursorPageInput, GetRepoErrorData, GetRepoInput, GitProvider, GitPullRequest, GitRepository, NumberedPageInput, Options } from '../gitProvider';
2
2
  import { Provider } from '../provider';
3
3
  export interface RefreshTokenResponse {
4
4
  access_token: string;
@@ -33,6 +33,7 @@ export declare class Bitbucket extends Provider implements GitProvider {
33
33
  }>;
34
34
  getRepos(inputs: GetRepoInput[], options?: Options): Promise<{
35
35
  data: GitRepository[];
36
+ errors: GetRepoErrorData[];
36
37
  }>;
37
38
  getReposForCurrentUser(inputs?: CursorPageInput, options?: Options): Promise<{
38
39
  pageInfo: {
@@ -90,4 +91,13 @@ export declare class Bitbucket extends Provider implements GitProvider {
90
91
  }, options?: Options): Promise<{
91
92
  data: GitPullRequest[];
92
93
  }>;
94
+ closePullRequest(input: {
95
+ repo: GetRepoInput;
96
+ pullRequestId: string;
97
+ }, options?: Options): Promise<void>;
98
+ mergePullRequest(input: {
99
+ repo: GetRepoInput;
100
+ pullRequestId: string;
101
+ expectedSourceSha: string;
102
+ }, options?: Options): Promise<void>;
93
103
  }
@@ -147,6 +147,10 @@ export interface NumberedPageInput {
147
147
  page?: number | null;
148
148
  }
149
149
  export type PageInput = CursorPageInput | NumberedPageInput;
150
+ export interface GetRepoErrorData {
151
+ input: GetRepoInput;
152
+ error?: Error;
153
+ }
150
154
  export interface GitProvider {
151
155
  getCurrentUser?(options: Options): Promise<Result<Account>>;
152
156
  getUserForCommit?(input: {
@@ -160,7 +164,9 @@ export interface GitProvider {
160
164
  username: string;
161
165
  }, options: Options): Promise<Result<Account>>;
162
166
  getRepo(input: GetRepoInput, options: Options): Promise<Result<GitRepository>>;
163
- getRepos(inputs: GetRepoInput[], options: Options): Promise<Result<GitRepository[]>>;
167
+ getRepos(inputs: GetRepoInput[], options: Options): Promise<Result<GitRepository[]> & {
168
+ errors?: GetRepoErrorData[];
169
+ }>;
164
170
  getReposForCurrentUser?(inputs: CursorPageInput, options: Options): Promise<PagedResult<GitRepository>>;
165
171
  getBranches?(input: {
166
172
  repo: GetRepoInput;
@@ -1,5 +1,4 @@
1
- import { PagedResult } from '../../types';
2
- import { Account, CursorPageInput, EnterpriseOptions, GetRepoInput, GitProvider, GitPullRequest, GitRepository, Organization } from '../gitProvider';
1
+ import { Account, CursorPageInput, EnterpriseOptions, GetRepoErrorData, GetRepoInput, GitProvider, GitPullRequest, GitRepository, Organization } from '../gitProvider';
3
2
  import { Issue } from '../issueProvider';
4
3
  import { EnterpriseProvider } from '../provider';
5
4
  import { FetchIssuesData, FetchPullRequestsData } from './githubTypes';
@@ -36,12 +35,26 @@ export declare class GitHub extends EnterpriseProvider implements GitProvider {
36
35
  }, options?: EnterpriseOptions): Promise<{
37
36
  data: Account;
38
37
  }>;
39
- getOrgsForCurrentUser(input?: CursorPageInput, options?: EnterpriseOptions): Promise<PagedResult<Organization>>;
38
+ getOrgsForCurrentUser(input?: CursorPageInput, options?: EnterpriseOptions): Promise<{
39
+ pageInfo: {
40
+ endCursor: string | null;
41
+ hasNextPage: boolean;
42
+ };
43
+ data: {
44
+ id: string;
45
+ graphQLId: string;
46
+ username: string;
47
+ name: string | null;
48
+ email: string | null;
49
+ avatarUrl: string;
50
+ }[];
51
+ }>;
40
52
  getRepo(input: GetRepoInput, options?: EnterpriseOptions): Promise<{
41
53
  data: GitRepository;
42
54
  }>;
43
55
  getRepos(inputs: GetRepoInput[], options?: EnterpriseOptions): Promise<{
44
56
  data: GitRepository[];
57
+ errors: GetRepoErrorData[];
45
58
  }>;
46
59
  getReposForUsernames(input: {
47
60
  usernames: string[];
@@ -126,13 +139,42 @@ export declare class GitHub extends EnterpriseProvider implements GitProvider {
126
139
  }[];
127
140
  };
128
141
  }>;
129
- getPullRequestsForRepos(input: FetchPullRequestsData & CursorPageInput, options?: EnterpriseOptions): Promise<{
142
+ searchPullRequests(input: {
143
+ query: string;
144
+ isDraft?: boolean;
145
+ } & CursorPageInput, options?: EnterpriseOptions): Promise<{
130
146
  pageInfo: {
147
+ hasNextPage: boolean;
131
148
  endCursor: string | null;
149
+ };
150
+ data: GitPullRequest[];
151
+ }>;
152
+ /**
153
+ * Returns pull requests that were created by, are assigned to, or have been requested to be reviewed by the user.
154
+ */
155
+ getPullRequestsAssociatedWithUser(input: {
156
+ username: string;
157
+ } & CursorPageInput, options?: EnterpriseOptions): Promise<{
158
+ pageInfo: {
159
+ hasNextPage: boolean;
160
+ endCursor: string;
161
+ };
162
+ data: GitPullRequest[];
163
+ }>;
164
+ getPullRequestsForRepos(input: FetchPullRequestsData & CursorPageInput, options?: EnterpriseOptions): Promise<{
165
+ pageInfo: {
132
166
  hasNextPage: boolean;
133
- } | undefined;
167
+ endCursor: string | null;
168
+ };
134
169
  data: GitPullRequest[];
135
170
  }>;
171
+ closePullRequest(input: {
172
+ pullRequestGraphQLId: string;
173
+ }, options?: EnterpriseOptions): Promise<void>;
174
+ mergePullRequest(input: {
175
+ pullRequestGraphQLId: string;
176
+ expectedSourceSha: string;
177
+ }, options?: EnterpriseOptions): Promise<void>;
136
178
  getIssuesForRepos(input: FetchIssuesData & CursorPageInput, options?: EnterpriseOptions): Promise<{
137
179
  pageInfo: {
138
180
  endCursor: string | null;
@@ -140,4 +182,12 @@ export declare class GitHub extends EnterpriseProvider implements GitProvider {
140
182
  };
141
183
  data: Issue[];
142
184
  }>;
185
+ private closeIssueWithReason;
186
+ private closeIssueWithoutReason;
187
+ private reopenIssue;
188
+ setIssueStatus(input: {
189
+ issueGraphQLId: string;
190
+ status: 'OPEN' | 'CLOSED';
191
+ closeReason?: 'COMPLETED' | 'NOT_PLANNED';
192
+ }, options?: EnterpriseOptions): Promise<void>;
143
193
  }
@@ -1,6 +1,5 @@
1
- import { GraphQLBody, GraphQLResponse, ProviderConfig } from '../../types';
2
- import { CursorPageInput, EnterpriseOptions } from '../gitProvider';
3
- import { FetchPullRequestsData, GraphQLPullRequest } from './githubTypes';
1
+ import { GraphQLBody, GraphQLError, GraphQLResponse, ProviderConfig } from '../../types';
2
+ import { EnterpriseOptions } from '../gitProvider';
4
3
  export declare const GITHUB_API_URL = "https://api.github.com";
5
4
  export declare const GITHUB_GRAPHQL_API_URL: string;
6
5
  export declare const getGraphQLEndpoint: (config: ProviderConfig, options: EnterpriseOptions) => string;
@@ -8,14 +7,8 @@ export declare const makeGitHubGraphQLRequest: <T>(config: ProviderConfig, data:
8
7
  export declare const hasEmailScope: (scopes: string[]) => boolean;
9
8
  export declare const getAccountFields: (withAvatarSizeVar?: boolean, includeEmail?: boolean) => string;
10
9
  export declare const getBotFields: (withAvatarSizeVar?: boolean) => string;
10
+ export declare const getProjectPullRequestFields: (isDraftPullRequestSupported: boolean, includeEmail?: boolean) => string;
11
11
  export declare const GithubSearchSyntaxQualifiers: Record<string, string>;
12
12
  export declare const getProjectGithubSearchSyntax: (search: string) => string[];
13
- export declare const fetchPullRequests: (config: ProviderConfig, input: FetchPullRequestsData & CursorPageInput, options: EnterpriseOptions, shouldFetchDraft?: boolean, includeEmail?: boolean) => Promise<import("../../types").Response<GraphQLResponse<{
14
- [key: string]: {
15
- pageInfo: {
16
- endCursor: string | null;
17
- hasNextPage: boolean;
18
- };
19
- nodes?: GraphQLPullRequest[] | undefined;
20
- };
21
- }>>>;
13
+ export declare const makeSearchPullRequestsGraphQLBody: (query: string, cursor: string | null | undefined, supportsDrafts: boolean, supportsEmail: boolean) => GraphQLBody;
14
+ export declare const hasDraftsNotSupportedError: (errors?: GraphQLError[]) => boolean;
@@ -1,4 +1,4 @@
1
- import { Account, CursorPageInput, EnterpriseOptions, GetRepoInput, GitProvider, GitPullRequest, GitRepository, NumberedPageInput } from '../gitProvider';
1
+ import { Account, CursorPageInput, EnterpriseOptions, GetRepoErrorData, GetRepoInput, GitProvider, GitPullRequest, GitRepository, NumberedPageInput } from '../gitProvider';
2
2
  import { GetIssueInput, Issue, IssueProvider } from '../issueProvider';
3
3
  import { EnterpriseProvider } from '../provider';
4
4
  export type PullRequestState = 'opened' | 'merged' | 'closed';
@@ -31,6 +31,7 @@ export declare class GitLab extends EnterpriseProvider implements GitProvider, I
31
31
  }>;
32
32
  getRepos(inputs: GetRepoInput[], options?: EnterpriseOptions): Promise<{
33
33
  data: GitRepository[];
34
+ errors: GetRepoErrorData[];
34
35
  }>;
35
36
  getReposForCurrentUser(input?: CursorPageInput, options?: EnterpriseOptions): Promise<{
36
37
  pageInfo: {
@@ -133,6 +134,15 @@ export declare class GitLab extends EnterpriseProvider implements GitProvider, I
133
134
  } | undefined;
134
135
  data: GitPullRequest[];
135
136
  }>;
137
+ closePullRequest(input: {
138
+ repo: GetRepoInput;
139
+ pullRequestId: string;
140
+ }, options?: EnterpriseOptions): Promise<void>;
141
+ mergePullRequest(input: {
142
+ repo: GetRepoInput;
143
+ pullRequestId: string;
144
+ expectedSourceSha: string;
145
+ }, options?: EnterpriseOptions): Promise<void>;
136
146
  getIssue(input: GetIssueInput, options?: EnterpriseOptions): Promise<{
137
147
  data: Issue;
138
148
  }>;
@@ -161,4 +171,9 @@ export declare class GitLab extends EnterpriseProvider implements GitProvider, I
161
171
  } | undefined;
162
172
  data: Issue[];
163
173
  }>;
174
+ setIssueStatus(input: {
175
+ repo: GetRepoInput;
176
+ issueId: string;
177
+ status: 'CLOSE' | 'REOPEN';
178
+ }, options?: EnterpriseOptions): Promise<void>;
164
179
  }
@@ -37,4 +37,9 @@ export declare class Jira extends Provider {
37
37
  }, options?: EnterpriseOptions): Promise<{
38
38
  data: Issue[];
39
39
  }>;
40
+ setIssueStatus(input: {
41
+ resourceId: string;
42
+ issueId: string;
43
+ status: string;
44
+ }, options?: EnterpriseOptions): Promise<void>;
40
45
  }
@@ -18,4 +18,9 @@ export declare class Trello extends Provider {
18
18
  }, options?: EnterpriseOptions): Promise<{
19
19
  data: Issue[];
20
20
  }>;
21
+ setIssueStatus(input: {
22
+ appKey: string;
23
+ cardId: string;
24
+ status: string;
25
+ }, options?: EnterpriseOptions): Promise<void>;
21
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitkraken/provider-apis",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "An SDK around different third-party APIs that accepts and returns data in a common format.",
5
5
  "author": "Axosoft, LLC dba GitKraken",
6
6
  "license": "SEE LICENSE IN LICENSE",