| b69ab31 | | | 1 | /** |
| b69ab31 | | | 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| b69ab31 | | | 3 | * |
| b69ab31 | | | 4 | * This source code is licensed under the MIT license found in the |
| b69ab31 | | | 5 | * LICENSE file in the root directory of this source tree. |
| b69ab31 | | | 6 | */ |
| b69ab31 | | | 7 | |
| b69ab31 | | | 8 | import type {TypeaheadResult} from 'isl-components/Types'; |
| b69ab31 | | | 9 | import type {TypeaheadKind} from 'isl/src/CommitInfoView/types'; |
| b69ab31 | | | 10 | import type { |
| b69ab31 | | | 11 | ClientToServerMessage, |
| b69ab31 | | | 12 | CodeReviewProviderSpecificClientToServerMessages, |
| b69ab31 | | | 13 | CommandArg, |
| b69ab31 | | | 14 | DiffComment, |
| b69ab31 | | | 15 | DiffId, |
| 083fd5f | | | 16 | DiffSignalSummary, |
| b69ab31 | | | 17 | DiffSummary, |
| b69ab31 | | | 18 | Disposable, |
| 083fd5f | | | 19 | Hash, |
| b69ab31 | | | 20 | LandConfirmationInfo, |
| b69ab31 | | | 21 | LandInfo, |
| b69ab31 | | | 22 | OperationCommandProgressReporter, |
| b69ab31 | | | 23 | Result, |
| 23ab721 | | | 24 | RunnableOperation, |
| b69ab31 | | | 25 | ServerToClientMessage, |
| b69ab31 | | | 26 | } from 'isl/src/types'; |
| b69ab31 | | | 27 | |
| b69ab31 | | | 28 | export type DiffSummaries = Map<DiffId, DiffSummary>; |
| b69ab31 | | | 29 | /** |
| b69ab31 | | | 30 | * API to fetch data from Remote Code Review system, like GitHub and Phabricator. |
| b69ab31 | | | 31 | */ |
| b69ab31 | | | 32 | export interface CodeReviewProvider { |
| b69ab31 | | | 33 | triggerDiffSummariesFetch(diffs: Array<DiffId>): unknown; |
| b69ab31 | | | 34 | |
| b69ab31 | | | 35 | onChangeDiffSummaries(callback: (result: Result<DiffSummaries>) => unknown): Disposable; |
| b69ab31 | | | 36 | |
| b69ab31 | | | 37 | /** Run a command not handled within sapling, such as a separate submit handler */ |
| b69ab31 | | | 38 | runExternalCommand?( |
| b69ab31 | | | 39 | cwd: string, |
| b69ab31 | | | 40 | args: CommandArg[], // Providers may need specific normalization for args |
| b69ab31 | | | 41 | onProgress: OperationCommandProgressReporter, |
| b69ab31 | | | 42 | signal: AbortSignal, |
| b69ab31 | | | 43 | ): Promise<void>; |
| b69ab31 | | | 44 | |
| b69ab31 | | | 45 | /** Run a conf command for configerator operations */ |
| b69ab31 | | | 46 | runConfCommand?( |
| b69ab31 | | | 47 | cwd: string, |
| b69ab31 | | | 48 | args: Array<string>, |
| b69ab31 | | | 49 | onProgress: OperationCommandProgressReporter, |
| b69ab31 | | | 50 | signal: AbortSignal, |
| b69ab31 | | | 51 | ): Promise<void>; |
| b69ab31 | | | 52 | |
| b69ab31 | | | 53 | dispose: () => void; |
| b69ab31 | | | 54 | |
| b69ab31 | | | 55 | /** Convert Code Review Provider info into a short summary string, usable in analytics */ |
| b69ab31 | | | 56 | getSummaryName(): string; |
| b69ab31 | | | 57 | |
| b69ab31 | | | 58 | typeahead?(kind: TypeaheadKind, query: string, cwd: string): Promise<Array<TypeaheadResult>>; |
| b69ab31 | | | 59 | |
| b69ab31 | | | 60 | getDiffUrlMarkdown(diffId: DiffId): string; |
| b69ab31 | | | 61 | getCommitHashUrlMarkdown(hash: string): string; |
| b69ab31 | | | 62 | |
| b69ab31 | | | 63 | getRemoteFileURL?( |
| b69ab31 | | | 64 | path: string, |
| b69ab31 | | | 65 | publicCommitHash: string | null, |
| b69ab31 | | | 66 | selectionStart?: {line: number; char: number}, |
| b69ab31 | | | 67 | selectionEnd?: {line: number; char: number}, |
| b69ab31 | | | 68 | ): string; |
| b69ab31 | | | 69 | |
| b69ab31 | | | 70 | updateDiffMessage?(diffId: DiffId, newTitle: string, newDescription: string): Promise<void>; |
| b69ab31 | | | 71 | |
| b69ab31 | | | 72 | getSuggestedReviewers?(context: {paths: Array<string>}): Promise<Array<string>>; |
| b69ab31 | | | 73 | |
| b69ab31 | | | 74 | /** Convert usernames/emails to avatar URIs */ |
| b69ab31 | | | 75 | fetchAvatars?(authors: Array<string>): Promise<Map<string, string>>; |
| b69ab31 | | | 76 | |
| b69ab31 | | | 77 | /** Convert usernames/emails to avatar URIs */ |
| b69ab31 | | | 78 | fetchComments?(diffId: DiffId): Promise<Array<DiffComment>>; |
| b69ab31 | | | 79 | |
| b69ab31 | | | 80 | renderMarkup?: (markup: string) => Promise<string>; |
| b69ab31 | | | 81 | |
| b69ab31 | | | 82 | fetchLandInfo?(topOfStack: DiffId): Promise<LandInfo>; |
| b69ab31 | | | 83 | confirmLand?(landConfirmationInfo: NonNullable<LandConfirmationInfo>): Promise<Result<undefined>>; |
| b69ab31 | | | 84 | |
| b69ab31 | | | 85 | handleClientToServerMessage?( |
| b69ab31 | | | 86 | message: ClientToServerMessage, |
| b69ab31 | | | 87 | postMessage: (message: ServerToClientMessage) => void, |
| b69ab31 | | | 88 | ): message is CodeReviewProviderSpecificClientToServerMessages; |
| 23ab721 | | | 89 | |
| 083fd5f | | | 90 | /** Subscribe to CI/CD build signals with commit messages for client-side matching. */ |
| e7069e1 | | | 91 | onChangeCanopySignals?(callback: (runs: Array<{commitMessage: string; signal: DiffSignalSummary; runId?: number; commitId?: string}>) => unknown): Disposable; |
| e7069e1 | | | 92 | |
| e7069e1 | | | 93 | /** Trigger a fetch of Canopy CI signals on demand. */ |
| e7069e1 | | | 94 | triggerCanopySignalsFetch?(): void; |
| 083fd5f | | | 95 | |
| 23ab721 | | | 96 | /** Called after a Sapling operation completes. Allows providers to react (e.g. create diffs after push). */ |
| 23ab721 | | | 97 | onPostOperation?( |
| 23ab721 | | | 98 | operation: RunnableOperation, |
| 23ab721 | | | 99 | exitCode: number, |
| 23ab721 | | | 100 | getCommitInfo: (rev: string) => Promise<{title: string; description: string; hash: string; parentHash: string} | undefined>, |
| 23ab721 | | | 101 | ): Promise<void>; |
| b69ab31 | | | 102 | } |