1import { GitFileDiff } from '../Git'; 2import { PullRequest } from '../GitHub'; 3 4/** 5 * See "Properties of the comments items" section on 6 * https://docs.github.com/en/rest/reference/pulls#create-a-review-for-a-pull-request 7 */ 8export type ReviewComment = { 9 path: string; 10 position: number; 11 body: string; 12}; 13 14/** 15 * The result of code reviews that is being used to generate the final review comment/report. 16 */ 17export type ReviewOutput = { 18 status: ReviewStatus; 19 title?: string; 20 body?: string; 21 comments?: ReviewComment[]; 22}; 23 24/** 25 * An input is an object that is passed to each code reviewer. 26 * It contains some data that are commonly used by all reviewers. 27 */ 28export type ReviewInput = { 29 pullRequest: PullRequest; 30 diff: GitFileDiff[]; 31}; 32 33/** 34 * A status of the review output. 35 */ 36export enum ReviewStatus { 37 /** 38 * Passive outputs are not included in the final report, 39 * but they may have some comments/suggestions which are not obligatory to apply. 40 */ 41 PASSIVE = 1, 42 43 /** 44 * Warnings are included in the final report and are not obligatory to fix. 45 */ 46 WARN = 2, 47 48 /** 49 * Errors are included in the final report and are obligatory to fix. 50 * It implies that the review will request for changes (will send `ReviewEvent.REQUEST_CHANGES` event). 51 */ 52 ERROR = 3, 53} 54 55/** 56 * Review event that is sent during review creation/submission. 57 * The final review state depends on this event. 58 */ 59export enum ReviewEvent { 60 COMMENT = 'COMMENT', 61 APPROVE = 'APPROVE', 62 REQUEST_CHANGES = 'REQUEST_CHANGES', 63} 64 65/** 66 * State of someone's review. 67 */ 68export enum ReviewState { 69 PENDING = 'PENDING', 70 COMMENTED = 'COMMENTED', 71 APPROVED = 'APPROVED', 72 CHANGES_REQUESTED = 'CHANGES_REQUESTED', 73} 74