@gitkraken/provider-apis 0.8.2 → 0.8.4
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 +15 -0
- package/dist/index.js +79 -65
- package/dist/providerUtils/github.d.ts +4 -2
- package/dist/providers/azureDevops/azureDevOps.d.ts +16 -0
- package/dist/providers/azureDevops/azureDevOpsTypes.d.ts +5 -9
- package/dist/providers/github/githubHelpers.d.ts +1 -0
- package/dist/providers/github/githubTypes.d.ts +10 -2
- package/dist/providers/issueProvider.d.ts +1 -0
- package/dist/providers/jira/jira.d.ts +27 -1
- package/dist/providers/trello/trello.d.ts +8 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.4
|
|
4
|
+
|
|
5
|
+
- added `getOrgsForUser` (Azure DevOps)
|
|
6
|
+
- added `getJiraResourcesForCurrentUser` (Jira)
|
|
7
|
+
- added `getJiraProjectsForResource` (Jira)
|
|
8
|
+
- added `getJiraProjectsForResources` (Jira)
|
|
9
|
+
- added `getBoardsForCurrentUser` (Trello)
|
|
10
|
+
- fixed GitHub `GitPullRequest` and GitHub `Issue` author fields being null if they were created by a bot
|
|
11
|
+
|
|
12
|
+
## 0.8.3
|
|
13
|
+
|
|
14
|
+
- added `getAzureProjects` (Azure DevOps)
|
|
15
|
+
- added `getPullRequestRank` to `GitHubUtils`
|
|
16
|
+
- added `type` field to `Issue` (GitLab, Azure DevOps, and Jira)
|
|
17
|
+
|
|
3
18
|
## 0.8.2
|
|
4
19
|
|
|
5
20
|
- added `getOrgsForCurrentUser` (GitHub)
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
"use strict";var xe=Object.create;var W=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Oe=Object.getPrototypeOf,ke=Object.prototype.hasOwnProperty;var G=(e,t)=>{for(var r in t)W(e,r,{get:t[r],enumerable:!0})},be=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of _e(t))!ke.call(e,s)&&s!==r&&W(e,s,{get:()=>t[s],enumerable:!(n=qe(t,s))||n.enumerable});return e};var Be=(e,t,r)=>(r=e!=null?xe(Oe(e)):{},be(t||!e||!e.__esModule?W(r,"default",{value:e,enumerable:!0}):r,e)),Ne=e=>be(W({},"__esModule",{value:!0}),e);var xt={};G(xt,{AzureDevOps:()=>B,AzureDevopsUtils:()=>J,Bitbucket:()=>N,BitbucketServer:()=>j,BitbucketServerUtils:()=>K,BitbucketUtils:()=>X,GitHub:()=>F,GitHubUtils:()=>Z,GitLab:()=>z,GitLabUtils:()=>Y,Jira:()=>M,JiraUtils:()=>ee,Trello:()=>H,TrelloUtils:()=>te,Utils:()=>Tt,default:()=>At});module.exports=Ne(xt);var C=100;var ye=Be(require("node-fetch")),Ie=globalThis.fetch||ye.default;var Pe=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 n={body:r,headers:Object.fromEntries(e.headers.entries()),status:e.status,statusText:e.statusText};if(!e.ok){let s=new Error(e.statusText);throw Object.assign(s,{response:n}),s}return n},re=e=>Pe(e)?async({url:t,...r})=>{let n=await e(t,r);return je(n)}:e;var w=class{constructor(t){this.config={...t,request:re((t==null?void 0:t.request)||Ie)}}updateConfig(t){this.config={...this.config,...t,request:t.request?re(t.request):this.config.request}}},L=class extends w{};var y=(e,t)=>{let r={};return e&&(r.Authorization=`${t?"Basic":"Bearer"} ${e}`),r};var U=(e,t={})=>y(t.token||e.token,t.isPAT||e.isPAT);var Fe="https://app.vssps.visualstudio.com/_apis",A="https://dev.azure.com",Qe={active:"OPEN",completed:"MERGED",abandoned:"CLOSED"},ze={10:"APPROVED",5:"APPROVED",0:"REVIEW_REQUESTED",[-5]:"CHANGES_REQUESTED",[-10]:"CHANGES_REQUESTED"},se=e=>({id:e.id,name:e.displayName,username:e.uniqueName||e.displayName,email:null,avatarUrl:e.imageUrl}),V=e=>e.startsWith("refs/heads/")?e.replace("refs/heads/",""):e,ve=e=>({id:e.pullRequestId.toString(),title:e.title,number:e.codeReviewId,state:Qe[e.status],isDraft:e.isDraft,commentCount:null,upvoteCount:null,author:se(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:V(e.targetRefName)},headRef:{name:V(e.sourceRefName)},url:null,assignees:e.reviewers.map(se),reviews:e.reviewers.filter(t=>t.vote!==0).map(t=>({reviewer:se(t),state:ze[t.vote]||"REVIEW_REQUESTED"})),additions:null,deletions:null,fileCount:null,commitCount:null,headRepository:null,mergeableState:"UNKNOWN"}),Ce=(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:V(t.defaultBranch)}:null,permission:null}),Me=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,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:`${Fe}/profile/profiles/me`,headers:U(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 s=(await this.config.request({url:`${A}/${encodeURIComponent(t.namespace)}/_apis/ConnectionData`,headers:U(this.config,r)})).body.authorizedUser;if(s.providerDisplayName==="Anonymous")throw new Error("Current user not found.");return{data:{id:s.id,name:s.providerDisplayName,username:s.providerDisplayName,email:s.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 s=(await this.config.request({url:`${A}/${encodeURIComponent(t.repo.namespace)}/${encodeURIComponent(t.repo.project)}/_apis/git/repositories/${encodeURIComponent(t.repo.name)}/commits/${t.oid}`,headers:U(this.config,r)})).body.author;return{data:{name:s.name,email:s.email,avatarUrl:s.imageUrl}}}async getRepo(t,r={}){if(!t.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let n=await this.config.request({url:`${A}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/git/repositories/${encodeURIComponent(t.name)}`,headers:U(this.config,r)});return{data:Ce(t.namespace,n.body)}}async getRepos(t,r={}){return{data:(await Promise.all(t.map(s=>this.getRepo(s,r)))).map(s=>s.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:`${A}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/git/repositories`,headers:U(this.config,r)})).body.value.map(s=>Ce(t.namespace,s))}}async getRefs(t,r,n={}){if(!r.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let s=new URL(`${A}/${encodeURIComponent(r.repo.namespace)}/${encodeURIComponent(r.repo.project)}/_apis/git/repositories/${encodeURIComponent(r.repo.name)}/refs`);s.searchParams.set("filter",t),s.searchParams.set("$top",C.toString()),r.cursor&&s.searchParams.set("continuationToken",r.cursor);let o=await this.config.request({url:s.toString(),headers:U(this.config,n)}),a=o.headers["x-ms-continuationtoken"];return{pageInfo:{hasNextPage:!!a,endCursor:a||null},data:o.body.value.map(i=>({name:V(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={},n=100){let{page:s,repo:o,assigneeLogins:a,authorLogin:i}=t||{},u=s||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||A}/${encodeURIComponent(o.namespace)}/${encodeURIComponent(o.project||"")}/_apis/git/repositories/${encodeURIComponent(o.name)}/pullRequests?${l}&%24top=${n}&%24skip=${(u-1)*n}`,headers:U(this.config,r)})}async getPullRequestsForRepo(t,r={}){let s=t.page||1,o=await this.getPullRequestsForRepoBase(t,r,100);return{pageInfo:{hasNextPage:o.body.value.length===100,nextPage:s+1},data:o.body.value.map(ve)}}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:n}=t||{},s=[];return await Promise.all(n.map(async o=>{try{(await this.getPullRequestsForRepoBase({repo:o,...t},r)).body.value.forEach(i=>{s.push(ve(i))})}catch(a){if(a.statusCode!==404&&a.statusCode!==401)throw a}})),{data:s}}async getIssuesForAzureProject(t,r={}){let{page:n,assigneeLogins:s,authorLogin:o,mentionLogin:a}=t||{},i=n||1,u=200,l=["[Microsoft.VSTS.Common.ClosedDate] = ''","[System.TeamProject] = @project","[Microsoft.VSTS.Common.ResolvedDate] = ''"];o&&l.push(`[System.CreatedBy] = '${o.replace("'","''")}'`),s&&s[0]&&l.push(`[System.AssignedTo] = '${s[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||A}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/wit/wiql?api-version=6.0`,body:JSON.stringify({query:p}),method:"POST",headers:{...U(this.config,r),"Content-Type":"application/json"}}),m=g.body.workItems.slice((i-1)*u,u*i).map(c=>c.id),d=await this.config.request({url:`${r.baseUrl||A}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/wit/workitemsbatch?api-version=6.0`,body:JSON.stringify({ids:m,$expand:"Links"}),method:"POST",headers:{...U(this.config,r),"Content-Type":"application/json"}});return{pageInfo:{hasNextPage:g.body.workItems.length>u*i,nextPage:i+1},data:d.body.value.map(Me)}}};var T=(e,t={})=>y(t.token||e.token,t.isPAT||e.isPAT);var q="https://api.bitbucket.org/2.0",He={OPEN:"OPEN",MERGED:"MERGED",DECLINED:"CLOSED"},Se=e=>({id:e.uuid,name:e.display_name||e.nickname,username:e.nickname||e.display_name,email:null,avatarUrl:e.links.avatar.href}),Ue=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(n=>n.name==="https"))==null?void 0:t.href)??null,sshUrl:((r=e.links.clone.find(n=>n.name==="ssh"))==null?void 0:r.href)??null,defaultBranch:{name:e.mainbranch.name},permission:null}},Ee=e=>{let t=e.id;return{id:t.toString(),title:e.title,number:t,state:He[e.state],isDraft:!1,commentCount:e.comment_count,upvoteCount:null,author:Se(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"}},N=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:T(this.config,t)});return{data:Se(r.body)}}async getUserForCommit(t,r={}){var a;let s=(await this.config.request({url:`${q}/repositories/${t.repo.namespace}/${t.repo.name}/commit/${t.oid}`,headers:T(this.config,r)})).body.author,o=s.raw.match(/([^<]+)<(.+)>/);return{data:{name:o?o[1].trim():null,email:o?o[2]:null,avatarUrl:((a=s.user)==null?void 0:a.links.avatar.href)||null}}}async getRepo(t,r={}){let n=await this.config.request({url:`${q}/repositories/${t.namespace}/${t.name}`,headers:T(this.config,r)});return{data:Ue(n.body)}}async getRepos(t,r={}){return{data:(await Promise.all(t.map(s=>this.getRepo(s,r)))).map(s=>s.data)}}async getReposForCurrentUser(t={},r={}){let n=new URL(`${q}/repositories`);n.searchParams.set("role","member"),n.searchParams.set("pagelen",C.toString()),t.cursor&&n.searchParams.set("after",t.cursor);let s=await this.config.request({url:n.toString(),headers:T(this.config,r)}),o=!!s.body.next,a=null;return s.body.next&&(a=new URL(s.body.next).searchParams.get("after")),{pageInfo:{hasNextPage:o,endCursor:a},data:s.body.values.map(Ue)}}async getBranches(t,r={}){var a;let n=new URL(`${q}/repositories/${t.repo.namespace}/${t.repo.name}/refs/branches`);n.searchParams.set("page",((a=t.page)==null?void 0:a.toString())||"1"),n.searchParams.set("pagelen",C.toString());let s=await this.config.request({url:n.toString(),headers:T(this.config,r)}),o=!!s.body.next;return{pageInfo:{hasNextPage:o,nextPage:o?s.body.page+1:null},data:s.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 n=new URL(`${q}/repositories/${t.repo.namespace}/${t.repo.name}/refs/tags`);n.searchParams.set("pagelen",C.toString()),t.cursor&&n.searchParams.set("page",t.cursor);let s=await this.config.request({url:n.toString(),headers:T(this.config,r)}),o=!!s.body.next,a=null;return s.body.next&&(a=new URL(s.body.next).searchParams.get("page")),{pageInfo:{hasNextPage:o,endCursor:a},data:s.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 s;let n=new URL(`${q}/repositories/${encodeURI(t.repo.namespace)}/${encodeURI(t.repo.name)}/pullrequests?state=OPEN`);return n.searchParams.set("page",((s=t.page)==null?void 0:s.toString())||"1"),n.searchParams.set("pagelen","50"),await this.config.request({url:n.toString(),headers:T(this.config,r)})}async getPullRequestsForRepo(t,r={}){let n=[],s=await this.getPullRequestsForRepoBase(t,r);s.body.values.forEach(a=>{if(t.authorLogin&&a.author.uuid!==t.authorLogin)return null;n.push(Ee(a))});let o=!!s.body.next;return{pageInfo:{hasNextPage:o,nextPage:o?s.body.page+1:null},data:n}}async getPullRequestsForRepos(t,r={}){let n=[];return await Promise.all(t.repos.map(async s=>{try{(await this.getPullRequestsForRepoBase({repo:s,...t},r)).body.values.forEach(a=>{if(t.authorLogin&&a.author.uuid!==t.authorLogin)return null;n.push(Ee(a))})}catch(o){if(o.statusCode!==404&&o.statusCode!==401)throw o}})),{data:n}}};var j=class extends L{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 s,o,a;let n=await this.config.request({url:`${this.getBaseUrl(r)}/projects/${t.namespace}/repos/${t.name}`,headers:this.getRequestHeaders(r)});return{data:{id:n.body.id.toString(),namespace:n.body.project.key,name:n.body.slug,webUrl:((s=n.body.links.self[0])==null?void 0:s.href)??null,httpsUrl:((o=n.body.links.clone.find(i=>i.name==="https"))==null?void 0:o.href)??null,sshUrl:((a=n.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(s=>this.getRepo(s,r)))).map(s=>s.data)}}};var ae="https://api.github.com",We=`${ae}/graphql`,De=/\/api\/v\d+$/,Ve=e=>{if(e.endsWith("/api/graphql"))throw new Error("The graphql endpoint is being used as the baseUrl. This package uses both GraphQL and REST APIs, and the REST version cannot be assumed. Use the REST endpoint as the baseUrl instead.")},Je=(e,t)=>{let r=t.baseUrl||e.baseUrl;return r?(r=r.replace(/\/$/,""),Ve(r),De.test(r)&&(r=r.replace(De,"")),`${r}/api/graphql`):We},I=(e,t,r)=>{let n=y(r.token||e.token);return n["X-Github-Next-Global-ID"]="1",n["Content-Type"]="application/json",e.request({url:Je(e,r),method:"POST",headers:n,body:JSON.stringify(t)})},Xe={user:!0,"user:email":!0,"read:user":!0},O=e=>e.some(t=>Xe[t]),E=(e=!1,t=!1)=>`
|
|
1
|
+
"use strict";var Be=Object.create;var W=Object.defineProperty;var je=Object.getOwnPropertyDescriptor;var Ne=Object.getOwnPropertyNames;var Fe=Object.getPrototypeOf,Qe=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 Ne(t))!Qe.call(e,n)&&n!==r&&W(e,n,{get:()=>t[n],enumerable:!(s=je(t,n))||s.enumerable});return e};var ze=(e,t,r)=>(r=e!=null?Be(Fe(e)):{},Ie(t||!e||!e.__esModule?W(r,"default",{value:e,enumerable:!0}):r,e)),Me=e=>Ie(W({},"__esModule",{value:!0}),e);var _t={};L(_t,{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:()=>qt,default:()=>Tt});module.exports=Me(_t);var v=100;var Pe=ze(require("node-fetch")),ve=globalThis.fetch||Pe.default;var Ue=e=>e.name==="fetch";var He=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 He(s)}:e;var C=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 C{};var y=(e,t)=>{let r={};return e&&(r.Authorization=`${t?"Basic":"Bearer"} ${e}`),r};var w=(e,t={})=>y(t.token||e.token,t.isPAT||e.isPAT);var we="https://app.vssps.visualstudio.com/_apis",$="https://dev.azure.com",We={active:"OPEN",completed:"MERGED",abandoned:"CLOSED"},Je={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,Ce=e=>({id:e.pullRequestId.toString(),title:e.title,number:e.codeReviewId,state:We[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:null,assignees:e.reviewers.map(ne),reviews:e.reviewers.filter(t=>t.vote!==0).map(t=>({reviewer:ne(t),state:Je[t.vote]||"REVIEW_REQUESTED"})),additions:null,deletions:null,fileCount:null,commitCount:null,headRepository:null,mergeableState:"UNKNOWN"}),Se=(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}),Ve=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 C{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: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:`${$}/${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:`${$}/${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:`${we}/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(`${$}/${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:`${$}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/git/repositories/${encodeURIComponent(t.name)}`,headers:w(this.config,r)});return{data:Se(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:`${$}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/git/repositories`,headers:w(this.config,r)})).body.value.map(n=>Se(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(`${$}/${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 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||$}/${encodeURIComponent(o.namespace)}/${encodeURIComponent(o.project||"")}/_apis/git/repositories/${encodeURIComponent(o.name)}/pullRequests?${l}&%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(Ce)}}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(Ce(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||$}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/wit/wiql?api-version=6.0`,body:JSON.stringify({query:p}),method:"POST",headers:{...w(this.config,r),"Content-Type":"application/json"}}),c=g.body.workItems.slice((i-1)*u,u*i).map(m=>m.id),d=await this.config.request({url:`${r.baseUrl||$}/${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:g.body.workItems.length>u*i,nextPage:i+1},data:d.body.value.map(Ve)}}};var x=(e,t={})=>y(t.token||e.token,t.isPAT||e.isPAT);var q="https://api.bitbucket.org/2.0",Xe={OPEN:"OPEN",MERGED:"MERGED",DECLINED:"CLOSED"},$e=e=>({id:e.uuid,name:e.display_name||e.nickname,username:e.nickname||e.display_name,email:null,avatarUrl:e.links.avatar.href}),Ee=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:Xe[e.state],isDraft:!1,commentCount:e.comment_count,upvoteCount:null,author:$e(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 C{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:$e(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:Ee(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(Ee)}}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",Ke=`${ie}/graphql`,Ge=/\/api\/v\d+$/,Ze=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.")},Ye=(e,t)=>{let r=t.baseUrl||e.baseUrl;return r?(r=r.replace(/\/$/,""),Ze(r),Ge.test(r)&&(r=r.replace(Ge,"")),`${r}/api/graphql`):Ke},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:Ye(e,r),method:"POST",headers:s,body:JSON.stringify(t)})},et={user:!0,"user:email":!0,"read:user":!0},k=e=>e.some(t=>et[t]),S=(e=!1,t=!1)=>`
|
|
2
|
+
__typename
|
|
2
3
|
id
|
|
3
4
|
databaseId
|
|
4
5
|
name
|
|
5
6
|
login
|
|
6
7
|
${t?"email":""}
|
|
7
8
|
avatarUrl${e?"(size: $avatarSize)":""}
|
|
8
|
-
`,
|
|
9
|
+
`,ue=(e=!1)=>`
|
|
10
|
+
__typename
|
|
11
|
+
id
|
|
12
|
+
databaseId
|
|
13
|
+
login
|
|
14
|
+
avatarUrl${e?"(size: $avatarSize)":""}
|
|
15
|
+
`,tt=(e,t=!1)=>`
|
|
9
16
|
id
|
|
10
17
|
databaseId
|
|
11
18
|
number
|
|
@@ -13,7 +20,10 @@ title
|
|
|
13
20
|
state
|
|
14
21
|
author {
|
|
15
22
|
... on User {
|
|
16
|
-
${
|
|
23
|
+
${S(!1,t)}
|
|
24
|
+
}
|
|
25
|
+
... on Bot {
|
|
26
|
+
${ue(!1)}
|
|
17
27
|
}
|
|
18
28
|
}
|
|
19
29
|
commits(last: 1) {
|
|
@@ -73,7 +83,7 @@ updatedAt
|
|
|
73
83
|
closedAt
|
|
74
84
|
assignees(first: 100) {
|
|
75
85
|
nodes {
|
|
76
|
-
${
|
|
86
|
+
${S(!1,t)}
|
|
77
87
|
}
|
|
78
88
|
}
|
|
79
89
|
reviewRequests(first: 100) {
|
|
@@ -81,7 +91,7 @@ reviewRequests(first: 100) {
|
|
|
81
91
|
asCodeOwner
|
|
82
92
|
requestedReviewer {
|
|
83
93
|
... on User {
|
|
84
|
-
${
|
|
94
|
+
${S(!1,t)}
|
|
85
95
|
}
|
|
86
96
|
}
|
|
87
97
|
}
|
|
@@ -90,7 +100,7 @@ latestReviews(first: 100) {
|
|
|
90
100
|
nodes {
|
|
91
101
|
author {
|
|
92
102
|
... on User {
|
|
93
|
-
${
|
|
103
|
+
${S(!1,t)}
|
|
94
104
|
}
|
|
95
105
|
}
|
|
96
106
|
state
|
|
@@ -100,7 +110,7 @@ additions
|
|
|
100
110
|
deletions
|
|
101
111
|
changedFiles
|
|
102
112
|
mergeable
|
|
103
|
-
`,
|
|
113
|
+
`,rt={"-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"},st=new RegExp('(([^\\s]+:)?\\"(?:[^\\"\\\\]|\\\\.)*\\"?)|([^\\"\\s]+)',"g"),le=e=>{let t=[];return(e.match(st)??[]).forEach(s=>{if(s.includes(":")&&s!="is:closed"){let n=s.split(":")[0];rt[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:c,mentionLogin:d}=t||{},m=le(c||"");p.forEach(f=>{m.push(`repo:${f.namespace}/${f.name}`)}),a&&a.forEach(f=>{m.push(`assignee:${f}`)}),i&&m.push(`updated:<${i}`),s&&u!=null&&u!=null&&m.push(`draft:${String(u)}`),l&&m.push(`author:${l}`),g&&m.push(`review-requested:${g}`),d&&m.push(`mentions:${d}`);let b=`
|
|
104
114
|
query (
|
|
105
115
|
$after: String
|
|
106
116
|
$search: String!
|
|
@@ -113,7 +123,7 @@ query (
|
|
|
113
123
|
) {
|
|
114
124
|
nodes {
|
|
115
125
|
... on PullRequest {
|
|
116
|
-
${
|
|
126
|
+
${tt(s,n)}
|
|
117
127
|
}
|
|
118
128
|
}
|
|
119
129
|
pageInfo {
|
|
@@ -123,7 +133,7 @@ query (
|
|
|
123
133
|
}
|
|
124
134
|
}
|
|
125
135
|
}
|
|
126
|
-
`;return I(e,{query:`${b}`,variables:{after:o??null,search:`sort:updated type:pr state:open ${
|
|
136
|
+
`;return I(e,{query:`${b}`,variables:{after:o??null,search:`sort:updated type:pr state:open ${m.join(" ")}`}},r)};var de=`
|
|
127
137
|
id
|
|
128
138
|
databaseId
|
|
129
139
|
owner {
|
|
@@ -136,13 +146,13 @@ defaultBranchRef {
|
|
|
136
146
|
name
|
|
137
147
|
}
|
|
138
148
|
viewerPermission
|
|
139
|
-
`,
|
|
149
|
+
`,ce={__typename:"User",id:"U_kgDNJ5k",databaseId:10137,name:"Deleted user",login:"ghost",email:"",avatarUrl:"https://avatars.githubusercontent.com/u/10137?v=4"},nt={APPROVED:"APPROVED",CHANGES_REQUESTED:"CHANGES_REQUESTED",COMMENTED:"COMMENTED",REVIEW_REQUESTED:"REVIEW_REQUESTED"},ot={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}),at={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}),it=e=>{var l,p,g,c,d,m,b,f;let t=null;e.author?t=(e.author.__typename==="Bot",e.author):t=ce;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=(c=r==null?void 0:r.status)==null?void 0:c.contexts)==null?void 0:d[0]:null,i=(((m=e.reviewRequests)==null?void 0:m.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:at[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||ce;return{reviewer:G(R),state:nt[h.state]}})),additions:e.additions,deletions:e.deletions,fileCount:e.changedFiles,commitCount:e.commits.totalCount,mergeableState:ot[e.mergeable]}},ut=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: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:`
|
|
140
150
|
query getCurrentUser {
|
|
141
151
|
viewer {
|
|
142
|
-
${
|
|
152
|
+
${S(!1,k(s))}
|
|
143
153
|
}
|
|
144
154
|
}
|
|
145
|
-
`},r)).body.data)==null?void 0:a.viewer;if(!o)throw new Error("Current user not found.");return{data
|
|
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:`
|
|
146
156
|
query getUserForCommit(
|
|
147
157
|
$owner: String!
|
|
148
158
|
$name: String!
|
|
@@ -161,23 +171,23 @@ query getUserForCommit(
|
|
|
161
171
|
}
|
|
162
172
|
}
|
|
163
173
|
}
|
|
164
|
-
`,variables:{owner:r.repo.namespace,name:r.repo.name,oid:r.oid,avatarSize:r.avatarSize}},
|
|
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:`
|
|
165
175
|
query getAccountForEmail($query: String! $avatarSize: Int) {
|
|
166
176
|
search(query: $query, type: USER, first: 1) {
|
|
167
177
|
nodes {
|
|
168
178
|
... on User {
|
|
169
|
-
${
|
|
179
|
+
${S(!0,k(n))}
|
|
170
180
|
}
|
|
171
181
|
}
|
|
172
182
|
}
|
|
173
183
|
}
|
|
174
|
-
`,variables:{query:`in:email ${r.email}`,avatarSize:r.avatarSize}},
|
|
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:`
|
|
175
185
|
query getUserForUsername($login: String! $avatarSize: Int) {
|
|
176
186
|
user(login: $login) {
|
|
177
|
-
${
|
|
187
|
+
${S(!0,k(n))}
|
|
178
188
|
}
|
|
179
189
|
}
|
|
180
|
-
`,variables:{login:r.username,avatarSize:r.avatarSize}},
|
|
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:`
|
|
181
191
|
query getOrgsForCurrentUser($cursor: String, $first: Int!) {
|
|
182
192
|
viewer {
|
|
183
193
|
organizations(first: $first after: $cursor) {
|
|
@@ -196,22 +206,22 @@ query getOrgsForCurrentUser($cursor: String, $first: Int!) {
|
|
|
196
206
|
}
|
|
197
207
|
}
|
|
198
208
|
}
|
|
199
|
-
`,variables:{cursor:r.cursor,first:
|
|
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:`
|
|
200
210
|
query getRepo($owner: String!, $name: String!) {
|
|
201
211
|
repository(owner: $owner, name: $name) {
|
|
202
|
-
${
|
|
212
|
+
${de}
|
|
203
213
|
}
|
|
204
214
|
}
|
|
205
|
-
`,variables:{owner:r.namespace,name:r.name}},
|
|
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)=>`
|
|
206
216
|
getRepo_${u}: repository(owner: "${a}", name: "${i}") {
|
|
207
|
-
${
|
|
217
|
+
${de}
|
|
208
218
|
}
|
|
209
219
|
`).join(`
|
|
210
220
|
`),o=await I(this.config,{query:`
|
|
211
221
|
query batchGetRepos {
|
|
212
|
-
${
|
|
222
|
+
${n}
|
|
213
223
|
}
|
|
214
|
-
`},
|
|
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:`
|
|
215
225
|
query getReposForUsernames($query: String!, $cursor: String, $first: Int!) {
|
|
216
226
|
search(query: $query, type: REPOSITORY, first: $first, after: $cursor) {
|
|
217
227
|
pageInfo {
|
|
@@ -220,12 +230,12 @@ query getReposForUsernames($query: String!, $cursor: String, $first: Int!) {
|
|
|
220
230
|
}
|
|
221
231
|
nodes {
|
|
222
232
|
... on Repository {
|
|
223
|
-
${
|
|
233
|
+
${de}
|
|
224
234
|
}
|
|
225
235
|
}
|
|
226
236
|
}
|
|
227
237
|
}
|
|
228
|
-
`,variables:{query:`fork:true ${r.usernames.map(i=>`user:${i}`).join(" ")}`,cursor:r.cursor,first:
|
|
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:`
|
|
229
239
|
query getRefs($owner: String!, $name: String!, $refPrefix: String!, $cursor: String, $first: Int!) {
|
|
230
240
|
repository(owner: $owner, name: $name) {
|
|
231
241
|
refs(refPrefix: $refPrefix first: $first after: $cursor) {
|
|
@@ -236,7 +246,7 @@ query getRefs($owner: String!, $name: String!, $refPrefix: String!, $cursor: Str
|
|
|
236
246
|
nodes {
|
|
237
247
|
name
|
|
238
248
|
target {
|
|
239
|
-
...on Commit {
|
|
249
|
+
... on Commit {
|
|
240
250
|
oid
|
|
241
251
|
authoredDate
|
|
242
252
|
committedDate
|
|
@@ -246,7 +256,7 @@ query getRefs($owner: String!, $name: String!, $refPrefix: String!, $cursor: Str
|
|
|
246
256
|
}
|
|
247
257
|
}
|
|
248
258
|
}
|
|
249
|
-
`,variables:{owner:
|
|
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:`
|
|
250
260
|
query getBlame($owner: String!, $name: String!, $ref: String!, $path: String!) {
|
|
251
261
|
repository(owner: $owner, name: $name) {
|
|
252
262
|
object(expression: $ref) {
|
|
@@ -285,7 +295,7 @@ query getBlame($owner: String!, $name: String!, $ref: String!, $path: String!) {
|
|
|
285
295
|
}
|
|
286
296
|
}
|
|
287
297
|
}
|
|
288
|
-
`,variables:{owner:r.repo.namespace,name:r.repo.name,ref:r.ref,path:r.path}},
|
|
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,c,d,m,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=(c=(g=i.body)==null?void 0:g.data)==null?void 0:c.search)==null?void 0:d.nodes)||[];return{pageInfo:(f=(b=(m=i.body)==null?void 0:m.data)==null?void 0:b.search)==null?void 0:f.pageInfo,data:u.map(it)}}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(D=>{a.push(`repo:${D.namespace}/${D.name}`)}),u&&u.forEach(D=>{a.push(`assignee:${D}`)}),l&&a.push(`updated:<${l}`),p&&a.push(`author:${p}`),g&&a.push(`mentions:${g}`);let c=`
|
|
289
299
|
query (
|
|
290
300
|
$after: String
|
|
291
301
|
$search: String!
|
|
@@ -303,7 +313,10 @@ query (
|
|
|
303
313
|
title
|
|
304
314
|
author {
|
|
305
315
|
... on User {
|
|
306
|
-
${
|
|
316
|
+
${S(!1,o)}
|
|
317
|
+
}
|
|
318
|
+
... on Bot {
|
|
319
|
+
${ue(!1)}
|
|
307
320
|
}
|
|
308
321
|
}
|
|
309
322
|
createdAt
|
|
@@ -324,7 +337,7 @@ query (
|
|
|
324
337
|
}
|
|
325
338
|
assignees(first: 100) {
|
|
326
339
|
nodes {
|
|
327
|
-
${
|
|
340
|
+
${S(!1,o)}
|
|
328
341
|
}
|
|
329
342
|
}
|
|
330
343
|
}
|
|
@@ -336,7 +349,7 @@ query (
|
|
|
336
349
|
}
|
|
337
350
|
}
|
|
338
351
|
}
|
|
339
|
-
`,d=await I(this.config,{query:`${
|
|
352
|
+
`,d=await I(this.config,{query:`${c}`,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 m=((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:m.map(ut)}}};var lt="https://gitlab.com/api/v4",pt="https://gitlab.com/api/graphql",Le=/\/api\/v\d+$/,Ae=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.")},me=(e,t)=>{let r=t.baseUrl||e.baseUrl;return r?(r=r.replace(/\/$/,""),Ae(r),r):lt},dt=(e,t)=>{let r=t.baseUrl||e.baseUrl;return r?(r=r.replace(/\/$/,""),Ae(r),Le.test(r)&&(r=r.replace(Le,"")),`${r}/api/graphql`):pt},U=(e,t,r)=>{let s=y(r.token||e.token);return e.request({url:dt(e,r),method:"POST",headers:{...s,"Content-Type":"application/json"},body:JSON.stringify(t)})};var gt={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/",mt="gid://gitlab/Issue/",he=`
|
|
340
353
|
id
|
|
341
354
|
path
|
|
342
355
|
fullPath
|
|
@@ -346,19 +359,19 @@ sshUrlToRepo
|
|
|
346
359
|
repository {
|
|
347
360
|
rootRef
|
|
348
361
|
}
|
|
349
|
-
`,
|
|
362
|
+
`,T=`
|
|
350
363
|
id
|
|
351
364
|
name
|
|
352
365
|
username
|
|
353
366
|
publicEmail
|
|
354
367
|
avatarUrl
|
|
355
|
-
`,
|
|
368
|
+
`,fe=`
|
|
356
369
|
author {
|
|
357
|
-
${
|
|
370
|
+
${T}
|
|
358
371
|
}
|
|
359
372
|
assignees {
|
|
360
373
|
nodes {
|
|
361
|
-
${
|
|
374
|
+
${T}
|
|
362
375
|
}
|
|
363
376
|
}
|
|
364
377
|
createdAt
|
|
@@ -368,15 +381,16 @@ id
|
|
|
368
381
|
iid
|
|
369
382
|
state
|
|
370
383
|
title
|
|
384
|
+
type
|
|
371
385
|
updatedAt
|
|
372
386
|
upvotes
|
|
373
387
|
userNotesCount
|
|
374
388
|
webUrl
|
|
375
|
-
`,
|
|
389
|
+
`,xe=`
|
|
376
390
|
id
|
|
377
391
|
state
|
|
378
392
|
author {
|
|
379
|
-
${
|
|
393
|
+
${T}
|
|
380
394
|
}
|
|
381
395
|
diffStatsSummary {
|
|
382
396
|
additions
|
|
@@ -397,25 +411,25 @@ targetBranch
|
|
|
397
411
|
sourceBranch
|
|
398
412
|
assignees {
|
|
399
413
|
nodes {
|
|
400
|
-
${
|
|
414
|
+
${T}
|
|
401
415
|
}
|
|
402
416
|
}
|
|
403
417
|
reviewers {
|
|
404
418
|
nodes {
|
|
405
|
-
${
|
|
419
|
+
${T}
|
|
406
420
|
mergeRequestInteraction {
|
|
407
421
|
approved
|
|
408
422
|
reviewState
|
|
409
423
|
}
|
|
410
424
|
}
|
|
411
425
|
}
|
|
412
|
-
mergeStatusEnum`,_=e=>`${e.namespace}/${e.name}`,
|
|
426
|
+
mergeStatusEnum`,_=e=>`${e.namespace}/${e.name}`,ht=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}},ft={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}),Te=(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:ft[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:gt[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(mt,""),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:`
|
|
413
427
|
query getCurrentUser {
|
|
414
428
|
currentUser {
|
|
415
|
-
${
|
|
429
|
+
${T}
|
|
416
430
|
}
|
|
417
431
|
}
|
|
418
|
-
`},t)).body.data)==null?void 0:
|
|
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:`
|
|
419
433
|
query getUserForCommit($fullPath: ID!, $oid: String!) {
|
|
420
434
|
project(fullPath: $fullPath) {
|
|
421
435
|
repository {
|
|
@@ -429,36 +443,36 @@ query getUserForCommit($fullPath: ID!, $oid: String!) {
|
|
|
429
443
|
}
|
|
430
444
|
}
|
|
431
445
|
}
|
|
432
|
-
`,variables:{fullPath:
|
|
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:`
|
|
433
447
|
query getAccountForEmail($email: String!) {
|
|
434
448
|
users(search: $email) {
|
|
435
449
|
nodes {
|
|
436
|
-
${
|
|
450
|
+
${T}
|
|
437
451
|
}
|
|
438
452
|
}
|
|
439
453
|
}
|
|
440
|
-
`,variables:{email:t.email}},r)).body.data)==null?void 0:o.users)==null?void 0:a.nodes)==null?void 0:i[0];if(!
|
|
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:`
|
|
441
455
|
query getAccountForUsername($username: String!) {
|
|
442
456
|
user(username: $username) {
|
|
443
|
-
${
|
|
457
|
+
${T}
|
|
444
458
|
}
|
|
445
459
|
}
|
|
446
|
-
`,variables:{username:t.username}},r)).body.data)==null?void 0:o.user;if(!
|
|
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:`
|
|
447
461
|
query getRepo($fullPath: ID!) {
|
|
448
462
|
project(fullPath: $fullPath) {
|
|
449
|
-
${
|
|
463
|
+
${he}
|
|
450
464
|
}
|
|
451
465
|
}
|
|
452
|
-
`,variables:{fullPath:
|
|
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)=>`
|
|
453
467
|
getRepo_${i}: project(fullPath: "${a}") {
|
|
454
|
-
${
|
|
468
|
+
${he}
|
|
455
469
|
}
|
|
456
470
|
`).join(`
|
|
457
|
-
`),o=await
|
|
471
|
+
`),o=await U(this.config,{query:`
|
|
458
472
|
query batchGetRepos {
|
|
459
|
-
${
|
|
473
|
+
${n}
|
|
460
474
|
}
|
|
461
|
-
`},r);if(!o.body.data)throw new Error(o.statusText||"Unknown error");return{data:
|
|
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:`
|
|
462
476
|
query getReposForCurrentUser($after: String) {
|
|
463
477
|
projects(membership: true first: 100 after: $after) {
|
|
464
478
|
pageInfo {
|
|
@@ -466,11 +480,11 @@ query getReposForCurrentUser($after: String) {
|
|
|
466
480
|
hasNextPage
|
|
467
481
|
}
|
|
468
482
|
nodes {
|
|
469
|
-
${
|
|
483
|
+
${he}
|
|
470
484
|
}
|
|
471
485
|
}
|
|
472
486
|
}
|
|
473
|
-
`,variables:{after:t.cursor}},r);if(!((o=
|
|
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(`${me(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(`${me(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,c,d)=>{u.push(`$${g}: ${d}`),l.push(`${g}: $${g}`),i[g]=c};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:`
|
|
474
488
|
query getPullRequestsForRepo(
|
|
475
489
|
$fullPath: ID!
|
|
476
490
|
$after: String
|
|
@@ -493,12 +507,12 @@ query getPullRequestsForRepo(
|
|
|
493
507
|
hasNextPage
|
|
494
508
|
}
|
|
495
509
|
nodes {
|
|
496
|
-
${
|
|
510
|
+
${xe}
|
|
497
511
|
}
|
|
498
512
|
}
|
|
499
513
|
}
|
|
500
514
|
}
|
|
501
|
-
`,variables:{...l,after:
|
|
515
|
+
`,variables:{...l,after:s}},r),g=[],c=(b=p.body.data)==null?void 0:b.project,d={name:(c==null?void 0:c.name)||"",owner:((c==null?void 0:c.fullPath)||"").split("/").slice(0,-1).join("/")};return(((f=c==null?void 0:c.mergeRequests)==null?void 0:f.nodes)||[]).forEach(R=>{g.push(Te(R,d))}),{pageInfo:(h=c==null?void 0:c.mergeRequests)==null?void 0:h.pageInfo,data:g}}async getPullRequestsForRepos(t,r={}){var c,d,m,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:`
|
|
502
516
|
query getPullRequests(
|
|
503
517
|
$projectIds: [ID!]
|
|
504
518
|
$after: String
|
|
@@ -522,23 +536,23 @@ query getPullRequests(
|
|
|
522
536
|
${i.length?i.join(" "):""}
|
|
523
537
|
) {
|
|
524
538
|
nodes {
|
|
525
|
-
${
|
|
539
|
+
${xe}
|
|
526
540
|
}
|
|
527
541
|
}
|
|
528
542
|
}
|
|
529
543
|
}
|
|
530
544
|
}
|
|
531
|
-
`,variables:{...u,after:
|
|
545
|
+
`,variables:{...u,after:s}},r),p=[];return(((d=(c=l.body.data)==null?void 0:c.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(D=>{p.push(Te(D,R))})}),{pageInfo:(f=(b=(m=l.body)==null?void 0:m.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=ht(t),n=await U(this.config,{query:`
|
|
532
546
|
query GetSingleIssue($projectId: ID!, $issueId: String!) {
|
|
533
547
|
project(fullPath: $projectId) {
|
|
534
548
|
name
|
|
535
549
|
fullPath
|
|
536
550
|
issue(iid: $issueId) {
|
|
537
|
-
${
|
|
551
|
+
${fe}
|
|
538
552
|
}
|
|
539
553
|
}
|
|
540
554
|
}
|
|
541
|
-
`,variables:{issueId:t.id,projectId:
|
|
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=`
|
|
542
556
|
query GetIssuesFromProject(
|
|
543
557
|
$fullPath: ID!
|
|
544
558
|
$after: String
|
|
@@ -557,7 +571,7 @@ query GetSingleIssue($projectId: ID!, $issueId: String!) {
|
|
|
557
571
|
${u.length?u.join(" "):""}
|
|
558
572
|
) {
|
|
559
573
|
nodes {
|
|
560
|
-
${
|
|
574
|
+
${fe}
|
|
561
575
|
}
|
|
562
576
|
pageInfo {
|
|
563
577
|
endCursor
|
|
@@ -565,7 +579,7 @@ query GetSingleIssue($projectId: ID!, $issueId: String!) {
|
|
|
565
579
|
}
|
|
566
580
|
}
|
|
567
581
|
}
|
|
568
|
-
}`,g=await
|
|
582
|
+
}`,g=await U(this.config,{query:p,variables:{...l,after:s}},r),c=[],d=(f=g.body.data)==null?void 0:f.project,m={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=>{c.push(be(P,m))}),{pageInfo:(R=d==null?void 0:d.issues)==null?void 0:R.pageInfo,data:c.sort((P,E)=>(P.updatedDate||P.createdDate).getTime()-(E.updatedDate||E.createdDate).getTime())}}async getIssuesForRepos(t,r={}){var d,m,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=`
|
|
569
583
|
query GetIssuesFromProject(
|
|
570
584
|
$projectIds: [ID!]
|
|
571
585
|
$after: String
|
|
@@ -589,9 +603,9 @@ query GetSingleIssue($projectId: ID!, $issueId: String!) {
|
|
|
589
603
|
${i.length?i.join(" "):""}
|
|
590
604
|
) {
|
|
591
605
|
nodes {
|
|
592
|
-
${
|
|
606
|
+
${fe}
|
|
593
607
|
}
|
|
594
608
|
}
|
|
595
609
|
}
|
|
596
610
|
}
|
|
597
|
-
}`,p=await
|
|
611
|
+
}`,p=await U(this.config,{query:l,variables:{...u,after:s}},r),g=[];return(((m=(d=p.body.data)==null?void 0:d.projects)==null?void 0:m.nodes)||[]).forEach(R=>{var D;let P={name:R.name,owner:R.fullPath.split("/").slice(0,-1).join("/")};(((D=R.issues)==null?void 0:D.nodes)||[]).forEach(Oe=>g.push(be(Oe,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 qe="https://api.atlassian.com/ex/jira",_e=100,Rt=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 C{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||qe}/${t.resourceId}/rest/api/2/project/search`);s.searchParams.set("maxResults",_e.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||qe}/${t.resourceId}/rest/api/2/search?jql=${i.join(" AND ")}&startAt=0&maxResults=${_e}&fields=${["assignee","comment","summary","created","creator","updated","votes","issuetype"].join(",")}`,headers:y(r.token||this.config.token)})).body.issues.map(Rt)}}};var ke="https://api.trello.com",bt=1e3,yt=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 C{async getBoardsForCurrentUser(t,r={}){return{data:(await this.config.request({url:`${r.baseUrl||ke}/1/members/me/boards?fields=name&key=${t.appKey}&token=${r.token||this.config.token}`,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||ke}/1/search?key=${n}&query=${u}&cards_limit=${bt}&token=${r.token||this.config.token}`,headers:y(r.token||this.config.token)})).body.cards.map(yt)}}};var X={};L(X,{getIssueUniqueId:()=>It,getPullRequestUniqueId:()=>Pt});var It=async(e,t,r,s="")=>{let n=[];return n.push(s),n.push(e),n.push(t),n.push(r),JSON.stringify(n)},Pt=async(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:()=>vt,getPullRequestUniqueId:()=>Ut});var vt=async(e,t)=>JSON.stringify(["",e,t]),Ut=async(e,t)=>JSON.stringify(["",e,t]);var Z={};L(Z,{getIssueUniqueId:()=>wt,getPullRequestUniqueId:()=>Ct});var wt=async(e,t,r)=>JSON.stringify([r,e,t]),Ct=async(e,t,r)=>JSON.stringify([r,e,t]);var Y={};L(Y,{getIssueUniqueId:()=>St,getPullRequestRank:()=>Dt,getPullRequestUniqueId:()=>Et});var St=(e,t="")=>{let r=[];return r.push(t),r.push(e),JSON.stringify(r)},Et=(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:()=>$t,getPullRequestUniqueId:()=>Gt});var $t=async(e,t="")=>{let r=[];return r.push(t),r.push(e),JSON.stringify(r)},Gt=async(e,t="")=>{let r=[];return r.push(t),r.push(e),JSON.stringify(r)};var te={};L(te,{getIssueUniqueId:()=>Lt});var Lt=async(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:()=>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 xt=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})}},Tt=xt;var qt={azureDevOps:X,bitbucket:K,bitbucketServer:Z,github:Y,gitlab:ee,jira:te,trello:re};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
1
|
+
import { GitPullRequest } from '../index';
|
|
2
|
+
export declare const getIssueUniqueId: (issueGraphqlId: string, domain?: string) => string;
|
|
3
|
+
export declare const getPullRequestUniqueId: (pullRequestGraphqlId: string, domain?: string) => string;
|
|
4
|
+
export declare const getPullRequestRank: (pr: GitPullRequest, currentUsersGithubDatabaseId: string, isFromMentionedFilter: boolean) => number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PagedResult, Result } from '../../types';
|
|
1
2
|
import { CursorPageInput, EnterpriseOptions, GetRepoInput, GitProvider, GitPullRequest, GitRepository, NumberedPageInput, Options } from '../gitProvider';
|
|
2
3
|
import { Issue } from '../issueProvider';
|
|
3
4
|
import { Provider } from '../provider';
|
|
@@ -8,6 +9,15 @@ export interface AzureGetReposInput {
|
|
|
8
9
|
namespace: string;
|
|
9
10
|
project: string;
|
|
10
11
|
}
|
|
12
|
+
export interface AzureProject {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
namespace: string;
|
|
16
|
+
}
|
|
17
|
+
export interface AzureOrganization {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
}
|
|
11
21
|
export declare class AzureDevOps extends Provider implements GitProvider {
|
|
12
22
|
/** Note: PATs are not supported for this function, only OAuth tokens are. */
|
|
13
23
|
getCurrentUser(options?: EnterpriseOptions): Promise<{
|
|
@@ -40,6 +50,12 @@ export declare class AzureDevOps extends Provider implements GitProvider {
|
|
|
40
50
|
avatarUrl: string;
|
|
41
51
|
};
|
|
42
52
|
}>;
|
|
53
|
+
getOrgsForUser(input: {
|
|
54
|
+
userId: string;
|
|
55
|
+
}, options?: Options): Promise<Result<AzureOrganization[]>>;
|
|
56
|
+
getAzureProjects(input: {
|
|
57
|
+
namespace: string;
|
|
58
|
+
} & CursorPageInput, options?: Options): Promise<PagedResult<AzureProject>>;
|
|
43
59
|
getRepo(input: AzureGetRepoInput, options?: Options): Promise<{
|
|
44
60
|
data: GitRepository;
|
|
45
61
|
}>;
|
|
@@ -18,15 +18,7 @@ interface RepositoryBase {
|
|
|
18
18
|
url: string;
|
|
19
19
|
}
|
|
20
20
|
export interface Repository extends RepositoryBase {
|
|
21
|
-
project:
|
|
22
|
-
id: string;
|
|
23
|
-
name: string;
|
|
24
|
-
url: string;
|
|
25
|
-
state: string;
|
|
26
|
-
revision: number;
|
|
27
|
-
visibility: string;
|
|
28
|
-
lastUpdateTime: string;
|
|
29
|
-
};
|
|
21
|
+
project: Project;
|
|
30
22
|
defaultBranch?: string;
|
|
31
23
|
size: number;
|
|
32
24
|
remoteUrl: string;
|
|
@@ -53,6 +45,10 @@ interface ProjectBase {
|
|
|
53
45
|
visibility: string;
|
|
54
46
|
lastUpdateTime: string;
|
|
55
47
|
}
|
|
48
|
+
export interface Project extends ProjectBase {
|
|
49
|
+
url: string;
|
|
50
|
+
revision: number;
|
|
51
|
+
}
|
|
56
52
|
export interface AzureUser {
|
|
57
53
|
displayName: string;
|
|
58
54
|
url: string;
|
|
@@ -7,6 +7,7 @@ export declare const getGraphQLEndpoint: (config: ProviderConfig, options: Enter
|
|
|
7
7
|
export declare const makeGitHubGraphQLRequest: <T>(config: ProviderConfig, data: GraphQLBody, options: EnterpriseOptions) => Promise<import("../../types").Response<GraphQLResponse<T>>>;
|
|
8
8
|
export declare const hasEmailScope: (scopes: string[]) => boolean;
|
|
9
9
|
export declare const getAccountFields: (withAvatarSizeVar?: boolean, includeEmail?: boolean) => string;
|
|
10
|
+
export declare const getBotFields: (withAvatarSizeVar?: boolean) => string;
|
|
10
11
|
export declare const GithubSearchSyntaxQualifiers: Record<string, string>;
|
|
11
12
|
export declare const getProjectGithubSearchSyntax: (search: string) => string[];
|
|
12
13
|
export declare const fetchPullRequests: (config: ProviderConfig, input: FetchPullRequestsData & CursorPageInput, options: EnterpriseOptions, shouldFetchDraft?: boolean, includeEmail?: boolean) => Promise<import("../../types").Response<GraphQLResponse<{
|
|
@@ -32,6 +32,7 @@ export declare enum GitHubPullRequestMergeableState {
|
|
|
32
32
|
Unknown = "UNKNOWN"
|
|
33
33
|
}
|
|
34
34
|
export interface GraphQLUser {
|
|
35
|
+
__typename: 'User';
|
|
35
36
|
id: string;
|
|
36
37
|
databaseId: number;
|
|
37
38
|
name: string | null;
|
|
@@ -39,6 +40,13 @@ export interface GraphQLUser {
|
|
|
39
40
|
email?: string;
|
|
40
41
|
avatarUrl: string;
|
|
41
42
|
}
|
|
43
|
+
export interface GraphQLBot {
|
|
44
|
+
__typename: 'Bot';
|
|
45
|
+
id: string;
|
|
46
|
+
databaseId: number;
|
|
47
|
+
login: string;
|
|
48
|
+
avatarUrl: string;
|
|
49
|
+
}
|
|
42
50
|
export interface GraphQLOrganization {
|
|
43
51
|
id: string;
|
|
44
52
|
databaseId: number;
|
|
@@ -69,7 +77,7 @@ export interface GraphQLPullRequest {
|
|
|
69
77
|
assignees: {
|
|
70
78
|
nodes: GraphQLUser[] | null;
|
|
71
79
|
};
|
|
72
|
-
author: GraphQLUser | Record<string, never> | null;
|
|
80
|
+
author: GraphQLUser | GraphQLBot | Record<string, never> | null;
|
|
73
81
|
commits: {
|
|
74
82
|
nodes: {
|
|
75
83
|
commit: {
|
|
@@ -143,7 +151,7 @@ export interface GraphQLIssue {
|
|
|
143
151
|
assignees: {
|
|
144
152
|
nodes: GraphQLUser[] | null;
|
|
145
153
|
};
|
|
146
|
-
author: GraphQLUser | Record<string, never> | null;
|
|
154
|
+
author: GraphQLUser | GraphQLBot | Record<string, never> | null;
|
|
147
155
|
createdAt: string;
|
|
148
156
|
updatedAt: string;
|
|
149
157
|
comments: {
|
|
@@ -1,7 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Result } from '../../types';
|
|
2
|
+
import { CursorPageInput, EnterpriseOptions } from '../gitProvider';
|
|
2
3
|
import { Issue } from '../issueProvider';
|
|
3
4
|
import { Provider } from '../provider';
|
|
5
|
+
export interface JiraResource {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
avatarUrl: string;
|
|
9
|
+
}
|
|
10
|
+
export interface JiraProject {
|
|
11
|
+
name: string;
|
|
12
|
+
resourceId: string;
|
|
13
|
+
}
|
|
4
14
|
export declare class Jira extends Provider {
|
|
15
|
+
getJiraResourcesForCurrentUser(options?: EnterpriseOptions): Promise<Result<JiraResource[]>>;
|
|
16
|
+
getJiraProjectsForResource(input: {
|
|
17
|
+
resourceId: string;
|
|
18
|
+
} & CursorPageInput, options?: EnterpriseOptions): Promise<{
|
|
19
|
+
pageInfo: {
|
|
20
|
+
hasNextPage: boolean;
|
|
21
|
+
endCursor: string;
|
|
22
|
+
};
|
|
23
|
+
data: {
|
|
24
|
+
name: string;
|
|
25
|
+
resourceId: string;
|
|
26
|
+
}[];
|
|
27
|
+
}>;
|
|
28
|
+
getJiraProjectsForResources(input: {
|
|
29
|
+
resourceIds: string[];
|
|
30
|
+
}, options?: EnterpriseOptions): Promise<Result<JiraProject[]>>;
|
|
5
31
|
getIssuesForProject(input: {
|
|
6
32
|
project: string;
|
|
7
33
|
resourceId: string;
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
import { Result } from '../../types';
|
|
1
2
|
import { EnterpriseOptions } from '../gitProvider';
|
|
2
3
|
import { Issue } from '../issueProvider';
|
|
3
4
|
import { Provider } from '../provider';
|
|
5
|
+
export interface TrelloBoard {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
4
9
|
export declare class Trello extends Provider {
|
|
10
|
+
getBoardsForCurrentUser(input: {
|
|
11
|
+
appKey: string;
|
|
12
|
+
}, options?: EnterpriseOptions): Promise<Result<TrelloBoard[]>>;
|
|
5
13
|
getIssuesForBoard(input: {
|
|
6
14
|
appKey: string;
|
|
7
15
|
boardId: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitkraken/provider-apis",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
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",
|