Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299export type GitHost = "bitbucket" | "github";
export interface RepoRef { host: GitHost; workspace: string; repo: string; fullName: string; displayName: string;}
export interface PullRequestRef { host: GitHost; workspace: string; repo: string; pullRequestId: string;}
export interface DiffStatEntry { status: "added" | "modified" | "removed" | "renamed"; new?: { path?: string }; old?: { path?: string }; linesAdded?: number; linesRemoved?: number;}
export interface PullRequestSummary { id: number; title: string; state: string; links?: { html?: { href?: string } }; author?: { displayName?: string; avatarUrl?: string };}
export interface Commit { hash: string; date?: string; message?: string; summary?: { raw?: string }; author?: { user?: { displayName?: string; avatarUrl?: string }; raw?: string; };}
export interface Comment { id: number; createdAt?: string; updatedAt?: string; deleted?: boolean; pending?: boolean; content?: { raw?: string; html?: string }; user?: { displayName?: string; avatarUrl?: string }; inline?: { path?: string; to?: number; from?: number }; parent?: { id?: number }; resolution?: { user?: { displayName?: string; avatarUrl?: string } } | null; hostThreadId?: string;}
export interface PullRequestDetails { id: number; title: string; description?: string; state: string; draft?: boolean; commentCount?: number; taskCount?: number; createdAt?: string; updatedAt?: string; closedAt?: string; mergedAt?: string; author?: { displayName?: string; avatarUrl?: string }; source?: { branch?: { name?: string }; repository?: { fullName?: string }; commit?: { hash?: string }; }; destination?: { branch?: { name?: string }; repository?: { fullName?: string }; commit?: { hash?: string }; }; participants?: Array<{ approved?: boolean; user?: { displayName?: string; avatarUrl?: string }; }>; currentUserReviewStatus?: "approved" | "changesRequested" | "none"; currentUser?: { displayName?: string; avatarUrl?: string }; links?: { html?: { href?: string } };}
export type PullRequestHistoryEventType = | "comment" | "approved" | "changesRequested" | "reviewRequested" | "reviewDismissed" | "reviewerAdded" | "reviewerRemoved" | "opened" | "updated" | "closed" | "merged" | "reopened";
export interface PullRequestHistoryEvent { id: string; type: PullRequestHistoryEventType; createdAt?: string; actor?: { displayName?: string; avatarUrl?: string }; content?: string; contentHtml?: string; details?: string; comment?: { id?: number; path?: string; line?: number; side?: "additions" | "deletions"; isInline?: boolean; };}
export type PullRequestReviewerStatus = "approved" | "changesRequested" | "commented" | "pending";
export interface PullRequestReviewer { id: string; displayName?: string; avatarUrl?: string; status: PullRequestReviewerStatus; approved: boolean; requested?: boolean; updatedAt?: string;}
export type PullRequestBuildState = "success" | "failed" | "pending" | "skipped" | "neutral" | "unknown";
export interface PullRequestBuildStatus { id: string; name: string; state: PullRequestBuildState; url?: string; provider?: string; startedAt?: string; completedAt?: string;}
export interface PullRequestBundle { prRef: PullRequestRef; pr: PullRequestDetails; diff: string; diffstat: DiffStatEntry[]; commits: Commit[]; comments: Comment[]; history?: PullRequestHistoryEvent[]; reviewers?: PullRequestReviewer[]; buildStatuses?: PullRequestBuildStatus[];}
export interface PullRequestCriticalBundle { prRef: PullRequestRef; pr: PullRequestDetails; diff: string; diffstat: DiffStatEntry[]; commits: Commit[];}
export interface PullRequestDeferredBundle { prRef: PullRequestRef; comments: Comment[]; history?: PullRequestHistoryEvent[]; reviewers?: PullRequestReviewer[]; buildStatuses?: PullRequestBuildStatus[]; prPatch?: Partial<PullRequestDetails>;}
export interface PullRequestHydrationState { criticalFetchedAt: number; deferredFetchedAt?: number; deferredStatus: "idle" | "loading" | "ready" | "error";}
export interface PullRequestCommitRangeDiff { prRef: PullRequestRef; baseCommitHash: string; headCommitHash: string; selectedCommitHashes: string[]; diff: string; diffstat: DiffStatEntry[];}
export interface PullRequestFileHistoryEntry { versionId: string; commitHash: string; commitDate?: string; commitMessage?: string; authorDisplayName?: string; filePathAtCommit: string; status: DiffStatEntry["status"]; patch: string;}
export interface PullRequestFileHistory { path: string; entries: PullRequestFileHistoryEntry[]; fetchedAt: number;}
export interface MergeOptions { closeSourceBranch?: boolean; message?: string; mergeStrategy?: string;}
export interface CommentPayload { content: string; inline?: { path: string; to?: number; from?: number }; parentId?: number;}
export interface CommentUpdatePayload { commentId: number; content: string; hasInlineContext: boolean;}
export interface HostCapabilities { publicReadSupported: boolean; supportsThreadResolution: boolean; mergeStrategies?: string[]; requestChangesAvailable: boolean; removeApprovalAvailable: boolean; declineAvailable: boolean; markDraftAvailable: boolean;}
interface HostApiErrorDetails { status?: number; statusText?: string; body?: string;}
export class HostApiError extends Error { status?: number; statusText?: string; body?: string;
constructor(message: string, details: HostApiErrorDetails = {}) { super(message); this.name = "HostApiError"; this.status = details.status; this.statusText = details.statusText; this.body = details.body; }}
export interface AuthState { authenticated: boolean;}
export type LoginCredentials = { host: "bitbucket"; email: string; apiToken: string } | { host: "github"; token: string };
export interface GitHostClient { readonly host: GitHost; readonly capabilities: HostCapabilities; getAuthState(): Promise<AuthState>; login(credentials: LoginCredentials): Promise<AuthState>; logout(): Promise<AuthState>; listRepositories(): Promise<RepoRef[]>; listPullRequestsForRepos(data: { repos: RepoRef[] }): Promise<Array<{ repo: RepoRef; pullRequests: PullRequestSummary[] }>>; fetchPullRequestCriticalByRef(data: { prRef: PullRequestRef }): Promise<PullRequestCriticalBundle>; fetchPullRequestDeferredByRef(data: { prRef: PullRequestRef }): Promise<PullRequestDeferredBundle>; fetchPullRequestBundleByRef(data: { prRef: PullRequestRef }): Promise<PullRequestBundle>; approvePullRequest(data: { prRef: PullRequestRef }): Promise<{ ok: true }>; removePullRequestApproval(data: { prRef: PullRequestRef }): Promise<{ ok: true }>; requestChanges(data: { prRef: PullRequestRef; body?: string }): Promise<{ ok: true }>; declinePullRequest(data: { prRef: PullRequestRef }): Promise<{ ok: true }>; markPullRequestAsDraft(data: { prRef: PullRequestRef }): Promise<{ ok: true }>; mergePullRequest(data: { prRef: PullRequestRef } & MergeOptions): Promise<{ ok: true }>; createPullRequestComment( data: { prRef: PullRequestRef; } & CommentPayload, ): Promise<{ ok: true }>; updatePullRequestComment( data: { prRef: PullRequestRef; } & CommentUpdatePayload, ): Promise<{ ok: true }>; resolvePullRequestComment(data: { prRef: PullRequestRef; commentId: number; resolve: boolean }): Promise<{ ok: true }>; deletePullRequestComment(data: { prRef: PullRequestRef; commentId: number; hasInlineContext: boolean }): Promise<{ ok: true }>; fetchPullRequestCommitRangeDiff(data: { prRef: PullRequestRef; baseCommitHash: string; headCommitHash: string; selectedCommitHashes: string[]; }): Promise<PullRequestCommitRangeDiff>; fetchPullRequestFileContents(data: { prRef: PullRequestRef; commit: string; path: string }): Promise<string>; fetchPullRequestFileHistory(data: { prRef: PullRequestRef; path: string; commits: Commit[]; limit?: number }): Promise<PullRequestFileHistory>;}