11/* eslint-disable @typescript-eslint/naming-convention */
22import { getOctokit } from '@actions/github'
3+ import { average , getHoursAgo , minutesBetweenDates , snapDate , SnapType } from '@krauters/utils'
34
45import { ignoreFilenamesForChanges } from '../../defaults.js'
5- import { adjustDate , average , getHoursAgo , getRelativeHumanReadableAge , minutesBetweenDates } from '../misc.js'
6- import { SnapType } from '../structures.js'
6+ import { getRelativeHumanReadableAge } from '../misc.js'
77import {
88 type FilesAndChanges ,
99 type GetCommitsProps ,
@@ -37,16 +37,17 @@ export class GitHubClient {
3737
3838 /**
3939 * A GitHub client for interacting with a GitHub API.
40- * @param {GitHubClientProps } props - Properties toi configure GitHub client.
40+ *
41+ * @param props Properties toi configure GitHub client.
4142 */
4243 constructor ( { options = { } , token } : GitHubClientProps ) {
4344 this . client = getOctokit ( token , options )
4445 }
4546
4647 /**
4748 * Get commits in a pull.
48- * @param { GetCommitsProps } props - Properties for which commit to get.
49- * @returns { Promise<GitHubPullCommits> }
49+ *
50+ * @param props Properties for which commit to get.
5051 */
5152 async getCommits ( { number, repo } : GetCommitsProps ) : Promise < GitHubPullCommits > {
5253 return await this . client . paginate ( this . client . rest . pulls . listCommits , {
@@ -58,8 +59,8 @@ export class GitHubClient {
5859
5960 /**
6061 * Get a GitHub user's email address from a username.
61- * @param { string } username - A GitHub username.
62- * @returns { Promise<string | undefined> }
62+ *
63+ * @param username A GitHub username.
6364 */
6465 async getEmail ( username : string ) : Promise < string | undefined > {
6566 console . log ( `Getting email from GitHub for username [${ username } ]...` )
@@ -72,8 +73,8 @@ export class GitHubClient {
7273
7374 /**
7475 * Get the number of changes for a given pull.
75- * @param { GetFilesAndChangesProps } props - Properties for which files and changes to get.
76- * @returns { Promise<FilesAndChanges> }
76+ *
77+ * @param props Properties for which files and changes to get.
7778 */
7879 async getFilesAndChanges ( { number, repo } : GetFilesAndChangesProps ) : Promise < FilesAndChanges > {
7980 const { data : fileList } = await this . client . rest . pulls . listFiles ( {
@@ -97,7 +98,6 @@ export class GitHubClient {
9798
9899 /**
99100 * Get organization associated with current token.
100- * @returns {Promise<Organization> }
101101 */
102102 async getOrg ( ) : Promise < Organization > {
103103 if ( ! this . cacheOrganization ) {
@@ -126,16 +126,15 @@ export class GitHubClient {
126126
127127 /**
128128 * Get organization name associated with current token.
129- * @returns {Promise<string> }
130129 */
131130 async getOrgName ( ) : Promise < string > {
132131 return ( await this . getOrg ( ) ) . name
133132 }
134133
135134 /**
136135 * Get a pull report.
137- * @param { Pull[] } pulls - Pulls against which a report will be generated.
138- * @returns { unknown }
136+ *
137+ * @param pulls Pulls against which a report will be generated.
139138 */
140139 getPullReport ( pulls : Pull [ ] ) {
141140 const report : Record < string , ReportItem > = { }
@@ -183,11 +182,11 @@ export class GitHubClient {
183182
184183 /**
185184 * Get all pulls in the GitHub org.
186- * @param { GetPullsProps } props - Properties for which pulls to get.
187- * @returns { Promise<Pull[]> }
185+ *
186+ * @param props Properties for which pulls to get.
188187 */
189188 async getPulls ( {
190- oldest = adjustDate ( { months : - 6 , snap : SnapType . Month } ) ,
189+ oldest = snapDate ( new Date ( ) , { months : - 6 , snap : SnapType . Month } ) ,
191190 onlyGhReviews = false ,
192191 repositories,
193192 state = PullState . All ,
@@ -283,10 +282,9 @@ export class GitHubClient {
283282 }
284283
285284 /**
286- *
287285 * Get repositories in the GitHub org that the token has access to.
288- * @param { GetRepositoriesProps } props - Properties for which repositories to get.
289- * @returns { Promise<GitHubRepositories> }
286+ *
287+ * @param props Properties for which repositories to get.
290288 */
291289 async getRepositories ( {
292290 repositoryFilter = [ ] ,
@@ -322,9 +320,9 @@ export class GitHubClient {
322320
323321 /**
324322 * Get requested reviewers in a pull.
325- * @param { string } repo - The repository associated with the pull.
326- * @param { number } number - The pull number .
327- * @returns { Promise<GitHubPullRequestedReviewers> }
323+ *
324+ * @param repo The repository associated with the pull .
325+ * @param number The pull number.
328326 */
329327 async getRequestedReviewers ( repo : string , number : number ) : Promise < GitHubPullRequestedReviewers > {
330328 const response = await this . client . rest . pulls . listRequestedReviewers ( {
@@ -338,9 +336,9 @@ export class GitHubClient {
338336
339337 /**
340338 * Get the required number of reviewers for a branch based on branch rules.
341- * @param { string } repo - The repository to get branch rules for.
342- * @param { string } branchName - The branch to get branch rules for.
343- * @returns { Promise<number> }
339+ *
340+ * @param repo The repository to get branch rules for.
341+ * @param branchName The branch to get branch rules for.
344342 */
345343 async getRequiredReviewers ( repo : string , branchName : string ) : Promise < number > {
346344 const org = await this . getOrgName ( )
@@ -392,12 +390,12 @@ export class GitHubClient {
392390
393391 /**
394392 * Get a report of the pull reviews.
395- * @param { string } repo - The repository associated with the pull.
396- * @param { number } number - The pull number .
397- * @param { string } baseRef - The base ref of the pull.
398- * @param { stringp[] } requestedReviewers - A list of requested reviewer logins .
399- * @param { boolean } [onlyGhReviews] - Only return Github review data in the report .
400- * @returns { Promise<ReviewReport> }
393+ *
394+ * @param repo The repository associated with the pull .
395+ * @param number The pull number .
396+ * @param baseRef The base ref of the pull .
397+ * @param requestedReviewers A list of requested reviewer logins .
398+ * @param [onlyGhReviews] Only return Github review data in the report.
401399 */
402400 async getReviewReport (
403401 repo : string ,
@@ -481,8 +479,8 @@ export class GitHubClient {
481479
482480 /**
483481 * Get a GitHub user object from a username.
484- * @param { string } username - A GitHub username.
485- * @returns { Promise<GitHubUser> }
482+ *
483+ * @param username A GitHub username.
486484 */
487485 async getUser ( username : string ) : Promise < GitHubUser > {
488486 console . log ( `Getting user from GitHub for username [${ username } ]...` )
0 commit comments