Skip to content
Clone
759ae5e
186 lines 5.1 KB
/**
* Pull-request (PR) row shapes.
*
* Types are derived from the generated response envelopes wherever the backend
* exposes one, so a schema change in `bun run gen:api` shows up here as a type
* error. Paged payloads are typed as the generic `Page` schema by the
* generator, so their rows are cast structurally in `api.ts`.
*/
import type {
AppResponseData_MergePullDto,
AppResponseData_MergeStatusDto,
AppResponseData_PullChecksDto,
AppResponseData_PullCommentDto,
AppResponseData_PullDto,
AppResponseData_Vec_IssuePullLinkDto,
AppResponseData_PullGateDto,
AppResponseData_PullReviewDto,
AppResponseData_PullSummaryDto,
AppResponseData_Vec_ChangedPathDiffDto,
AppResponseData_Vec_LabelDto,
AppResponseData_Vec_MergeCommitDto,
AppResponseData_Vec_PullAssigneeDto,
AppResponseData_Vec_PullCommentThreadDto,
AppResponseData_Vec_PullReviewerDto,
MergeMethod,
PullState,
ReviewIntent,
ReviewState,
ReviewerState,
UserDto,
} from '@/shared/api'
export type {
MergeMethod,
PullState,
ReviewIntent,
ReviewState,
ReviewerState,
UserDto,
}
export const PULL_STATES = ['open', 'closed', 'merged'] as const
export const MY_PULL_SCOPES = ['created', 'review-requested', 'reviewed'] as const
export type MyPullScope = (typeof MY_PULL_SCOPES)[number]
/** Full pull payload (`GET …/pulls/{pull_ref}`). */
export type Pull = NonNullable<AppResponseData_PullDto['data']>
export type PullComment = NonNullable<AppResponseData_PullCommentDto['data']>
export type PullCommentThread = NonNullable<
NonNullable<AppResponseData_Vec_PullCommentThreadDto['data']>[number]
>
export type PullReview = NonNullable<AppResponseData_PullReviewDto['data']>
export type PullReviewer = NonNullable<
NonNullable<AppResponseData_Vec_PullReviewerDto['data']>[number]
>
export type PullAssignee = NonNullable<
NonNullable<AppResponseData_Vec_PullAssigneeDto['data']>[number]
>
export type PullChecks = NonNullable<AppResponseData_PullChecksDto['data']>
export type PullGate = NonNullable<AppResponseData_PullGateDto['data']>
/** The gate embedded in `PullGate` (no standalone response envelope). */
export type MergeGate = PullGate['gate']
export type PullSummary = NonNullable<AppResponseData_PullSummaryDto['data']>
/** `{pull, result, summary}` of a successful merge. */
export type MergeOutcome = NonNullable<AppResponseData_MergePullDto['data']>
export type MergeStatus = NonNullable<AppResponseData_MergeStatusDto['data']>
export type MergeCommitRow = NonNullable<
NonNullable<AppResponseData_Vec_MergeCommitDto['data']>[number]
>
/** One changed file with its patch section (`GET …/files`). */
export type ChangedFile = NonNullable<
NonNullable<AppResponseData_Vec_ChangedPathDiffDto['data']>[number]
>
/** Activity line of `GET …/events` (paged generically, so declared here). */
export interface PullEvent {
id: string
pull_request_id: string
actor?: UserDto | null
event_type: string
commit_sha?: string | null
content?: string | null
created_at: string
}
/** A board label bound to a PR (`GET …/labels` → Vec<LabelDto>). */
export type PullLabel = NonNullable<
NonNullable<AppResponseData_Vec_LabelDto['data']>[number]
>
/** Issue↔PR relation row (`GET …/issues/{id}/pulls`). */
export type IssuePullLink = NonNullable<
NonNullable<AppResponseData_Vec_IssuePullLinkDto['data']>[number]
>
/** Offset page as emitted by the backend. */
export interface PullPage<T> {
items: T[]
total: number
limit: number
offset: number
}
/** Filters accepted by `GET …/pulls` (plus paging). */
export interface PullQuery {
/** `draft` is UI-only: it maps to state=open + draft=true server-side. */
state?: PullState | 'all' | 'draft'
author?: string
base?: string
head?: string
draft?: boolean
search?: string
sort?: string
order?: string
limit?: number
offset?: number
}
/** Body of `POST …/pulls/{ref}`. */
export interface PullPatchCmd {
title?: string
body?: string | null
base_branch?: string | null
draft?: boolean | null
auto_merge?: boolean | null
issue_id?: string | null
}
/** Body of `POST …/pulls` (create). */
export interface NewPullCmd {
title: string
head_branch: string
base_branch?: string | null
body?: string | null
draft?: boolean
issue_id?: string | null
}
/** Body of `POST …/merge`. */
export interface MergeCmd {
method?: MergeMethod
title?: string | null
message?: string | null
fast_forward_only?: boolean
delete_branch_after_merge?: boolean
expect_head_sha?: string | null
}
/** Inline comment draft carried by `POST …/reviews` (submit review). */
export interface InlineDraft {
path: string
line: number
side?: string | null
body?: string | null
}
/** Body of `POST …/reviews` and `POST …/reviews/{id}/submit`. */
export interface ReviewCmd {
state: ReviewIntent
body?: string | null
comments?: InlineDraft[]
}
/** Body of `POST …/comments` — conversation or inline (path+line). */
export interface NewPullCommentCmd {
body: string
parent_comment_id?: string | null
path?: string | null
line?: number | null
side?: string | null
commit_sha?: string | null
review_id?: string | null
}