Files
orca/src/preload/api/github-work-item-api.ts
T
Brennan Benson 252b427dfd Display private GitHub attachment images in fetched items (#39250)
* Display private GitHub attachment images in fetched items

* Keep attachment event identity aligned with committed renders

* Complete GitHub image response type contracts

* Return private image sources with accepted issue edits

* Keep issue edits successful without optional display data

* Cover unusable issue edit image responses

* Keep optional GitHub image parsing from failing accepted saves

* Fetch GitHub body images with the existing body read
2026-11-08 11:58:15 -08:00

187 lines
6.2 KiB
TypeScript

import type { GhAccountBinding } from '../../shared/github/account-binding'
import type {
GetProjectViewTableResult,
GitHubProjectCommentMutationResult,
GitHubProjectMutationResult,
ListAccessibleProjectsResult,
ListAssignableUsersBySlugResult,
ListIssueTypesBySlugResult,
ListLabelsBySlugResult,
ListProjectViewsResult,
ProjectWorkItemDetailsBySlugResult,
ResolveProjectRefResult
} from '../../shared/github/project-result-types'
import type {
AddIssueCommentBySlugArgs,
ClearProjectItemFieldArgs,
DeleteIssueCommentBySlugArgs,
GetProjectViewTableArgs,
ListAccessibleProjectsArgs,
ListAssignableUsersBySlugArgs,
ListIssueTypesBySlugArgs,
ListLabelsBySlugArgs,
ListProjectViewsArgs,
ProjectWorkItemDetailsBySlugArgs,
ResolveProjectRefArgs,
UpdateIssueBySlugArgs,
UpdateIssueCommentBySlugArgs,
UpdateIssueTypeBySlugArgs,
UpdateProjectItemFieldArgs,
UpdatePullRequestBySlugArgs
} from '../../shared/github/project-request-types'
import type { TaskSourceContext } from '../../shared/work-items/task-source-context'
import type { GitHubCommentResult } from '../../shared/github/comment-types'
import type {
GitHubAssignableUser,
GitHubOwnerRepo,
IssueInfo
} from '../../shared/github/pull-request-types'
import type {
GitHubWorkItem,
GitHubWorkItemDetails,
ListWorkItemsResult
} from '../../shared/github/work-item-types'
import type { GitHubCreateIssueResult, GitHubIssueUpdate } from '../../shared/issue-mutation-types'
export type GitHubRepoSelectorArgs = {
repoOwnerExecutionHostId?: string
repoPath: string
repoId?: string | null
sourceContext?: TaskSourceContext | null
}
export type GithubWorkItemApi = {
issue: (args: {
repoPath: string
repoId?: string
sourceContext?: TaskSourceContext | null
number: number
}) => Promise<IssueInfo | null>
workItem: (args: {
repoPath: string
repoId?: string
sourceContext?: TaskSourceContext | null
number: number
type?: 'issue' | 'pr'
}) => Promise<Omit<GitHubWorkItem, 'repoId'> | null>
workItemByOwnerRepo: (args: {
repoPath: string
repoId?: string
sourceContext?: TaskSourceContext | null
owner: string
repo: string
host?: string
number: number
type: 'issue' | 'pr'
}) => Promise<Omit<GitHubWorkItem, 'repoId'> | null>
workItemDetails: (
args: GitHubRepoSelectorArgs & {
expectedGhAccount?: GhAccountBinding | null
number: number
type?: 'issue' | 'pr'
ownerRepo?: GitHubOwnerRepo
canonical?: boolean
}
) => Promise<GitHubWorkItemDetails | null>
notifyWorkItemMutated: (args: {
repoPath: string
repoId?: string
type: 'issue' | 'pr'
number: number
}) => Promise<boolean>
listIssues: (args: { repoPath: string; repoId?: string; limit?: number }) => Promise<IssueInfo[]>
createIssue: (args: {
repoPath: string
repoId?: string
sourceContext?: TaskSourceContext | null
title: string
body: string
labels?: string[]
assignees?: string[]
}) => Promise<GitHubCreateIssueResult>
countWorkItems: (args: {
repoPath: string
repoId?: string
query?: string
wakeWslDistro?: boolean
}) => Promise<number>
listWorkItems: (args: {
repoPath: string
repoId?: string
limit?: number
query?: string
page?: number
noCache?: boolean
wakeWslDistro?: boolean
}) => Promise<ListWorkItemsResult<Omit<GitHubWorkItem, 'repoId'>>>
updateIssue: (
args: GitHubRepoSelectorArgs & {
number: number
updates: GitHubIssueUpdate
ownerRepo?: GitHubOwnerRepo
}
) => Promise<{ ok: true; bodyImageUrls?: Record<string, string> } | { ok: false; error: string }>
addIssueComment: (
args: GitHubRepoSelectorArgs & {
number: number
body: string
/** Keep PR and issue cache invalidation separate when their numbers match. */
type?: 'issue' | 'pr'
prRepo?: GitHubOwnerRepo | null
}
) => Promise<GitHubCommentResult>
listLabels: (args: {
expectedGhAccount?: GhAccountBinding | null
repoPath: string
repoId?: string
sourceContext?: TaskSourceContext | null
ownerRepo?: GitHubOwnerRepo
}) => Promise<string[]>
listAssignableUsers: (args: {
expectedGhAccount?: GhAccountBinding | null
repoPath: string
repoId?: string
sourceContext?: TaskSourceContext | null
ownerRepo?: GitHubOwnerRepo
}) => Promise<GitHubAssignableUser[]>
/** Invalidate work-item caches across windows after local mutations. */
onWorkItemMutated: (
callback: (payload: {
repoPath: string
repoId?: string
type: 'issue' | 'pr'
number: number
}) => void
) => () => void
listAccessibleProjects: (
args?: ListAccessibleProjectsArgs
) => Promise<ListAccessibleProjectsResult>
resolveProjectRef: (args: ResolveProjectRefArgs) => Promise<ResolveProjectRefResult>
listProjectViews: (args: ListProjectViewsArgs) => Promise<ListProjectViewsResult>
getProjectViewTable: (args: GetProjectViewTableArgs) => Promise<GetProjectViewTableResult>
projectWorkItemDetailsBySlug: (
args: ProjectWorkItemDetailsBySlugArgs
) => Promise<ProjectWorkItemDetailsBySlugResult>
updateProjectItemField: (args: UpdateProjectItemFieldArgs) => Promise<GitHubProjectMutationResult>
clearProjectItemField: (args: ClearProjectItemFieldArgs) => Promise<GitHubProjectMutationResult>
updateIssueBySlug: (args: UpdateIssueBySlugArgs) => Promise<GitHubProjectMutationResult>
updatePullRequestBySlug: (
args: UpdatePullRequestBySlugArgs
) => Promise<GitHubProjectMutationResult>
addIssueCommentBySlug: (
args: AddIssueCommentBySlugArgs
) => Promise<GitHubProjectCommentMutationResult>
updateIssueCommentBySlug: (
args: UpdateIssueCommentBySlugArgs
) => Promise<GitHubProjectMutationResult>
deleteIssueCommentBySlug: (
args: DeleteIssueCommentBySlugArgs
) => Promise<GitHubProjectMutationResult>
listLabelsBySlug: (args: ListLabelsBySlugArgs) => Promise<ListLabelsBySlugResult>
listAssignableUsersBySlug: (
args: ListAssignableUsersBySlugArgs
) => Promise<ListAssignableUsersBySlugResult>
listIssueTypesBySlug: (args: ListIssueTypesBySlugArgs) => Promise<ListIssueTypesBySlugResult>
updateIssueTypeBySlug: (args: UpdateIssueTypeBySlugArgs) => Promise<GitHubProjectMutationResult>
}