@gitkraken/provider-apis 0.22.5 → 0.22.6
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 +4 -0
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.22.6
|
|
4
|
+
|
|
5
|
+
- exclude data from archived repos in the results of functions that return PRs: `getPullRequestsForUser`, `getPullRequestsAssociatedWithUser` (GitLab)
|
|
6
|
+
|
|
3
7
|
## 0.22.5
|
|
4
8
|
|
|
5
9
|
- exclude data from archived repos in the results of functions that return PRs and issues: `searchPullRequests`, `getPullRequestsAssociatedWithUser`, `getPullRequestsForRepos`, `searchIssues`, `getIssuesAssociatedWithUser`, `getIssuesForRepos` (GitHub)
|
package/dist/index.js
CHANGED
|
@@ -752,7 +752,7 @@ labels {
|
|
|
752
752
|
${wt}
|
|
753
753
|
}
|
|
754
754
|
}
|
|
755
|
-
${s?"project { id httpUrlToRepo fullPath sshUrlToRepo webUrl } sourceProject { id httpUrlToRepo fullPath sshUrlToRepo webUrl }":""}
|
|
755
|
+
${s?"project { id httpUrlToRepo fullPath sshUrlToRepo webUrl archived } sourceProject { id httpUrlToRepo fullPath sshUrlToRepo webUrl }":""}
|
|
756
756
|
${e?`milestone { ${bt} }`:""}
|
|
757
757
|
${t?`headPipeline { ${gs} }`:""}
|
|
758
758
|
`,J=s=>`${s.namespace}/${s.name}`,ms=s=>`${s.namespace}/${s.name}`,ft=s=>{var e;return{id:s.id.replace(X,""),graphQLId:s.id,namespace:Rt(s.fullPath),name:yt(s.fullPath),webUrl:s.webUrl,httpsUrl:s.httpUrlToRepo,sshUrl:s.sshUrlToRepo,defaultBranch:(e=s.repository)!=null&&e.rootRef?{name:s.repository.rootRef}:null,permission:null}},hs={opened:"OPEN",merged:"MERGED",closed:"CLOSED"},M=(s,e)=>{let t=s.avatarUrl;return!e&&(t!=null&&t.startsWith("/"))&&(t=`https://gitlab.com${t}`),{id:s.id.replace(as,""),graphQLId:s.id,name:s.name,username:s.username,email:s.publicEmail??null,avatarUrl:t,url:s.webUrl}},Pt=s=>({color:s.color,description:s.description,id:s.id.replace(ps,""),graphQLId:s.id,name:s.title}),fs=(s,e)=>s?s==="FAILED"&&e?"WARNING":{CANCELED:"CANCELLED",CREATED:"PENDING",FAILED:"FAILED",MANUAL:"OPTIONAL_ACTION_REQUIRED",PENDING:"PENDING",PREPARING:"RUNNING",RUNNING:"RUNNING",SCHEDULED:"PENDING",SKIPPED:"SKIPPED",SUCCESS:"SUCCESS",WAITING_FOR_CALLBACK:"PENDING",WAITING_FOR_RESOURCE:"PENDING"}[s]:null,ir=(s,e,t,r)=>{var o,i,a,u,l,p,d,c,g,m,I,w;let n=(o=s.reviewers)!=null&&o.nodes?s.reviewers.nodes.map(h=>{var y,v;return{reviewer:M(h,r),state:(y=h.mergeRequestInteraction)!=null&&y.approved?"APPROVED":((v=h.mergeRequestInteraction)==null?void 0:v.reviewState)==="REVIEWED"?"CHANGES_REQUESTED":"CHANGES_REQUESTED"}}):null;return{id:s.id.replace(us,""),graphQLId:s.id,title:s.title,number:parseInt(s.iid,10),state:hs[s.state],commentCount:s.userNotesCount||0,upvoteCount:s.upvotes,author:s.author?M(s.author,r):null,createdDate:new Date(s.createdAt),isDraft:s.draft,repository:{id:e.id,graphQLId:e.graphQLId,name:e.name,owner:{login:e.namespace},remoteInfo:e.httpsUrl&&e.sshUrl?{cloneUrlHTTPS:e.httpsUrl,cloneUrlSSH:e.sshUrl}:null},headRepository:t?{id:t.id,graphQLId:t.graphQLId,name:t.name,owner:{login:t.namespace},remoteInfo:{cloneUrlHTTPS:t.httpsUrl,cloneUrlSSH:t.sshUrl}}:null,headCommit:{buildStatuses:((u=(a=(i=s.headPipeline)==null?void 0:i.stages)==null?void 0:a.nodes)==null?void 0:u.flatMap(h=>{var y,v;return((v=(y=h.jobs)==null?void 0:y.nodes)==null?void 0:v.map(C=>({completedAt:C.finishedAt?new Date(C.finishedAt):null,description:null,name:C.name??null,state:fs(C.status,C.allowFailure),stage:h.name??null,startedAt:new Date(C.createdAt),url:`${e.webUrl}/-/jobs/${C.id.replace(cs,"")}`})))??[]}))??[]},baseRef:{name:s.targetBranch,oid:((l=s.diffRefs)==null?void 0:l.baseSha)??null},headRef:{name:s.sourceBranch,oid:((p=s.diffRefs)==null?void 0:p.headSha)??null},url:s.webUrl,updatedDate:new Date(s.updatedAt),closedDate:s.mergedAt?new Date(s.mergedAt):null,mergedDate:s.mergedAt?new Date(s.mergedAt):null,assignees:(d=s.assignees)!=null&&d.nodes?s.assignees.nodes.map(h=>M(h,r)):null,reviews:n,reviewDecision:s.approved?"APPROVED":z(n),additions:((c=s.diffStatsSummary)==null?void 0:c.additions)||0,deletions:((g=s.diffStatsSummary)==null?void 0:g.deletions)||0,fileCount:((m=s.diffStatsSummary)==null?void 0:m.fileCount)||0,commitCount:s.commitCount||0,mergeableState:is[s.mergeStatusEnum],milestone:s.milestone?Et(s.milestone,e.webUrl):null,labels:((w=(I=s.labels)==null?void 0:I.nodes)==null?void 0:w.map(Pt))??[],permissions:null}},It=(s,e,t)=>{var r,n;return{author:M(s.author,t),assignees:s.assignees.nodes.map(o=>M(o,t)),commentCount:s.userNotesCount,closedDate:s.closedAt?new Date(s.closedAt):null,createdDate:new Date(s.createdAt),description:s.description,graphQLId:s.id,id:s.id.replace(ls,""),labels:((n=(r=s.labels)==null?void 0:r.nodes)==null?void 0:n.map(Pt))??[],number:s.iid,repository:{id:e.id.replace(X,""),graphQLId:e.id,name:e.name,owner:{login:e.namespace}},updatedDate:new Date(s.updatedAt),upvoteCount:s.upvotes,state:{name:s.state,color:null},type:s.type,title:s.title,url:s.webUrl,milestone:s.milestone?Et(s.milestone,e.webUrl):null}},Et=(s,e)=>({id:s.id.replace(ds,""),graphQLId:s.id,number:parseInt(s.iid,10),title:s.title,description:s.description,isOpen:s.state==="active",url:`${e}/-/${s.webPath.replace(/.+?\/-\//,"")}`,startDate:s.startDate?new Date(s.startDate):null,dueDate:s.dueDate?new Date(s.dueDate):null}),ne=class extends k{getIsSelfHosted(e){return!!e.baseUrl||!!this.config.baseUrl}async getCurrentUser(e={},t={}){var o;let n=(o=(await b(this.config,{query:`
|
|
@@ -851,7 +851,7 @@ query getPullRequestsForUser($username: String! $cursor: String) {
|
|
|
851
851
|
}
|
|
852
852
|
}
|
|
853
853
|
}
|
|
854
|
-
`,variables:{username:e.username,cursor:e.cursor}},t);if(!n.body.data)throw new Error(we(n.body.errors)||n.statusText||"Unknown error");if(!n.body.data.user)throw new Error("User not found");let o=n.body.data.user[r];if(!o)throw new Error("Unexpected response");return{pageInfo:o.pageInfo,data:((i=o.nodes)==null?void 0:i.map(a=>ir(a,nr(a.project),nr(a.sourceProject),this.getIsSelfHosted(t))))||[]}}async getPullRequestsAssociatedWithUser(e,t={}){var c;let[r,n,o]=((c=e.cursor)==null?void 0:c.split(";"))||[void 0,void 0,void 0],[i,a,u]=await Promise.all([r==="null"?null:this.getPullRequestsForUser({username:e.username,association:"authored",cursor:r},t),n==="null"?null:this.getPullRequestsForUser({username:e.username,association:"assigned",cursor:n},t),o==="null"?null:this.getPullRequestsForUser({username:e.username,association:"reviewRequested",cursor:o},t)]),l={},p=[],d=g=>{l[g.id]||(l[g.id]=!0,p.push(g))};return i==null||i.data.forEach(d),a==null||a.data.forEach(d),u==null||u.data.forEach(d),{pageInfo:{hasNextPage:(i==null?void 0:i.pageInfo.hasNextPage)||(a==null?void 0:a.pageInfo.hasNextPage)||(u==null?void 0:u.pageInfo.hasNextPage)||!1,endCursor:`${(i==null?void 0:i.pageInfo.hasNextPage)&&(i==null?void 0:i.pageInfo.endCursor)||"null"};${(a==null?void 0:a.pageInfo.hasNextPage)&&(a==null?void 0:a.pageInfo.endCursor)||"null"};${(u==null?void 0:u.pageInfo.hasNextPage)&&(u==null?void 0:u.pageInfo.endCursor)||"null"}`},data:p}}getVariablesForPullRequests(e){let{updatedBefore:t,isDraft:r,authorLogin:n,assigneeLogins:o,reviewRequestedLogin:i}=e||{},a={},u=[],l=[],p=(d,c,g)=>{u.push(`$${d}: ${g}`),l.push(`${d}: $${d}`),a[d]=c};return t&&p("updatedBefore",t,"Time"),n&&p("authorUsername",n,"String"),o&&p("assigneeUsername",o[0],"String"),r!=null&&p("draft",r,"Boolean"),i&&p("reviewerUsername",i,"String"),{variables:a,variableTypes:u,mergeRequestArguments:l}}async getPullRequestsForRepo(e,t={}){var I,w,h;let{cursor:r,repo:n}=e||{},o=J(n),{variables:i,variableTypes:a,mergeRequestArguments:u}=this.getVariablesForPullRequests(e),l={fullPath:o,...i},p=await b(this.config,{query:`
|
|
854
|
+
`,variables:{username:e.username,cursor:e.cursor}},t);if(!n.body.data)throw new Error(we(n.body.errors)||n.statusText||"Unknown error");if(!n.body.data.user)throw new Error("User not found");let o=n.body.data.user[r];if(!o)throw new Error("Unexpected response");return{pageInfo:o.pageInfo,data:((i=o.nodes)==null?void 0:i.filter(a=>!a.project.archived).map(a=>ir(a,nr(a.project),nr(a.sourceProject),this.getIsSelfHosted(t))))||[]}}async getPullRequestsAssociatedWithUser(e,t={}){var c;let[r,n,o]=((c=e.cursor)==null?void 0:c.split(";"))||[void 0,void 0,void 0],[i,a,u]=await Promise.all([r==="null"?null:this.getPullRequestsForUser({username:e.username,association:"authored",cursor:r},t),n==="null"?null:this.getPullRequestsForUser({username:e.username,association:"assigned",cursor:n},t),o==="null"?null:this.getPullRequestsForUser({username:e.username,association:"reviewRequested",cursor:o},t)]),l={},p=[],d=g=>{l[g.id]||(l[g.id]=!0,p.push(g))};return i==null||i.data.forEach(d),a==null||a.data.forEach(d),u==null||u.data.forEach(d),{pageInfo:{hasNextPage:(i==null?void 0:i.pageInfo.hasNextPage)||(a==null?void 0:a.pageInfo.hasNextPage)||(u==null?void 0:u.pageInfo.hasNextPage)||!1,endCursor:`${(i==null?void 0:i.pageInfo.hasNextPage)&&(i==null?void 0:i.pageInfo.endCursor)||"null"};${(a==null?void 0:a.pageInfo.hasNextPage)&&(a==null?void 0:a.pageInfo.endCursor)||"null"};${(u==null?void 0:u.pageInfo.hasNextPage)&&(u==null?void 0:u.pageInfo.endCursor)||"null"}`},data:p}}getVariablesForPullRequests(e){let{updatedBefore:t,isDraft:r,authorLogin:n,assigneeLogins:o,reviewRequestedLogin:i}=e||{},a={},u=[],l=[],p=(d,c,g)=>{u.push(`$${d}: ${g}`),l.push(`${d}: $${d}`),a[d]=c};return t&&p("updatedBefore",t,"Time"),n&&p("authorUsername",n,"String"),o&&p("assigneeUsername",o[0],"String"),r!=null&&p("draft",r,"Boolean"),i&&p("reviewerUsername",i,"String"),{variables:a,variableTypes:u,mergeRequestArguments:l}}async getPullRequestsForRepo(e,t={}){var I,w,h;let{cursor:r,repo:n}=e||{},o=J(n),{variables:i,variableTypes:a,mergeRequestArguments:u}=this.getVariablesForPullRequests(e),l={fullPath:o,...i},p=await b(this.config,{query:`
|
|
855
855
|
query getPullRequestsForRepo(
|
|
856
856
|
$fullPath: ID!
|
|
857
857
|
$after: String
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitkraken/provider-apis",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.6",
|
|
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",
|