@gitkraken/provider-apis 0.8.4 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/index.js +17 -17
- package/dist/providerUtils/azureDevops.d.ts +2 -2
- package/dist/providerUtils/bitbucket.d.ts +2 -2
- package/dist/providerUtils/bitbucketServer.d.ts +2 -2
- package/dist/providerUtils/gitlab.d.ts +2 -2
- package/dist/providerUtils/jira.d.ts +1 -1
- package/dist/providers/azureDevops/azureDevOps.d.ts +6 -0
- package/dist/providers/azureDevops/azureDevOpsHelpers.d.ts +2 -0
- package/dist/providers/azureDevops/azureDevOpsTypes.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
- Azure DevOps `GitPullRequest` objects now include `url`
|
|
6
|
+
- fixed `getIssuesForAzureProject` throwing an error if the project has no issues
|
|
7
|
+
|
|
8
|
+
### ⚠️ Breaking Changes
|
|
9
|
+
|
|
10
|
+
- Trello `getBoardsForCurrentUser` now only returns open boards
|
|
11
|
+
- All "get unique id" functions now return `string` instead of `Promise<string`
|
|
12
|
+
|
|
3
13
|
## 0.8.4
|
|
4
14
|
|
|
5
15
|
- added `getOrgsForUser` (Azure DevOps)
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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)=>`
|
|
1
|
+
"use strict";var je=Object.create;var W=Object.defineProperty;var Ne=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var Qe=Object.getPrototypeOf,ze=Object.prototype.hasOwnProperty;var L=(e,t)=>{for(var r in t)W(e,r,{get:t[r],enumerable:!0})},Ie=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Fe(t))!ze.call(e,n)&&n!==r&&W(e,n,{get:()=>t[n],enumerable:!(s=Ne(t,n))||s.enumerable});return e};var Me=(e,t,r)=>(r=e!=null?je(Qe(e)):{},Ie(t||!e||!e.__esModule?W(r,"default",{value:e,enumerable:!0}):r,e)),He=e=>Ie(W({},"__esModule",{value:!0}),e);var kt={};L(kt,{AzureDevOps:()=>B,AzureDevopsUtils:()=>X,Bitbucket:()=>j,BitbucketServer:()=>N,BitbucketServerUtils:()=>Z,BitbucketUtils:()=>K,GitHub:()=>F,GitHubUtils:()=>Y,GitLab:()=>z,GitLabUtils:()=>ee,Jira:()=>M,JiraUtils:()=>te,Trello:()=>H,TrelloUtils:()=>re,Utils:()=>_t,default:()=>qt});module.exports=He(kt);var v=100;var Pe=Me(require("node-fetch")),ve=globalThis.fetch||Pe.default;var Ue=e=>e.name==="fetch";var We=async e=>{let t=e.headers.get("content-type")||"",r=null;if(t.startsWith("application/json"))r=await e.json();else if(t.startsWith("text/"))r=await e.text();else throw new Error(`Unsupported content-type: ${t}`);let s={body:r,headers:Object.fromEntries(e.headers.entries()),status:e.status,statusText:e.statusText};if(!e.ok){let n=new Error(e.statusText);throw Object.assign(n,{response:s}),n}return s},se=e=>Ue(e)?async({url:t,...r})=>{let s=await e(t,r);return We(s)}:e;var w=class{constructor(t){this.config={...t,request:se((t==null?void 0:t.request)||ve)}}updateConfig(t){this.config={...this.config,...t,request:t.request?se(t.request):this.config.request}}},A=class extends w{};var y=(e,t)=>{let r={};return e&&(r.Authorization=`${t?"Basic":"Bearer"} ${e}`),r};var C=(e,t={})=>y(t.token||e.token,t.isPAT||e.isPAT),Ce=e=>e.url.replace("/_apis/git/repositories/","/_git/").replace(`/${e.repository.project.id}/`,`/${encodeURIComponent(e.repository.project.name)}/`).replace(`/${e.repository.id}/`,`/${encodeURIComponent(e.repository.name)}/`).replace("/pullRequests/","/pullrequest/");var we="https://app.vssps.visualstudio.com/_apis",D="https://dev.azure.com",Je={active:"OPEN",completed:"MERGED",abandoned:"CLOSED"},Ve={10:"APPROVED",5:"APPROVED",0:"REVIEW_REQUESTED",[-5]:"CHANGES_REQUESTED",[-10]:"CHANGES_REQUESTED"},ne=e=>({id:e.id,name:e.displayName,username:e.uniqueName||e.displayName,email:null,avatarUrl:e.imageUrl}),J=e=>e.startsWith("refs/heads/")?e.replace("refs/heads/",""):e,Se=e=>({id:e.pullRequestId.toString(),title:e.title,number:e.codeReviewId,state:Je[e.status],isDraft:e.isDraft,commentCount:null,upvoteCount:null,author:ne(e.createdBy),createdDate:new Date(e.creationDate),updatedDate:new Date(e.closedDate||e.creationDate),closedDate:e.closedDate?new Date(e.closedDate):null,repository:{name:e.repository.name,owner:{login:void 0}},headCommit:{buildStatus:null},baseRef:{name:J(e.targetRefName)},headRef:{name:J(e.sourceRefName)},url:Ce(e),assignees:e.reviewers.map(ne),reviews:e.reviewers.filter(t=>t.vote!==0).map(t=>({reviewer:ne(t),state:Ve[t.vote]||"REVIEW_REQUESTED"})),additions:null,deletions:null,fileCount:null,commitCount:null,headRepository:null,mergeableState:"UNKNOWN"}),Ee=(e,t)=>({id:t.id,name:t.name,namespace:e,project:t.project.name,webUrl:t.webUrl,httpsUrl:t.remoteUrl,sshUrl:t.sshUrl,defaultBranch:t.defaultBranch?{name:J(t.defaultBranch)}:null,permission:null}),Xe=e=>{let t=e.fields,r=t["System.AssignedTo"];return{id:e.id.toString(),number:e.id.toString(),title:t["System.Title"],commentCount:t["System.CommentCount"],author:{avatarUrl:t["System.CreatedBy"]._links.avatar.href,email:null,id:t["System.CreatedBy"].id,name:t["System.CreatedBy"].uniqueName,username:t["System.CreatedBy"].displayName},createdDate:new Date(t["System.CreatedDate"]),updatedDate:new Date(t["System.ChangedDate"]),url:e._links.html.href,assignees:r?[{avatarUrl:r._links.avatar.href,email:null,id:r.id,name:r.uniqueName,username:r.displayName}]:[],description:null,state:null,type:t["System.WorkItemType"],repository:null,upvoteCount:0}},B=class extends w{async getCurrentUser(t={}){if(t.isPAT||this.config.isPAT)throw new Error("Azure DevOps does not support PATs for this function.");let r=await this.config.request({url:`${we}/profile/profiles/me`,headers:C(this.config,t)});return{data:{id:r.body.id,name:r.body.displayName,username:r.body.displayName,email:r.body.emailAddress,avatarUrl:null}}}async getCurrentUserForInstance(t,r={}){let n=(await this.config.request({url:`${D}/${encodeURIComponent(t.namespace)}/_apis/ConnectionData`,headers:C(this.config,r)})).body.authorizedUser;if(n.providerDisplayName==="Anonymous")throw new Error("Current user not found.");return{data:{id:n.id,name:n.providerDisplayName,username:n.providerDisplayName,email:n.properties.Account.$value,avatarUrl:null}}}async getUserForCommit(t,r={}){if(!t.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let n=(await this.config.request({url:`${D}/${encodeURIComponent(t.repo.namespace)}/${encodeURIComponent(t.repo.project)}/_apis/git/repositories/${encodeURIComponent(t.repo.name)}/commits/${t.oid}`,headers:C(this.config,r)})).body.author;return{data:{name:n.name,email:n.email,avatarUrl:n.imageUrl}}}async getOrgsForUser(t,r={}){return{data:(await this.config.request({url:`${we}/accounts?memberId=${t.userId}&api-version=6.0`,headers:C(this.config,r)})).body.value.map(n=>({id:n.accountId,name:n.accountName}))}}async getAzureProjects(t,r={}){let s=new URL(`${D}/${encodeURIComponent(t.namespace)}/_apis/projects`);s.searchParams.set("$top",v.toString()),t.cursor&&s.searchParams.set("$skip",t.cursor);let n=await this.config.request({url:s.toString(),headers:C(this.config,r)}),o=n.headers["x-ms-continuationtoken"];return{pageInfo:{hasNextPage:!!o,endCursor:o||null},data:n.body.value.map(a=>({id:a.id,name:a.name,namespace:t.namespace}))}}async getRepo(t,r={}){if(!t.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let s=await this.config.request({url:`${D}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/git/repositories/${encodeURIComponent(t.name)}`,headers:C(this.config,r)});return{data:Ee(t.namespace,s.body)}}async getRepos(t,r={}){return{data:(await Promise.all(t.map(n=>this.getRepo(n,r)))).map(n=>n.data)}}async getReposForAzureProject(t,r={}){if(!t.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');return{data:(await this.config.request({url:`${D}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/git/repositories`,headers:C(this.config,r)})).body.value.map(n=>Ee(t.namespace,n))}}async getRefs(t,r,s={}){if(!r.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let n=new URL(`${D}/${encodeURIComponent(r.repo.namespace)}/${encodeURIComponent(r.repo.project)}/_apis/git/repositories/${encodeURIComponent(r.repo.name)}/refs`);n.searchParams.set("filter",t),n.searchParams.set("$top",v.toString()),r.cursor&&n.searchParams.set("continuationToken",r.cursor);let o=await this.config.request({url:n.toString(),headers:C(this.config,s)}),a=o.headers["x-ms-continuationtoken"];return{pageInfo:{hasNextPage:!!a,endCursor:a||null},data:o.body.value.map(i=>({name:J(i.name),commit:{oid:i.objectId,authoredDate:null,committedDate:null}}))}}async getBranches(t,r={}){return this.getRefs("heads",t,r)}async getTags(t,r={}){return this.getRefs("tags",t,r)}async getPullRequestsForRepoBase(t,r={},s=100){let{page:n,repo:o,assigneeLogins:a,authorLogin:i}=t||{},u=n||1;if(!o.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let l="searchCriteria.status=1";return a&&a.length&&(l+=`&searchCriteria.reviewerId=${a[0]}`),i&&(l+=`&searchCriteria.creatorId=${i}`),await this.config.request({url:`${r.baseUrl||D}/${encodeURIComponent(o.namespace)}/${encodeURIComponent(o.project||"")}/_apis/git/repositories/${encodeURIComponent(o.name)}/pullRequests?${l}&%24top=${s}&%24skip=${(u-1)*s}`,headers:C(this.config,r)})}async getPullRequestsForRepo(t,r={}){let n=t.page||1,o=await this.getPullRequestsForRepoBase(t,r,100);return{pageInfo:{hasNextPage:o.body.value.length===100,nextPage:n+1},data:o.body.value.map(Se)}}async getPullRequestsForRepos(t,r={}){if(!t.repos.every(o=>o.project))throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{repos:s}=t||{},n=[];return await Promise.all(s.map(async o=>{try{(await this.getPullRequestsForRepoBase({repo:o,...t},r)).body.value.forEach(i=>{n.push(Se(i))})}catch(a){if(a.statusCode!==404&&a.statusCode!==401)throw a}})),{data:n}}async getIssuesForAzureProject(t,r={}){let{page:s,assigneeLogins:n,authorLogin:o,mentionLogin:a}=t||{},i=s||1,u=200,l=["[Microsoft.VSTS.Common.ClosedDate] = ''","[System.TeamProject] = @project","[Microsoft.VSTS.Common.ResolvedDate] = ''"];o&&l.push(`[System.CreatedBy] = '${o.replace("'","''")}'`),n&&n[0]&&l.push(`[System.AssignedTo] = '${n[0].replace("'","''")}'`),a&&l.push("[System.Id] IN (@recentMentions)");let p=`Select [Microsoft.VSTS.Common.ClosedDate], [Microsoft.VSTS.Common.ResolvedDate] From WorkItems Where ${l.join(" AND ")} order by [System.CreatedDate] desc`,g=await this.config.request({url:`${r.baseUrl||D}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/wit/wiql?api-version=6.0`,body:JSON.stringify({query:p}),method:"POST",headers:{...C(this.config,r),"Content-Type":"application/json"}}),m=g.body.workItems.slice((i-1)*u,u*i).map(c=>c.id);if(m.length==0)return{pageInfo:{hasNextPage:!1,nextPage:null},data:[]};let d=await this.config.request({url:`${r.baseUrl||D}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/wit/workitemsbatch?api-version=6.0`,body:JSON.stringify({ids:m,$expand:"Links"}),method:"POST",headers:{...C(this.config,r),"Content-Type":"application/json"}});return{pageInfo:{hasNextPage:g.body.workItems.length>u*i,nextPage:i+1},data:d.body.value.map(Xe)}}};var x=(e,t={})=>y(t.token||e.token,t.isPAT||e.isPAT);var q="https://api.bitbucket.org/2.0",Ke={OPEN:"OPEN",MERGED:"MERGED",DECLINED:"CLOSED"},Ge=e=>({id:e.uuid,name:e.display_name||e.nickname,username:e.nickname||e.display_name,email:null,avatarUrl:e.links.avatar.href}),$e=e=>{var t,r;return{id:e.uuid,namespace:e.workspace.slug,name:e.slug,webUrl:e.links.html.href,httpsUrl:((t=e.links.clone.find(s=>s.name==="https"))==null?void 0:t.href)??null,sshUrl:((r=e.links.clone.find(s=>s.name==="ssh"))==null?void 0:r.href)??null,defaultBranch:{name:e.mainbranch.name},permission:null}},De=e=>{let t=e.id;return{id:t.toString(),title:e.title,number:t,state:Ke[e.state],isDraft:!1,commentCount:e.comment_count,upvoteCount:null,author:Ge(e.author),createdDate:new Date(e.created_on),updatedDate:new Date(e.updated_on),closedDate:null,repository:{name:e.source.repository.name,owner:{login:void 0}},headCommit:{buildStatus:null},baseRef:{name:e.destination.branch.name},headRef:{name:e.source.branch.name},url:e.links.html.href,assignees:null,reviews:null,additions:null,deletions:null,fileCount:null,commitCount:null,headRepository:null,mergeableState:"UNKNOWN"}},j=class extends w{async refreshToken(t){return{data:(await this.config.request({url:"https://bitbucket.org/site/oauth2/access_token",method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:`Basic ${t.base64ClientIDColonClientSecret}`},body:`grant_type=refresh_token&refresh_token=${t.refreshToken}`})).body}}async getCurrentUser(t={}){let r=await this.config.request({url:`${q}/user`,headers:x(this.config,t)});return{data:Ge(r.body)}}async getUserForCommit(t,r={}){var a;let n=(await this.config.request({url:`${q}/repositories/${t.repo.namespace}/${t.repo.name}/commit/${t.oid}`,headers:x(this.config,r)})).body.author,o=n.raw.match(/([^<]+)<(.+)>/);return{data:{name:o?o[1].trim():null,email:o?o[2]:null,avatarUrl:((a=n.user)==null?void 0:a.links.avatar.href)||null}}}async getRepo(t,r={}){let s=await this.config.request({url:`${q}/repositories/${t.namespace}/${t.name}`,headers:x(this.config,r)});return{data:$e(s.body)}}async getRepos(t,r={}){return{data:(await Promise.all(t.map(n=>this.getRepo(n,r)))).map(n=>n.data)}}async getReposForCurrentUser(t={},r={}){let s=new URL(`${q}/repositories`);s.searchParams.set("role","member"),s.searchParams.set("pagelen",v.toString()),t.cursor&&s.searchParams.set("after",t.cursor);let n=await this.config.request({url:s.toString(),headers:x(this.config,r)}),o=!!n.body.next,a=null;return n.body.next&&(a=new URL(n.body.next).searchParams.get("after")),{pageInfo:{hasNextPage:o,endCursor:a},data:n.body.values.map($e)}}async getBranches(t,r={}){var a;let s=new URL(`${q}/repositories/${t.repo.namespace}/${t.repo.name}/refs/branches`);s.searchParams.set("page",((a=t.page)==null?void 0:a.toString())||"1"),s.searchParams.set("pagelen",v.toString());let n=await this.config.request({url:s.toString(),headers:x(this.config,r)}),o=!!n.body.next;return{pageInfo:{hasNextPage:o,nextPage:o?n.body.page+1:null},data:n.body.values.map(i=>{let u=new Date(i.target.date);return{name:i.name,commit:{oid:i.target.hash,authoredDate:u,committedDate:u}}})}}async getTags(t,r={}){let s=new URL(`${q}/repositories/${t.repo.namespace}/${t.repo.name}/refs/tags`);s.searchParams.set("pagelen",v.toString()),t.cursor&&s.searchParams.set("page",t.cursor);let n=await this.config.request({url:s.toString(),headers:x(this.config,r)}),o=!!n.body.next,a=null;return n.body.next&&(a=new URL(n.body.next).searchParams.get("page")),{pageInfo:{hasNextPage:o,endCursor:a},data:n.body.values.map(i=>{let u=new Date(i.target.date);return{name:i.name,commit:{oid:i.target.hash,authoredDate:u,committedDate:u}}})}}async getPullRequestsForRepoBase(t,r={}){var n;let s=new URL(`${q}/repositories/${encodeURI(t.repo.namespace)}/${encodeURI(t.repo.name)}/pullrequests?state=OPEN`);return s.searchParams.set("page",((n=t.page)==null?void 0:n.toString())||"1"),s.searchParams.set("pagelen","50"),await this.config.request({url:s.toString(),headers:x(this.config,r)})}async getPullRequestsForRepo(t,r={}){let s=[],n=await this.getPullRequestsForRepoBase(t,r);n.body.values.forEach(a=>{if(t.authorLogin&&a.author.uuid!==t.authorLogin)return null;s.push(De(a))});let o=!!n.body.next;return{pageInfo:{hasNextPage:o,nextPage:o?n.body.page+1:null},data:s}}async getPullRequestsForRepos(t,r={}){let s=[];return await Promise.all(t.repos.map(async n=>{try{(await this.getPullRequestsForRepoBase({repo:n,...t},r)).body.values.forEach(a=>{if(t.authorLogin&&a.author.uuid!==t.authorLogin)return null;s.push(De(a))})}catch(o){if(o.statusCode!==404&&o.statusCode!==401)throw o}})),{data:s}}};var N=class extends A{getBaseUrl(t){let r=t.baseUrl||this.config.baseUrl;if(!r)throw new Error('Bitbucket Server requires "baseUrl"');return r}getRequestHeaders(t){return y(t.token||this.config.token)}async getRepo(t,r={}){var n,o,a;let s=await this.config.request({url:`${this.getBaseUrl(r)}/projects/${t.namespace}/repos/${t.name}`,headers:this.getRequestHeaders(r)});return{data:{id:s.body.id.toString(),namespace:s.body.project.key,name:s.body.slug,webUrl:((n=s.body.links.self[0])==null?void 0:n.href)??null,httpsUrl:((o=s.body.links.clone.find(i=>i.name==="https"))==null?void 0:o.href)??null,sshUrl:((a=s.body.links.clone.find(i=>i.name==="ssh"))==null?void 0:a.href)??null,defaultBranch:null,permission:null}}}async getRepos(t,r={}){return{data:(await Promise.all(t.map(n=>this.getRepo(n,r)))).map(n=>n.data)}}};var ie="https://api.github.com",Ze=`${ie}/graphql`,Le=/\/api\/v\d+$/,Ye=e=>{if(e.endsWith("/api/graphql"))throw new Error("The graphql endpoint is being used as the baseUrl. This package uses both GraphQL and REST APIs, and the REST version cannot be assumed. Use the REST endpoint as the baseUrl instead.")},et=(e,t)=>{let r=t.baseUrl||e.baseUrl;return r?(r=r.replace(/\/$/,""),Ye(r),Le.test(r)&&(r=r.replace(Le,"")),`${r}/api/graphql`):Ze},I=(e,t,r)=>{let s=y(r.token||e.token);return s["X-Github-Next-Global-ID"]="1",s["Content-Type"]="application/json",e.request({url:et(e,r),method:"POST",headers:s,body:JSON.stringify(t)})},tt={user:!0,"user:email":!0,"read:user":!0},k=e=>e.some(t=>tt[t]),S=(e=!1,t=!1)=>`
|
|
2
2
|
__typename
|
|
3
3
|
id
|
|
4
4
|
databaseId
|
|
@@ -12,7 +12,7 @@ id
|
|
|
12
12
|
databaseId
|
|
13
13
|
login
|
|
14
14
|
avatarUrl${e?"(size: $avatarSize)":""}
|
|
15
|
-
`,
|
|
15
|
+
`,rt=(e,t=!1)=>`
|
|
16
16
|
id
|
|
17
17
|
databaseId
|
|
18
18
|
number
|
|
@@ -110,7 +110,7 @@ additions
|
|
|
110
110
|
deletions
|
|
111
111
|
changedFiles
|
|
112
112
|
mergeable
|
|
113
|
-
`,
|
|
113
|
+
`,st={"-linked":"-linked",archived:"archived",assignee:"assignee",author:"author",base:"base",closed:"closed",commenter:"commenter",comments:"comments",created:"created",draft:"draft",head:"head",label:"label",language:"language",linked:"linked",in:"in",interactions:"interactions",involves:"involves",is:"is",mentions:"mentions",merged:"merged",milestone:"milestone",no:"no",org:"org",project:"project",reactions:"reactions",repo:"repo",review:"review","reviewed-by":"reviewed-by","review-requested":"review-requested",state:"state",status:"status",team:"team","team-review-requested":"team-review-requested",type:"type",updated:"updated",user:"user","user-review-requested":"user-review-requested"},nt=new RegExp('(([^\\s]+:)?\\"(?:[^\\"\\\\]|\\\\.)*\\"?)|([^\\"\\s]+)',"g"),le=e=>{let t=[];return(e.match(nt)??[]).forEach(s=>{if(s.includes(":")&&s!="is:closed"){let n=s.split(":")[0];st[n]&&t.push(s)}}),t},pe=async(e,t,r,s=!0,n=!1)=>{let{cursor:o,assigneeLogins:a,updatedBefore:i,isDraft:u,authorLogin:l,repos:p,reviewRequestedLogin:g,startQuery:m,mentionLogin:d}=t||{},c=le(m||"");p.forEach(f=>{c.push(`repo:${f.namespace}/${f.name}`)}),a&&a.forEach(f=>{c.push(`assignee:${f}`)}),i&&c.push(`updated:<${i}`),s&&u!=null&&u!=null&&c.push(`draft:${String(u)}`),l&&c.push(`author:${l}`),g&&c.push(`review-requested:${g}`),d&&c.push(`mentions:${d}`);let b=`
|
|
114
114
|
query (
|
|
115
115
|
$after: String
|
|
116
116
|
$search: String!
|
|
@@ -123,7 +123,7 @@ query (
|
|
|
123
123
|
) {
|
|
124
124
|
nodes {
|
|
125
125
|
... on PullRequest {
|
|
126
|
-
${
|
|
126
|
+
${rt(s,n)}
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
pageInfo {
|
|
@@ -133,7 +133,7 @@ query (
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
-
`;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 ${c.join(" ")}`}},r)};var de=`
|
|
137
137
|
id
|
|
138
138
|
databaseId
|
|
139
139
|
owner {
|
|
@@ -146,7 +146,7 @@ defaultBranchRef {
|
|
|
146
146
|
name
|
|
147
147
|
}
|
|
148
148
|
viewerPermission
|
|
149
|
-
`,
|
|
149
|
+
`,me={__typename:"User",id:"U_kgDNJ5k",databaseId:10137,name:"Deleted user",login:"ghost",email:"",avatarUrl:"https://avatars.githubusercontent.com/u/10137?v=4"},ot={APPROVED:"APPROVED",CHANGES_REQUESTED:"CHANGES_REQUESTED",COMMENTED:"COMMENTED",REVIEW_REQUESTED:"REVIEW_REQUESTED"},at={MERGEABLE:"MERGEABLE",CONFLICTING:"CONFLICTS",UNKNOWN:"UNKNOWN"},ge=e=>({id:e.databaseId.toString(),graphQLId:e.id,namespace:e.owner.login,name:e.name,webUrl:e.url,httpsUrl:e.url.endsWith(".git")?e.url:`${e.url}.git`,sshUrl:e.sshUrl,defaultBranch:e.defaultBranchRef,permission:e.viewerPermission}),it={OPEN:"OPEN",CLOSED:"CLOSED",MERGED:"MERGED"},G=e=>({id:e.databaseId.toString(),graphQLId:e.id,name:e.name??e.login,username:e.login,email:e.email??null,avatarUrl:e.avatarUrl}),ut=e=>{var l,p,g,m,d,c,b,f;let t=null;e.author?t=(e.author.__typename==="Bot",e.author):t=me;let r=(p=(l=e.commits.nodes)==null?void 0:l[0])==null?void 0:p.commit,s=((g=e.headRef)==null?void 0:g.target)||r,n=s==null?void 0:s.oid,o=r==null?void 0:r.oid,a=n===o?(d=(m=r==null?void 0:r.status)==null?void 0:m.contexts)==null?void 0:d[0]:null,i=(((c=e.reviewRequests)==null?void 0:c.nodes)||[]).filter(h=>!h.asCodeOwner),u=(b=e.headRepository)==null?void 0:b.url;return u&&!u.endsWith(".git")&&(u=`${u}.git`),{id:e.databaseId.toString(),graphQLId:e.id,title:e.title,number:e.number,state:it[e.state],commentCount:e.comments.totalCount,upvoteCount:e.reactions.totalCount,author:t?G(t):null,createdDate:new Date(e.createdAt),isDraft:e.isDraft,repository:{name:e.repository.name,owner:{login:e.repository.owner.login}},headRepository:e.headRepository?{name:e.headRepository.name,owner:{login:e.headRepository.owner.login},remoteInfo:{cloneUrlHTTPS:u,cloneUrlSSH:e.headRepository.sshUrl}}:null,headCommit:{buildStatus:a||null},headRef:e.headRef?{name:e.headRef.name}:null,baseRef:e.baseRef?{name:e.baseRef.name}:null,url:e.url,updatedDate:new Date(e.updatedAt),closedDate:e.closedAt?new Date(e.closedAt):null,assignees:e.assignees.nodes?e.assignees.nodes.map(G):null,reviews:i.map(h=>({reviewer:G(h.requestedReviewer),state:"REVIEW_REQUESTED"})).concat((((f=e.latestReviews)==null?void 0:f.nodes)||[]).map(h=>{let R=h.author||me;return{reviewer:G(R),state:ot[h.state]}})),additions:e.additions,deletions:e.deletions,fileCount:e.changedFiles,commitCount:e.commits.totalCount,mergeableState:at[e.mergeable]}},lt=e=>{let t=null;return e.author?t=(e.author.__typename==="Bot",e.author):t=me,{id:e.databaseId.toString(),graphQLId:e.id,number:e.number,title:e.title,author:G(t),commentCount:e.comments.totalCount,createdDate:new Date(e.createdAt),description:null,state:null,type:null,repository:{name:e.repository.name,owner:{login:e.repository.owner.login}},url:e.url,updatedDate:new Date(e.updatedAt),assignees:e.assignees.nodes?e.assignees.nodes.map(G):[],upvoteCount:e.reactions.totalCount}},F=class extends A{constructor(){super(...arguments);this._scopesCache={}}async getScopes(r){let s=r.token||this.config.token;if(!s)return[];let n=this._scopesCache[s];if(!n){let a=(await I(this.config,{query:"query { rateLimit(dryRun: true) { __typename } }"},r)).headers["x-oauth-scopes"];n=a?a.split(", "):[],this._scopesCache[s]=n}return n}getEnterpriseAvatarUrlIfNeeded(r,s,n){let o=n.baseUrl||this.config.baseUrl;return!o||o.startsWith(ie)?r:s?`https://avatars.githubusercontent.com/u/e?email=${encodeURIComponent(s)}`:""}async getCurrentUser(r={}){var a;let s=await this.getScopes(r),o=(a=(await I(this.config,{query:`
|
|
150
150
|
query getCurrentUser {
|
|
151
151
|
viewer {
|
|
152
152
|
${S(!1,k(s))}
|
|
@@ -295,7 +295,7 @@ query getBlame($owner: String!, $name: String!, $ref: String!, $path: String!) {
|
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
}
|
|
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,
|
|
298
|
+
`,variables:{owner:r.repo.namespace,name:r.repo.name,ref:r.ref,path:r.path}},s)).body.data)==null?void 0:i.repository;if(!o)throw new Error("Repository not found.");let a=o.object;if(!a||!("blame"in a))throw new Error("Ref not found.");if(a.blame.ranges.length===0)throw new Error("File not found.");return{data:{ranges:a.blame.ranges.map(u=>{var l;return{startingLine:u.startingLine,endingLine:u.endingLine,commit:{oid:u.commit.oid,parentOids:((l=u.commit.parents.nodes)==null?void 0:l.map(p=>p.oid))||[],authoredDate:new Date(u.commit.authoredDate),author:u.commit.author?{name:u.commit.author.name,email:u.commit.author.email,avatarUrl:u.commit.author.avatarUrl}:null,committedDate:new Date(u.commit.committedDate),committer:u.commit.committer?{name:u.commit.committer.name,email:u.commit.committer.email,avatarUrl:u.commit.committer.avatarUrl}:null,message:u.commit.message,fileCount:u.commit.changedFilesIfAvailable,additions:u.commit.additions,deletions:u.commit.deletions}}})}}}async getPullRequestsForRepos(r,s={}){var l,p,g,m,d,c,b,f;let n=await this.getScopes(s),o=k(n),a="Field 'isDraft' doesn't exist on type 'PullRequest'",i=await pe(this.config,r,s,!0,o);if(i.body.errors){let R=((p=(l=i==null?void 0:i.body.errors)==null?void 0:l[0])==null?void 0:p.message)===a;s.baseUrl&&R&&(i=await pe(this.config,r,s,!1,o))}let u=((d=(m=(g=i.body)==null?void 0:g.data)==null?void 0:m.search)==null?void 0:d.nodes)||[];return{pageInfo:(f=(b=(c=i.body)==null?void 0:c.data)==null?void 0:b.search)==null?void 0:f.pageInfo,data:u.map(ut)}}async getIssuesForRepos(r,s={}){var b,f,h,R,P,E;let n=await this.getScopes(s),o=k(n),a=le(r.startQuery||""),{cursor:i,assigneeLogins:u,updatedBefore:l,authorLogin:p,mentionLogin:g}=r||{};r.repos.forEach($=>{a.push(`repo:${$.namespace}/${$.name}`)}),u&&u.forEach($=>{a.push(`assignee:${$}`)}),l&&a.push(`updated:<${l}`),p&&a.push(`author:${p}`),g&&a.push(`mentions:${g}`);let m=`
|
|
299
299
|
query (
|
|
300
300
|
$after: String
|
|
301
301
|
$search: String!
|
|
@@ -349,7 +349,7 @@ query (
|
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
|
-
`,d=await I(this.config,{query:`${
|
|
352
|
+
`,d=await I(this.config,{query:`${m}`,variables:{after:i??null,search:`sort:updated type:issue state:open ${a.join(" ")}`}},s);if(!d.body.data)throw new Error(d.statusText||"Unknown error");let c=((h=(f=(b=d.body)==null?void 0:b.data)==null?void 0:f.search)==null?void 0:h.nodes)||[];return{pageInfo:(E=(P=(R=d.body)==null?void 0:R.data)==null?void 0:P.search)==null?void 0:E.pageInfo,data:c.map(lt)}}};var pt="https://gitlab.com/api/v4",dt="https://gitlab.com/api/graphql",Ae=/\/api\/v\d+$/,xe=e=>{if(e.endsWith("/api/graphql"))throw new Error("The graphql endpoint is being used as the baseUrl. This package uses both GraphQL and REST APIs, and the REST version cannot be assumed. Use the REST endpoint as the baseUrl instead.")},ce=(e,t)=>{let r=t.baseUrl||e.baseUrl;return r?(r=r.replace(/\/$/,""),xe(r),r):pt},gt=(e,t)=>{let r=t.baseUrl||e.baseUrl;return r?(r=r.replace(/\/$/,""),xe(r),Ae.test(r)&&(r=r.replace(Ae,"")),`${r}/api/graphql`):dt},U=(e,t,r)=>{let s=y(r.token||e.token);return e.request({url:gt(e,r),method:"POST",headers:{...s,"Content-Type":"application/json"},body:JSON.stringify(t)})};var mt={CAN_BE_MERGED:"MERGEABLE",CANNOT_BE_MERGED:"CONFLICTS",CANNOT_BE_MERGED_RECHECK:"UNKNOWN",UNCHECKED:"UNKNOWN",CHECKING:"UNKNOWN"},ye="gid://gitlab/User/",Q="gid://gitlab/Project/",ct="gid://gitlab/MergeRequest/",ht="gid://gitlab/Issue/",he=`
|
|
353
353
|
id
|
|
354
354
|
path
|
|
355
355
|
fullPath
|
|
@@ -386,7 +386,7 @@ updatedAt
|
|
|
386
386
|
upvotes
|
|
387
387
|
userNotesCount
|
|
388
388
|
webUrl
|
|
389
|
-
`,
|
|
389
|
+
`,Te=`
|
|
390
390
|
id
|
|
391
391
|
state
|
|
392
392
|
author {
|
|
@@ -423,7 +423,7 @@ reviewers {
|
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
|
-
mergeStatusEnum`,_=e=>`${e.namespace}/${e.name}`,
|
|
426
|
+
mergeStatusEnum`,_=e=>`${e.namespace}/${e.name}`,ft=e=>`${e.namespace}/${e.name}`,Re=e=>{var t;return{id:e.id.replace(Q,""),graphQLId:e.id,namespace:e.fullPath.split("/").slice(0,-1).join("/"),name:e.path,webUrl:e.webUrl,httpsUrl:e.httpUrlToRepo,sshUrl:e.sshUrlToRepo,defaultBranch:(t=e.repository)!=null&&t.rootRef?{name:e.repository.rootRef}:null,permission:null}},Rt={opened:"OPEN",merged:"MERGED",closed:"CLOSED"},O=e=>({id:e.id.replace(ye,""),graphQLId:e.id,name:e.name,username:e.username,email:e.publicEmail,avatarUrl:e.avatarUrl}),qe=(e,t)=>{var r,s,n,o,a;return{id:e.id.replace(ct,""),graphQLId:e.id,title:e.title,number:parseInt(e.iid,10),state:Rt[e.state],commentCount:e.userNotesCount||0,upvoteCount:e.upvotes,author:e.author?O(e.author):null,createdDate:new Date(e.createdAt),isDraft:e.draft,repository:{name:t.name,owner:{login:t.owner}},headRepository:null,headCommit:{buildStatus:null},baseRef:{name:e.targetBranch},headRef:{name:e.sourceBranch},url:e.webUrl,updatedDate:new Date(e.updatedAt),closedDate:e.mergedAt?new Date(e.mergedAt):null,assignees:(r=e.assignees)!=null&&r.nodes?e.assignees.nodes.map(O):null,reviews:(s=e.reviewers)!=null&&s.nodes?e.reviewers.nodes.map(i=>{var u,l;return{reviewer:O(i),state:(u=i.mergeRequestInteraction)!=null&&u.approved?"APPROVED":((l=i.mergeRequestInteraction)==null?void 0:l.reviewState)==="REVIEWED"?"CHANGES_REQUESTED":"CHANGES_REQUESTED"}}):null,additions:((n=e.diffStatsSummary)==null?void 0:n.additions)||0,deletions:((o=e.diffStatsSummary)==null?void 0:o.deletions)||0,fileCount:((a=e.diffStatsSummary)==null?void 0:a.fileCount)||0,commitCount:e.commitCount||0,mergeableState:mt[e.mergeStatusEnum]}},be=(e,t)=>({author:{avatarUrl:e.author.avatarUrl,email:null,graphQLId:e.author.id,id:e.author.id.replace(ye,""),name:e.author.name,username:e.author.username},assignees:e.assignees.nodes.map(r=>({avatarUrl:r.avatarUrl,email:null,graphQLId:r.id,id:r.id.replace(ye,""),name:r.name,username:r.username})),commentCount:e.userNotesCount,createdDate:new Date(e.createdAt),description:e.description,graphQLId:e.id,id:e.id.replace(ht,""),number:e.iid,repository:{name:t.name,owner:{login:t.owner}},updatedDate:new Date(e.updatedAt),upvoteCount:e.upvotes,state:e.state,type:e.type,title:e.title,url:e.webUrl}),z=class extends A{async getCurrentUser(t={}){var n;let s=(n=(await U(this.config,{query:`
|
|
427
427
|
query getCurrentUser {
|
|
428
428
|
currentUser {
|
|
429
429
|
${T}
|
|
@@ -484,7 +484,7 @@ query getReposForCurrentUser($after: String) {
|
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
486
|
}
|
|
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(`${
|
|
487
|
+
`,variables:{after:t.cursor}},r);if(!((o=s.body.data)!=null&&o.projects))throw new Error(((a=s.body.errors)==null?void 0:a[0].message)||s.statusText||"Unknown error");let n=((u=(i=s.body.data)==null?void 0:i.projects)==null?void 0:u.nodes)||[];return{pageInfo:(p=(l=s.body.data)==null?void 0:l.projects)==null?void 0:p.pageInfo,data:n.map(Re)}}async getRefs(t,r,s={}){var u;let n=_(r.repo),o=new URL(`${ce(this.config,s)}/projects/${encodeURIComponent(n)}/repository/${t}`);o.searchParams.set("page",((u=r.page)==null?void 0:u.toString())||"1"),o.searchParams.set("per_page",v.toString());let a=await this.config.request({url:o.toString(),headers:y(s.token||this.config.token)}),i=a.headers["x-next-page"];return{pageInfo:{hasNextPage:!!i,nextPage:i?parseInt(i,10):null},data:a.body.map(l=>({name:l.name,commit:{oid:l.commit.id,authoredDate:new Date(l.commit.authored_date),committedDate:new Date(l.commit.committed_date)}}))}}async getBranches(t,r={}){return this.getRefs("branches",t,r)}async getTags(t,r={}){return this.getRefs("tags",t,r)}async getBlame(t,r={}){let s=_(t.repo),n=new URL(`${ce(this.config,r)}/projects/${encodeURIComponent(s)}/repository/files/${encodeURIComponent(t.path)}/blame`);n.searchParams.set("ref",t.ref);let o=await this.config.request({url:n.toString(),headers:y(r.token||this.config.token)}),a=0;return{data:{ranges:o.body.map(i=>{let u=a+1;return a+=i.lines.length,{startingLine:u,endingLine:a,commit:{oid:i.commit.id,parentOids:i.commit.parent_ids,authoredDate:new Date(i.commit.authored_date),author:{name:i.commit.author_name,email:i.commit.author_email,avatarUrl:null},committedDate:new Date(i.commit.committed_date),committer:{name:i.commit.committer_name,email:i.commit.committer_email,avatarUrl:null},message:i.commit.message,fileCount:null,additions:null,deletions:null}}})}}}getVariablesForPullRequests(t){let{updatedBefore:r,isDraft:s,authorLogin:n,assigneeLogins:o,reviewRequestedLogin:a}=t||{},i={},u=[],l=[],p=(g,m,d)=>{u.push(`$${g}: ${d}`),l.push(`${g}: $${g}`),i[g]=m};return r&&p("updatedBefore",r,"Time"),n&&p("authorUsername",n,"String"),o&&p("assigneeUsername",o[0],"String"),s!=null&&p("draft",s,"Boolean"),a&&p("reviewerUsername",a,"String"),{variables:i,variableTypes:u,mergeRequestArguments:l}}async getPullRequestsForRepo(t,r={}){var b,f,h;let{cursor:s,repo:n}=t||{},o=_(n),{variables:a,variableTypes:i,mergeRequestArguments:u}=this.getVariablesForPullRequests(t),l={fullPath:o,...a},p=await U(this.config,{query:`
|
|
488
488
|
query getPullRequestsForRepo(
|
|
489
489
|
$fullPath: ID!
|
|
490
490
|
$after: String
|
|
@@ -507,12 +507,12 @@ query getPullRequestsForRepo(
|
|
|
507
507
|
hasNextPage
|
|
508
508
|
}
|
|
509
509
|
nodes {
|
|
510
|
-
${
|
|
510
|
+
${Te}
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
513
|
}
|
|
514
514
|
}
|
|
515
|
-
`,variables:{...l,after:s}},r),g=[],
|
|
515
|
+
`,variables:{...l,after:s}},r),g=[],m=(b=p.body.data)==null?void 0:b.project,d={name:(m==null?void 0:m.name)||"",owner:((m==null?void 0:m.fullPath)||"").split("/").slice(0,-1).join("/")};return(((f=m==null?void 0:m.mergeRequests)==null?void 0:f.nodes)||[]).forEach(R=>{g.push(qe(R,d))}),{pageInfo:(h=m==null?void 0:m.mergeRequests)==null?void 0:h.pageInfo,data:g}}async getPullRequestsForRepos(t,r={}){var m,d,c,b,f;let{cursor:s}=t||{},n=t.repoIds.map(h=>h.toString().startsWith(Q)?h:`${Q}${h}`),{variables:o,variableTypes:a,mergeRequestArguments:i}=this.getVariablesForPullRequests(t),u={projectIds:n,...o},l=await U(this.config,{query:`
|
|
516
516
|
query getPullRequests(
|
|
517
517
|
$projectIds: [ID!]
|
|
518
518
|
$after: String
|
|
@@ -536,13 +536,13 @@ query getPullRequests(
|
|
|
536
536
|
${i.length?i.join(" "):""}
|
|
537
537
|
) {
|
|
538
538
|
nodes {
|
|
539
|
-
${
|
|
539
|
+
${Te}
|
|
540
540
|
}
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
544
|
}
|
|
545
|
-
`,variables:{...u,after:s}},r),p=[];return(((d=(
|
|
545
|
+
`,variables:{...u,after:s}},r),p=[];return(((d=(m=l.body.data)==null?void 0:m.projects)==null?void 0:d.nodes)||[]).forEach(h=>{var E;let R={name:h.name,owner:h.fullPath.split("/").slice(0,-1).join("/")};(((E=h.mergeRequests)==null?void 0:E.nodes)||[]).forEach($=>{p.push(qe($,R))})}),{pageInfo:(f=(b=(c=l.body)==null?void 0:c.data)==null?void 0:b.projects)==null?void 0:f.pageInfo,data:p}}async getIssue(t,r={}){var o,a,i,u,l,p,g;let s=ft(t),n=await U(this.config,{query:`
|
|
546
546
|
query GetSingleIssue($projectId: ID!, $issueId: String!) {
|
|
547
547
|
project(fullPath: $projectId) {
|
|
548
548
|
name
|
|
@@ -579,7 +579,7 @@ query GetSingleIssue($projectId: ID!, $issueId: String!) {
|
|
|
579
579
|
}
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
|
-
}`,g=await U(this.config,{query:p,variables:{...l,after:s}},r),
|
|
582
|
+
}`,g=await U(this.config,{query:p,variables:{...l,after:s}},r),m=[],d=(f=g.body.data)==null?void 0:f.project,c={name:(d==null?void 0:d.name)||"",owner:((d==null?void 0:d.fullPath)||"").split("/").slice(0,-1).join("/")};return(((h=d==null?void 0:d.issues)==null?void 0:h.nodes)||[]).forEach(P=>{m.push(be(P,c))}),{pageInfo:(R=d==null?void 0:d.issues)==null?void 0:R.pageInfo,data:m.sort((P,E)=>(P.updatedDate||P.createdDate).getTime()-(E.updatedDate||E.createdDate).getTime())}}async getIssuesForRepos(t,r={}){var d,c,b,f,h;let{cursor:s}=t||{},n=t.repoIds.map(R=>R.toString().startsWith(Q)?R:`${Q}${R}`),{variables:o,variableTypes:a,mergeRequestArguments:i}=this.getVariablesForPullRequests(t),u={projectIds:n,...o},l=`
|
|
583
583
|
query GetIssuesFromProject(
|
|
584
584
|
$projectIds: [ID!]
|
|
585
585
|
$after: String
|
|
@@ -608,4 +608,4 @@ query GetSingleIssue($projectId: ID!, $issueId: String!) {
|
|
|
608
608
|
}
|
|
609
609
|
}
|
|
610
610
|
}
|
|
611
|
-
}`,p=await U(this.config,{query:l,variables:{...u,after:s}},r),g=[];return(((
|
|
611
|
+
}`,p=await U(this.config,{query:l,variables:{...u,after:s}},r),g=[];return(((c=(d=p.body.data)==null?void 0:d.projects)==null?void 0:c.nodes)||[]).forEach(R=>{var $;let P={name:R.name,owner:R.fullPath.split("/").slice(0,-1).join("/")};((($=R.issues)==null?void 0:$.nodes)||[]).forEach(Be=>g.push(be(Be,P)))}),{pageInfo:(h=(f=(b=p.body)==null?void 0:b.data)==null?void 0:f.projects)==null?void 0:h.pageInfo,data:g.sort((R,P)=>(R.updatedDate||R.createdDate).getTime()-(P.updatedDate||P.createdDate).getTime())}}};var _e="https://api.atlassian.com/ex/jira",ke=100,bt=e=>{var r;let t=e.fields.assignee;return{id:e.id,commentCount:e.fields.comment.comments.length,number:e.key,title:e.fields.summary,url:e.self,createdDate:new Date(e.fields.created),author:{id:e.fields.creator.accountId,name:e.fields.creator.displayName,email:e.fields.creator.emailAddress,avatarUrl:e.fields.creator.avatarUrls["32x32"],username:e.fields.creator.displayName},updatedDate:new Date(e.fields.updated),assignees:t?[{id:t.accountId,name:t.displayName,email:t.emailAddress,avatarUrl:t.avatarUrls["32x32"],username:t.displayName}]:[],description:null,repository:null,state:null,type:e.fields.issuetype.name,upvoteCount:((r=e.fields.votes)==null?void 0:r.votes)||0}},M=class extends w{async getJiraResourcesForCurrentUser(t={}){return{data:(await this.config.request({url:`${t.baseUrl||"https://api.atlassian.com/"}/oauth/token/accessible-resources`,headers:y(t.token||this.config.token)})).body.map(s=>({avatarUrl:s.avatarUrl,id:s.id,name:s.name}))}}async getJiraProjectsForResource(t,r={}){let s=new URL(`${r.baseUrl||_e}/${t.resourceId}/rest/api/2/project/search`);s.searchParams.set("maxResults",ke.toString()),t.cursor&&s.searchParams.set("startAt",t.cursor);let n=await this.config.request({url:s.toString(),headers:y(r.token||this.config.token)});return{pageInfo:{hasNextPage:n.body.values.length!==0,endCursor:(n.body.startAt+n.body.values.length).toString()},data:n.body.values.map(o=>({name:o.name,resourceId:t.resourceId}))}}async getJiraProjectsForResources(t,r={}){let s=[];return await Promise.all(t.resourceIds.map(async n=>{let o=await this.getJiraProjectsForResource({resourceId:n},r);s.push(...o.data)})),{data:s}}async getIssuesForProject(t,r={}){let{assigneeLogins:s,authorLogin:n,mentionLogin:o,project:a}=t||{},i=[`project = "${a}"`];return n&&i.push(`creator in (${n})`),s&&i.push(`assignee in (${s.join(", ")})`),o&&i.push(`comment ~ ${o}`),{data:(await this.config.request({url:`${r.baseUrl||_e}/${t.resourceId}/rest/api/2/search?jql=${i.join(" AND ")}&startAt=0&maxResults=${ke}&fields=${["assignee","comment","summary","created","creator","updated","votes","issuetype"].join(",")}`,headers:y(r.token||this.config.token)})).body.issues.map(bt)}}};var Oe="https://api.trello.com",yt=1e3,It=e=>{let t=new Date(1e3*parseInt(e.id.substring(0,8),16));return{id:e.id,commentCount:e.badges.comments,number:e.idShort.toString(),title:e.name,url:e.url,createdDate:new Date(t.toISOString()),author:null,updatedDate:new Date(e.dateLastActivity),assignees:e.idMembers.map(r=>({id:r,username:null,name:null,email:null,avatarUrl:null})),description:null,state:null,type:null,repository:null,upvoteCount:e.badges.votes}},H=class extends w{async getBoardsForCurrentUser(t,r={}){return{data:(await this.config.request({url:`${r.baseUrl||Oe}/1/members/me/boards?fields=name&key=${t.appKey}&token=${r.token||this.config.token}&filter=open`,headers:y(r.token||this.config.token)})).body.map(n=>({id:n.id,name:n.name}))}}async getIssuesForBoard(t,r={}){let s=["-is:archived","sort:edited"],{appKey:n,boardId:o,filterText:a,assigneeLogins:i}=t||{};i&&s.push("@me");let u=`${a?`${a}`:""}${s.join(" ")} board:${o}`;return{data:(await this.config.request({url:`${r.baseUrl||Oe}/1/search?key=${n}&query=${u}&cards_limit=${yt}&token=${r.token||this.config.token}`,headers:y(r.token||this.config.token)})).body.cards.map(It)}}};var X={};L(X,{getIssueUniqueId:()=>Pt,getPullRequestUniqueId:()=>vt});var Pt=(e,t,r,s="")=>{let n=[];return n.push(s),n.push(e),n.push(t),n.push(r),JSON.stringify(n)},vt=(e,t,r,s,n="")=>{let o=[];return o.push(n),o.push(e),o.push(t),o.push(r),o.push(s),JSON.stringify(o)};var K={};L(K,{getIssueUniqueId:()=>Ut,getPullRequestUniqueId:()=>Ct});var Ut=(e,t)=>JSON.stringify(["",e,t]),Ct=(e,t)=>JSON.stringify(["",e,t]);var Z={};L(Z,{getIssueUniqueId:()=>wt,getPullRequestUniqueId:()=>St});var wt=(e,t,r)=>JSON.stringify([r,e,t]),St=(e,t,r)=>JSON.stringify([r,e,t]);var Y={};L(Y,{getIssueUniqueId:()=>Et,getPullRequestRank:()=>Dt,getPullRequestUniqueId:()=>$t});var Et=(e,t="")=>{let r=[];return r.push(t),r.push(e),JSON.stringify(r)},$t=(e,t="")=>{let r=[];return r.push(t),r.push(e),JSON.stringify(r)},Dt=(e,t,r)=>{var a,i,u;let s=0,n,o;return(a=e.reviews)==null||a.forEach(l=>{l.reviewer.id===t&&(n=l.state),l.state==="CHANGES_REQUESTED"?o="CHANGES_REQUESTED":l.state==="APPROVED"&&o!=="CHANGES_REQUESTED"&&(o="APPROVED")}),o||(o="REVIEW_REQUESTED"),((i=e.author)==null?void 0:i.id)===t?s+=1e3:(u=e.assignees)!=null&&u.find(l=>l.id===t)?s+=900:n==="REVIEW_REQUESTED"?s+=800:r&&(s+=700),o==="APPROVED"?e.mergeableState==="MERGEABLE"?s+=100:e.mergeableState==="CONFLICTS"?s+=90:s+=80:o=="CHANGES_REQUESTED"&&(s+=70),s};var ee={};L(ee,{getIssueUniqueId:()=>Gt,getPullRequestUniqueId:()=>Lt});var Gt=(e,t="")=>{let r=[];return r.push(t),r.push(e),JSON.stringify(r)},Lt=(e,t="")=>{let r=[];return r.push(t),r.push(e),JSON.stringify(r)};var te={};L(te,{getIssueUniqueId:()=>At});var At=(e,t,r,s="")=>{let n=[];return n.push(s),n.push(e),n.push(t),n.push(r),JSON.stringify(n)};var re={};L(re,{getIssueUniqueId:()=>xt});var xt=(e,t,r,s="")=>{let n=[];return n.push(s),n.push(e),n.push(t),n.push(r),JSON.stringify(n)};var Tt=e=>{let t={request:e==null?void 0:e.request};return{azureDevOps:new B({...t,...e==null?void 0:e.azureDevOps}),bitbucket:new j({...t,...e==null?void 0:e.bitbucket}),bitbucketServer:new N({...t,...e==null?void 0:e.bitbucketServer}),github:new F({...t,...e==null?void 0:e.github}),gitlab:new z({...t,...e==null?void 0:e.gitlab}),jira:new M({...t,...e==null?void 0:e.jira}),trello:new H({...t,...e==null?void 0:e.trello})}},qt=Tt;var _t={azureDevOps:X,bitbucket:K,bitbucketServer:Z,github:Y,gitlab:ee,jira:te,trello:re};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const getIssueUniqueId: (organizationName: string, projectId: string, issueId: string, domain?: string) =>
|
|
2
|
-
export declare const getPullRequestUniqueId: (organizationName: string, projectId: string, repoId: string, pullRequestId: string, domain?: string) =>
|
|
1
|
+
export declare const getIssueUniqueId: (organizationName: string, projectId: string, issueId: string, domain?: string) => string;
|
|
2
|
+
export declare const getPullRequestUniqueId: (organizationName: string, projectId: string, repoId: string, pullRequestId: string, domain?: string) => string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const getIssueUniqueId: (repoId: string, issueId: string) =>
|
|
2
|
-
export declare const getPullRequestUniqueId: (repoId: string, pullRequestId: string) =>
|
|
1
|
+
export declare const getIssueUniqueId: (repoId: string, issueId: string) => string;
|
|
2
|
+
export declare const getPullRequestUniqueId: (repoId: string, pullRequestId: string) => string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const getIssueUniqueId: (repoId: string, issueId: string, domain: string) =>
|
|
2
|
-
export declare const getPullRequestUniqueId: (repoId: string, pullRequestId: string, domain: string) =>
|
|
1
|
+
export declare const getIssueUniqueId: (repoId: string, issueId: string, domain: string) => string;
|
|
2
|
+
export declare const getPullRequestUniqueId: (repoId: string, pullRequestId: string, domain: string) => string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const getIssueUniqueId: (issueGraphqlId: string, domain?: string) =>
|
|
2
|
-
export declare const getPullRequestUniqueId: (pullRequestGraphqlId: string, domain?: string) =>
|
|
1
|
+
export declare const getIssueUniqueId: (issueGraphqlId: string, domain?: string) => string;
|
|
2
|
+
export declare const getPullRequestUniqueId: (pullRequestGraphqlId: string, domain?: string) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getIssueUniqueId: (resourceId: string, projectId: string, issueId: string, domain?: string) =>
|
|
1
|
+
export declare const getIssueUniqueId: (resourceId: string, projectId: string, issueId: string, domain?: string) => string;
|
|
@@ -124,6 +124,12 @@ export declare class AzureDevOps extends Provider implements GitProvider {
|
|
|
124
124
|
authorLogin?: string;
|
|
125
125
|
mentionLogin?: string;
|
|
126
126
|
} & NumberedPageInput, options?: EnterpriseOptions): Promise<{
|
|
127
|
+
pageInfo: {
|
|
128
|
+
hasNextPage: boolean;
|
|
129
|
+
nextPage: null;
|
|
130
|
+
};
|
|
131
|
+
data: never[];
|
|
132
|
+
} | {
|
|
127
133
|
pageInfo: {
|
|
128
134
|
hasNextPage: boolean;
|
|
129
135
|
nextPage: number;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { ProviderConfig } from '../../types';
|
|
2
2
|
import { Options } from '../gitProvider';
|
|
3
|
+
import { AzurePullRequest } from './azureDevOpsTypes';
|
|
3
4
|
export declare const getAzureRequestHeaders: (config: ProviderConfig, options?: Options) => Record<string, string>;
|
|
5
|
+
export declare const getPullRequestUrl: (pullRequest: AzurePullRequest) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitkraken/provider-apis",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "An SDK around different third-party APIs that accepts and returns data in a common format.",
|
|
5
5
|
"author": "Axosoft, LLC dba GitKraken",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|