Skip to content

Commit c809e0b

Browse files
authored
Improve webhook reviewer type definitions (#3803)
1 parent 53a0574 commit c809e0b

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

packages/core/src/resources/MergeRequests.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type {
1313
import type { CommitDiffSchema, CommitSchema } from './Commits';
1414
import type { IssueSchema, TimeStatsSchema } from './Issues';
1515
import type { ExpandedPipelineSchema, PipelineSchema } from './Pipelines';
16+
import type { ReviewerState } from './Webhooks';
1617
import type { SimpleProjectSchema } from './Projects';
1718
import type { TodoSchema } from './TodoLists';
1819
import type { SimpleUserSchema } from './Users';
@@ -191,7 +192,7 @@ export interface MergeRequestChangesSchema
191192

192193
export interface MergeRequestReviewerSchema extends Record<string, unknown> {
193194
user: MappedOmit<SimpleUserSchema, 'created_at'>;
194-
state: 'unreviewed' | 'requested_changes' | 'reviewed' | 'approved' | 'review_started';
195+
state: ReviewerState;
195196
created_at: string;
196197
}
197198

packages/core/src/resources/Webhooks.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,16 @@ export interface WebhookDiffSchema {
6464
deleted_file: boolean;
6565
}
6666

67-
export type WebhookUserSchema = Pick<SimpleUserSchema, 'id' | 'name' | 'username' | 'avatar_url'>;
67+
export type ReviewerState = 'unreviewed' | 'requested_changes' | 'reviewed' | 'approved' | 'review_started' | 'unapproved';
68+
69+
export type WebhookUserSchema = Pick<SimpleUserSchema, 'id' | 'name' | 'username' | 'avatar_url'> & {
70+
email: string;
71+
};
72+
73+
export interface WebhookReviewerSchema extends WebhookUserSchema {
74+
state: ReviewerState;
75+
re_requested: boolean;
76+
}
6877

6978
export interface BaseWebhookEventSchema {
7079
object_kind: string;
@@ -376,8 +385,8 @@ export interface WebhookMergeRequestEventSchema extends BaseWebhookEventSchema {
376385
current: WebhookUserSchema[] | null;
377386
};
378387
reviewers: {
379-
previous: WebhookUserSchema[] | null;
380-
current: WebhookUserSchema[] | null;
388+
previous: WebhookReviewerSchema[] | null;
389+
current: WebhookReviewerSchema[] | null;
381390
};
382391
labels: {
383392
previous: WebhookLabelSchema[] | null;
@@ -393,7 +402,7 @@ export interface WebhookMergeRequestEventSchema extends BaseWebhookEventSchema {
393402
};
394403
};
395404
assignees: WebhookUserSchema[] | null;
396-
reviewers: WebhookUserSchema[] | null;
405+
reviewers: WebhookReviewerSchema[] | null;
397406
}
398407

399408
export interface WebhookWikiEventSchema extends MappedOmit<BaseWebhookEventSchema, 'event_name'> {

0 commit comments

Comments
 (0)