import type { ReviewThreadComment } from "./review-thread.mts"; import type { PrActivitySummary } from "./activity.mts"; import type { BatchPrMergeFields, MergeRequirements } from "./merge-requirements.mts"; export type CheckConclusion = "ACTION_REQUIRED" | "CANCELLED" | "FAILURE" | "NEUTRAL" | "SKIPPED" | "STALE" | "STARTUP_FAILURE" | "SUCCESS" | "TIMED_OUT" | null; export type CheckStatus = "COMPLETED" | "IN_PROGRESS" | "PENDING" | "QUEUED" | "REQUESTED" | "WAITING"; export type MergeableState = "CONFLICTING" | "MERGEABLE" | "UNKNOWN"; export type MergeStateStatus = "BEHIND" | "BLOCKED" | "CLEAN" | "DIRTY" | "DRAFT" | "HAS_HOOKS" | "UNKNOWN" | "UNSTABLE"; export type ReviewDecision = "APPROVED" | "CHANGES_REQUESTED" | "REVIEW_REQUIRED" | null; export type AuthorType = "User" | "Bot" | "Unknown"; type RepositoryPermission = "NONE" | "READ" | "TRIAGE" | "WRITE" | "MAINTAIN" | "ADMIN"; /** Raw GitHub viewer fields used to gate remote actions. */ export interface ViewerAuthorization { repositoryPermission: RepositoryPermission | null; viewerCanAdminister: boolean; viewerDidAuthor: boolean; viewerCanUpdate: boolean; viewerCanEnableAutoMerge: boolean; viewerCanEditFiles: boolean; headRepositoryPermission: RepositoryPermission | null; } /** Raw relationship between a comment author and the repository, as reported by GitHub. */ export type CommentAuthorAssociation = "COLLABORATOR" | "CONTRIBUTOR" | "FIRST_TIMER" | "FIRST_TIME_CONTRIBUTOR" | "MANNEQUIN" | "MEMBER" | "NONE" | "OWNER"; export interface CheckRun { /** GitHub node ID for CheckRun contexts. Missing for StatusContext and synthetic checks. */ id?: string | null; name: string; status: CheckStatus; conclusion: CheckConclusion; source?: "check_run" | "status_context" | "startup_failure"; detailsUrl: string; event: string | null; runId: string | null; /** GitHub Actions workflow-run attempt number. Omitted for non-Actions or unavailable metadata. */ runAttempt?: number; /** Commit scope that supplied this check. Omitted for ordinary PR-head checks. */ scope?: "merge_group"; /** Synthetic merge-group commit OID, when `scope` is `merge_group`. */ commitOid?: string; createdAtUnix?: number; startedAtUnix?: number; completedAtUnix?: number; updatedAtUnix?: number; /** One-line status text shown in the GitHub UI (CheckRun.title or first line of summary; StatusContext.description). */ summary?: string; /** Workflow display name for GitHub Actions check runs, when GraphQL exposes it. */ workflowName?: string; workflowId?: string; /** True when GraphQL reported at least one CheckRun annotation. Omitted when false. */ hasAnnotations?: boolean; } export interface ReviewThread { id: string; isResolved: boolean; isOutdated: boolean; isMinimized: boolean; viewerCanReply?: boolean; viewerCanResolve?: boolean; path: string | null; line: number | null; /** Start of the comment's line range. Null for single-line comments (use `line` for both). */ startLine: number | null; /** PullRequestReview ID that created the top comment, when GitHub exposes it. */ reviewId?: string; author: string; authorType: AuthorType; authorAssociation?: CommentAuthorAssociation; viewerDidAuthor?: true; body: string; url: string; createdAtUnix?: number; comments?: ReviewThreadComment[]; /** True when Shepherd re-surfaced this thread because its body changed after first look. */ edited?: boolean; } /** Parsed GitHub ```suggestion block attached to a review thread. */ export interface SuggestionBlock { /** 1-indexed inclusive start line. Equal to `endLine` for single-line suggestions. */ startLine: number; /** 1-indexed inclusive end line. */ endLine: number; /** Replacement lines verbatim. Empty array = delete; `[""]` = single blank line. Join with `"\n"` to display as a string. */ lines: readonly string[]; /** Reviewer login, surfaced so callers can co-credit them in commits. */ author: string; } export interface PrComment { id: string; isMinimized: boolean; viewerCanMinimize?: boolean; author: string; authorType: AuthorType; authorAssociation?: CommentAuthorAssociation; body: string; url: string; createdAtUnix: number; } export interface Review { id: string; author: string; authorType: AuthorType; authorAssociation?: CommentAuthorAssociation; /** Present for minimizable COMMENTED/APPROVED reviews; false for non-minimizable review rows. */ viewerCanMinimize?: boolean; body: string; createdAtUnix?: number; edited?: boolean; /** True for bot CR re-surfaced after first look (body unchanged). Terse render. */ staleBotCr?: boolean; /** Commit OID the review was made against, when available from GraphQL. */ commitOid?: string; /** True when commitOid !== headRefOid AND all associated threads are resolved/outdated. Distinct from `staleBotCr` (time-based). Reviews with no threads are not marked stale. */ staleReview?: boolean; } export interface BranchProtection { requiresApprovingReviews: boolean; requiredApprovingReviewCount: number; requiresConversationResolution: boolean; requiresStatusChecks: boolean; /** Required status check context names (e.g. "ci/build", "ci/test"). Empty when requiresStatusChecks is false, or when requiresStatusChecks is true but GitHub returns no explicit contexts. */ requiredStatusCheckContexts: string[]; } export type ShepherdMergeStatus = "CLEAN" | "BEHIND" | "CONFLICTS" | "BLOCKED" | "UNSTABLE" | "DRAFT" | "UNKNOWN"; export interface MergeStatusResult { status: ShepherdMergeStatus; state: "OPEN" | "CLOSED" | "MERGED"; isDraft: boolean; mergeable: MergeableState; reviewDecision: ReviewDecision; blockingBotReviewInProgress: boolean; mergeStateStatus: MergeStateStatus; mergeRequirements?: MergeRequirements; } export interface BatchPrData extends BatchPrMergeFields { nodeId: string; number: number; state: "OPEN" | "CLOSED" | "MERGED"; isDraft: boolean; mergeable: MergeableState; mergeStateStatus: MergeStateStatus; reviewDecision: ReviewDecision; headRefOid: string; headRefName: string; /** `"owner/name"` of the head repository; null when the fork has been deleted. */ headRepoWithOwner: string | null; viewerAuthorization?: ViewerAuthorization; baseRefName: string; /** Git OID of the base branch tip observed with this PR, when available. */ baseRefOid?: string; reviewRequests: Array<{ login: string; }>; latestReviews: Array<{ login: string; state: string; }>; reviewThreads: ReviewThread[]; comments: PrComment[]; changesRequestedReviews: Review[]; reviewSummaries: Review[]; approvedReviews: Review[]; checks: CheckRun[]; mergeQueueChecks?: CheckRun[]; mergeQueueChecksIncomplete?: true; removedMergeQueueChecks?: CheckRun[]; removedMergeQueueChecksIncomplete?: true; branchProtection: BranchProtection | null; activity?: PrActivitySummary; } export {};