@gitkraken/provider-apis 0.6.3 → 0.7.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.js +48 -48
- package/dist/providers/azureDevops/azureDevOps.d.ts +12 -12
- package/dist/providers/azureDevops/azureDevOpsHelpers.d.ts +2 -2
- package/dist/providers/bitbucket/bitbucket.d.ts +9 -9
- package/dist/providers/bitbucket/bitbucketHelpers.d.ts +2 -2
- package/dist/providers/gitProvider.d.ts +12 -12
- package/dist/providers/github/github.d.ts +12 -12
- package/dist/providers/github/githubHelpers.d.ts +4 -3
- package/dist/providers/gitlab/gitlab.d.ts +16 -17
- package/dist/providers/gitlab/gitlabHelpers.d.ts +5 -2
- package/dist/providers/issueProvider.d.ts +3 -3
- package/dist/providers/jira/jira.d.ts +2 -2
- package/dist/providers/trello/trello.d.ts +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.7.0-alpha.1
|
|
4
|
+
|
|
5
|
+
- enable the `baseUrl` option for GitLab
|
|
6
|
+
- prohibit using a GraphQL url as `baseUrl`
|
|
7
|
+
- fixed potential bug if `baseUrl` did not end with `/api/v*`
|
|
8
|
+
|
|
3
9
|
## 0.6.3
|
|
4
10
|
|
|
5
11
|
- fixed GitLab `GitRepository` objects having an empty `namespace` field
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";var Ce=Object.create;var Q=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var we=Object.getPrototypeOf,Ue=Object.prototype.hasOwnProperty;var De=(e,t)=>{for(var r in t)Q(e,r,{get:t[r],enumerable:!0})},oe=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ve(t))!Ue.call(e,s)&&s!==r&&Q(e,s,{get:()=>t[s],enumerable:!(n=Se(t,s))||n.enumerable});return e};var Ee=(e,t,r)=>(r=e!=null?Ce(we(e)):{},oe(t||!e||!e.__esModule?Q(r,"default",{value:e,enumerable:!0}):r,e)),$e=e=>oe(Q({},"__esModule",{value:!0}),e);var ut={};De(ut,{AzureDevOps:()=>k,Bitbucket:()=>O,GitHub:()=>j,GitLab:()=>F,default:()=>it});module.exports=$e(ut);var ae=Ee(require("node-fetch")),ie=globalThis.fetch||ae.default;var ue=e=>e.name==="fetch";var Ae=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},V=e=>ue(e)?async({url:t,...r})=>{let n=await e(t,r);return Ae(n)}:e;var S=class{constructor(t){this.config={...t,request:V((t==null?void 0:t.request)||ie)}}updateConfig(t){this.config={...this.config,...t,request:t.request?V(t.request):this.config.request}}};var G=class extends S{},z=class extends G{},E=100;var y=(e,t)=>{let r={};return e&&(r.Authorization=`${t?"Basic":"Bearer"} ${e}`),r};var v=(e,t={})=>y(t.token||e.token,t.isPAT||e.isPAT);var Le="https://app.vssps.visualstudio.com/_apis",A="https://dev.azure.com",Ge={active:"OPEN",completed:"MERGED",abandoned:"CLOSED"},Te={10:"APPROVED",5:"APPROVED",0:"REVIEW_REQUESTED",[-5]:"CHANGES_REQUESTED",[-10]:"CHANGES_REQUESTED"},X=e=>({id:e.id,name:e.displayName,username:e.uniqueName||e.displayName,email:null,avatarUrl:e.imageUrl}),M=e=>e.startsWith("refs/heads/")?e.replace("refs/heads/",""):e,le=e=>({id:e.pullRequestId.toString(),title:e.title,number:e.codeReviewId,state:Ge[e.status],isDraft:e.isDraft,commentCount:null,upvoteCount:null,author:X(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:M(e.targetRefName)},headRef:{name:M(e.sourceRefName)},url:null,assignees:e.reviewers.map(X),reviews:e.reviewers.filter(t=>t.vote!==0).map(t=>({reviewer:X(t),state:Te[t.vote]||"REVIEW_REQUESTED"})),additions:null,deletions:null,fileCount:null,commitCount:null,headRepository:null,mergeableState:"UNKNOWN"}),de=(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:M(t.defaultBranch)}:null,permission:null}),_e=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}},k=class extends G{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:`${Le}/profile/profiles/me`,headers:v(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:v(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:v(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:v(this.config,r)});return{data:de(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:v(this.config,r)})).body.value.map(s=>de(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",E.toString()),r.cursor&&s.searchParams.set("continuationToken",r.cursor);let a=await this.config.request({url:s.toString(),headers:v(this.config,n)}),o=a.headers["x-ms-continuationtoken"];return{pageInfo:{hasNextPage:!!o,endCursor:o||null},data:a.body.value.map(i=>({name:M(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:a,assigneeLogins:o,authorLogin:i}=t||{},u=s||1;if(!a.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let l="searchCriteria.status=1";return o&&o.length&&(l+=`&searchCriteria.reviewerId=${o[0]}`),i&&(l+=`&searchCriteria.creatorId=${i}`),await this.config.request({url:`${r.baseUrl||A}/${encodeURIComponent(a.namespace)}/${encodeURIComponent(a.project||"")}/_apis/git/repositories/${encodeURIComponent(a.name)}/pullRequests?${l}&%24top=${n}&%24skip=${(u-1)*n}`,headers:v(this.config,r)})}async getPullRequestsForRepo(t,r={}){let s=t.page||1,a=await this.getPullRequestsForRepoBase(t,r,100);return{pageInfo:{hasNextPage:a.body.value.length===100,nextPage:s+1},data:a.body.value.map(le)}}async getPullRequestsForRepos(t,r={}){if(!t.repos.every(a=>a.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 a=>{try{(await this.getPullRequestsForRepoBase({repo:a,...t},r)).body.value.forEach(i=>{s.push(le(i))})}catch(o){if(o.statusCode!==404&&o.statusCode!==401)throw o}})),{data:s}}async getIssuesForAzureProject(t,r={}){let{page:n,assigneeLogins:s,authorLogin:a,mentionLogin:o}=t||{},i=n||1,u=200,l=["[Microsoft.VSTS.Common.ClosedDate] = ''","[System.TeamProject] = @project","[Microsoft.VSTS.Common.ResolvedDate] = ''"];a&&l.push(`[System.CreatedBy] = '${a.replace("'","''")}'`),s&&s[0]&&l.push(`[System.AssignedTo] = '${s[0].replace("'","''")}'`),o&&l.push("[System.Id] IN (@recentMentions)");let d=`Select [Microsoft.VSTS.Common.ClosedDate], [Microsoft.VSTS.Common.ResolvedDate] From WorkItems Where ${l.join(" AND ")} order by [System.CreatedDate] desc`,m=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:d}),method:"POST",headers:{...v(this.config,r),"Content-Type":"application/json"}}),c=m.body.workItems.slice((i-1)*u,u*i).map(g=>g.id),p=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:c,$expand:"Links"}),method:"POST",headers:{...v(this.config,r),"Content-Type":"application/json"}});return{pageInfo:{hasNextPage:m.body.workItems.length>u*i,nextPage:i+1},data:p.body.value.map(_e)}}};var T=(e,t={})=>y(t.token||e.token,t.isPAT||e.isPAT);var x="https://api.bitbucket.org/2.0",xe={OPEN:"OPEN",MERGED:"MERGED",DECLINED:"CLOSED"},ce=e=>({id:e.uuid,name:e.display_name||e.nickname,username:e.nickname||e.display_name,email:null,avatarUrl:e.links.avatar.href}),me=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:ce(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"}},O=class extends G{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:`${x}/user`,headers:T(this.config,t)});return{data:ce(r.body)}}async getUserForCommit(t,r={}){var o;let s=(await this.config.request({url:`${x}/repositories/${t.repo.namespace}/${t.repo.name}/commit/${t.oid}`,headers:T(this.config,r)})).body.author,a=s.raw.match(/([^<]+)<(.+)>/);return{data:{name:a?a[1].trim():null,email:a?a[2]:null,avatarUrl:((o=s.user)==null?void 0:o.links.avatar.href)||null}}}async getRepo(t,r={}){var s,a;let n=await this.config.request({url:`${x}/repositories/${t.namespace}/${t.name}`,headers:T(this.config,r)});return{data:{id:n.body.uuid,namespace:n.body.workspace.slug,name:n.body.slug,webUrl:n.body.links.html.href,httpsUrl:((s=n.body.links.clone.find(o=>o.name==="https"))==null?void 0:s.href)??null,sshUrl:((a=n.body.links.clone.find(o=>o.name==="ssh"))==null?void 0:a.href)??null,defaultBranch:{name:n.body.mainbranch.name},permission:null}}}async getRepos(t,r={}){return{data:(await Promise.all(t.map(s=>this.getRepo(s,r)))).map(s=>s.data)}}async getBranches(t,r={}){var o;let n=new URL(`${x}/repositories/${t.repo.namespace}/${t.repo.name}/refs/branches`);n.searchParams.set("page",((o=t.page)==null?void 0:o.toString())||"1"),n.searchParams.set("pagelen",E.toString());let s=await this.config.request({url:n.toString(),headers:T(this.config,r)}),a=!!s.body.next;return{pageInfo:{hasNextPage:a,nextPage:a?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(`${x}/repositories/${t.repo.namespace}/${t.repo.name}/refs/tags`);n.searchParams.set("pagelen",E.toString()),t.cursor&&n.searchParams.set("page",t.cursor);let s=await this.config.request({url:n.toString(),headers:T(this.config,r)}),a=!!s.body.next,o=null;return s.body.next&&(o=new URL(s.body.next).searchParams.get("page")),{pageInfo:{hasNextPage:a,endCursor:o},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(`${r.baseUrl||x}/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(o=>{if(t.authorLogin&&o.author.uuid!==t.authorLogin)return null;n.push(me(o))});let a=!!s.body.next;return{pageInfo:{hasNextPage:a,nextPage:a?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(o=>{if(t.authorLogin&&o.author.uuid!==t.authorLogin)return null;n.push(me(o))})}catch(a){if(a.statusCode!==404&&a.statusCode!==401)throw a}})),{data:n}}};var Z="https://api.github.com",qe=`${Z}/graphql`,Be=/\/api\/v3\/?$/,ke=e=>e?e.replace(Be,"/api/graphql"):qe,P=(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:ke(r.baseUrl||e.baseUrl),method:"POST",headers:n,body:JSON.stringify(t)})},Oe={user:!0,"user:email":!0,"read:user":!0},q=e=>e.some(t=>Oe[t]),w=(e=!1,t=!1)=>`
|
|
1
|
+
"use strict";var Ee=Object.create;var z=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var Se=Object.getOwnPropertyNames;var De=Object.getPrototypeOf,$e=Object.prototype.hasOwnProperty;var Ae=(e,t)=>{for(var r in t)z(e,r,{get:t[r],enumerable:!0})},ae=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Se(t))!$e.call(e,s)&&s!==r&&z(e,s,{get:()=>t[s],enumerable:!(n=Ue(t,s))||n.enumerable});return e};var Ge=(e,t,r)=>(r=e!=null?Ee(De(e)):{},ae(t||!e||!e.__esModule?z(r,"default",{value:e,enumerable:!0}):r,e)),Le=e=>ae(z({},"__esModule",{value:!0}),e);var ct={};Ae(ct,{AzureDevOps:()=>B,Bitbucket:()=>j,GitHub:()=>N,GitLab:()=>Q,default:()=>mt});module.exports=Le(ct);var ie=Ge(require("node-fetch")),ue=globalThis.fetch||ie.default;var le=e=>e.name==="fetch";var Te=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},V=e=>le(e)?async({url:t,...r})=>{let n=await e(t,r);return Te(n)}:e;var $=class{constructor(t){this.config={...t,request:V((t==null?void 0:t.request)||ue)}}updateConfig(t){this.config={...this.config,...t,request:t.request?V(t.request):this.config.request}}};var L=class extends ${},x=class extends L{},S=100;var y=(e,t)=>{let r={};return e&&(r.Authorization=`${t?"Basic":"Bearer"} ${e}`),r};var v=(e,t={})=>y(t.token||e.token,t.isPAT||e.isPAT);var _e="https://app.vssps.visualstudio.com/_apis",A="https://dev.azure.com",xe={active:"OPEN",completed:"MERGED",abandoned:"CLOSED"},qe={10:"APPROVED",5:"APPROVED",0:"REVIEW_REQUESTED",[-5]:"CHANGES_REQUESTED",[-10]:"CHANGES_REQUESTED"},X=e=>({id:e.id,name:e.displayName,username:e.uniqueName||e.displayName,email:null,avatarUrl:e.imageUrl}),M=e=>e.startsWith("refs/heads/")?e.replace("refs/heads/",""):e,pe=e=>({id:e.pullRequestId.toString(),title:e.title,number:e.codeReviewId,state:xe[e.status],isDraft:e.isDraft,commentCount:null,upvoteCount:null,author:X(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:M(e.targetRefName)},headRef:{name:M(e.sourceRefName)},url:null,assignees:e.reviewers.map(X),reviews:e.reviewers.filter(t=>t.vote!==0).map(t=>({reviewer:X(t),state:qe[t.vote]||"REVIEW_REQUESTED"})),additions:null,deletions:null,fileCount:null,commitCount:null,headRepository:null,mergeableState:"UNKNOWN"}),de=(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:M(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,repository:null,upvoteCount:0}},B=class extends L{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:`${_e}/profile/profiles/me`,headers:v(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:v(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:v(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:v(this.config,r)});return{data:de(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:v(this.config,r)})).body.value.map(s=>de(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",S.toString()),r.cursor&&s.searchParams.set("continuationToken",r.cursor);let a=await this.config.request({url:s.toString(),headers:v(this.config,n)}),o=a.headers["x-ms-continuationtoken"];return{pageInfo:{hasNextPage:!!o,endCursor:o||null},data:a.body.value.map(i=>({name:M(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:a,assigneeLogins:o,authorLogin:i}=t||{},u=s||1;if(!a.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let l="searchCriteria.status=1";return o&&o.length&&(l+=`&searchCriteria.reviewerId=${o[0]}`),i&&(l+=`&searchCriteria.creatorId=${i}`),await this.config.request({url:`${r.baseUrl||A}/${encodeURIComponent(a.namespace)}/${encodeURIComponent(a.project||"")}/_apis/git/repositories/${encodeURIComponent(a.name)}/pullRequests?${l}&%24top=${n}&%24skip=${(u-1)*n}`,headers:v(this.config,r)})}async getPullRequestsForRepo(t,r={}){let s=t.page||1,a=await this.getPullRequestsForRepoBase(t,r,100);return{pageInfo:{hasNextPage:a.body.value.length===100,nextPage:s+1},data:a.body.value.map(pe)}}async getPullRequestsForRepos(t,r={}){if(!t.repos.every(a=>a.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 a=>{try{(await this.getPullRequestsForRepoBase({repo:a,...t},r)).body.value.forEach(i=>{s.push(pe(i))})}catch(o){if(o.statusCode!==404&&o.statusCode!==401)throw o}})),{data:s}}async getIssuesForAzureProject(t,r={}){let{page:n,assigneeLogins:s,authorLogin:a,mentionLogin:o}=t||{},i=n||1,u=200,l=["[Microsoft.VSTS.Common.ClosedDate] = ''","[System.TeamProject] = @project","[Microsoft.VSTS.Common.ResolvedDate] = ''"];a&&l.push(`[System.CreatedBy] = '${a.replace("'","''")}'`),s&&s[0]&&l.push(`[System.AssignedTo] = '${s[0].replace("'","''")}'`),o&&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`,m=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:{...v(this.config,r),"Content-Type":"application/json"}}),c=m.body.workItems.slice((i-1)*u,u*i).map(g=>g.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:c,$expand:"Links"}),method:"POST",headers:{...v(this.config,r),"Content-Type":"application/json"}});return{pageInfo:{hasNextPage:m.body.workItems.length>u*i,nextPage:i+1},data:d.body.value.map(ke)}}};var T=(e,t={})=>y(t.token||e.token,t.isPAT||e.isPAT);var q="https://api.bitbucket.org/2.0",Oe={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}),ce=e=>{let t=e.id;return{id:t.toString(),title:e.title,number:t,state:Oe[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 L{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:ge(r.body)}}async getUserForCommit(t,r={}){var o;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,a=s.raw.match(/([^<]+)<(.+)>/);return{data:{name:a?a[1].trim():null,email:a?a[2]:null,avatarUrl:((o=s.user)==null?void 0:o.links.avatar.href)||null}}}async getRepo(t,r={}){var s,a;let n=await this.config.request({url:`${q}/repositories/${t.namespace}/${t.name}`,headers:T(this.config,r)});return{data:{id:n.body.uuid,namespace:n.body.workspace.slug,name:n.body.slug,webUrl:n.body.links.html.href,httpsUrl:((s=n.body.links.clone.find(o=>o.name==="https"))==null?void 0:s.href)??null,sshUrl:((a=n.body.links.clone.find(o=>o.name==="ssh"))==null?void 0:a.href)??null,defaultBranch:{name:n.body.mainbranch.name},permission:null}}}async getRepos(t,r={}){return{data:(await Promise.all(t.map(s=>this.getRepo(s,r)))).map(s=>s.data)}}async getBranches(t,r={}){var o;let n=new URL(`${q}/repositories/${t.repo.namespace}/${t.repo.name}/refs/branches`);n.searchParams.set("page",((o=t.page)==null?void 0:o.toString())||"1"),n.searchParams.set("pagelen",S.toString());let s=await this.config.request({url:n.toString(),headers:T(this.config,r)}),a=!!s.body.next;return{pageInfo:{hasNextPage:a,nextPage:a?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",S.toString()),t.cursor&&n.searchParams.set("page",t.cursor);let s=await this.config.request({url:n.toString(),headers:T(this.config,r)}),a=!!s.body.next,o=null;return s.body.next&&(o=new URL(s.body.next).searchParams.get("page")),{pageInfo:{hasNextPage:a,endCursor:o},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(`${r.baseUrl||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(o=>{if(t.authorLogin&&o.author.uuid!==t.authorLogin)return null;n.push(ce(o))});let a=!!s.body.next;return{pageInfo:{hasNextPage:a,nextPage:a?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(o=>{if(t.authorLogin&&o.author.uuid!==t.authorLogin)return null;n.push(ce(o))})}catch(a){if(a.statusCode!==404&&a.statusCode!==401)throw a}})),{data:n}}};var Z="https://api.github.com",Be=`${Z}/graphql`,he=/\/api\/v\d+$/,je=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.")},Ne=(e,t)=>{let r=t.baseUrl||e.baseUrl;return r?(r=r.replace(/\/$/,""),je(r),he.test(r)&&(r=r.replace(he,"")),`${r}/api/graphql`):Be},P=(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:Ne(e,r),method:"POST",headers:n,body:JSON.stringify(t)})},Fe={user:!0,"user:email":!0,"read:user":!0},k=e=>e.some(t=>Fe[t]),w=(e=!1,t=!1)=>`
|
|
2
2
|
id
|
|
3
3
|
databaseId
|
|
4
4
|
name
|
|
5
5
|
login
|
|
6
6
|
${t?"email":""}
|
|
7
7
|
avatarUrl${e?"(size: $avatarSize)":""}
|
|
8
|
-
`,
|
|
8
|
+
`,Qe=(e,t=!1)=>`
|
|
9
9
|
id
|
|
10
10
|
databaseId
|
|
11
11
|
number
|
|
@@ -100,7 +100,7 @@ additions
|
|
|
100
100
|
deletions
|
|
101
101
|
changedFiles
|
|
102
102
|
mergeable
|
|
103
|
-
`,
|
|
103
|
+
`,ze={"-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"},Me=new RegExp('(([^\\s]+:)?\\"(?:[^\\"\\\\]|\\\\.)*\\"?)|([^\\"\\s]+)',"g"),Y=e=>{let t=[];return(e.match(Me)??[]).forEach(n=>{if(n.includes(":")&&n!="is:closed"){let s=n.split(":")[0];ze[s]&&t.push(n)}}),t},ee=async(e,t,r,n=!0,s=!1)=>{let{cursor:a,assigneeLogins:o,updatedBefore:i,isDraft:u,authorLogin:l,repos:p,reviewRequestedLogin:m,startQuery:c,mentionLogin:d}=t||{},g=Y(c||"");p.forEach(f=>{g.push(`repo:${f.namespace}/${f.name}`)}),o&&o.forEach(f=>{g.push(`assignee:${f}`)}),i&&g.push(`updated:<${i}`),n&&u!=null&&u!=null&&g.push(`draft:${String(u)}`),l&&g.push(`author:${l}`),m&&g.push(`review-requested:${m}`),d&&g.push(`mentions:${d}`);let b=`
|
|
104
104
|
query (
|
|
105
105
|
$after: String
|
|
106
106
|
$search: String!
|
|
@@ -113,7 +113,7 @@ query (
|
|
|
113
113
|
) {
|
|
114
114
|
nodes {
|
|
115
115
|
... on PullRequest {
|
|
116
|
-
${
|
|
116
|
+
${Qe(n,s)}
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
pageInfo {
|
|
@@ -123,7 +123,7 @@ query (
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
`;return P(e,{query:`${b}`,variables:{after:a??null,search:`sort:updated type:pr state:open ${g.join(" ")}`}},r)};var
|
|
126
|
+
`;return P(e,{query:`${b}`,variables:{after:a??null,search:`sort:updated type:pr state:open ${g.join(" ")}`}},r)};var fe=`
|
|
127
127
|
id
|
|
128
128
|
databaseId
|
|
129
129
|
owner {
|
|
@@ -136,13 +136,13 @@ defaultBranchRef {
|
|
|
136
136
|
name
|
|
137
137
|
}
|
|
138
138
|
viewerPermission
|
|
139
|
-
`,te={id:"U_kgDNJ5k",databaseId:10137,name:"Deleted user",login:"ghost",email:"",avatarUrl:"https://avatars.githubusercontent.com/u/10137?v=4"},
|
|
139
|
+
`,te={id:"U_kgDNJ5k",databaseId:10137,name:"Deleted user",login:"ghost",email:"",avatarUrl:"https://avatars.githubusercontent.com/u/10137?v=4"},He={APPROVED:"APPROVED",CHANGES_REQUESTED:"CHANGES_REQUESTED",COMMENTED:"COMMENTED",REVIEW_REQUESTED:"REVIEW_REQUESTED"},We={MERGEABLE:"MERGEABLE",CONFLICTING:"CONFLICTS",UNKNOWN:"UNKNOWN"},Re=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}),Ve={OPEN:"OPEN",CLOSED:"CLOSED",MERGED:"MERGED"},D=e=>({id:e.databaseId.toString(),graphQLId:e.id,name:e.name,username:e.login,email:e.email??null,avatarUrl:e.avatarUrl}),Xe=e=>{var l,p,m,c,d,g,b,f;let t=e.author?e.author.id?e.author:null:te,r=(p=(l=e.commits.nodes)==null?void 0:l[0])==null?void 0:p.commit,n=((m=e.headRef)==null?void 0:m.target)||r,s=n==null?void 0:n.oid,a=r==null?void 0:r.oid,o=s===a?(d=(c=r==null?void 0:r.status)==null?void 0:c.contexts)==null?void 0:d[0]:null,i=(((g=e.reviewRequests)==null?void 0:g.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:Ve[e.state],commentCount:e.comments.totalCount,upvoteCount:e.reactions.totalCount,author:t?D(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:o||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(D):null,reviews:i.map(h=>({reviewer:D(h.requestedReviewer),state:"REVIEW_REQUESTED"})).concat((((f=e.latestReviews)==null?void 0:f.nodes)||[]).map(h=>{let R=h.author||te;return{reviewer:D(R),state:He[h.state]}})),additions:e.additions,deletions:e.deletions,fileCount:e.changedFiles,commitCount:e.commits.totalCount,mergeableState:We[e.mergeable]}},Je=e=>{var r;let t=(r=e.author)!=null&&r.id?e.author:te;return{id:e.databaseId.toString(),graphQLId:e.id,number:e.number,title:e.title,author:D(t),commentCount:e.comments.totalCount,createdDate:new Date(e.createdAt),description:null,state: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(D):[],upvoteCount:e.reactions.totalCount}},N=class extends x{constructor(){super(...arguments);this._scopesCache={}}async getScopes(r){let n=r.token||this.config.token;if(!n)return[];let s=this._scopesCache[n];if(!s){let o=(await P(this.config,{query:"query { rateLimit(dryRun: true) { __typename } }"},r)).headers["x-oauth-scopes"];s=o?o.split(", "):[],this._scopesCache[n]=s}return s}getEnterpriseAvatarUrlIfNeeded(r,n,s){let a=s.baseUrl||this.config.baseUrl;return!a||a.startsWith(Z)?r:n?`https://avatars.githubusercontent.com/u/e?email=${encodeURIComponent(n)}`:""}async getCurrentUser(r={}){var o;let n=await this.getScopes(r),a=(o=(await P(this.config,{query:`
|
|
140
140
|
query getCurrentUser {
|
|
141
141
|
viewer {
|
|
142
|
-
${w(!1,
|
|
142
|
+
${w(!1,k(n))}
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
`},r)).body.data)==null?void 0:o.viewer;if(!a)throw new Error("Current user not found.");return{data
|
|
145
|
+
`},r)).body.data)==null?void 0:o.viewer;if(!a)throw new Error("Current user not found.");return{data:D(a)}}async getUserForCommit(r,n={}){var i,u;let a=(i=(await P(this.config,{query:`
|
|
146
146
|
query getUserForCommit(
|
|
147
147
|
$owner: String!
|
|
148
148
|
$name: String!
|
|
@@ -166,33 +166,33 @@ query getAccountForEmail($query: String! $avatarSize: Int) {
|
|
|
166
166
|
search(query: $query, type: USER, first: 1) {
|
|
167
167
|
nodes {
|
|
168
168
|
... on User {
|
|
169
|
-
${w(!0,
|
|
169
|
+
${w(!0,k(s))}
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
-
`,variables:{query:`in:email ${r.email}`,avatarSize:r.avatarSize}},n)).body.data)==null?void 0:i.search)==null?void 0:u.nodes)==null?void 0:l[0];if(!o)throw new Error("User not found.");return{data
|
|
174
|
+
`,variables:{query:`in:email ${r.email}`,avatarSize:r.avatarSize}},n)).body.data)==null?void 0:i.search)==null?void 0:u.nodes)==null?void 0:l[0];if(!o)throw new Error("User not found.");return{data:D({...o,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(o.avatarUrl,o.email,n)})}}async getAccountForUsername(r,n={}){var i;let s=await this.getScopes(n),o=(i=(await P(this.config,{query:`
|
|
175
175
|
query getUserForUsername($login: String! $avatarSize: Int) {
|
|
176
176
|
user(login: $login) {
|
|
177
|
-
${w(!0,
|
|
177
|
+
${w(!0,k(s))}
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
`,variables:{login:r.username,avatarSize:r.avatarSize}},n)).body.data)==null?void 0:i.user;if(!o)throw new Error("User not found.");return{data
|
|
180
|
+
`,variables:{login:r.username,avatarSize:r.avatarSize}},n)).body.data)==null?void 0:i.user;if(!o)throw new Error("User not found.");return{data:D({...o,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(o.avatarUrl,o.email,n)})}}async getRepo(r,n={}){var a;let s=await P(this.config,{query:`
|
|
181
181
|
query getRepo($owner: String!, $name: String!) {
|
|
182
182
|
repository(owner: $owner, name: $name) {
|
|
183
|
-
${
|
|
183
|
+
${fe}
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
|
-
`,variables:{owner:r.namespace,name:r.name}},n);if(!((a=s.body.data)!=null&&a.repository))throw new Error(`Repository ${r.namespace}/${r.name} not found`);return{data:
|
|
186
|
+
`,variables:{owner:r.namespace,name:r.name}},n);if(!((a=s.body.data)!=null&&a.repository))throw new Error(`Repository ${r.namespace}/${r.name} not found`);return{data:Re(s.body.data.repository)}}async getRepos(r,n={}){let s=r.map(({namespace:o,name:i},u)=>`
|
|
187
187
|
getRepo_${u}: repository(owner: "${o}", name: "${i}") {
|
|
188
|
-
${
|
|
188
|
+
${fe}
|
|
189
189
|
}
|
|
190
190
|
`).join(`
|
|
191
191
|
`),a=await P(this.config,{query:`
|
|
192
192
|
query batchGetRepos {
|
|
193
193
|
${s}
|
|
194
194
|
}
|
|
195
|
-
`},n);if(!a.body.data)throw new Error(a.statusText||"Unknown error");return{data:r.map(({namespace:o,name:i},u)=>{let l=a.body.data[`getRepo_${u}`];if(!l)throw new Error(`Repository ${o}/${i} not found`);return
|
|
195
|
+
`},n);if(!a.body.data)throw new Error(a.statusText||"Unknown error");return{data:r.map(({namespace:o,name:i},u)=>{let l=a.body.data[`getRepo_${u}`];if(!l)throw new Error(`Repository ${o}/${i} not found`);return Re(l)})}}async getRefs(r,n,s={}){var u;let o=(u=(await P(this.config,{query:`
|
|
196
196
|
query getRefs($owner: String!, $name: String!, $refPrefix: String!, $cursor: String, $first: Int!) {
|
|
197
197
|
repository(owner: $owner, name: $name) {
|
|
198
198
|
refs(refPrefix: $refPrefix first: $first after: $cursor) {
|
|
@@ -213,7 +213,7 @@ query getRefs($owner: String!, $name: String!, $refPrefix: String!, $cursor: Str
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
-
`,variables:{owner:n.repo.namespace,name:n.repo.name,refPrefix:r,cursor:n.cursor,first:
|
|
216
|
+
`,variables:{owner:n.repo.namespace,name:n.repo.name,refPrefix:r,cursor:n.cursor,first:S}},s)).body.data)==null?void 0:u.repository;if(!o)throw new Error("Repository not found.");let i=o.refs;return i?{pageInfo:i.pageInfo,data:(i.nodes||[]).map(l=>{var m;let p=(m=l.target)!=null&&m.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,n={}){return this.getRefs("refs/heads/",r,n)}async getTags(r,n={}){return this.getRefs("refs/tags/",r,n)}async getBlame(r,n={}){var i;let a=(i=(await P(this.config,{query:`
|
|
217
217
|
query getBlame($owner: String!, $name: String!, $ref: String!, $path: String!) {
|
|
218
218
|
repository(owner: $owner, name: $name) {
|
|
219
219
|
object(expression: $ref) {
|
|
@@ -252,7 +252,7 @@ query getBlame($owner: String!, $name: String!, $ref: String!, $path: String!) {
|
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
|
-
`,variables:{owner:r.repo.namespace,name:r.repo.name,ref:r.ref,path:r.path}},n)).body.data)==null?void 0:i.repository;if(!a)throw new Error("Repository not found.");let o=a.object;if(!o||!("blame"in o))throw new Error("Ref not found.");if(o.blame.ranges.length===0)throw new Error("File not found.");return{data:{ranges:o.blame.ranges.map(u=>{var l;return{startingLine:u.startingLine,endingLine:u.endingLine,commit:{oid:u.commit.oid,parentOids:((l=u.commit.parents.nodes)==null?void 0:l.map(
|
|
255
|
+
`,variables:{owner:r.repo.namespace,name:r.repo.name,ref:r.ref,path:r.path}},n)).body.data)==null?void 0:i.repository;if(!a)throw new Error("Repository not found.");let o=a.object;if(!o||!("blame"in o))throw new Error("Ref not found.");if(o.blame.ranges.length===0)throw new Error("File not found.");return{data:{ranges:o.blame.ranges.map(u=>{var l;return{startingLine:u.startingLine,endingLine:u.endingLine,commit:{oid:u.commit.oid,parentOids:((l=u.commit.parents.nodes)==null?void 0:l.map(p=>p.oid))||[],authoredDate:new Date(u.commit.authoredDate),author:u.commit.author?{name:u.commit.author.name,email:u.commit.author.email,avatarUrl:u.commit.author.avatarUrl}:null,committedDate:new Date(u.commit.committedDate),committer:u.commit.committer?{name:u.commit.committer.name,email:u.commit.committer.email,avatarUrl:u.commit.committer.avatarUrl}:null,message:u.commit.message,fileCount:u.commit.changedFilesIfAvailable,additions:u.commit.additions,deletions:u.commit.deletions}}})}}}async getPullRequestsForRepos(r,n={}){var l,p,m,c,d,g,b,f;let s=await this.getScopes(n),a=k(s),o="Field 'isDraft' doesn't exist on type 'PullRequest'",i=await ee(this.config,r,n,!0,a);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)===o;n.baseUrl&&R&&(i=await ee(this.config,r,n,!1,a))}let u=((d=(c=(m=i.body)==null?void 0:m.data)==null?void 0:c.search)==null?void 0:d.nodes)||[];return{pageInfo:(f=(b=(g=i.body)==null?void 0:g.data)==null?void 0:b.search)==null?void 0:f.pageInfo,data:u.map(Xe)}}async getIssuesForRepos(r,n={}){var b,f,h,R,I,E;let s=await this.getScopes(n),a=k(s),o=Y(r.startQuery||""),{cursor:i,assigneeLogins:u,updatedBefore:l,authorLogin:p,mentionLogin:m}=r||{};r.repos.forEach(U=>{o.push(`repo:${U.namespace}/${U.name}`)}),u&&u.forEach(U=>{o.push(`assignee:${U}`)}),l&&o.push(`updated:<${l}`),p&&o.push(`author:${p}`),m&&o.push(`mentions:${m}`);let c=`
|
|
256
256
|
query (
|
|
257
257
|
$after: String
|
|
258
258
|
$search: String!
|
|
@@ -303,7 +303,7 @@ query (
|
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
|
-
`,
|
|
306
|
+
`,d=await P(this.config,{query:`${c}`,variables:{after:i??null,search:`sort:updated type:issue state:open ${o.join(" ")}`}},n);if(!d.body.data)throw new Error(d.statusText||"Unknown error");let g=((h=(f=(b=d.body)==null?void 0:b.data)==null?void 0:f.search)==null?void 0:h.nodes)||[];return{pageInfo:(E=(I=(R=d.body)==null?void 0:R.data)==null?void 0:I.search)==null?void 0:E.pageInfo,data:g.map(Je)}}};var Ke="https://gitlab.com/api/v4",Ze="https://gitlab.com/api/graphql",be=/\/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.")},re=(e,t)=>{let r=t.baseUrl||e.baseUrl;return r?(r=r.replace(/\/$/,""),ye(r),r):Ke},Ye=(e,t)=>{let r=t.baseUrl||e.baseUrl;return r?(r=r.replace(/\/$/,""),ye(r),be.test(r)&&(r=r.replace(be,"")),`${r}/api/graphql`):Ze},C=(e,t,r)=>{let n=y(r.token||e.token);return e.request({url:Ye(e,r),method:"POST",headers:{...n,"Content-Type":"application/json"},body:JSON.stringify(t)})};var et={CAN_BE_MERGED:"MERGEABLE",CANNOT_BE_MERGED:"CONFLICTS",CANNOT_BE_MERGED_RECHECK:"UNKNOWN",UNCHECKED:"UNKNOWN",CHECKING:"UNKNOWN"},oe="gid://gitlab/User/",F="gid://gitlab/Project/",tt="gid://gitlab/MergeRequest/",rt="gid://gitlab/Issue/",Ie=`
|
|
307
307
|
id
|
|
308
308
|
path
|
|
309
309
|
fullPath
|
|
@@ -313,19 +313,19 @@ sshUrlToRepo
|
|
|
313
313
|
repository {
|
|
314
314
|
rootRef
|
|
315
315
|
}
|
|
316
|
-
`,
|
|
316
|
+
`,G=`
|
|
317
317
|
id
|
|
318
318
|
name
|
|
319
319
|
username
|
|
320
320
|
publicEmail
|
|
321
321
|
avatarUrl
|
|
322
|
-
`,
|
|
322
|
+
`,ne=`
|
|
323
323
|
author {
|
|
324
|
-
${
|
|
324
|
+
${G}
|
|
325
325
|
}
|
|
326
326
|
assignees {
|
|
327
327
|
nodes {
|
|
328
|
-
${
|
|
328
|
+
${G}
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
createdAt
|
|
@@ -339,11 +339,11 @@ updatedAt
|
|
|
339
339
|
upvotes
|
|
340
340
|
userNotesCount
|
|
341
341
|
webUrl
|
|
342
|
-
`,
|
|
342
|
+
`,Pe=`
|
|
343
343
|
id
|
|
344
344
|
state
|
|
345
345
|
author {
|
|
346
|
-
${
|
|
346
|
+
${G}
|
|
347
347
|
}
|
|
348
348
|
diffStatsSummary {
|
|
349
349
|
additions
|
|
@@ -364,25 +364,25 @@ targetBranch
|
|
|
364
364
|
sourceBranch
|
|
365
365
|
assignees {
|
|
366
366
|
nodes {
|
|
367
|
-
${
|
|
367
|
+
${G}
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
370
|
reviewers {
|
|
371
371
|
nodes {
|
|
372
|
-
${
|
|
372
|
+
${G}
|
|
373
373
|
mergeRequestInteraction {
|
|
374
374
|
approved
|
|
375
375
|
reviewState
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
378
|
}
|
|
379
|
-
mergeStatusEnum`,_=e=>`${e.namespace}/${e.name}`,
|
|
379
|
+
mergeStatusEnum`,_=e=>`${e.namespace}/${e.name}`,nt=e=>`${e.namespace}/${e.name}`,Ce=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}},st={opened:"OPEN",merged:"MERGED",closed:"CLOSED"},O=e=>({id:e.id.replace(oe,""),graphQLId:e.id,name:e.name,username:e.username,email:e.publicEmail,avatarUrl:e.avatarUrl}),ve=(e,t)=>{var r,n,s,a,o;return{id:e.id.replace(tt,""),graphQLId:e.id,title:e.title,number:parseInt(e.iid,10),state:st[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:(n=e.reviewers)!=null&&n.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:((s=e.diffStatsSummary)==null?void 0:s.additions)||0,deletions:((a=e.diffStatsSummary)==null?void 0:a.deletions)||0,fileCount:((o=e.diffStatsSummary)==null?void 0:o.fileCount)||0,commitCount:e.commitCount||0,mergeableState:et[e.mergeStatusEnum]}},se=(e,t)=>({author:{avatarUrl:e.author.avatarUrl,email:null,graphQLId:e.author.id,id:e.author.id.replace(oe,""),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(oe,""),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,title:e.title,url:e.webUrl}),Q=class extends x{async getCurrentUser(t={}){var s;let n=(s=(await C(this.config,{query:`
|
|
380
380
|
query getCurrentUser {
|
|
381
381
|
currentUser {
|
|
382
|
-
${
|
|
382
|
+
${G}
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
|
-
`},t)).body.data)==null?void 0:s.currentUser;if(!n)throw new Error("Current user not found.");return{data:
|
|
385
|
+
`},t)).body.data)==null?void 0:s.currentUser;if(!n)throw new Error("Current user not found.");return{data:O(n)}}async getUserForCommit(t,r={}){var o,i,u,l;let n=_(t.repo),a=(l=(u=(i=(o=(await C(this.config,{query:`
|
|
386
386
|
query getUserForCommit($fullPath: ID!, $oid: String!) {
|
|
387
387
|
project(fullPath: $fullPath) {
|
|
388
388
|
repository {
|
|
@@ -400,32 +400,32 @@ query getUserForCommit($fullPath: ID!, $oid: String!) {
|
|
|
400
400
|
query getAccountForEmail($email: String!) {
|
|
401
401
|
users(search: $email) {
|
|
402
402
|
nodes {
|
|
403
|
-
${
|
|
403
|
+
${G}
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
406
|
}
|
|
407
|
-
`,variables:{email:t.email}},r)).body.data)==null?void 0:a.users)==null?void 0:o.nodes)==null?void 0:i[0];if(!s)throw new Error("User not found.");return{data:
|
|
407
|
+
`,variables:{email:t.email}},r)).body.data)==null?void 0:a.users)==null?void 0:o.nodes)==null?void 0:i[0];if(!s)throw new Error("User not found.");return{data:O(s)}}async getAccountForUsername(t,r={}){var a;let s=(a=(await C(this.config,{query:`
|
|
408
408
|
query getAccountForUsername($username: String!) {
|
|
409
409
|
user(username: $username) {
|
|
410
|
-
${
|
|
410
|
+
${G}
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
|
-
`,variables:{username:t.username}},r)).body.data)==null?void 0:a.user;if(!s)throw new Error("User not found.");return{data:
|
|
413
|
+
`,variables:{username:t.username}},r)).body.data)==null?void 0:a.user;if(!s)throw new Error("User not found.");return{data:O(s)}}async getRepo(t,r={}){var a;let n=_(t),s=await C(this.config,{query:`
|
|
414
414
|
query getRepo($fullPath: ID!) {
|
|
415
415
|
project(fullPath: $fullPath) {
|
|
416
|
-
${
|
|
416
|
+
${Ie}
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
|
-
`,variables:{fullPath:n}},r);if(!((a=s.body.data)!=null&&a.project))throw new Error(`Repository ${n} not found`);return{data:
|
|
419
|
+
`,variables:{fullPath:n}},r);if(!((a=s.body.data)!=null&&a.project))throw new Error(`Repository ${n} not found`);return{data:Ce(s.body.data.project)}}async getRepos(t,r={}){let n=t.map(_),s=n.map((o,i)=>`
|
|
420
420
|
getRepo_${i}: project(fullPath: "${o}") {
|
|
421
|
-
${
|
|
421
|
+
${Ie}
|
|
422
422
|
}
|
|
423
423
|
`).join(`
|
|
424
424
|
`),a=await C(this.config,{query:`
|
|
425
425
|
query batchGetRepos {
|
|
426
426
|
${s}
|
|
427
427
|
}
|
|
428
|
-
`},r);if(!a.body.data)throw new Error(a.statusText||"Unknown error");return{data:n.map((o,i)=>{let u=a.body.data[`getRepo_${i}`];if(!u)throw new Error(`Repository ${o} not found`);return
|
|
428
|
+
`},r);if(!a.body.data)throw new Error(a.statusText||"Unknown error");return{data:n.map((o,i)=>{let u=a.body.data[`getRepo_${i}`];if(!u)throw new Error(`Repository ${o} not found`);return Ce(u)})}}async getRefs(t,r,n={}){var u;let s=_(r.repo),a=new URL(`${re(this.config,n)}/projects/${encodeURIComponent(s)}/repository/${t}`);a.searchParams.set("page",((u=r.page)==null?void 0:u.toString())||"1"),a.searchParams.set("per_page",S.toString());let o=await this.config.request({url:a.toString(),headers:y(n.token||this.config.token)}),i=o.headers["x-next-page"];return{pageInfo:{hasNextPage:!!i,nextPage:i?parseInt(i,10):null},data:o.body.map(l=>({name:l.name,commit:{oid:l.commit.id,authoredDate:new Date(l.commit.authored_date),committedDate:new Date(l.commit.committed_date)}}))}}async getBranches(t,r={}){return this.getRefs("branches",t,r)}async getTags(t,r={}){return this.getRefs("tags",t,r)}async getBlame(t,r={}){let n=_(t.repo),s=new URL(`${re(this.config,r)}/projects/${encodeURIComponent(n)}/repository/files/${encodeURIComponent(t.path)}/blame`);s.searchParams.set("ref",t.ref);let a=await this.config.request({url:s.toString(),headers:y(r.token||this.config.token)}),o=0;return{data:{ranges:a.body.map(i=>{let u=o+1;return o+=i.lines.length,{startingLine:u,endingLine:o,commit:{oid:i.commit.id,parentOids:i.commit.parent_ids,authoredDate:new Date(i.commit.authored_date),author:{name:i.commit.author_name,email:i.commit.author_email,avatarUrl:null},committedDate:new Date(i.commit.committed_date),committer:{name:i.commit.committer_name,email:i.commit.committer_email,avatarUrl:null},message:i.commit.message,fileCount:null,additions:null,deletions:null}}})}}}getVariablesForPullRequests(t){let{updatedBefore:r,isDraft:n,authorLogin:s,assigneeLogins:a,reviewRequestedLogin:o}=t||{},i={},u=[],l=[],p=(m,c,d)=>{u.push(`$${m}: ${d}`),l.push(`${m}: $${m}`),i[m]=c};return r&&p("updatedBefore",r,"Time"),s&&p("authorUsername",s,"String"),a&&p("assigneeUsername",a[0],"String"),n!=null&&p("draft",n,"Boolean"),o&&p("reviewerUsername",o,"String"),{variables:i,variableTypes:u,mergeRequestArguments:l}}async getPullRequestsForRepo(t,r={}){var b,f,h;let{cursor:n,repo:s}=t||{},a=_(s),{variables:o,variableTypes:i,mergeRequestArguments:u}=this.getVariablesForPullRequests(t),l={fullPath:a,...o},p=await C(this.config,{query:`
|
|
429
429
|
query getPullRequestsForRepo(
|
|
430
430
|
$fullPath: ID!
|
|
431
431
|
$after: String
|
|
@@ -448,12 +448,12 @@ query getPullRequestsForRepo(
|
|
|
448
448
|
hasNextPage
|
|
449
449
|
}
|
|
450
450
|
nodes {
|
|
451
|
-
${
|
|
451
|
+
${Pe}
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
454
|
}
|
|
455
455
|
}
|
|
456
|
-
`,variables:{...l,after:n}},r),m=[],c=(b=
|
|
456
|
+
`,variables:{...l,after:n}},r),m=[],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=>{m.push(ve(R,d))}),{pageInfo:(h=c==null?void 0:c.mergeRequests)==null?void 0:h.pageInfo,data:m}}async getPullRequestsForRepos(t,r={}){var c,d,g,b,f;let{cursor:n}=t||{},s=t.repoIds.map(h=>h.toString().startsWith(F)?h:`${F}${h}`),{variables:a,variableTypes:o,mergeRequestArguments:i}=this.getVariablesForPullRequests(t),u={projectIds:s,...a},l=await C(this.config,{query:`
|
|
457
457
|
query getPullRequests(
|
|
458
458
|
$projectIds: [ID!]
|
|
459
459
|
$after: String
|
|
@@ -477,23 +477,23 @@ query getPullRequests(
|
|
|
477
477
|
${i.length?i.join(" "):""}
|
|
478
478
|
) {
|
|
479
479
|
nodes {
|
|
480
|
-
${
|
|
480
|
+
${Pe}
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
483
|
}
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
|
-
`,variables:{...u,after:n}},r),
|
|
486
|
+
`,variables:{...u,after:n}},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(U=>{p.push(ve(U,R))})}),{pageInfo:(f=(b=(g=l.body)==null?void 0:g.data)==null?void 0:b.projects)==null?void 0:f.pageInfo,data:p}}async getIssue(t,r={}){var a,o,i,u,l,p,m;let n=nt(t),s=await C(this.config,{query:`
|
|
487
487
|
query GetSingleIssue($projectId: ID!, $issueId: String!) {
|
|
488
488
|
project(fullPath: $projectId) {
|
|
489
489
|
name
|
|
490
490
|
fullPath
|
|
491
491
|
issue(iid: $issueId) {
|
|
492
|
-
${
|
|
492
|
+
${ne}
|
|
493
493
|
}
|
|
494
494
|
}
|
|
495
495
|
}
|
|
496
|
-
`,variables:{issueId:t.id,projectId:n}},r);if(!((a=s.body.data)!=null&&a.project))throw new Error(`Repository ${n} not found`);if(!((i=(o=s.body.data)==null?void 0:o.project)!=null&&i.issue))throw new Error(`Issue ${t.id} not found`);return{data:
|
|
496
|
+
`,variables:{issueId:t.id,projectId:n}},r);if(!((a=s.body.data)!=null&&a.project))throw new Error(`Repository ${n} not found`);if(!((i=(o=s.body.data)==null?void 0:o.project)!=null&&i.issue))throw new Error(`Issue ${t.id} not found`);return{data:se((l=(u=s.body.data)==null?void 0:u.project)==null?void 0:l.issue,{name:(p=s.body.data)==null?void 0:p.project.name,owner:(m=s.body.data)==null?void 0:m.project.fullPath.split("/").slice(0,-1).join("/")})}}getVariablesForIssues(t){let{updatedBefore:r,authorLogin:n,assigneeLogins:s}=t||{},a={},o=[],i=[],u=(l,p,m)=>{o.push(`$${l}: ${m}`),i.push(`${l}: $${l}`),a[l]=p};return r&&u("updatedBefore",r,"Time"),n&&u("authorUsername",n,"String"),s&&u("assigneeUsername",s[0],"String"),{variables:a,variableTypes:o,issueArguments:i}}async getIssuesForRepo(t,r={}){var f,h,R;let{cursor:n,repo:s}=t||{},a=_(s),{variables:o,variableTypes:i,issueArguments:u}=this.getVariablesForIssues(t),l={fullPath:a,...o},p=`
|
|
497
497
|
query GetIssuesFromProject(
|
|
498
498
|
$fullPath: ID!
|
|
499
499
|
$after: String
|
|
@@ -512,7 +512,7 @@ query GetSingleIssue($projectId: ID!, $issueId: String!) {
|
|
|
512
512
|
${u.length?u.join(" "):""}
|
|
513
513
|
) {
|
|
514
514
|
nodes {
|
|
515
|
-
${
|
|
515
|
+
${ne}
|
|
516
516
|
}
|
|
517
517
|
pageInfo {
|
|
518
518
|
endCursor
|
|
@@ -520,7 +520,7 @@ query GetSingleIssue($projectId: ID!, $issueId: String!) {
|
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
|
-
}`,m=await C(this.config,{query:
|
|
523
|
+
}`,m=await C(this.config,{query:p,variables:{...l,after:n}},r),c=[],d=(f=m.body.data)==null?void 0:f.project,g={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(I=>{c.push(se(I,g))}),{pageInfo:(R=d==null?void 0:d.issues)==null?void 0:R.pageInfo,data:c.sort((I,E)=>(I.updatedDate||I.createdDate).getTime()-(E.updatedDate||E.createdDate).getTime())}}async getIssuesForRepos(t,r={}){var d,g,b,f,h;let{cursor:n}=t||{},s=t.repoIds.map(R=>R.toString().startsWith(F)?R:`${F}${R}`),{variables:a,variableTypes:o,mergeRequestArguments:i}=this.getVariablesForPullRequests(t),u={projectIds:s,...a},l=`
|
|
524
524
|
query GetIssuesFromProject(
|
|
525
525
|
$projectIds: [ID!]
|
|
526
526
|
$after: String
|
|
@@ -544,9 +544,9 @@ query GetSingleIssue($projectId: ID!, $issueId: String!) {
|
|
|
544
544
|
${i.length?i.join(" "):""}
|
|
545
545
|
) {
|
|
546
546
|
nodes {
|
|
547
|
-
${
|
|
547
|
+
${ne}
|
|
548
548
|
}
|
|
549
549
|
}
|
|
550
550
|
}
|
|
551
551
|
}
|
|
552
|
-
}`,
|
|
552
|
+
}`,p=await C(this.config,{query:l,variables:{...u,after:n}},r),m=[];return(((g=(d=p.body.data)==null?void 0:d.projects)==null?void 0:g.nodes)||[]).forEach(R=>{var U;let I={name:R.name,owner:R.fullPath.split("/").slice(0,-1).join("/")};(((U=R.issues)==null?void 0:U.nodes)||[]).forEach(we=>m.push(se(we,I)))}),{pageInfo:(h=(f=(b=p.body)==null?void 0:b.data)==null?void 0:f.projects)==null?void 0:h.pageInfo,data:m.sort((R,I)=>(R.updatedDate||R.createdDate).getTime()-(I.updatedDate||I.createdDate).getTime())}}};var ot="https://api.atlassian.com/ex/jira",at=100,it=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,upvoteCount:((r=e.fields.votes)==null?void 0:r.votes)||0}},H=class extends ${async getIssuesForProject(t,r={}){let{assigneeLogins:n,authorLogin:s,mentionLogin:a,project:o}=t||{},i=[`project = "${o}"`];return s&&i.push(`creator in (${s})`),n&&i.push(`assignee in (${n.join(", ")})`),a&&i.push(`comment ~ ${a}`),{data:(await this.config.request({url:`${r.baseUrl||ot}/${t.resourceId}/rest/api/2/search?jql=${i.join(" AND ")}&startAt=0&maxResults=${at}&fields=${["assignee","comment","summary","created","creator","updated","votes"].join(",")}`,headers:y(r.token||this.config.token)})).body.issues.map(it)}}};var ut="https://api.trello.com",lt=1e3,pt=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,repository:null,upvoteCount:e.badges.votes}},W=class extends ${async getIssuesForBoard(t,r={}){let n=["-is:archived","sort:edited"],{appKey:s,boardId:a,filterText:o,assigneeLogins:i}=t||{};i&&n.push("@me");let u=`${o?`${o}`:""}${n.join(" ")} board:${a}`;return{data:(await this.config.request({url:`${r.baseUrl||ut}/1/search?key=${s}&query=${u}&cards_limit=${lt}&token=${r.token||this.config.token}`,headers:y(r.token||this.config.token)})).body.cards.map(pt)}}};var dt=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}),github:new N({...t,...e==null?void 0:e.github}),gitlab:new Q({...t,...e==null?void 0:e.gitlab}),jira:new H({...t,...e==null?void 0:e.jira}),trello:new W({...t,...e==null?void 0:e.trello})}},mt=dt;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CursorPageInput, EnterpriseOptions, GetRepoInput, GitProvider, GitPullRequest, GitRepository, NumberedPageInput, Options } from '../gitProvider';
|
|
2
2
|
import { Issue } from '../issueProvider';
|
|
3
3
|
export interface AzureGetRepoInput extends GetRepoInput {
|
|
4
4
|
project: string;
|
|
@@ -9,7 +9,7 @@ export interface AzureGetReposInput {
|
|
|
9
9
|
}
|
|
10
10
|
export declare class AzureDevOps extends GitProvider {
|
|
11
11
|
/** Note: PATs are not supported for this function, only OAuth tokens are. */
|
|
12
|
-
getCurrentUser(options?:
|
|
12
|
+
getCurrentUser(options?: EnterpriseOptions): Promise<{
|
|
13
13
|
data: {
|
|
14
14
|
id: string;
|
|
15
15
|
name: string;
|
|
@@ -20,7 +20,7 @@ export declare class AzureDevOps extends GitProvider {
|
|
|
20
20
|
}>;
|
|
21
21
|
getCurrentUserForInstance(input: {
|
|
22
22
|
namespace: string;
|
|
23
|
-
}, options?:
|
|
23
|
+
}, options?: Options): Promise<{
|
|
24
24
|
data: {
|
|
25
25
|
id: string;
|
|
26
26
|
name: string;
|
|
@@ -32,26 +32,26 @@ export declare class AzureDevOps extends GitProvider {
|
|
|
32
32
|
getUserForCommit(input: {
|
|
33
33
|
repo: GetRepoInput;
|
|
34
34
|
oid: string;
|
|
35
|
-
}, options?:
|
|
35
|
+
}, options?: Options): Promise<{
|
|
36
36
|
data: {
|
|
37
37
|
name: string;
|
|
38
38
|
email: string | null;
|
|
39
39
|
avatarUrl: string;
|
|
40
40
|
};
|
|
41
41
|
}>;
|
|
42
|
-
getRepo(input: AzureGetRepoInput, options?:
|
|
42
|
+
getRepo(input: AzureGetRepoInput, options?: Options): Promise<{
|
|
43
43
|
data: GitRepository;
|
|
44
44
|
}>;
|
|
45
|
-
getRepos(inputs: AzureGetRepoInput[], options?:
|
|
45
|
+
getRepos(inputs: AzureGetRepoInput[], options?: Options): Promise<{
|
|
46
46
|
data: GitRepository[];
|
|
47
47
|
}>;
|
|
48
|
-
getReposForAzureProject(input: AzureGetReposInput, options?:
|
|
48
|
+
getReposForAzureProject(input: AzureGetReposInput, options?: Options): Promise<{
|
|
49
49
|
data: GitRepository[];
|
|
50
50
|
}>;
|
|
51
51
|
private getRefs;
|
|
52
52
|
getBranches(inputs: {
|
|
53
53
|
repo: GetRepoInput;
|
|
54
|
-
} & CursorPageInput, options?:
|
|
54
|
+
} & CursorPageInput, options?: Options): Promise<{
|
|
55
55
|
pageInfo: {
|
|
56
56
|
hasNextPage: boolean;
|
|
57
57
|
endCursor: string | null;
|
|
@@ -67,7 +67,7 @@ export declare class AzureDevOps extends GitProvider {
|
|
|
67
67
|
}>;
|
|
68
68
|
getTags(inputs: {
|
|
69
69
|
repo: GetRepoInput;
|
|
70
|
-
} & CursorPageInput, options?:
|
|
70
|
+
} & CursorPageInput, options?: Options): Promise<{
|
|
71
71
|
pageInfo: {
|
|
72
72
|
hasNextPage: boolean;
|
|
73
73
|
endCursor: string | null;
|
|
@@ -86,7 +86,7 @@ export declare class AzureDevOps extends GitProvider {
|
|
|
86
86
|
repo: GetRepoInput;
|
|
87
87
|
assigneeLogins?: string[];
|
|
88
88
|
authorLogin?: string;
|
|
89
|
-
} & NumberedPageInput, options?:
|
|
89
|
+
} & NumberedPageInput, options?: EnterpriseOptions): Promise<{
|
|
90
90
|
pageInfo: {
|
|
91
91
|
hasNextPage: boolean;
|
|
92
92
|
nextPage: number;
|
|
@@ -97,7 +97,7 @@ export declare class AzureDevOps extends GitProvider {
|
|
|
97
97
|
repos: GetRepoInput[];
|
|
98
98
|
assigneeLogins?: string[];
|
|
99
99
|
authorLogin?: string;
|
|
100
|
-
}, options?:
|
|
100
|
+
}, options?: EnterpriseOptions): Promise<{
|
|
101
101
|
data: GitPullRequest[];
|
|
102
102
|
}>;
|
|
103
103
|
getIssuesForAzureProject(input: {
|
|
@@ -106,7 +106,7 @@ export declare class AzureDevOps extends GitProvider {
|
|
|
106
106
|
assigneeLogins?: string[];
|
|
107
107
|
authorLogin?: string;
|
|
108
108
|
mentionLogin?: string;
|
|
109
|
-
} & NumberedPageInput, options?:
|
|
109
|
+
} & NumberedPageInput, options?: EnterpriseOptions): Promise<{
|
|
110
110
|
pageInfo: {
|
|
111
111
|
hasNextPage: boolean;
|
|
112
112
|
nextPage: number;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ProviderConfig } from '../../types';
|
|
2
|
-
import {
|
|
3
|
-
export declare const getAzureRequestHeaders: (config: ProviderConfig, options?:
|
|
2
|
+
import { Options } from '../gitProvider';
|
|
3
|
+
export declare const getAzureRequestHeaders: (config: ProviderConfig, options?: Options) => Record<string, string>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Account,
|
|
1
|
+
import { Account, CursorPageInput, EnterpriseOptions, GetRepoInput, GitProvider, GitPullRequest, NumberedPageInput, Options } from '../gitProvider';
|
|
2
2
|
export interface RefreshTokenResponse {
|
|
3
3
|
access_token: string;
|
|
4
4
|
scopes: string;
|
|
@@ -14,20 +14,20 @@ export declare class Bitbucket extends GitProvider {
|
|
|
14
14
|
}): Promise<{
|
|
15
15
|
data: RefreshTokenResponse;
|
|
16
16
|
}>;
|
|
17
|
-
getCurrentUser(options?:
|
|
17
|
+
getCurrentUser(options?: Options): Promise<{
|
|
18
18
|
data: Account;
|
|
19
19
|
}>;
|
|
20
20
|
getUserForCommit(input: {
|
|
21
21
|
repo: GetRepoInput;
|
|
22
22
|
oid: string;
|
|
23
|
-
}, options?:
|
|
23
|
+
}, options?: Options): Promise<{
|
|
24
24
|
data: {
|
|
25
25
|
name: string | null;
|
|
26
26
|
email: string | null;
|
|
27
27
|
avatarUrl: string | null;
|
|
28
28
|
};
|
|
29
29
|
}>;
|
|
30
|
-
getRepo(inputs: GetRepoInput, options?:
|
|
30
|
+
getRepo(inputs: GetRepoInput, options?: Options): Promise<{
|
|
31
31
|
data: {
|
|
32
32
|
id: string;
|
|
33
33
|
namespace: string;
|
|
@@ -41,7 +41,7 @@ export declare class Bitbucket extends GitProvider {
|
|
|
41
41
|
permission: null;
|
|
42
42
|
};
|
|
43
43
|
}>;
|
|
44
|
-
getRepos(inputs: GetRepoInput[], options?:
|
|
44
|
+
getRepos(inputs: GetRepoInput[], options?: Options): Promise<{
|
|
45
45
|
data: {
|
|
46
46
|
id: string;
|
|
47
47
|
namespace: string;
|
|
@@ -57,7 +57,7 @@ export declare class Bitbucket extends GitProvider {
|
|
|
57
57
|
}>;
|
|
58
58
|
getBranches(input: {
|
|
59
59
|
repo: GetRepoInput;
|
|
60
|
-
} & NumberedPageInput, options?:
|
|
60
|
+
} & NumberedPageInput, options?: Options): Promise<{
|
|
61
61
|
pageInfo: {
|
|
62
62
|
hasNextPage: boolean;
|
|
63
63
|
nextPage: number | null;
|
|
@@ -73,7 +73,7 @@ export declare class Bitbucket extends GitProvider {
|
|
|
73
73
|
}>;
|
|
74
74
|
getTags(input: {
|
|
75
75
|
repo: GetRepoInput;
|
|
76
|
-
} & CursorPageInput, options?:
|
|
76
|
+
} & CursorPageInput, options?: Options): Promise<{
|
|
77
77
|
pageInfo: {
|
|
78
78
|
hasNextPage: boolean;
|
|
79
79
|
endCursor: string | null;
|
|
@@ -91,7 +91,7 @@ export declare class Bitbucket extends GitProvider {
|
|
|
91
91
|
getPullRequestsForRepo(input: {
|
|
92
92
|
repo: GetRepoInput;
|
|
93
93
|
authorLogin?: string;
|
|
94
|
-
} & NumberedPageInput, options?:
|
|
94
|
+
} & NumberedPageInput, options?: EnterpriseOptions): Promise<{
|
|
95
95
|
pageInfo: {
|
|
96
96
|
hasNextPage: boolean;
|
|
97
97
|
nextPage: number | null;
|
|
@@ -101,7 +101,7 @@ export declare class Bitbucket extends GitProvider {
|
|
|
101
101
|
getPullRequestsForRepos(input: {
|
|
102
102
|
repos: GetRepoInput[];
|
|
103
103
|
authorLogin?: string;
|
|
104
|
-
}, options?:
|
|
104
|
+
}, options?: EnterpriseOptions): Promise<{
|
|
105
105
|
data: GitPullRequest[];
|
|
106
106
|
}>;
|
|
107
107
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ProviderConfig } from '../../types';
|
|
2
|
-
import {
|
|
3
|
-
export declare const getBitbucketRequestHeaders: (config: ProviderConfig, options?:
|
|
2
|
+
import { Options } from '../gitProvider';
|
|
3
|
+
export declare const getBitbucketRequestHeaders: (config: ProviderConfig, options?: Options) => Record<string, string>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { EnterpriseProviderConfigInit, PagedResult, ProviderConfigInit, Result } from '../types';
|
|
2
2
|
import { Provider } from './provider';
|
|
3
|
-
export interface
|
|
3
|
+
export interface Options {
|
|
4
4
|
token?: string;
|
|
5
5
|
isPAT?: boolean;
|
|
6
6
|
}
|
|
7
|
-
export interface
|
|
7
|
+
export interface EnterpriseOptions extends Options {
|
|
8
8
|
baseUrl?: string;
|
|
9
9
|
}
|
|
10
10
|
export interface User {
|
|
@@ -141,31 +141,31 @@ export interface NumberedPageInput {
|
|
|
141
141
|
}
|
|
142
142
|
export type PageInput = CursorPageInput | NumberedPageInput;
|
|
143
143
|
export declare abstract class GitProvider<Config extends ProviderConfigInit = ProviderConfigInit> extends Provider<Config> {
|
|
144
|
-
abstract getCurrentUser(options:
|
|
144
|
+
abstract getCurrentUser(options: Options): Promise<Result<Account>>;
|
|
145
145
|
abstract getUserForCommit(input: {
|
|
146
146
|
repo: GetRepoInput;
|
|
147
147
|
oid: string;
|
|
148
|
-
}, options:
|
|
148
|
+
}, options: Options): Promise<Result<User>>;
|
|
149
149
|
getAccountForEmail?(input: {
|
|
150
150
|
email: string;
|
|
151
|
-
}, options:
|
|
151
|
+
}, options: Options): Promise<Result<Account>>;
|
|
152
152
|
getAccountForUsername?(input: {
|
|
153
153
|
username: string;
|
|
154
|
-
}, options:
|
|
155
|
-
abstract getRepo(input: GetRepoInput, options:
|
|
156
|
-
abstract getRepos(inputs: GetRepoInput[], options:
|
|
154
|
+
}, options: Options): Promise<Result<Account>>;
|
|
155
|
+
abstract getRepo(input: GetRepoInput, options: Options): Promise<Result<GitRepository>>;
|
|
156
|
+
abstract getRepos(inputs: GetRepoInput[], options: Options): Promise<Result<GitRepository[]>>;
|
|
157
157
|
abstract getBranches(input: {
|
|
158
158
|
repo: GetRepoInput;
|
|
159
|
-
} & PageInput, options:
|
|
159
|
+
} & PageInput, options: Options): Promise<PagedResult<GitRefWithCommit>>;
|
|
160
160
|
abstract getTags(input: {
|
|
161
161
|
repo: GetRepoInput;
|
|
162
|
-
} & PageInput, options:
|
|
162
|
+
} & PageInput, options: Options): Promise<PagedResult<GitRefWithCommit>>;
|
|
163
163
|
getBlame?(input: {
|
|
164
164
|
repo: GetRepoInput;
|
|
165
165
|
ref: string;
|
|
166
166
|
path: string;
|
|
167
|
-
}, options:
|
|
168
|
-
abstract getPullRequestsForRepos(input: GetPRsForReposInput, options:
|
|
167
|
+
}, options: Options): Promise<Result<GitBlame>>;
|
|
168
|
+
abstract getPullRequestsForRepos(input: GetPRsForReposInput, options: Options): Promise<Result<GitPullRequest[]>>;
|
|
169
169
|
}
|
|
170
170
|
export declare abstract class EnterpriseGitProvider extends GitProvider<EnterpriseProviderConfigInit> {
|
|
171
171
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { Account,
|
|
1
|
+
import { Account, CursorPageInput, EnterpriseGitProvider, EnterpriseOptions, GetRepoInput, GitPullRequest, GitRepository } from '../gitProvider';
|
|
2
2
|
import { Issue } from '../issueProvider';
|
|
3
3
|
import { FetchIssuesData, FetchPullRequestsData } from './githubTypes';
|
|
4
4
|
export declare class GitHub extends EnterpriseGitProvider {
|
|
5
5
|
private _scopesCache;
|
|
6
6
|
private getScopes;
|
|
7
7
|
private getEnterpriseAvatarUrlIfNeeded;
|
|
8
|
-
getCurrentUser(options?:
|
|
8
|
+
getCurrentUser(options?: EnterpriseOptions): Promise<{
|
|
9
9
|
data: Account;
|
|
10
10
|
}>;
|
|
11
11
|
getUserForCommit(input: {
|
|
12
12
|
repo: GetRepoInput;
|
|
13
13
|
oid: string;
|
|
14
14
|
avatarSize?: number;
|
|
15
|
-
}, options?:
|
|
15
|
+
}, options?: EnterpriseOptions): Promise<{
|
|
16
16
|
data: {
|
|
17
17
|
name: string | null;
|
|
18
18
|
email: string | null;
|
|
@@ -25,25 +25,25 @@ export declare class GitHub extends EnterpriseGitProvider {
|
|
|
25
25
|
getAccountForEmail(input: {
|
|
26
26
|
email: string;
|
|
27
27
|
avatarSize?: number;
|
|
28
|
-
}, options?:
|
|
28
|
+
}, options?: EnterpriseOptions): Promise<{
|
|
29
29
|
data: Account;
|
|
30
30
|
}>;
|
|
31
31
|
getAccountForUsername(input: {
|
|
32
32
|
username: string;
|
|
33
33
|
avatarSize?: number;
|
|
34
|
-
}, options?:
|
|
34
|
+
}, options?: EnterpriseOptions): Promise<{
|
|
35
35
|
data: Account;
|
|
36
36
|
}>;
|
|
37
|
-
getRepo(input: GetRepoInput, options?:
|
|
37
|
+
getRepo(input: GetRepoInput, options?: EnterpriseOptions): Promise<{
|
|
38
38
|
data: GitRepository;
|
|
39
39
|
}>;
|
|
40
|
-
getRepos(inputs: GetRepoInput[], options?:
|
|
40
|
+
getRepos(inputs: GetRepoInput[], options?: EnterpriseOptions): Promise<{
|
|
41
41
|
data: GitRepository[];
|
|
42
42
|
}>;
|
|
43
43
|
private getRefs;
|
|
44
44
|
getBranches(input: {
|
|
45
45
|
repo: GetRepoInput;
|
|
46
|
-
} & CursorPageInput, options?:
|
|
46
|
+
} & CursorPageInput, options?: EnterpriseOptions): Promise<{
|
|
47
47
|
pageInfo: {
|
|
48
48
|
endCursor: string | null;
|
|
49
49
|
hasNextPage: boolean;
|
|
@@ -59,7 +59,7 @@ export declare class GitHub extends EnterpriseGitProvider {
|
|
|
59
59
|
}>;
|
|
60
60
|
getTags(input: {
|
|
61
61
|
repo: GetRepoInput;
|
|
62
|
-
} & CursorPageInput, options?:
|
|
62
|
+
} & CursorPageInput, options?: EnterpriseOptions): Promise<{
|
|
63
63
|
pageInfo: {
|
|
64
64
|
endCursor: string | null;
|
|
65
65
|
hasNextPage: boolean;
|
|
@@ -77,7 +77,7 @@ export declare class GitHub extends EnterpriseGitProvider {
|
|
|
77
77
|
repo: GetRepoInput;
|
|
78
78
|
ref: string;
|
|
79
79
|
path: string;
|
|
80
|
-
}, options?:
|
|
80
|
+
}, options?: EnterpriseOptions): Promise<{
|
|
81
81
|
data: {
|
|
82
82
|
ranges: {
|
|
83
83
|
startingLine: number;
|
|
@@ -105,14 +105,14 @@ export declare class GitHub extends EnterpriseGitProvider {
|
|
|
105
105
|
}[];
|
|
106
106
|
};
|
|
107
107
|
}>;
|
|
108
|
-
getPullRequestsForRepos(input: FetchPullRequestsData & CursorPageInput, options?:
|
|
108
|
+
getPullRequestsForRepos(input: FetchPullRequestsData & CursorPageInput, options?: EnterpriseOptions): Promise<{
|
|
109
109
|
pageInfo: {
|
|
110
110
|
endCursor: string | null;
|
|
111
111
|
hasNextPage: boolean;
|
|
112
112
|
} | undefined;
|
|
113
113
|
data: GitPullRequest[];
|
|
114
114
|
}>;
|
|
115
|
-
getIssuesForRepos(input: FetchIssuesData & CursorPageInput, options?:
|
|
115
|
+
getIssuesForRepos(input: FetchIssuesData & CursorPageInput, options?: EnterpriseOptions): Promise<{
|
|
116
116
|
pageInfo: {
|
|
117
117
|
endCursor: string | null;
|
|
118
118
|
hasNextPage: boolean;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { GraphQLBody, GraphQLResponse, ProviderConfig } from '../../types';
|
|
2
|
-
import {
|
|
2
|
+
import { CursorPageInput, EnterpriseOptions } from '../gitProvider';
|
|
3
3
|
import { FetchPullRequestsData, GraphQLPullRequest } from './githubTypes';
|
|
4
4
|
export declare const GITHUB_API_URL = "https://api.github.com";
|
|
5
5
|
export declare const GITHUB_GRAPHQL_API_URL: string;
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const getGraphQLEndpoint: (config: ProviderConfig, options: EnterpriseOptions) => string;
|
|
7
|
+
export declare const makeGitHubGraphQLRequest: <T>(config: ProviderConfig, data: GraphQLBody, options: EnterpriseOptions) => Promise<import("../../types").Response<GraphQLResponse<T>>>;
|
|
7
8
|
export declare const hasEmailScope: (scopes: string[]) => boolean;
|
|
8
9
|
export declare const getAccountFields: (withAvatarSizeVar?: boolean, includeEmail?: boolean) => string;
|
|
9
10
|
export declare const GithubSearchSyntaxQualifiers: Record<string, string>;
|
|
10
11
|
export declare const getProjectGithubSearchSyntax: (search: string) => string[];
|
|
11
|
-
export declare const fetchPullRequests: (config: ProviderConfig, input: FetchPullRequestsData & CursorPageInput, options:
|
|
12
|
+
export declare const fetchPullRequests: (config: ProviderConfig, input: FetchPullRequestsData & CursorPageInput, options: EnterpriseOptions, shouldFetchDraft?: boolean, includeEmail?: boolean) => Promise<import("../../types").Response<GraphQLResponse<{
|
|
12
13
|
[key: string]: {
|
|
13
14
|
pageInfo: {
|
|
14
15
|
endCursor: string | null;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { Account, CursorPageInput, GetRepoInput, GitProvider, GitPullRequest, GitRepository, NumberedPageInput
|
|
1
|
+
import { Account, CursorPageInput, EnterpriseGitProvider, EnterpriseOptions, GetRepoInput, GitProvider, GitPullRequest, GitRepository, NumberedPageInput } from '../gitProvider';
|
|
2
2
|
import { GetIssueInput, Issue, IssueProvider } from '../issueProvider';
|
|
3
|
-
import { Provider } from '../provider';
|
|
4
3
|
export type PullRequestState = 'opened' | 'merged' | 'closed';
|
|
5
|
-
export declare class GitLab extends
|
|
6
|
-
getCurrentUser(options?:
|
|
4
|
+
export declare class GitLab extends EnterpriseGitProvider implements GitProvider, IssueProvider {
|
|
5
|
+
getCurrentUser(options?: EnterpriseOptions): Promise<{
|
|
7
6
|
data: Account;
|
|
8
7
|
}>;
|
|
9
8
|
getUserForCommit(input: {
|
|
10
9
|
repo: GetRepoInput;
|
|
11
10
|
oid: string;
|
|
12
|
-
}, options?:
|
|
11
|
+
}, options?: EnterpriseOptions): Promise<{
|
|
13
12
|
data: {
|
|
14
13
|
name: string | null;
|
|
15
14
|
email: string | null;
|
|
@@ -18,24 +17,24 @@ export declare class GitLab extends Provider implements GitProvider, IssueProvid
|
|
|
18
17
|
}>;
|
|
19
18
|
getAccountForEmail(input: {
|
|
20
19
|
email: string;
|
|
21
|
-
}, options?:
|
|
20
|
+
}, options?: EnterpriseOptions): Promise<{
|
|
22
21
|
data: Account;
|
|
23
22
|
}>;
|
|
24
23
|
getAccountForUsername(input: {
|
|
25
24
|
username: string;
|
|
26
|
-
}, options?:
|
|
25
|
+
}, options?: EnterpriseOptions): Promise<{
|
|
27
26
|
data: Account;
|
|
28
27
|
}>;
|
|
29
|
-
getRepo(input: GetRepoInput, options?:
|
|
28
|
+
getRepo(input: GetRepoInput, options?: EnterpriseOptions): Promise<{
|
|
30
29
|
data: GitRepository;
|
|
31
30
|
}>;
|
|
32
|
-
getRepos(inputs: GetRepoInput[], options?:
|
|
31
|
+
getRepos(inputs: GetRepoInput[], options?: EnterpriseOptions): Promise<{
|
|
33
32
|
data: GitRepository[];
|
|
34
33
|
}>;
|
|
35
34
|
private getRefs;
|
|
36
35
|
getBranches(input: {
|
|
37
36
|
repo: GetRepoInput;
|
|
38
|
-
} & NumberedPageInput, options?:
|
|
37
|
+
} & NumberedPageInput, options?: EnterpriseOptions): Promise<{
|
|
39
38
|
pageInfo: {
|
|
40
39
|
hasNextPage: boolean;
|
|
41
40
|
nextPage: number | null;
|
|
@@ -51,7 +50,7 @@ export declare class GitLab extends Provider implements GitProvider, IssueProvid
|
|
|
51
50
|
}>;
|
|
52
51
|
getTags(input: {
|
|
53
52
|
repo: GetRepoInput;
|
|
54
|
-
} & NumberedPageInput, options?:
|
|
53
|
+
} & NumberedPageInput, options?: EnterpriseOptions): Promise<{
|
|
55
54
|
pageInfo: {
|
|
56
55
|
hasNextPage: boolean;
|
|
57
56
|
nextPage: number | null;
|
|
@@ -69,7 +68,7 @@ export declare class GitLab extends Provider implements GitProvider, IssueProvid
|
|
|
69
68
|
repo: GetRepoInput;
|
|
70
69
|
ref: string;
|
|
71
70
|
path: string;
|
|
72
|
-
}, options?:
|
|
71
|
+
}, options?: EnterpriseOptions): Promise<{
|
|
73
72
|
data: {
|
|
74
73
|
ranges: {
|
|
75
74
|
startingLine: number;
|
|
@@ -105,7 +104,7 @@ export declare class GitLab extends Provider implements GitProvider, IssueProvid
|
|
|
105
104
|
authorLogin?: string;
|
|
106
105
|
isDraft?: boolean;
|
|
107
106
|
reviewRequestedLogin?: string;
|
|
108
|
-
} & CursorPageInput, options?:
|
|
107
|
+
} & CursorPageInput, options?: EnterpriseOptions): Promise<{
|
|
109
108
|
pageInfo: {
|
|
110
109
|
endCursor: string | null;
|
|
111
110
|
hasNextPage: boolean;
|
|
@@ -119,14 +118,14 @@ export declare class GitLab extends Provider implements GitProvider, IssueProvid
|
|
|
119
118
|
authorLogin?: string;
|
|
120
119
|
isDraft?: boolean;
|
|
121
120
|
reviewRequestedLogin?: string;
|
|
122
|
-
} & CursorPageInput, options?:
|
|
121
|
+
} & CursorPageInput, options?: EnterpriseOptions): Promise<{
|
|
123
122
|
pageInfo: {
|
|
124
123
|
endCursor: string | null;
|
|
125
124
|
hasNextPage: boolean;
|
|
126
125
|
} | undefined;
|
|
127
126
|
data: GitPullRequest[];
|
|
128
127
|
}>;
|
|
129
|
-
getIssue(input: GetIssueInput, options?:
|
|
128
|
+
getIssue(input: GetIssueInput, options?: EnterpriseOptions): Promise<{
|
|
130
129
|
data: Issue;
|
|
131
130
|
}>;
|
|
132
131
|
private getVariablesForIssues;
|
|
@@ -135,7 +134,7 @@ export declare class GitLab extends Provider implements GitProvider, IssueProvid
|
|
|
135
134
|
assigneeLogins?: string[];
|
|
136
135
|
updatedBefore?: string;
|
|
137
136
|
authorLogin?: string;
|
|
138
|
-
} & CursorPageInput, options?:
|
|
137
|
+
} & CursorPageInput, options?: EnterpriseOptions): Promise<{
|
|
139
138
|
pageInfo: {
|
|
140
139
|
endCursor: string | null;
|
|
141
140
|
hasNextPage: boolean;
|
|
@@ -147,7 +146,7 @@ export declare class GitLab extends Provider implements GitProvider, IssueProvid
|
|
|
147
146
|
assigneeLogins?: string[];
|
|
148
147
|
updatedBefore?: string;
|
|
149
148
|
authorLogin?: string;
|
|
150
|
-
} & CursorPageInput, options?:
|
|
149
|
+
} & CursorPageInput, options?: EnterpriseOptions): Promise<{
|
|
151
150
|
pageInfo: {
|
|
152
151
|
endCursor: string | null;
|
|
153
152
|
hasNextPage: boolean;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { GraphQLBody, GraphQLResponse, ProviderConfig } from '../../types';
|
|
2
|
-
import {
|
|
2
|
+
import { EnterpriseOptions } from '../gitProvider';
|
|
3
|
+
export declare const GITLAB_API_URL = "https://gitlab.com/api/v4";
|
|
3
4
|
export declare const GITLAB_GRAPHQL_API_URL = "https://gitlab.com/api/graphql";
|
|
4
|
-
export declare const
|
|
5
|
+
export declare const getRESTBaseUrl: (config: ProviderConfig, options: EnterpriseOptions) => string;
|
|
6
|
+
export declare const getGraphQLEndpoint: (config: ProviderConfig, options: EnterpriseOptions) => string;
|
|
7
|
+
export declare const makeGitLabGraphQLRequest: <T>(config: ProviderConfig, data: GraphQLBody, options: EnterpriseOptions) => Promise<import("../../types").Response<GraphQLResponse<T>>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Result } from '../types';
|
|
2
|
-
import { Account, GetReposInput,
|
|
2
|
+
import { Account, GetReposInput, Options } from './gitProvider';
|
|
3
3
|
import { Provider } from './provider';
|
|
4
4
|
export interface GetIssueInput {
|
|
5
5
|
id: string;
|
|
@@ -32,6 +32,6 @@ export interface Issue {
|
|
|
32
32
|
url: string;
|
|
33
33
|
}
|
|
34
34
|
export declare abstract class IssueProvider extends Provider {
|
|
35
|
-
abstract getIssue(input: GetIssueInput, options:
|
|
36
|
-
abstract getIssuesForRepos(input: GetIssuesForReposInput, options:
|
|
35
|
+
abstract getIssue(input: GetIssueInput, options: Options): Promise<Result<Issue>>;
|
|
36
|
+
abstract getIssuesForRepos(input: GetIssuesForReposInput, options: Options): Promise<Result<Issue[]>>;
|
|
37
37
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EnterpriseOptions } from '../gitProvider';
|
|
2
2
|
import { Issue } from '../issueProvider';
|
|
3
3
|
import { Provider } from '../provider';
|
|
4
4
|
export declare class Jira extends Provider {
|
|
@@ -8,7 +8,7 @@ export declare class Jira extends Provider {
|
|
|
8
8
|
assigneeLogins?: string[];
|
|
9
9
|
authorLogin?: string;
|
|
10
10
|
mentionLogin?: string;
|
|
11
|
-
}, options?:
|
|
11
|
+
}, options?: EnterpriseOptions): Promise<{
|
|
12
12
|
data: Issue[];
|
|
13
13
|
}>;
|
|
14
14
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EnterpriseOptions } from '../gitProvider';
|
|
2
2
|
import { Issue } from '../issueProvider';
|
|
3
3
|
import { Provider } from '../provider';
|
|
4
4
|
export declare class Trello extends Provider {
|
|
@@ -7,7 +7,7 @@ export declare class Trello extends Provider {
|
|
|
7
7
|
boardId: string;
|
|
8
8
|
filterText?: string;
|
|
9
9
|
assigneeLogins?: string[];
|
|
10
|
-
}, options?:
|
|
10
|
+
}, options?: EnterpriseOptions): Promise<{
|
|
11
11
|
data: Issue[];
|
|
12
12
|
}>;
|
|
13
13
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitkraken/provider-apis",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-alpha.1",
|
|
4
4
|
"description": "An SDK around different third-party APIs that accepts and returns data in a common format.",
|
|
5
5
|
"author": "Axosoft, LLC dba GitKraken",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|