Skip to content
Clone
eeff292
165 lines 4.8 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 {
EnvelopeMergePullDto,
EnvelopeMergeStatusDto,
EnvelopePullChecksDto,
EnvelopePullCommentDto,
EnvelopePullDto,
EnvelopePullGateDto,
EnvelopePullReviewDto,
EnvelopePullSummaryDto,
EnvelopeVecChangedPathDiffDto,
EnvelopeVecIssuePullLinkDto,
EnvelopeVecLabelDto,
EnvelopeVecMergeCommitDto,
EnvelopeVecPullAssigneeDto,
EnvelopeVecPullCommentThreadDto,
EnvelopeVecPullReviewerDto,
MergeMethod,
PullState,
ReviewerState,
ReviewIntent,
ReviewState,
UserDto,
} from '@app/services/api'
export type { MergeMethod, PullState, ReviewerState, ReviewIntent, ReviewState, 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<EnvelopePullDto['data']>
export type PullComment = NonNullable<EnvelopePullCommentDto['data']>
export type PullCommentThread = NonNullable<NonNullable<EnvelopeVecPullCommentThreadDto['data']>[number]>
export type PullReview = NonNullable<EnvelopePullReviewDto['data']>
export type PullReviewer = NonNullable<NonNullable<EnvelopeVecPullReviewerDto['data']>[number]>
export type PullAssignee = NonNullable<NonNullable<EnvelopeVecPullAssigneeDto['data']>[number]>
export type PullChecks = NonNullable<EnvelopePullChecksDto['data']>
export type PullGate = NonNullable<EnvelopePullGateDto['data']>
/** The gate embedded in `PullGate` (no standalone response envelope). */
export type MergeGate = PullGate['gate']
export type PullSummary = NonNullable<EnvelopePullSummaryDto['data']>
/** `{pull, result, summary}` of a successful merge. */
export type MergeOutcome = NonNullable<EnvelopeMergePullDto['data']>
export type MergeStatus = NonNullable<EnvelopeMergeStatusDto['data']>
export type MergeCommitRow = NonNullable<NonNullable<EnvelopeVecMergeCommitDto['data']>[number]>
/** One changed file with its patch section (`GET …/files`). */
export type ChangedFile = NonNullable<NonNullable<EnvelopeVecChangedPathDiffDto['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<EnvelopeVecLabelDto['data']>[number]>
/** Issue↔PR relation row (`GET …/issues/{id}/pulls`). */
export type IssuePullLink = NonNullable<NonNullable<EnvelopeVecIssuePullLinkDto['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
}