@gitkraken/provider-apis 0.7.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### ⚠️ Breaking Changes
6
+
7
+ - Util functions are no longer in classes
8
+ - changed export structure of the Util object
9
+
3
10
  ## 0.7.2
4
11
 
5
12
  - added utility functions for getting the unique ID of an entity
package/dist/index.d.ts CHANGED
@@ -43,4 +43,4 @@ declare const Utils: {
43
43
  jira: typeof JiraUtils;
44
44
  trello: typeof TrelloUtils;
45
45
  };
46
- export { Utils };
46
+ export { AzureDevopsUtils, BitbucketServerUtils, BitbucketUtils, GitHubUtils, GitLabUtils, JiraUtils, TrelloUtils, Utils, };
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- "use strict";var Ne=Object.create;var M=Object.defineProperty;var je=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var Qe=Object.getPrototypeOf,ze=Object.prototype.hasOwnProperty;var G=(e,t)=>{for(var r in t)M(e,r,{get:t[r],enumerable:!0})},Pe=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Fe(t))!ze.call(e,n)&&n!==r&&M(e,n,{get:()=>t[n],enumerable:!(s=je(t,n))||s.enumerable});return e};var Me=(e,t,r)=>(r=e!=null?Ne(Qe(e)):{},Pe(t||!e||!e.__esModule?M(r,"default",{value:e,enumerable:!0}):r,e)),He=e=>Pe(M({},"__esModule",{value:!0}),e);var Dt={};G(Dt,{AzureDevOps:()=>B,Bitbucket:()=>N,BitbucketServer:()=>j,GitHub:()=>F,GitLab:()=>z,Utils:()=>St,default:()=>Et});module.exports=He(Dt);var D=100;var ve=Me(require("node-fetch")),Ce=globalThis.fetch||ve.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},J=e=>Ue(e)?async({url:t,...r})=>{let s=await e(t,r);return We(s)}:e;var C=class{constructor(t){this.config={...t,request:J((t==null?void 0:t.request)||Ce)}}updateConfig(t){this.config={...this.config,...t,request:t.request?J(t.request):this.config.request}}},L=class extends C{};var y=(e,t)=>{let r={};return e&&(r.Authorization=`${t?"Basic":"Bearer"} ${e}`),r};var U=(e,t={})=>y(t.token||e.token,t.isPAT||e.isPAT);var Ve="https://app.vssps.visualstudio.com/_apis",A="https://dev.azure.com",Je={active:"OPEN",completed:"MERGED",abandoned:"CLOSED"},Xe={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}),H=e=>e.startsWith("refs/heads/")?e.replace("refs/heads/",""):e,we=e=>({id:e.pullRequestId.toString(),title:e.title,number:e.codeReviewId,state:Je[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:H(e.targetRefName)},headRef:{name:H(e.sourceRefName)},url:null,assignees:e.reviewers.map(X),reviews:e.reviewers.filter(t=>t.vote!==0).map(t=>({reviewer:X(t),state:Xe[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:H(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 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:`${Ve}/profile/profiles/me`,headers:U(this.config,t)});return{data:{id:r.body.id,name:r.body.displayName,username:r.body.displayName,email:r.body.emailAddress,avatarUrl:null}}}async getCurrentUserForInstance(t,r={}){let n=(await this.config.request({url:`${A}/${encodeURIComponent(t.namespace)}/_apis/ConnectionData`,headers:U(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:`${A}/${encodeURIComponent(t.repo.namespace)}/${encodeURIComponent(t.repo.project)}/_apis/git/repositories/${encodeURIComponent(t.repo.name)}/commits/${t.oid}`,headers:U(this.config,r)})).body.author;return{data:{name:n.name,email:n.email,avatarUrl:n.imageUrl}}}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:`${A}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/git/repositories/${encodeURIComponent(t.name)}`,headers:U(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:`${A}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/git/repositories`,headers:U(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(`${A}/${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",D.toString()),r.cursor&&n.searchParams.set("continuationToken",r.cursor);let o=await this.config.request({url:n.toString(),headers:U(this.config,s)}),a=o.headers["x-ms-continuationtoken"];return{pageInfo:{hasNextPage:!!a,endCursor:a||null},data:o.body.value.map(i=>({name:H(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||A}/${encodeURIComponent(o.namespace)}/${encodeURIComponent(o.project||"")}/_apis/git/repositories/${encodeURIComponent(o.name)}/pullRequests?${l}&%24top=${s}&%24skip=${(u-1)*s}`,headers:U(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(we)}}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(we(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`,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:{...U(this.config,r),"Content-Type":"application/json"}}),g=m.body.workItems.slice((i-1)*u,u*i).map(c=>c.id),d=await this.config.request({url:`${r.baseUrl||A}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/wit/workitemsbatch?api-version=6.0`,body:JSON.stringify({ids:g,$expand:"Links"}),method:"POST",headers:{...U(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 _=(e,t={})=>y(t.token||e.token,t.isPAT||e.isPAT);var q="https://api.bitbucket.org/2.0",Ze={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}),De=e=>{let t=e.id;return{id:t.toString(),title:e.title,number:t,state:Ze[e.state],isDraft:!1,commentCount:e.comment_count,upvoteCount:null,author:$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"}},N=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:_(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:_(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={}){var n,o;let s=await this.config.request({url:`${q}/repositories/${t.namespace}/${t.name}`,headers:_(this.config,r)});return{data:{id:s.body.uuid,namespace:s.body.workspace.slug,name:s.body.slug,webUrl:s.body.links.html.href,httpsUrl:((n=s.body.links.clone.find(a=>a.name==="https"))==null?void 0:n.href)??null,sshUrl:((o=s.body.links.clone.find(a=>a.name==="ssh"))==null?void 0:o.href)??null,defaultBranch:{name:s.body.mainbranch.name},permission:null}}}async getRepos(t,r={}){return{data:(await Promise.all(t.map(n=>this.getRepo(n,r)))).map(n=>n.data)}}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",D.toString());let n=await this.config.request({url:s.toString(),headers:_(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",D.toString()),t.cursor&&s.searchParams.set("page",t.cursor);let n=await this.config.request({url:s.toString(),headers:_(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:_(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 j=class extends L{getBaseUrl(t){let r=t.baseUrl||this.config.baseUrl;if(!r)throw new Error('Bitbucket Server requires "baseUrl"');return r}getRequestHeaders(t){return y(t.token||this.config.token)}async getRepo(t,r={}){var 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 Y="https://api.github.com",Ye=`${Y}/graphql`,Ge=/\/api\/v\d+$/,et=e=>{if(e.endsWith("/api/graphql"))throw new Error("The graphql endpoint is being used as the baseUrl. This package uses both GraphQL and REST APIs, and the REST version cannot be assumed. Use the REST endpoint as the baseUrl instead.")},tt=(e,t)=>{let r=t.baseUrl||e.baseUrl;return r?(r=r.replace(/\/$/,""),et(r),Ge.test(r)&&(r=r.replace(Ge,"")),`${r}/api/graphql`):Ye},P=(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:tt(e,r),method:"POST",headers:s,body:JSON.stringify(t)})},rt={user:!0,"user:email":!0,"read:user":!0},k=e=>e.some(t=>rt[t]),w=(e=!1,t=!1)=>`
1
+ "use strict";var Te=Object.create;var M=Object.defineProperty;var xe=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var qe=Object.getPrototypeOf,ke=Object.prototype.hasOwnProperty;var G=(e,t)=>{for(var r in t)M(e,r,{get:t[r],enumerable:!0})},ge=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of _e(t))!ke.call(e,s)&&s!==r&&M(e,s,{get:()=>t[s],enumerable:!(n=xe(t,s))||n.enumerable});return e};var Oe=(e,t,r)=>(r=e!=null?Te(qe(e)):{},ge(t||!e||!e.__esModule?M(r,"default",{value:e,enumerable:!0}):r,e)),Be=e=>ge(M({},"__esModule",{value:!0}),e);var Tt={};G(Tt,{AzureDevOps:()=>B,AzureDevopsUtils:()=>J,Bitbucket:()=>N,BitbucketServer:()=>j,BitbucketServerUtils:()=>K,BitbucketUtils:()=>X,GitHub:()=>F,GitHubUtils:()=>Z,GitLab:()=>z,GitLabUtils:()=>Y,JiraUtils:()=>ee,TrelloUtils:()=>te,Utils:()=>At,default:()=>Lt});module.exports=Be(Tt);var D=100;var he=Oe(require("node-fetch")),fe=globalThis.fetch||he.default;var Re=e=>e.name==="fetch";var Ne=async e=>{let t=e.headers.get("content-type")||"",r=null;if(t.startsWith("application/json"))r=await e.json();else if(t.startsWith("text/"))r=await e.text();else throw new Error(`Unsupported content-type: ${t}`);let n={body:r,headers:Object.fromEntries(e.headers.entries()),status:e.status,statusText:e.statusText};if(!e.ok){let s=new Error(e.statusText);throw Object.assign(s,{response:n}),s}return n},re=e=>Re(e)?async({url:t,...r})=>{let n=await e(t,r);return Ne(n)}:e;var C=class{constructor(t){this.config={...t,request:re((t==null?void 0:t.request)||fe)}}updateConfig(t){this.config={...this.config,...t,request:t.request?re(t.request):this.config.request}}},L=class extends C{};var y=(e,t)=>{let r={};return e&&(r.Authorization=`${t?"Basic":"Bearer"} ${e}`),r};var U=(e,t={})=>y(t.token||e.token,t.isPAT||e.isPAT);var je="https://app.vssps.visualstudio.com/_apis",A="https://dev.azure.com",Fe={active:"OPEN",completed:"MERGED",abandoned:"CLOSED"},Qe={10:"APPROVED",5:"APPROVED",0:"REVIEW_REQUESTED",[-5]:"CHANGES_REQUESTED",[-10]:"CHANGES_REQUESTED"},se=e=>({id:e.id,name:e.displayName,username:e.uniqueName||e.displayName,email:null,avatarUrl:e.imageUrl}),H=e=>e.startsWith("refs/heads/")?e.replace("refs/heads/",""):e,be=e=>({id:e.pullRequestId.toString(),title:e.title,number:e.codeReviewId,state:Fe[e.status],isDraft:e.isDraft,commentCount:null,upvoteCount:null,author:se(e.createdBy),createdDate:new Date(e.creationDate),updatedDate:new Date(e.closedDate||e.creationDate),closedDate:e.closedDate?new Date(e.closedDate):null,repository:{name:e.repository.name,owner:{login:void 0}},headCommit:{buildStatus:null},baseRef:{name:H(e.targetRefName)},headRef:{name:H(e.sourceRefName)},url:null,assignees:e.reviewers.map(se),reviews:e.reviewers.filter(t=>t.vote!==0).map(t=>({reviewer:se(t),state:Qe[t.vote]||"REVIEW_REQUESTED"})),additions:null,deletions:null,fileCount:null,commitCount:null,headRepository:null,mergeableState:"UNKNOWN"}),ye=(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:H(t.defaultBranch)}:null,permission:null}),ze=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 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:`${je}/profile/profiles/me`,headers:U(this.config,t)});return{data:{id:r.body.id,name:r.body.displayName,username:r.body.displayName,email:r.body.emailAddress,avatarUrl:null}}}async getCurrentUserForInstance(t,r={}){let s=(await this.config.request({url:`${A}/${encodeURIComponent(t.namespace)}/_apis/ConnectionData`,headers:U(this.config,r)})).body.authorizedUser;if(s.providerDisplayName==="Anonymous")throw new Error("Current user not found.");return{data:{id:s.id,name:s.providerDisplayName,username:s.providerDisplayName,email:s.properties.Account.$value,avatarUrl:null}}}async getUserForCommit(t,r={}){if(!t.repo.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let s=(await this.config.request({url:`${A}/${encodeURIComponent(t.repo.namespace)}/${encodeURIComponent(t.repo.project)}/_apis/git/repositories/${encodeURIComponent(t.repo.name)}/commits/${t.oid}`,headers:U(this.config,r)})).body.author;return{data:{name:s.name,email:s.email,avatarUrl:s.imageUrl}}}async getRepo(t,r={}){if(!t.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let n=await this.config.request({url:`${A}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/git/repositories/${encodeURIComponent(t.name)}`,headers:U(this.config,r)});return{data:ye(t.namespace,n.body)}}async getRepos(t,r={}){return{data:(await Promise.all(t.map(s=>this.getRepo(s,r)))).map(s=>s.data)}}async getReposForAzureProject(t,r={}){if(!t.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');return{data:(await this.config.request({url:`${A}/${encodeURIComponent(t.namespace)}/${encodeURIComponent(t.project)}/_apis/git/repositories`,headers:U(this.config,r)})).body.value.map(s=>ye(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",D.toString()),r.cursor&&s.searchParams.set("continuationToken",r.cursor);let o=await this.config.request({url:s.toString(),headers:U(this.config,n)}),a=o.headers["x-ms-continuationtoken"];return{pageInfo:{hasNextPage:!!a,endCursor:a||null},data:o.body.value.map(i=>({name:H(i.name),commit:{oid:i.objectId,authoredDate:null,committedDate:null}}))}}async getBranches(t,r={}){return this.getRefs("heads",t,r)}async getTags(t,r={}){return this.getRefs("tags",t,r)}async getPullRequestsForRepoBase(t,r={},n=100){let{page:s,repo:o,assigneeLogins:a,authorLogin:i}=t||{},u=s||1;if(!o.project)throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let l="searchCriteria.status=1";return a&&a.length&&(l+=`&searchCriteria.reviewerId=${a[0]}`),i&&(l+=`&searchCriteria.creatorId=${i}`),await this.config.request({url:`${r.baseUrl||A}/${encodeURIComponent(o.namespace)}/${encodeURIComponent(o.project||"")}/_apis/git/repositories/${encodeURIComponent(o.name)}/pullRequests?${l}&%24top=${n}&%24skip=${(u-1)*n}`,headers:U(this.config,r)})}async getPullRequestsForRepo(t,r={}){let s=t.page||1,o=await this.getPullRequestsForRepoBase(t,r,100);return{pageInfo:{hasNextPage:o.body.value.length===100,nextPage:s+1},data:o.body.value.map(be)}}async getPullRequestsForRepos(t,r={}){if(!t.repos.every(o=>o.project))throw new Error('Azure DevOps requires a "project" (name or ID) for this function.');let{repos:n}=t||{},s=[];return await Promise.all(n.map(async o=>{try{(await this.getPullRequestsForRepoBase({repo:o,...t},r)).body.value.forEach(i=>{s.push(be(i))})}catch(a){if(a.statusCode!==404&&a.statusCode!==401)throw a}})),{data:s}}async getIssuesForAzureProject(t,r={}){let{page:n,assigneeLogins:s,authorLogin:o,mentionLogin:a}=t||{},i=n||1,u=200,l=["[Microsoft.VSTS.Common.ClosedDate] = ''","[System.TeamProject] = @project","[Microsoft.VSTS.Common.ResolvedDate] = ''"];o&&l.push(`[System.CreatedBy] = '${o.replace("'","''")}'`),s&&s[0]&&l.push(`[System.AssignedTo] = '${s[0].replace("'","''")}'`),a&&l.push("[System.Id] IN (@recentMentions)");let p=`Select [Microsoft.VSTS.Common.ClosedDate], [Microsoft.VSTS.Common.ResolvedDate] From WorkItems Where ${l.join(" AND ")} order by [System.CreatedDate] desc`,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:{...U(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:{...U(this.config,r),"Content-Type":"application/json"}});return{pageInfo:{hasNextPage:m.body.workItems.length>u*i,nextPage:i+1},data:d.body.value.map(ze)}}};var x=(e,t={})=>y(t.token||e.token,t.isPAT||e.isPAT);var q="https://api.bitbucket.org/2.0",Me={OPEN:"OPEN",MERGED:"MERGED",DECLINED:"CLOSED"},ve=e=>({id:e.uuid,name:e.display_name||e.nickname,username:e.nickname||e.display_name,email:null,avatarUrl:e.links.avatar.href}),Pe=e=>{let t=e.id;return{id:t.toString(),title:e.title,number:t,state:Me[e.state],isDraft:!1,commentCount:e.comment_count,upvoteCount:null,author:ve(e.author),createdDate:new Date(e.created_on),updatedDate:new Date(e.updated_on),closedDate:null,repository:{name:e.source.repository.name,owner:{login:void 0}},headCommit:{buildStatus:null},baseRef:{name:e.destination.branch.name},headRef:{name:e.source.branch.name},url:e.links.html.href,assignees:null,reviews:null,additions:null,deletions:null,fileCount:null,commitCount:null,headRepository:null,mergeableState:"UNKNOWN"}},N=class extends 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:ve(r.body)}}async getUserForCommit(t,r={}){var a;let s=(await this.config.request({url:`${q}/repositories/${t.repo.namespace}/${t.repo.name}/commit/${t.oid}`,headers:x(this.config,r)})).body.author,o=s.raw.match(/([^<]+)<(.+)>/);return{data:{name:o?o[1].trim():null,email:o?o[2]:null,avatarUrl:((a=s.user)==null?void 0:a.links.avatar.href)||null}}}async getRepo(t,r={}){var s,o;let n=await this.config.request({url:`${q}/repositories/${t.namespace}/${t.name}`,headers:x(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(a=>a.name==="https"))==null?void 0:s.href)??null,sshUrl:((o=n.body.links.clone.find(a=>a.name==="ssh"))==null?void 0:o.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 a;let n=new URL(`${q}/repositories/${t.repo.namespace}/${t.repo.name}/refs/branches`);n.searchParams.set("page",((a=t.page)==null?void 0:a.toString())||"1"),n.searchParams.set("pagelen",D.toString());let s=await this.config.request({url:n.toString(),headers:x(this.config,r)}),o=!!s.body.next;return{pageInfo:{hasNextPage:o,nextPage:o?s.body.page+1:null},data:s.body.values.map(i=>{let u=new Date(i.target.date);return{name:i.name,commit:{oid:i.target.hash,authoredDate:u,committedDate:u}}})}}async getTags(t,r={}){let n=new URL(`${q}/repositories/${t.repo.namespace}/${t.repo.name}/refs/tags`);n.searchParams.set("pagelen",D.toString()),t.cursor&&n.searchParams.set("page",t.cursor);let s=await this.config.request({url:n.toString(),headers:x(this.config,r)}),o=!!s.body.next,a=null;return s.body.next&&(a=new URL(s.body.next).searchParams.get("page")),{pageInfo:{hasNextPage:o,endCursor:a},data:s.body.values.map(i=>{let u=new Date(i.target.date);return{name:i.name,commit:{oid:i.target.hash,authoredDate:u,committedDate:u}}})}}async getPullRequestsForRepoBase(t,r={}){var s;let n=new URL(`${q}/repositories/${encodeURI(t.repo.namespace)}/${encodeURI(t.repo.name)}/pullrequests?state=OPEN`);return n.searchParams.set("page",((s=t.page)==null?void 0:s.toString())||"1"),n.searchParams.set("pagelen","50"),await this.config.request({url:n.toString(),headers:x(this.config,r)})}async getPullRequestsForRepo(t,r={}){let n=[],s=await this.getPullRequestsForRepoBase(t,r);s.body.values.forEach(a=>{if(t.authorLogin&&a.author.uuid!==t.authorLogin)return null;n.push(Pe(a))});let o=!!s.body.next;return{pageInfo:{hasNextPage:o,nextPage:o?s.body.page+1:null},data:n}}async getPullRequestsForRepos(t,r={}){let n=[];return await Promise.all(t.repos.map(async s=>{try{(await this.getPullRequestsForRepoBase({repo:s,...t},r)).body.values.forEach(a=>{if(t.authorLogin&&a.author.uuid!==t.authorLogin)return null;n.push(Pe(a))})}catch(o){if(o.statusCode!==404&&o.statusCode!==401)throw o}})),{data:n}}};var j=class extends L{getBaseUrl(t){let r=t.baseUrl||this.config.baseUrl;if(!r)throw new Error('Bitbucket Server requires "baseUrl"');return r}getRequestHeaders(t){return y(t.token||this.config.token)}async getRepo(t,r={}){var s,o,a;let n=await this.config.request({url:`${this.getBaseUrl(r)}/projects/${t.namespace}/repos/${t.name}`,headers:this.getRequestHeaders(r)});return{data:{id:n.body.id.toString(),namespace:n.body.project.key,name:n.body.slug,webUrl:((s=n.body.links.self[0])==null?void 0:s.href)??null,httpsUrl:((o=n.body.links.clone.find(i=>i.name==="https"))==null?void 0:o.href)??null,sshUrl:((a=n.body.links.clone.find(i=>i.name==="ssh"))==null?void 0:a.href)??null,defaultBranch:null,permission:null}}}async getRepos(t,r={}){return{data:(await Promise.all(t.map(s=>this.getRepo(s,r)))).map(s=>s.data)}}};var ae="https://api.github.com",He=`${ae}/graphql`,Ce=/\/api\/v\d+$/,We=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.")},Ve=(e,t)=>{let r=t.baseUrl||e.baseUrl;return r?(r=r.replace(/\/$/,""),We(r),Ce.test(r)&&(r=r.replace(Ce,"")),`${r}/api/graphql`):He},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:Ve(e,r),method:"POST",headers:n,body:JSON.stringify(t)})},Je={user:!0,"user:email":!0,"read:user":!0},k=e=>e.some(t=>Je[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
- `,st=(e,t=!1)=>`
8
+ `,Xe=(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
- `,nt={"-linked":"-linked",archived:"archived",assignee:"assignee",author:"author",base:"base",closed:"closed",commenter:"commenter",comments:"comments",created:"created",draft:"draft",head:"head",label:"label",language:"language",linked:"linked",in:"in",interactions:"interactions",involves:"involves",is:"is",mentions:"mentions",merged:"merged",milestone:"milestone",no:"no",org:"org",project:"project",reactions:"reactions",repo:"repo",review:"review","reviewed-by":"reviewed-by","review-requested":"review-requested",state:"state",status:"status",team:"team","team-review-requested":"team-review-requested",type:"type",updated:"updated",user:"user","user-review-requested":"user-review-requested"},ot=new RegExp('(([^\\s]+:)?\\"(?:[^\\"\\\\]|\\\\.)*\\"?)|([^\\"\\s]+)',"g"),ee=e=>{let t=[];return(e.match(ot)??[]).forEach(s=>{if(s.includes(":")&&s!="is:closed"){let n=s.split(":")[0];nt[n]&&t.push(s)}}),t},te=async(e,t,r,s=!0,n=!1)=>{let{cursor:o,assigneeLogins:a,updatedBefore:i,isDraft:u,authorLogin:l,repos:p,reviewRequestedLogin:m,startQuery:g,mentionLogin:d}=t||{},c=ee(g||"");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}`),m&&c.push(`review-requested:${m}`),d&&c.push(`mentions:${d}`);let b=`
103
+ `,Ke={"-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"},Ze=new RegExp('(([^\\s]+:)?\\"(?:[^\\"\\\\]|\\\\.)*\\"?)|([^\\"\\s]+)',"g"),ie=e=>{let t=[];return(e.match(Ze)??[]).forEach(n=>{if(n.includes(":")&&n!="is:closed"){let s=n.split(":")[0];Ke[s]&&t.push(n)}}),t},ue=async(e,t,r,n=!0,s=!1)=>{let{cursor:o,assigneeLogins:a,updatedBefore:i,isDraft:u,authorLogin:l,repos:p,reviewRequestedLogin:m,startQuery:c,mentionLogin:d}=t||{},g=ie(c||"");p.forEach(f=>{g.push(`repo:${f.namespace}/${f.name}`)}),a&&a.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
- ${st(s,n)}
116
+ ${Xe(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:o??null,search:`sort:updated type:pr state:open ${c.join(" ")}`}},r)};var Le=`
126
+ `;return P(e,{query:`${b}`,variables:{after:o??null,search:`sort:updated type:pr state:open ${g.join(" ")}`}},r)};var Ue=`
127
127
  id
128
128
  databaseId
129
129
  owner {
@@ -136,13 +136,13 @@ defaultBranchRef {
136
136
  name
137
137
  }
138
138
  viewerPermission
139
- `,re={id:"U_kgDNJ5k",databaseId:10137,name:"Deleted user",login:"ghost",email:"",avatarUrl:"https://avatars.githubusercontent.com/u/10137?v=4"},at={APPROVED:"APPROVED",CHANGES_REQUESTED:"CHANGES_REQUESTED",COMMENTED:"COMMENTED",REVIEW_REQUESTED:"REVIEW_REQUESTED"},it={MERGEABLE:"MERGEABLE",CONFLICTING:"CONFLICTS",UNKNOWN:"UNKNOWN"},Ae=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}),ut={OPEN:"OPEN",CLOSED:"CLOSED",MERGED:"MERGED"},$=e=>({id:e.databaseId.toString(),graphQLId:e.id,name:e.name,username:e.login,email:e.email??null,avatarUrl:e.avatarUrl}),lt=e=>{var l,p,m,g,d,c,b,f;let t=e.author?e.author.id?e.author:null:re,r=(p=(l=e.commits.nodes)==null?void 0:l[0])==null?void 0:p.commit,s=((m=e.headRef)==null?void 0:m.target)||r,n=s==null?void 0:s.oid,o=r==null?void 0:r.oid,a=n===o?(d=(g=r==null?void 0:r.status)==null?void 0:g.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:ut[e.state],commentCount:e.comments.totalCount,upvoteCount:e.reactions.totalCount,author:t?$(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($):null,reviews:i.map(h=>({reviewer:$(h.requestedReviewer),state:"REVIEW_REQUESTED"})).concat((((f=e.latestReviews)==null?void 0:f.nodes)||[]).map(h=>{let R=h.author||re;return{reviewer:$(R),state:at[h.state]}})),additions:e.additions,deletions:e.deletions,fileCount:e.changedFiles,commitCount:e.commits.totalCount,mergeableState:it[e.mergeable]}},pt=e=>{var r;let t=(r=e.author)!=null&&r.id?e.author:re;return{id:e.databaseId.toString(),graphQLId:e.id,number:e.number,title:e.title,author:$(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($):[],upvoteCount:e.reactions.totalCount}},F=class extends L{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 P(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(Y)?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 P(this.config,{query:`
139
+ `,le={id:"U_kgDNJ5k",databaseId:10137,name:"Deleted user",login:"ghost",email:"",avatarUrl:"https://avatars.githubusercontent.com/u/10137?v=4"},Ye={APPROVED:"APPROVED",CHANGES_REQUESTED:"CHANGES_REQUESTED",COMMENTED:"COMMENTED",REVIEW_REQUESTED:"REVIEW_REQUESTED"},et={MERGEABLE:"MERGEABLE",CONFLICTING:"CONFLICTS",UNKNOWN:"UNKNOWN"},we=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}),tt={OPEN:"OPEN",CLOSED:"CLOSED",MERGED:"MERGED"},$=e=>({id:e.databaseId.toString(),graphQLId:e.id,name:e.name,username:e.login,email:e.email??null,avatarUrl:e.avatarUrl}),rt=e=>{var l,p,m,c,d,g,b,f;let t=e.author?e.author.id?e.author:null:le,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,o=r==null?void 0:r.oid,a=s===o?(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:tt[e.state],commentCount:e.comments.totalCount,upvoteCount:e.reactions.totalCount,author:t?$(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($):null,reviews:i.map(h=>({reviewer:$(h.requestedReviewer),state:"REVIEW_REQUESTED"})).concat((((f=e.latestReviews)==null?void 0:f.nodes)||[]).map(h=>{let R=h.author||le;return{reviewer:$(R),state:Ye[h.state]}})),additions:e.additions,deletions:e.deletions,fileCount:e.changedFiles,commitCount:e.commits.totalCount,mergeableState:et[e.mergeable]}},st=e=>{var r;let t=(r=e.author)!=null&&r.id?e.author:le;return{id:e.databaseId.toString(),graphQLId:e.id,number:e.number,title:e.title,author:$(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($):[],upvoteCount:e.reactions.totalCount}},F=class extends L{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 a=(await P(this.config,{query:"query { rateLimit(dryRun: true) { __typename } }"},r)).headers["x-oauth-scopes"];s=a?a.split(", "):[],this._scopesCache[n]=s}return s}getEnterpriseAvatarUrlIfNeeded(r,n,s){let o=s.baseUrl||this.config.baseUrl;return!o||o.startsWith(ae)?r:n?`https://avatars.githubusercontent.com/u/e?email=${encodeURIComponent(n)}`:""}async getCurrentUser(r={}){var a;let n=await this.getScopes(r),o=(a=(await P(this.config,{query:`
140
140
  query getCurrentUser {
141
141
  viewer {
142
- ${w(!1,k(s))}
142
+ ${w(!1,k(n))}
143
143
  }
144
144
  }
145
- `},r)).body.data)==null?void 0:a.viewer;if(!o)throw new Error("Current user not found.");return{data:$(o)}}async getUserForCommit(r,s={}){var i,u;let o=(i=(await P(this.config,{query:`
145
+ `},r)).body.data)==null?void 0:a.viewer;if(!o)throw new Error("Current user not found.");return{data:$(o)}}async getUserForCommit(r,n={}){var i,u;let o=(i=(await P(this.config,{query:`
146
146
  query getUserForCommit(
147
147
  $owner: String!
148
148
  $name: String!
@@ -161,38 +161,38 @@ query getUserForCommit(
161
161
  }
162
162
  }
163
163
  }
164
- `,variables:{owner:r.repo.namespace,name:r.repo.name,oid:r.oid,avatarSize:r.avatarSize}},s)).body.data)==null?void 0:i.repository;if(!o)throw new Error("Repository not found.");let a=(u=o.object)==null?void 0:u.author;if(!a)throw new Error("Commit not found.");return{data:{name:a.name,email:a.email,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(a.avatarUrl,a.email,s)}}}async getAccountForEmail(r,s={}){var i,u,l;let n=await this.getScopes(s),a=(l=(u=(i=(await P(this.config,{query:`
164
+ `,variables:{owner:r.repo.namespace,name:r.repo.name,oid:r.oid,avatarSize:r.avatarSize}},n)).body.data)==null?void 0:i.repository;if(!o)throw new Error("Repository not found.");let a=(u=o.object)==null?void 0:u.author;if(!a)throw new Error("Commit not found.");return{data:{name:a.name,email:a.email,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(a.avatarUrl,a.email,n)}}}async getAccountForEmail(r,n={}){var i,u,l;let s=await this.getScopes(n),a=(l=(u=(i=(await P(this.config,{query:`
165
165
  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,k(n))}
169
+ ${w(!0,k(s))}
170
170
  }
171
171
  }
172
172
  }
173
173
  }
174
- `,variables:{query:`in:email ${r.email}`,avatarSize:r.avatarSize}},s)).body.data)==null?void 0:i.search)==null?void 0:u.nodes)==null?void 0:l[0];if(!a)throw new Error("User not found.");return{data:$({...a,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(a.avatarUrl,a.email,s)})}}async getAccountForUsername(r,s={}){var i;let n=await this.getScopes(s),a=(i=(await P(this.config,{query:`
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(!a)throw new Error("User not found.");return{data:$({...a,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(a.avatarUrl,a.email,n)})}}async getAccountForUsername(r,n={}){var i;let s=await this.getScopes(n),a=(i=(await P(this.config,{query:`
175
175
  query getUserForUsername($login: String! $avatarSize: Int) {
176
176
  user(login: $login) {
177
- ${w(!0,k(n))}
177
+ ${w(!0,k(s))}
178
178
  }
179
179
  }
180
- `,variables:{login:r.username,avatarSize:r.avatarSize}},s)).body.data)==null?void 0:i.user;if(!a)throw new Error("User not found.");return{data:$({...a,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(a.avatarUrl,a.email,s)})}}async getRepo(r,s={}){var o;let n=await P(this.config,{query:`
180
+ `,variables:{login:r.username,avatarSize:r.avatarSize}},n)).body.data)==null?void 0:i.user;if(!a)throw new Error("User not found.");return{data:$({...a,avatarUrl:this.getEnterpriseAvatarUrlIfNeeded(a.avatarUrl,a.email,n)})}}async getRepo(r,n={}){var o;let s=await P(this.config,{query:`
181
181
  query getRepo($owner: String!, $name: String!) {
182
182
  repository(owner: $owner, name: $name) {
183
- ${Le}
183
+ ${Ue}
184
184
  }
185
185
  }
186
- `,variables:{owner:r.namespace,name:r.name}},s);if(!((o=n.body.data)!=null&&o.repository))throw new Error(`Repository ${r.namespace}/${r.name} not found`);return{data:Ae(n.body.data.repository)}}async getRepos(r,s={}){let n=r.map(({namespace:a,name:i},u)=>`
186
+ `,variables:{owner:r.namespace,name:r.name}},n);if(!((o=s.body.data)!=null&&o.repository))throw new Error(`Repository ${r.namespace}/${r.name} not found`);return{data:we(s.body.data.repository)}}async getRepos(r,n={}){let s=r.map(({namespace:a,name:i},u)=>`
187
187
  getRepo_${u}: repository(owner: "${a}", name: "${i}") {
188
- ${Le}
188
+ ${Ue}
189
189
  }
190
190
  `).join(`
191
191
  `),o=await P(this.config,{query:`
192
192
  query batchGetRepos {
193
- ${n}
193
+ ${s}
194
194
  }
195
- `},s);if(!o.body.data)throw new Error(o.statusText||"Unknown error");return{data:r.map(({namespace:a,name:i},u)=>{let l=o.body.data[`getRepo_${u}`];if(!l)throw new Error(`Repository ${a}/${i} not found`);return Ae(l)})}}async getRefs(r,s,n={}){var u;let a=(u=(await P(this.config,{query:`
195
+ `},n);if(!o.body.data)throw new Error(o.statusText||"Unknown error");return{data:r.map(({namespace:a,name:i},u)=>{let l=o.body.data[`getRepo_${u}`];if(!l)throw new Error(`Repository ${a}/${i} not found`);return we(l)})}}async getRefs(r,n,s={}){var u;let a=(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:s.repo.namespace,name:s.repo.name,refPrefix:r,cursor:s.cursor,first:D}},n)).body.data)==null?void 0:u.repository;if(!a)throw new Error("Repository not found.");let i=a.refs;return i?{pageInfo:i.pageInfo,data:(i.nodes||[]).map(l=>{var 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,s={}){return this.getRefs("refs/heads/",r,s)}async getTags(r,s={}){return this.getRefs("refs/tags/",r,s)}async getBlame(r,s={}){var i;let o=(i=(await P(this.config,{query:`
216
+ `,variables:{owner:n.repo.namespace,name:n.repo.name,refPrefix:r,cursor:n.cursor,first:D}},s)).body.data)==null?void 0:u.repository;if(!a)throw new Error("Repository not found.");let i=a.refs;return i?{pageInfo:i.pageInfo,data:(i.nodes||[]).map(l=>{var 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 o=(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}},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,m,g,d,c,b,f;let n=await this.getScopes(s),o=k(n),a="Field 'isDraft' doesn't exist on type 'PullRequest'",i=await te(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 te(this.config,r,s,!1,o))}let u=((d=(g=(m=i.body)==null?void 0:m.data)==null?void 0:g.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(lt)}}async getIssuesForRepos(r,s={}){var b,f,h,R,I,E;let n=await this.getScopes(s),o=k(n),a=ee(r.startQuery||""),{cursor:i,assigneeLogins:u,updatedBefore:l,authorLogin:p,mentionLogin:m}=r||{};r.repos.forEach(S=>{a.push(`repo:${S.namespace}/${S.name}`)}),u&&u.forEach(S=>{a.push(`assignee:${S}`)}),l&&a.push(`updated:<${l}`),p&&a.push(`author:${p}`),m&&a.push(`mentions:${m}`);let g=`
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(!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,n={}){var l,p,m,c,d,g,b,f;let s=await this.getScopes(n),o=k(s),a="Field 'isDraft' doesn't exist on type 'PullRequest'",i=await ue(this.config,r,n,!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;n.baseUrl&&R&&(i=await ue(this.config,r,n,!1,o))}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(rt)}}async getIssuesForRepos(r,n={}){var b,f,h,R,I,E;let s=await this.getScopes(n),o=k(s),a=ie(r.startQuery||""),{cursor:i,assigneeLogins:u,updatedBefore:l,authorLogin:p,mentionLogin:m}=r||{};r.repos.forEach(S=>{a.push(`repo:${S.namespace}/${S.name}`)}),u&&u.forEach(S=>{a.push(`assignee:${S}`)}),l&&a.push(`updated:<${l}`),p&&a.push(`author:${p}`),m&&a.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
- `,d=await P(this.config,{query:`${g}`,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=(I=(R=d.body)==null?void 0:R.data)==null?void 0:I.search)==null?void 0:E.pageInfo,data:c.map(pt)}}};var dt="https://gitlab.com/api/v4",mt="https://gitlab.com/api/graphql",Te=/\/api\/v\d+$/,_e=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.")},se=(e,t)=>{let r=t.baseUrl||e.baseUrl;return r?(r=r.replace(/\/$/,""),_e(r),r):dt},gt=(e,t)=>{let r=t.baseUrl||e.baseUrl;return r?(r=r.replace(/\/$/,""),_e(r),Te.test(r)&&(r=r.replace(Te,"")),`${r}/api/graphql`):mt},v=(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 ct={CAN_BE_MERGED:"MERGEABLE",CANNOT_BE_MERGED:"CONFLICTS",CANNOT_BE_MERGED_RECHECK:"UNKNOWN",UNCHECKED:"UNKNOWN",CHECKING:"UNKNOWN"},ae="gid://gitlab/User/",Q="gid://gitlab/Project/",ht="gid://gitlab/MergeRequest/",ft="gid://gitlab/Issue/",xe=`
306
+ `,d=await P(this.config,{query:`${c}`,variables:{after:i??null,search:`sort:updated type:issue state:open ${a.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(st)}}};var nt="https://gitlab.com/api/v4",ot="https://gitlab.com/api/graphql",Ee=/\/api\/v\d+$/,Se=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.")},pe=(e,t)=>{let r=t.baseUrl||e.baseUrl;return r?(r=r.replace(/\/$/,""),Se(r),r):nt},at=(e,t)=>{let r=t.baseUrl||e.baseUrl;return r?(r=r.replace(/\/$/,""),Se(r),Ee.test(r)&&(r=r.replace(Ee,"")),`${r}/api/graphql`):ot},v=(e,t,r)=>{let n=y(r.token||e.token);return e.request({url:at(e,r),method:"POST",headers:{...n,"Content-Type":"application/json"},body:JSON.stringify(t)})};var it={CAN_BE_MERGED:"MERGEABLE",CANNOT_BE_MERGED:"CONFLICTS",CANNOT_BE_MERGED_RECHECK:"UNKNOWN",UNCHECKED:"UNKNOWN",CHECKING:"UNKNOWN"},ce="gid://gitlab/User/",Q="gid://gitlab/Project/",ut="gid://gitlab/MergeRequest/",lt="gid://gitlab/Issue/",De=`
307
307
  id
308
308
  path
309
309
  fullPath
@@ -319,7 +319,7 @@ name
319
319
  username
320
320
  publicEmail
321
321
  avatarUrl
322
- `,ne=`
322
+ `,de=`
323
323
  author {
324
324
  ${T}
325
325
  }
@@ -339,7 +339,7 @@ updatedAt
339
339
  upvotes
340
340
  userNotesCount
341
341
  webUrl
342
- `,qe=`
342
+ `,$e=`
343
343
  id
344
344
  state
345
345
  author {
@@ -376,13 +376,13 @@ reviewers {
376
376
  }
377
377
  }
378
378
  }
379
- mergeStatusEnum`,x=e=>`${e.namespace}/${e.name}`,Rt=e=>`${e.namespace}/${e.name}`,ke=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}},bt={opened:"OPEN",merged:"MERGED",closed:"CLOSED"},O=e=>({id:e.id.replace(ae,""),graphQLId:e.id,name:e.name,username:e.username,email:e.publicEmail,avatarUrl:e.avatarUrl}),Oe=(e,t)=>{var r,s,n,o,a;return{id:e.id.replace(ht,""),graphQLId:e.id,title:e.title,number:parseInt(e.iid,10),state:bt[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:ct[e.mergeStatusEnum]}},oe=(e,t)=>({author:{avatarUrl:e.author.avatarUrl,email:null,graphQLId:e.author.id,id:e.author.id.replace(ae,""),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(ae,""),name:r.name,username:r.username})),commentCount:e.userNotesCount,createdDate:new Date(e.createdAt),description:e.description,graphQLId:e.id,id:e.id.replace(ft,""),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}),z=class extends L{async getCurrentUser(t={}){var n;let s=(n=(await v(this.config,{query:`
379
+ mergeStatusEnum`,_=e=>`${e.namespace}/${e.name}`,pt=e=>`${e.namespace}/${e.name}`,Ge=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}},dt={opened:"OPEN",merged:"MERGED",closed:"CLOSED"},O=e=>({id:e.id.replace(ce,""),graphQLId:e.id,name:e.name,username:e.username,email:e.publicEmail,avatarUrl:e.avatarUrl}),Le=(e,t)=>{var r,n,s,o,a;return{id:e.id.replace(ut,""),graphQLId:e.id,title:e.title,number:parseInt(e.iid,10),state:dt[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:((o=e.diffStatsSummary)==null?void 0:o.deletions)||0,fileCount:((a=e.diffStatsSummary)==null?void 0:a.fileCount)||0,commitCount:e.commitCount||0,mergeableState:it[e.mergeStatusEnum]}},me=(e,t)=>({author:{avatarUrl:e.author.avatarUrl,email:null,graphQLId:e.author.id,id:e.author.id.replace(ce,""),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(ce,""),name:r.name,username:r.username})),commentCount:e.userNotesCount,createdDate:new Date(e.createdAt),description:e.description,graphQLId:e.id,id:e.id.replace(lt,""),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}),z=class extends L{async getCurrentUser(t={}){var s;let n=(s=(await v(this.config,{query:`
380
380
  query getCurrentUser {
381
381
  currentUser {
382
382
  ${T}
383
383
  }
384
384
  }
385
- `},t)).body.data)==null?void 0:n.currentUser;if(!s)throw new Error("Current user not found.");return{data:O(s)}}async getUserForCommit(t,r={}){var a,i,u,l;let s=x(t.repo),o=(l=(u=(i=(a=(await v(this.config,{query:`
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 a,i,u,l;let n=_(t.repo),o=(l=(u=(i=(a=(await v(this.config,{query:`
386
386
  query getUserForCommit($fullPath: ID!, $oid: String!) {
387
387
  project(fullPath: $fullPath) {
388
388
  repository {
@@ -396,7 +396,7 @@ query getUserForCommit($fullPath: ID!, $oid: String!) {
396
396
  }
397
397
  }
398
398
  }
399
- `,variables:{fullPath:s,oid:t.oid}},r)).body.data)==null?void 0:a.project)==null?void 0:i.repository)==null?void 0:u.tree)==null?void 0:l.lastCommit;if(!o)throw new Error("Commit not found.");return{data:{name:o.authorName,email:o.authorEmail,avatarUrl:o.authorGravatar}}}async getAccountForEmail(t,r={}){var o,a,i;let n=(i=(a=(o=(await v(this.config,{query:`
399
+ `,variables:{fullPath:n,oid:t.oid}},r)).body.data)==null?void 0:a.project)==null?void 0:i.repository)==null?void 0:u.tree)==null?void 0:l.lastCommit;if(!o)throw new Error("Commit not found.");return{data:{name:o.authorName,email:o.authorEmail,avatarUrl:o.authorGravatar}}}async getAccountForEmail(t,r={}){var o,a,i;let s=(i=(a=(o=(await v(this.config,{query:`
400
400
  query getAccountForEmail($email: String!) {
401
401
  users(search: $email) {
402
402
  nodes {
@@ -404,28 +404,28 @@ query getAccountForEmail($email: String!) {
404
404
  }
405
405
  }
406
406
  }
407
- `,variables:{email:t.email}},r)).body.data)==null?void 0:o.users)==null?void 0:a.nodes)==null?void 0:i[0];if(!n)throw new Error("User not found.");return{data:O(n)}}async getAccountForUsername(t,r={}){var o;let n=(o=(await v(this.config,{query:`
407
+ `,variables:{email:t.email}},r)).body.data)==null?void 0:o.users)==null?void 0:a.nodes)==null?void 0:i[0];if(!s)throw new Error("User not found.");return{data:O(s)}}async getAccountForUsername(t,r={}){var o;let s=(o=(await v(this.config,{query:`
408
408
  query getAccountForUsername($username: String!) {
409
409
  user(username: $username) {
410
410
  ${T}
411
411
  }
412
412
  }
413
- `,variables:{username:t.username}},r)).body.data)==null?void 0:o.user;if(!n)throw new Error("User not found.");return{data:O(n)}}async getRepo(t,r={}){var o;let s=x(t),n=await v(this.config,{query:`
413
+ `,variables:{username:t.username}},r)).body.data)==null?void 0:o.user;if(!s)throw new Error("User not found.");return{data:O(s)}}async getRepo(t,r={}){var o;let n=_(t),s=await v(this.config,{query:`
414
414
  query getRepo($fullPath: ID!) {
415
415
  project(fullPath: $fullPath) {
416
- ${xe}
416
+ ${De}
417
417
  }
418
418
  }
419
- `,variables:{fullPath:s}},r);if(!((o=n.body.data)!=null&&o.project))throw new Error(`Repository ${s} not found`);return{data:ke(n.body.data.project)}}async getRepos(t,r={}){let s=t.map(x),n=s.map((a,i)=>`
419
+ `,variables:{fullPath:n}},r);if(!((o=s.body.data)!=null&&o.project))throw new Error(`Repository ${n} not found`);return{data:Ge(s.body.data.project)}}async getRepos(t,r={}){let n=t.map(_),s=n.map((a,i)=>`
420
420
  getRepo_${i}: project(fullPath: "${a}") {
421
- ${xe}
421
+ ${De}
422
422
  }
423
423
  `).join(`
424
424
  `),o=await v(this.config,{query:`
425
425
  query batchGetRepos {
426
- ${n}
426
+ ${s}
427
427
  }
428
- `},r);if(!o.body.data)throw new Error(o.statusText||"Unknown error");return{data:s.map((a,i)=>{let u=o.body.data[`getRepo_${i}`];if(!u)throw new Error(`Repository ${a} not found`);return ke(u)})}}async getRefs(t,r,s={}){var u;let n=x(r.repo),o=new URL(`${se(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",D.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=x(t.repo),n=new URL(`${se(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=(m,g,d)=>{u.push(`$${m}: ${d}`),l.push(`${m}: $${m}`),i[m]=g};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=x(n),{variables:a,variableTypes:i,mergeRequestArguments:u}=this.getVariablesForPullRequests(t),l={fullPath:o,...a},p=await v(this.config,{query:`
428
+ `},r);if(!o.body.data)throw new Error(o.statusText||"Unknown error");return{data:n.map((a,i)=>{let u=o.body.data[`getRepo_${i}`];if(!u)throw new Error(`Repository ${a} not found`);return Ge(u)})}}async getRefs(t,r,n={}){var u;let s=_(r.repo),o=new URL(`${pe(this.config,n)}/projects/${encodeURIComponent(s)}/repository/${t}`);o.searchParams.set("page",((u=r.page)==null?void 0:u.toString())||"1"),o.searchParams.set("per_page",D.toString());let a=await this.config.request({url:o.toString(),headers:y(n.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 n=_(t.repo),s=new URL(`${pe(this.config,r)}/projects/${encodeURIComponent(n)}/repository/files/${encodeURIComponent(t.path)}/blame`);s.searchParams.set("ref",t.ref);let o=await this.config.request({url:s.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:n,authorLogin:s,assigneeLogins:o,reviewRequestedLogin:a}=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"),o&&p("assigneeUsername",o[0],"String"),n!=null&&p("draft",n,"Boolean"),a&&p("reviewerUsername",a,"String"),{variables:i,variableTypes:u,mergeRequestArguments:l}}async getPullRequestsForRepo(t,r={}){var b,f,h;let{cursor:n,repo:s}=t||{},o=_(s),{variables:a,variableTypes:i,mergeRequestArguments:u}=this.getVariablesForPullRequests(t),l={fullPath:o,...a},p=await v(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
- ${qe}
451
+ ${$e}
452
452
  }
453
453
  }
454
454
  }
455
455
  }
456
- `,variables:{...l,after:s}},r),m=[],g=(b=p.body.data)==null?void 0:b.project,d={name:(g==null?void 0:g.name)||"",owner:((g==null?void 0:g.fullPath)||"").split("/").slice(0,-1).join("/")};return(((f=g==null?void 0:g.mergeRequests)==null?void 0:f.nodes)||[]).forEach(R=>{m.push(Oe(R,d))}),{pageInfo:(h=g==null?void 0:g.mergeRequests)==null?void 0:h.pageInfo,data:m}}async getPullRequestsForRepos(t,r={}){var g,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 v(this.config,{query:`
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(Le(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(Q)?h:`${Q}${h}`),{variables:o,variableTypes:a,mergeRequestArguments:i}=this.getVariablesForPullRequests(t),u={projectIds:s,...o},l=await v(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
- ${qe}
480
+ ${$e}
481
481
  }
482
482
  }
483
483
  }
484
484
  }
485
485
  }
486
- `,variables:{...u,after:s}},r),p=[];return(((d=(g=l.body.data)==null?void 0:g.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(S=>{p.push(Oe(S,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,m;let s=Rt(t),n=await v(this.config,{query:`
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(S=>{p.push(Le(S,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 o,a,i,u,l,p,m;let n=pt(t),s=await v(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
- ${ne}
492
+ ${de}
493
493
  }
494
494
  }
495
495
  }
496
- `,variables:{issueId:t.id,projectId:s}},r);if(!((o=n.body.data)!=null&&o.project))throw new Error(`Repository ${s} not found`);if(!((i=(a=n.body.data)==null?void 0:a.project)!=null&&i.issue))throw new Error(`Issue ${t.id} not found`);return{data:oe((l=(u=n.body.data)==null?void 0:u.project)==null?void 0:l.issue,{name:(p=n.body.data)==null?void 0:p.project.name,owner:(m=n.body.data)==null?void 0:m.project.fullPath.split("/").slice(0,-1).join("/")})}}getVariablesForIssues(t){let{updatedBefore:r,authorLogin:s,assigneeLogins:n}=t||{},o={},a=[],i=[],u=(l,p,m)=>{a.push(`$${l}: ${m}`),i.push(`${l}: $${l}`),o[l]=p};return r&&u("updatedBefore",r,"Time"),s&&u("authorUsername",s,"String"),n&&u("assigneeUsername",n[0],"String"),{variables:o,variableTypes:a,issueArguments:i}}async getIssuesForRepo(t,r={}){var f,h,R;let{cursor:s,repo:n}=t||{},o=x(n),{variables:a,variableTypes:i,issueArguments:u}=this.getVariablesForIssues(t),l={fullPath:o,...a},p=`
496
+ `,variables:{issueId:t.id,projectId:n}},r);if(!((o=s.body.data)!=null&&o.project))throw new Error(`Repository ${n} not found`);if(!((i=(a=s.body.data)==null?void 0:a.project)!=null&&i.issue))throw new Error(`Issue ${t.id} not found`);return{data:me((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||{},o={},a=[],i=[],u=(l,p,m)=>{a.push(`$${l}: ${m}`),i.push(`${l}: $${l}`),o[l]=p};return r&&u("updatedBefore",r,"Time"),n&&u("authorUsername",n,"String"),s&&u("assigneeUsername",s[0],"String"),{variables:o,variableTypes:a,issueArguments:i}}async getIssuesForRepo(t,r={}){var f,h,R;let{cursor:n,repo:s}=t||{},o=_(s),{variables:a,variableTypes:i,issueArguments:u}=this.getVariablesForIssues(t),l={fullPath:o,...a},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
- ${ne}
515
+ ${de}
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 v(this.config,{query:p,variables:{...l,after:s}},r),g=[],d=(f=m.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(I=>{g.push(oe(I,c))}),{pageInfo:(R=d==null?void 0:d.issues)==null?void 0:R.pageInfo,data:g.sort((I,E)=>(I.updatedDate||I.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=`
523
+ }`,m=await v(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(me(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(Q)?R:`${Q}${R}`),{variables:o,variableTypes:a,mergeRequestArguments:i}=this.getVariablesForPullRequests(t),u={projectIds:s,...o},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
- ${ne}
547
+ ${de}
548
548
  }
549
549
  }
550
550
  }
551
551
  }
552
- }`,p=await v(this.config,{query:l,variables:{...u,after:s}},r),m=[];return(((c=(d=p.body.data)==null?void 0:d.projects)==null?void 0:c.nodes)||[]).forEach(R=>{var S;let I={name:R.name,owner:R.fullPath.split("/").slice(0,-1).join("/")};(((S=R.issues)==null?void 0:S.nodes)||[]).forEach(Be=>m.push(oe(Be,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 yt="https://api.atlassian.com/ex/jira",It=100,Pt=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}},W=class extends C{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||yt}/${t.resourceId}/rest/api/2/search?jql=${i.join(" AND ")}&startAt=0&maxResults=${It}&fields=${["assignee","comment","summary","created","creator","updated","votes"].join(",")}`,headers:y(r.token||this.config.token)})).body.issues.map(Pt)}}};var vt="https://api.trello.com",Ct=1e3,Ut=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}},V=class extends C{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||vt}/1/search?key=${n}&query=${u}&cards_limit=${Ct}&token=${r.token||this.config.token}`,headers:y(r.token||this.config.token)})).body.cards.map(Ut)}}};var ue={};G(ue,{AzureDevOps:()=>ie});var ie=class{async getIssueUniqueId(t,r,s,n=""){let o=[];return o.push(n),o.push(t),o.push(r),o.push(s),JSON.stringify(o)}async getPullRequestUniqueId(t,r,s,n,o=""){let a=[];return a.push(o),a.push(t),a.push(r),a.push(s),a.push(n),JSON.stringify(a)}};var pe={};G(pe,{Bitbucket:()=>le});var le=class{async getIssueUniqueId(t,r){return JSON.stringify(["",t,r])}async getPullRequestUniqueId(t,r){return JSON.stringify(["",t,r])}};var me={};G(me,{BitbucketServer:()=>de});var de=class{async getIssueUniqueId(t,r,s){return JSON.stringify([s,t,r])}async getPullRequestUniqueId(t,r,s){return JSON.stringify([s,t,r])}};var ce={};G(ce,{GitHub:()=>ge});var ge=class{async getIssueUniqueId(t,r=""){let s=[];return s.push(r),s.push(t),JSON.stringify(s)}async getPullRequestUniqueId(t,r=""){let s=[];return s.push(r),s.push(t),JSON.stringify(s)}};var fe={};G(fe,{GitLab:()=>he});var he=class{async getIssueUniqueId(t,r=""){let s=[];return s.push(r),s.push(t),JSON.stringify(s)}async getPullRequestUniqueId(t,r=""){let s=[];return s.push(r),s.push(t),JSON.stringify(s)}};var be={};G(be,{Jira:()=>Re});var Re=class{async getIssueUniqueId(t,r,s,n=""){let o=[];return o.push(n),o.push(t),o.push(r),o.push(s),JSON.stringify(o)}};var Ie={};G(Ie,{Trello:()=>ye});var ye=class{async getIssueUniqueId(t,r,s,n=""){let o=[];return o.push(n),o.push(t),o.push(r),o.push(s),JSON.stringify(o)}};var wt=e=>{let t={request:e==null?void 0:e.request};return{azureDevOps:new B({...t,...e==null?void 0:e.azureDevOps}),bitbucket:new N({...t,...e==null?void 0:e.bitbucket}),bitbucketServer:new j({...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 W({...t,...e==null?void 0:e.jira}),trello:new V({...t,...e==null?void 0:e.trello})}},Et=wt;var St={azureDevOps:ue,bitbucket:pe,bitbucketServer:me,github:ce,gitlab:fe,jira:be,trello:Ie};
552
+ }`,p=await v(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 S;let I={name:R.name,owner:R.fullPath.split("/").slice(0,-1).join("/")};(((S=R.issues)==null?void 0:S.nodes)||[]).forEach(Ae=>m.push(me(Ae,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 mt="https://api.atlassian.com/ex/jira",ct=100,gt=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}},W=class extends C{async getIssuesForProject(t,r={}){let{assigneeLogins:n,authorLogin:s,mentionLogin:o,project:a}=t||{},i=[`project = "${a}"`];return s&&i.push(`creator in (${s})`),n&&i.push(`assignee in (${n.join(", ")})`),o&&i.push(`comment ~ ${o}`),{data:(await this.config.request({url:`${r.baseUrl||mt}/${t.resourceId}/rest/api/2/search?jql=${i.join(" AND ")}&startAt=0&maxResults=${ct}&fields=${["assignee","comment","summary","created","creator","updated","votes"].join(",")}`,headers:y(r.token||this.config.token)})).body.issues.map(gt)}}};var ht="https://api.trello.com",ft=1e3,Rt=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}},V=class extends C{async getIssuesForBoard(t,r={}){let n=["-is:archived","sort:edited"],{appKey:s,boardId:o,filterText:a,assigneeLogins:i}=t||{};i&&n.push("@me");let u=`${a?`${a}`:""}${n.join(" ")} board:${o}`;return{data:(await this.config.request({url:`${r.baseUrl||ht}/1/search?key=${s}&query=${u}&cards_limit=${ft}&token=${r.token||this.config.token}`,headers:y(r.token||this.config.token)})).body.cards.map(Rt)}}};var J={};G(J,{getIssueUniqueId:()=>bt,getPullRequestUniqueId:()=>yt});var bt=async(e,t,r,n="")=>{let s=[];return s.push(n),s.push(e),s.push(t),s.push(r),JSON.stringify(s)},yt=async(e,t,r,n,s="")=>{let o=[];return o.push(s),o.push(e),o.push(t),o.push(r),o.push(n),JSON.stringify(o)};var X={};G(X,{getIssueUniqueId:()=>It,getPullRequestUniqueId:()=>Pt});var It=async(e,t)=>JSON.stringify(["",e,t]),Pt=async(e,t)=>JSON.stringify(["",e,t]);var K={};G(K,{getIssueUniqueId:()=>vt,getPullRequestUniqueId:()=>Ct});var vt=async(e,t,r)=>JSON.stringify([r,e,t]),Ct=async(e,t,r)=>JSON.stringify([r,e,t]);var Z={};G(Z,{getIssueUniqueId:()=>Ut,getPullRequestUniqueId:()=>wt});var Ut=async(e,t="")=>{let r=[];return r.push(t),r.push(e),JSON.stringify(r)},wt=async(e,t="")=>{let r=[];return r.push(t),r.push(e),JSON.stringify(r)};var Y={};G(Y,{getIssueUniqueId:()=>Et,getPullRequestUniqueId:()=>St});var Et=async(e,t="")=>{let r=[];return r.push(t),r.push(e),JSON.stringify(r)},St=async(e,t="")=>{let r=[];return r.push(t),r.push(e),JSON.stringify(r)};var ee={};G(ee,{getIssueUniqueId:()=>Dt});var Dt=async(e,t,r,n="")=>{let s=[];return s.push(n),s.push(e),s.push(t),s.push(r),JSON.stringify(s)};var te={};G(te,{getIssueUniqueId:()=>$t});var $t=(e,t,r,n="")=>{let s=[];return s.push(n),s.push(e),s.push(t),s.push(r),JSON.stringify(s)};var Gt=e=>{let t={request:e==null?void 0:e.request};return{azureDevOps:new B({...t,...e==null?void 0:e.azureDevOps}),bitbucket:new N({...t,...e==null?void 0:e.bitbucket}),bitbucketServer:new j({...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 W({...t,...e==null?void 0:e.jira}),trello:new V({...t,...e==null?void 0:e.trello})}},Lt=Gt;var At={azureDevOps:J,bitbucket:X,bitbucketServer:K,github:Z,gitlab:Y,jira:ee,trello:te};
@@ -1,4 +1,2 @@
1
- export declare class AzureDevOps {
2
- getIssueUniqueId(organizationName: string, projectId: string, issueId: string, domain?: string): Promise<string>;
3
- getPullRequestUniqueId(organizationName: string, projectId: string, repoId: string, pullRequestId: string, domain?: string): Promise<string>;
4
- }
1
+ export declare const getIssueUniqueId: (organizationName: string, projectId: string, issueId: string, domain?: string) => Promise<string>;
2
+ export declare const getPullRequestUniqueId: (organizationName: string, projectId: string, repoId: string, pullRequestId: string, domain?: string) => Promise<string>;
@@ -1,4 +1,2 @@
1
- export declare class Bitbucket {
2
- getIssueUniqueId(repoId: string, issueId: string): Promise<string>;
3
- getPullRequestUniqueId(repoId: string, pullRequestId: string): Promise<string>;
4
- }
1
+ export declare const getIssueUniqueId: (repoId: string, issueId: string) => Promise<string>;
2
+ export declare const getPullRequestUniqueId: (repoId: string, pullRequestId: string) => Promise<string>;
@@ -1,4 +1,2 @@
1
- export declare class BitbucketServer {
2
- getIssueUniqueId(repoId: string, issueId: string, domain: string): Promise<string>;
3
- getPullRequestUniqueId(repoId: string, pullRequestId: string, domain: string): Promise<string>;
4
- }
1
+ export declare const getIssueUniqueId: (repoId: string, issueId: string, domain: string) => Promise<string>;
2
+ export declare const getPullRequestUniqueId: (repoId: string, pullRequestId: string, domain: string) => Promise<string>;
@@ -1,4 +1,2 @@
1
- export declare class GitHub {
2
- getIssueUniqueId(issueGraphqlId: string, domain?: string): Promise<string>;
3
- getPullRequestUniqueId(pullRequestGraphqlId: string, domain?: string): Promise<string>;
4
- }
1
+ export declare const getIssueUniqueId: (issueGraphqlId: string, domain?: string) => Promise<string>;
2
+ export declare const getPullRequestUniqueId: (pullRequestGraphqlId: string, domain?: string) => Promise<string>;
@@ -1,4 +1,2 @@
1
- export declare class GitLab {
2
- getIssueUniqueId(issueGraphqlId: string, domain?: string): Promise<string>;
3
- getPullRequestUniqueId(pullRequestGraphqlId: string, domain?: string): Promise<string>;
4
- }
1
+ export declare const getIssueUniqueId: (issueGraphqlId: string, domain?: string) => Promise<string>;
2
+ export declare const getPullRequestUniqueId: (pullRequestGraphqlId: string, domain?: string) => Promise<string>;
@@ -1,3 +1 @@
1
- export declare class Jira {
2
- getIssueUniqueId(resourceId: string, projectId: string, issueId: string, domain?: string): Promise<string>;
3
- }
1
+ export declare const getIssueUniqueId: (resourceId: string, projectId: string, issueId: string, domain?: string) => Promise<string>;
@@ -1,3 +1 @@
1
- export declare class Trello {
2
- getIssueUniqueId(accountOrOrgId: string, projectId: string, issueId: string, domain?: string): Promise<string>;
3
- }
1
+ export declare const getIssueUniqueId: (accountOrOrgId: string, projectId: string, issueId: string, domain?: string) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitkraken/provider-apis",
3
- "version": "0.7.2",
3
+ "version": "0.8.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",