@@ -67,3 +67,105 @@ export type GithubPullRequest = GithubRef;
6767// git-interaction UI (PR status menu actions).
6868export const prActionTypeSchema = z . enum ( [ "close" , "reopen" , "ready" , "draft" ] ) ;
6969export type PrActionType = z . infer < typeof prActionTypeSchema > ;
70+
71+ // Native PR review schemas (PR overview, approve/merge, CI checks,
72+ // conversation comments). Defined once here and re-exported by
73+ // `@posthog/core/git/router-schemas` and workspace-server's git schemas so
74+ // the tRPC layers on both sides of the boundary share one source of truth.
75+
76+ /** Full PR overview (title/body/branches/stats) for the native in-app PR view. */
77+ export const getPrInfoByUrlInput = z . object ( { prUrl : z . string ( ) } ) ;
78+
79+ export const getPrInfoByUrlOutput = z . object ( {
80+ number : z . number ( ) ,
81+ title : z . string ( ) ,
82+ body : z . string ( ) ,
83+ author : z . string ( ) . nullable ( ) ,
84+ state : z . string ( ) ,
85+ merged : z . boolean ( ) ,
86+ draft : z . boolean ( ) ,
87+ /** GitHub computes mergeability asynchronously; null until it settles. */
88+ mergeable : z . boolean ( ) . nullable ( ) ,
89+ /**
90+ * GitHub's `mergeable_state`: "clean" | "unstable" | "blocked" | "dirty" |
91+ * "behind" | "draft" | "unknown". "blocked" means branch protection forbids
92+ * the merge for this viewer — e.g. a required approving review is missing
93+ * (authors can't approve their own PRs) or required checks are failing.
94+ * Kept as a plain string so an undocumented value can't fail the parse.
95+ */
96+ mergeStateStatus : z . string ( ) . catch ( "unknown" ) ,
97+ baseRefName : z . string ( ) . nullable ( ) ,
98+ headRefName : z . string ( ) . nullable ( ) ,
99+ additions : z . number ( ) ,
100+ deletions : z . number ( ) ,
101+ changedFiles : z . number ( ) ,
102+ } ) ;
103+
104+ export type PrInfoByUrlOutput = z . infer < typeof getPrInfoByUrlOutput > ;
105+
106+ export const approvePrInput = z . object ( { prUrl : z . string ( ) } ) ;
107+
108+ export const approvePrOutput = z . object ( {
109+ success : z . boolean ( ) ,
110+ message : z . string ( ) ,
111+ } ) ;
112+
113+ export type ApprovePrOutput = z . infer < typeof approvePrOutput > ;
114+
115+ export const prMergeMethodSchema = z . enum ( [ "merge" , "squash" , "rebase" ] ) ;
116+ export type PrMergeMethod = z . infer < typeof prMergeMethodSchema > ;
117+
118+ export const mergePrInput = z . object ( {
119+ prUrl : z . string ( ) ,
120+ method : prMergeMethodSchema ,
121+ } ) ;
122+
123+ export const mergePrOutput = z . object ( {
124+ success : z . boolean ( ) ,
125+ message : z . string ( ) ,
126+ } ) ;
127+
128+ export type MergePrOutput = z . infer < typeof mergePrOutput > ;
129+
130+ // CI check runs / commit statuses for a PR, via `gh pr checks`.
131+ export const prCheckBucketSchema = z . enum ( [
132+ "fail" ,
133+ "cancel" ,
134+ "pending" ,
135+ "pass" ,
136+ "skipping" ,
137+ ] ) ;
138+ export type PrCheckBucket = z . infer < typeof prCheckBucketSchema > ;
139+
140+ export const prCheckSchema = z . object ( {
141+ name : z . string ( ) ,
142+ bucket : prCheckBucketSchema ,
143+ link : z . string ( ) . nullable ( ) ,
144+ workflow : z . string ( ) . nullable ( ) ,
145+ description : z . string ( ) . nullable ( ) ,
146+ } ) ;
147+ export type PrCheck = z . infer < typeof prCheckSchema > ;
148+
149+ export const getPrChecksInput = z . object ( { prUrl : z . string ( ) } ) ;
150+ /** Null means the checks couldn't be fetched; [] means none reported. */
151+ export const getPrChecksOutput = z . array ( prCheckSchema ) . nullable ( ) ;
152+ export type GetPrChecksOutput = z . infer < typeof getPrChecksOutput > ;
153+
154+ // Conversation (issue) comments and review summaries on a PR. Inline review
155+ // comments live in `prReviewThreadSchema` above.
156+ export const prConversationCommentSchema = z . object ( {
157+ id : z . number ( ) ,
158+ author : z . string ( ) ,
159+ avatarUrl : z . string ( ) . nullable ( ) ,
160+ body : z . string ( ) ,
161+ createdAt : z . string ( ) ,
162+ url : z . string ( ) . nullable ( ) ,
163+ } ) ;
164+ export type PrConversationComment = z . infer < typeof prConversationCommentSchema > ;
165+
166+ export const getPrCommentsInput = z . object ( { prUrl : z . string ( ) } ) ;
167+ /** Null means the comments couldn't be fetched; [] means none. */
168+ export const getPrCommentsOutput = z
169+ . array ( prConversationCommentSchema )
170+ . nullable ( ) ;
171+ export type GetPrCommentsOutput = z . infer < typeof getPrCommentsOutput > ;
0 commit comments