Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

PullRequestProvider.ts

702 lines29.1 KB

1import * as Effect from "effect/Effect";
2import * as Schema from "effect/Schema";
3import type {
4 PullRequestStackMembership,
5 PullRequestAction,
6 PullRequestStackHead,
7 PullRequestActor,
8 PullRequestBaseComparison,
9 PullRequestCapabilities,
10 PullRequestChecksState,
11 PullRequestCheck,
12 PullRequestChecks,
13 PullRequestComment,
14 PullRequestFileViewed,
15 PullRequestCommit,
16 PullRequestInvolvement,
17 PullRequestLabel,
18 PullRequestListFilters,
19 PullRequestListState,
20 PullRequestMergeCapabilities,
21 PullRequestMergeMethod,
22 PullRequestMergeability,
23 PullRequestOmittedFileStat,
24 PullRequestReaction,
25 PullRequestReactionContent,
26 PullRequestReviewCommentDraft,
27 PullRequestReviewDecision,
28 PullRequestReviewThread,
29 PullRequestThreadCommentsResult,
30 PullRequestReviewVerdict,
31 PullRequestReviewerCandidateList,
32 PullRequestReviewerKind,
33 PullRequestLabelCandidateList,
34 PullRequestState,
35 PullRequestPreview,
36 PullRequestUpdateMethod,
37 PullRequestViewerPermissions,
38 SourceControlProviderKind,
39} from "@t3tools/contracts";
40import { SourceControlProviderKind as SourceControlProviderKindSchema } from "@t3tools/contracts";
41​
42/**
43 * The one failure shape every provider reports, so the service can decide what a failure means
44 * without knowing which CLI or API produced it.
45 *
46 * `reason` is the part the service acts on: a missing or unauthenticated tool disables the
47 * provider for the whole workspace, a rate limit pauses its host, and anything else is specific
48 * to the request.
49 */
50export class PullRequestProviderError extends Schema.TaggedError<PullRequestProviderError>()(
51 "PullRequestProviderError",
52 {
53 provider: SourceControlProviderKindSchema,
54 operation: Schema.String,
55 reason: Schema.Literals([
56 "missing-tool",
57 "unauthenticated",
58 "rate-limited",
59 "not-found",
60 "failed",
61 ]),
62 detail: Schema.String,
63 retryAt: Schema.optional(Schema.Number),
64 cause: Schema.optional(Schema.Defect()),
65 },
66) {
67 override get message(): string {
68 return `${this.provider} failed in ${this.operation}: ${this.detail}`;
69 }
71​
72/**
73 * `status` moves with the state, mergeability, head, or checks, which the detail read reports;
74 * `remarks` moves with comments and reviews, which only the activity read reports.
75 */
76export interface ProviderChangeRequestWatchFingerprint {
77 readonly status: string;
78 readonly remarks: string;
80​
81export interface PullRequestProviderFailure {
82 readonly reason: PullRequestProviderError["reason"];
83 readonly retryAt?: number | undefined;
85​
86/** A change request as the provider sees it, before the service attaches project context. */
87export interface ProviderChangeRequest {
88 readonly stack?: PullRequestStackMembership;
89 readonly number: number;
90 readonly title: string;
91 readonly url: string;
92 readonly author: PullRequestActor | null;
93 readonly headBranch: string;
94 readonly headRepositoryNameWithOwner?: string | null;
95 readonly baseBranch: string;
96 readonly state: PullRequestState;
97 readonly isDraft: boolean;
98 readonly mergeability: PullRequestMergeability;
99 readonly additions: number;
100 readonly deletions: number;
101 readonly createdAt: string;
102 readonly closedAt?: string | null;
103 readonly mergedAt?: string | null;
104 readonly updatedAt: string;
105 /** Accounts with a review requested. Team-level requests are excluded by each provider. */
106 readonly reviewRequestLogins: ReadonlyArray<string>;
107 readonly labels: ReadonlyArray<PullRequestLabel>;
108 /** Absent from a host that does not summarise its reviews, which is every host but GitHub. */
109 readonly reviewDecision?: PullRequestReviewDecision | null | undefined;
110 /** Absent from a host that reports no check rollup on its listings. */
111 readonly checksState?: PullRequestChecksState | null | undefined;
113​
114/** The fields needed to keep a linked thread's pull request status live. */
115export interface ProviderChangeRequestSummary {
116 readonly number: number;
117 readonly title: string;
118 readonly url: string;
119 readonly headBranch: string;
120 readonly baseBranch: string;
121 readonly state: PullRequestState;
122 /** Present when the host says an open pull request is still a draft. */
123 readonly isDraft?: boolean;
124 readonly closedAt?: string | null;
125 readonly mergedAt?: string | null;
126 readonly updatedAt: string;
127 /** Overview fields, present where the host's single read returns them at no extra cost. */
128 readonly author?: PullRequestActor | null | undefined;
129 readonly additions?: number | undefined;
130 readonly deletions?: number | undefined;
131 readonly changedFiles?: number | undefined;
132 readonly reviewDecision?: PullRequestReviewDecision | null | undefined;
133 readonly checksState?: PullRequestChecksState | null | undefined;
134 readonly mergeability?: PullRequestMergeability | undefined;
135 /**
136 * The host-native stack the pull request sits in, from the same read. Null when the host says
137 * it is in none; absent when the read did not ask.
138 */
139 readonly stack?: PullRequestStackMembership | null | undefined;
141​
142/** One layer of a host-native stack, bottom to top order is the array's. */
143export interface ProviderChangeRequestStackLayer {
144 readonly title?: string;
145 readonly isDraft?: boolean;
146 readonly headSha?: string;
147 readonly number: number;
148 readonly headBranch: string;
149 readonly state: PullRequestState;
151​
152/**
153 * A host-native stack: an ordered set of change requests the host itself merges and retargets as
154 * a unit. Only GitHub offers one today; the neutral shape lets the sync reactor and the UI stay
155 * ignorant of which host said so.
156 */
157export interface ProviderChangeRequestStack {
158 readonly id: string;
159 readonly number: number;
160 readonly url: string;
161 readonly base: string;
162 readonly layers: ReadonlyArray<ProviderChangeRequestStackLayer>;
164​
165export interface ProviderChangeRequestPage {
166 readonly items: ReadonlyArray<ProviderChangeRequest>;
167 /** True when the host has more rows than the page size asked for. */
168 readonly truncated: boolean;
169 /**
170 * Optional count-based cursor advance. Most hosts advance by the rows delivered after local
171 * de-duplication; an offset-paged host may need to count malformed raw rows it consumed too.
172 */
173 readonly cursorAdvance?: number;
174 /**
175 * This page can be carried on from, so the service may hand the caller a cursor for it. False
176 * where the host answered in an order a cursor means nothing in, which leaves a larger `limit`
177 * as the only way to the rest — what every listing did before there were cursors.
178 */
179 readonly continues: boolean;
181​
182/**
183 * Where a repository's next slice starts, as the provider that has to ask for it needs it. Built
184 * by the service out of the slice it just handed over, so the boundary that decides whether a row
185 * arrives twice or not at all is decided in one place rather than in four.
186 */
187export interface ProviderListCursor {
188 /**
189 * The instant of the oldest row already handed over, checked against a timestamp's shape before
190 * it gets here because it goes into a host's own filter. Asked for inclusively: several rows
191 * share one instant often enough — a bot that touches eight change requests writes one timestamp
192 * on all eight — and asking for strictly older would lose whichever of them the slice ended
193 * before. The service drops the ones it has already sent.
194 */
195 readonly updatedBefore: string;
196 /**
197 * How many provider rows this repository has consumed so far, for a host that carries on by
198 * counting rather than by date. Usually this is the number handed over; malformed raw rows may
199 * count too when the provider reports a `cursorAdvance`.
200 */
201 readonly delivered: number;
203​
204/** One repository's row inside an answer that spans several of them. */
205export interface ProviderBatchedChangeRequest extends ProviderChangeRequest {
206 /** Provider-native identity, exactly as it was asked for, so the caller can file the row. */
207 readonly repository: string;
209​
210/**
211 * One slice of a host read across several repositories at once, newest update first across all
212 * of them. There is no per-repository page here because the host was asked one question: the
213 * caller splits the rows by `repository` and works out where each of them carries on from the
214 * oldest row in the slice, which every repository the slice covers is now read up to.
215 */
216export interface ProviderBatchedChangeRequestPage {
217 readonly items: ReadonlyArray<ProviderBatchedChangeRequest>;
218 /** True when the host has more rows than the slice asked for, for any of the repositories. */
219 readonly truncated: boolean;
221​
222/** The line counts for one change request, which a listing may leave for a second read. */
223export interface ProviderChangeRequestStat {
224 readonly repository: string;
225 readonly number: number;
226 readonly additions: number;
227 readonly deletions: number;
229​
230export interface ProviderChangeRequestDetail extends ProviderChangeRequest {
231 /** The head commit, where the host's detail read reports it. */
232 readonly headSha?: string | null;
233 readonly body: string;
234 readonly changedFiles: number;
235 readonly mergedAt: string | null;
236 readonly closedAt: string | null;
237 readonly reviewers: ReadonlyArray<PullRequestActor>;
238 readonly checks: ReadonlyArray<PullRequestCheck>;
239 readonly mergeCapabilities: PullRequestMergeCapabilities;
240 readonly viewerPermissions: PullRequestViewerPermissions;
241 /** Absent from a host that cannot compare the branch with its base, which is most of them. */
242 readonly baseComparison?: PullRequestBaseComparison;
243 readonly behindBy?: number;
244 /** Absent from a host that does not report whether it is armed to merge this on its own. */
245 readonly autoMergeEnabled?: boolean;
246 /** The strategy stored with an armed auto-merge, where the host reports it. */
247 readonly autoMergeMethod?: PullRequestMergeMethod;
248 /** Workflow runs on this head commit that still need a maintainer's approval. */
249 readonly workflowApprovalsRequired?: number;
251​
252/** The conversation-shaped half of a detail, loaded after the core can already render. */
253export interface ProviderChangeRequestActivity {
254 /** An optional richer actor, e.g. after GitHub's GraphQL read supplies an avatar. */
255 readonly author?: PullRequestActor | null;
256 /** Optional because most hosts already report their reviewer list in the core detail. */
257 readonly reviewers?: ReadonlyArray<PullRequestActor>;
258 readonly comments: ReadonlyArray<PullRequestComment>;
259 /**
260 * The host's own count of the conversation, which a bounded read can fall short of. A host
261 * that reports no count of its own answers with what it handed over, which is the same number
262 * once the read went to the end.
263 */
264 readonly commentCount: number;
265 readonly commentsTruncated: boolean;
266 readonly reviewThreadsTruncated?: boolean;
267 readonly reviewThreads: ReadonlyArray<PullRequestReviewThread>;
268 readonly commits: ReadonlyArray<PullRequestCommit>;
269 /** The change request's own reactions, from a host that has them. */
270 readonly reactions?: ReadonlyArray<PullRequestReaction>;
272​
273export interface ProviderDiffSlice {
274 readonly patch: string;
275 /** Something in this slice could not be shown, as opposed to there being more slices. */
276 readonly truncated: boolean;
277 readonly nextCursor: string | null;
278 /** The host's own counts for the files whose hunks it withheld from this slice. */
279 readonly omittedFileStats?: ReadonlyArray<PullRequestOmittedFileStat>;
281​
282export interface ProviderDiffFileContents {
283 readonly oldContents: string;
284 readonly newContents: string;
286​
287export interface ProviderFilesViewed {
288 readonly files: ReadonlyArray<PullRequestFileViewed>;
289 /** The host has more files than were read, so the ones missing here are not "unviewed". */
290 readonly truncated: boolean;
292​
293/**
294 * What version each of the asked-for files is at, on the change request's head. Opaque strings,
295 * compared only against one another, where the empty string is the answer for a file the change
296 * request deletes rather than a gap. A path is absent only where the read could not say, so a
297 * provider converts its host's own absences on the way here.
298 *
299 * The whole path a version travels, and the three senses of null along it, are in
300 * `docs/internals/pull-request-file-revisions.md`.
301 */
302export interface ProviderFileRevisions {
303 readonly revisions: ReadonlyMap<string, string>;
304 /**
305 * Whether these are every file the change request carries rather than only the paths asked
306 * about. A host with no per-file version reads the whole change to answer for one file, and
307 * saying so is what keeps the next tick, naming a path nothing asked about before, from making
308 * it read the whole change again. False for a read cut short, which cannot speak past the cut.
309 */
310 readonly complete?: boolean;
312​
313export interface ProviderRepositoryRef {
314 readonly cwd: string;
315 /** Provider-native repository identity, e.g. `owner/repo` or `group/subgroup/project`. */
316 readonly repository: string;
317 /**
318 * The host it lives on, which `repository` deliberately leaves out — the same `owner/repo`
319 * exists on github.com and on a GitHub Enterprise install, and only the caller knows which
320 * one a project's remote points at.
321 */
322 readonly host: string;
324​
325/**
326 * One host's change requests. Implementations own their own tool and JSON shapes and hand back
327 * the neutral types above; anything a host cannot do is declared in `capabilities` rather than
328 * failing at call time.
329 */
330export interface PullRequestProviderApi {
331 readonly withVerifiedCredential?: <A, E, R>(
332 input: { readonly cwd: string; readonly host: string },
333 use: (identity: {
334 readonly accountId: string;
335 readonly viewer: string;
336 readonly credentialFingerprint: string;
337 }) => Effect.Effect<A, E, R>,
338 ) => Effect.Effect<A, E | PullRequestProviderError, R>;
339 readonly getRoutingIdentity?: (input: {
340 readonly cwd: string;
341 readonly host: string;
342 }) => Effect.Effect<
343 { readonly accountId: string; readonly viewer: string },
344 PullRequestProviderError
345 >;
346 readonly kind: SourceControlProviderKind;
347 readonly capabilities: PullRequestCapabilities;
348​
349 /** The signed-in account, which is what involvement filtering compares against. */
350 readonly getViewer: (input: {
351 readonly cwd: string;
352 readonly host?: string;
353 }) => Effect.Effect<string, PullRequestProviderError>;
354​
355 readonly listChangeRequests: (
356 input: ProviderRepositoryRef & {
357 readonly state: PullRequestListState;
358 readonly involvement: PullRequestInvolvement;
359 readonly viewer: string;
360 readonly limit: number;
361 /**
362 * Free text to narrow the listing by, as the host understands it. A host with no text
363 * filter of its own ignores it and answers with the page it would have answered with
364 * anyway — the caller narrows what it gets, so an unfiltered page is a wider answer
365 * rather than a wrong one.
366 */
367 readonly query?: string | undefined;
368 /**
369 * Where to carry on from, rather than reading this repository from its newest row. Absent
370 * asks for the first slice, which is every listing that has not been continued.
371 */
372 readonly cursor?: ProviderListCursor | undefined;
373 /**
374 * Further narrowings, which a host applies as far as it can and ignores the rest of —
375 * an unnarrowed page is a wider answer rather than a wrong one, and the caller narrows
376 * what it gets for the fields a row carries.
377 */
378 readonly filters?: PullRequestListFilters | undefined;
379 },
380 ) => Effect.Effect<ProviderChangeRequestPage, PullRequestProviderError>;
381​
382 /**
383 * The same listing for a whole host in one request, for a host that has a search across
384 * repositories. Optional: three of the four hosts here have no such API, and breaking the port
385 * for them to spare GitHub a fan-out would be paying for the fix with everyone else's clarity.
386 * The caller falls back to `listChangeRequests` per repository where this is absent, and where
387 * it fails.
388 *
389 * `limit` is the whole slice rather than a size per repository, because that is the shape of
390 * the answer: the newest `limit` rows across every repository named, which is exactly the rows
391 * a page ordered by update shows.
392 *
393 * `cursor` is one boundary for all of them, so a caller with repositories standing at different
394 * boundaries asks in groups rather than in one call.
395 */
396 readonly listChangeRequestsAcross?: (input: {
397 /** Any checkout on the host, which is what the tool is run in. */
398 readonly cwd: string;
399 readonly host: string;
400 readonly repositories: ReadonlyArray<string>;
401 readonly state: PullRequestListState;
402 readonly involvement: PullRequestInvolvement;
403 readonly viewer: string;
404 readonly limit: number;
405 readonly query?: string | undefined;
406 readonly cursor?: ProviderListCursor | undefined;
407 readonly filters?: PullRequestListFilters | undefined;
408 }) => Effect.Effect<ProviderBatchedChangeRequestPage, PullRequestProviderError>;
409​
410 /**
411 * The line counts for rows a listing has already handed over. Only implemented by a provider
412 * whose listing leaves them out — for everyone else the numbers arrived with the row, and the
413 * caller has nothing to ask for.
414 */
415 readonly listChangeRequestStats?: (input: {
416 readonly cwd: string;
417 readonly host: string;
418 readonly changeRequests: ReadonlyArray<{
419 readonly repository: string;
420 readonly number: number;
421 }>;
422 }) => Effect.Effect<ReadonlyArray<ProviderChangeRequestStat>, PullRequestProviderError>;
423​
424 readonly getChangeRequestChecks?: (
425 input: ProviderRepositoryRef & { readonly number: number },
426 ) => Effect.Effect<PullRequestChecks, PullRequestProviderError>;
427​
428 readonly getChangeRequest: (
429 input: ProviderRepositoryRef & { readonly number: number },
430 ) => Effect.Effect<ProviderChangeRequestDetail, PullRequestProviderError>;
431​
432 /** Hosts without a narrow read use their existing detail response for hover cards. */
433 readonly getChangeRequestPreview?: (
434 input: ProviderRepositoryRef & { readonly number: number },
435 ) => Effect.Effect<
436 Omit<PullRequestPreview, "projectId" | "repository">,
437 PullRequestProviderError
438 >;
439​
440 /**
441 * The cheap live fields used by linked threads. Optional because a provider without a narrow
442 * endpoint can fall back to its full detail read at the service boundary.
443 */
444 readonly getChangeRequestSummary?: (
445 input: ProviderRepositoryRef & { readonly number: number },
446 ) => Effect.Effect<ProviderChangeRequestSummary, PullRequestProviderError>;
447​
448 /**
449 * A cheap fingerprint of what a pull request watch reports, so it reads the change request in
450 * full only when this moves. Null when the host gave no answer for it. Optional: a host
451 * without one has its watched change requests read in full on every pass.
452 */
453 readonly getChangeRequestWatchFingerprint?: (
454 input: ProviderRepositoryRef & { readonly number: number },
455 ) => Effect.Effect<ProviderChangeRequestWatchFingerprint | null, PullRequestProviderError>;
456​
457 /**
458 * The host-native stack a change request belongs to, or null when it is not stacked. Optional
459 * because most hosts have no such object; the service derives chains from base branches there.
460 */
461 readonly getChangeRequestStack?: (
462 input: ProviderRepositoryRef & { readonly includeDetails?: boolean; readonly number: number },
463 ) => Effect.Effect<ProviderChangeRequestStack | null, PullRequestProviderError>;
464​
465 /** Comments, line threads, and commits, kept off the critical path for the core detail. */
466 readonly getChangeRequestActivity: (
467 input: ProviderRepositoryRef & { readonly number: number },
468 ) => Effect.Effect<ProviderChangeRequestActivity, PullRequestProviderError>;
469​
470 /** One explicit page after a reader asks to continue an unfinished review thread. */
471 readonly getReviewThreadComments?: (
472 input: ProviderRepositoryRef & {
473 readonly number: number;
474 readonly threadId: string;
475 readonly cursor: string;
476 },
477 ) => Effect.Effect<PullRequestThreadCommentsResult, PullRequestProviderError>;
478​
479 /**
480 * The same answer `getChangeRequest` carries, on its own. Asked before anything is written, so
481 * a request that reached the server without going past the page is refused by what the host
482 * says rather than by what the client claimed — and asked freshly, because access granted or
483 * taken away since the page loaded is exactly the case this guards.
484 *
485 * Implementations read the cheapest thing that answers it, which for a host with nothing to say
486 * is no request at all.
487 */
488 readonly getViewerPermissions: (
489 input: ProviderRepositoryRef & {
490 readonly number: number;
491 /** Skip branch comparison when checking permission for an unrelated operation. */
492 readonly includeUpdateBranch?: boolean;
493 },
494 ) => Effect.Effect<PullRequestViewerPermissions, PullRequestProviderError>;
495​
496 /**
497 * One slice of the patch. Only called when `capabilities.diff` is true. A provider that can
498 * serve the whole diff at once answers with `nextCursor: null` and is done; one that pages
499 * hands back whatever it needs to find the next slice.
500 */
501 readonly getDiff: (
502 input: ProviderRepositoryRef & {
503 readonly number: number;
504 readonly cursor?: string | undefined;
505 /** One commit's own changes, rather than everything the change request carries. */
506 readonly commit?: string | undefined;
507 },
508 ) => Effect.Effect<ProviderDiffSlice, PullRequestProviderError>;
509​
510 /**
511 * Full files at the exact revisions the host used for its patch. Optional where the provider
512 * exposes no diff at all; the service refuses expansion there just as it refuses the patch.
513 */
514 readonly getDiffFileContents?: (
515 input: ProviderRepositoryRef & {
516 readonly number: number;
517 readonly commit?: string | undefined;
518 readonly changeType: "change" | "rename-pure" | "rename-changed" | "new" | "deleted";
519 readonly oldPath: string;
520 readonly newPath: string;
521 },
522 ) => Effect.Effect<ProviderDiffFileContents, PullRequestProviderError>;
523​
524 /**
525 * Which files the reader has already cleared. Only called when `capabilities.viewedFiles` is
526 * `"host"`, and read apart from the patch: this moves with every press rather than every push.
527 */
528 readonly getFilesViewed?: (
529 input: ProviderRepositoryRef & { readonly number: number },
530 ) => Effect.Effect<ProviderFilesViewed, PullRequestProviderError>;
531​
532 /**
533 * Clears files, or puts them back. Only called when `capabilities.viewedFiles` is `"host"`.
534 * A host with no bulk form is still owed one round trip for the batch rather than one per file,
535 * since the point of gathering presses is that the host is asked once.
536 */
537 readonly setFilesViewed?: (
538 input: ProviderRepositoryRef & {
539 readonly number: number;
540 readonly files: ReadonlyArray<{ readonly path: string; readonly viewed: boolean }>;
541 },
542 ) => Effect.Effect<void, PullRequestProviderError>;
543​
544 /**
545 * What version the head has of each of these files. Required of a host whose
546 * `capabilities.viewedFiles` is `"environment"`, and unused by one that keeps the marks itself:
547 * the marks live here, but only the host can say whether what a reader cleared last week is
548 * still what is in front of them. Asked for the marked paths alone, so the cost follows how
549 * much of the change request has been read rather than how large it is.
550 */
551 readonly getFileRevisions?: (
552 input: ProviderRepositoryRef & {
553 readonly number: number;
554 readonly paths: ReadonlyArray<string>;
555 },
556 ) => Effect.Effect<ProviderFileRevisions, PullRequestProviderError>;
557​
558 readonly runAction: (
559 input: ProviderRepositoryRef & {
560 readonly number: number;
561 readonly action: PullRequestAction;
562 readonly stackNumber?: number;
563 readonly expectedStackHeads?: ReadonlyArray<PullRequestStackHead>;
564 /** GitHub merge message cleanup; ignored by hosts without support. */
565 readonly removeAgentCreditsOnMerge?: boolean;
566 /** Meaningful for `merge` and `enable-auto-merge`; absent takes the host's own default. */
567 readonly mergeMethod?: PullRequestMergeMethod;
568 /** Only meaningful for `update-branch`; absent takes the host's own default. */
569 readonly updateMethod?: PullRequestUpdateMethod;
570 },
571 ) => Effect.Effect<void, PullRequestProviderError>;
572​
573 /**
574 * Rewrites the change request's own words. Only called when `capabilities.edit.changeRequest`
575 * is true, and never with both fields absent — the caller refuses that before it gets here,
576 * because a host asked to change nothing answers differently on each of them.
577 */
578 readonly updateChangeRequest?: (
579 input: ProviderRepositoryRef & {
580 readonly number: number;
581 readonly title?: string | undefined;
582 readonly body?: string | undefined;
583 },
584 ) => Effect.Effect<void, PullRequestProviderError>;
585​
586 readonly comment: (
587 input: ProviderRepositoryRef & { readonly number: number; readonly body: string },
588 ) => Effect.Effect<void, PullRequestProviderError>;
589​
590 /**
591 * Rewrites a remark somebody already posted. Only called when `capabilities.edit.comment` is
592 * true, with an id exactly as the conversation carried it.
593 *
594 * Whether this remark is the reader's to rewrite is the host's own answer: no read here can
595 * settle it, since access can be taken away between the conversation being read and the
596 * rewrite being sent, and a host refuses a stranger's remark with a sentence saying so.
597 */
598 readonly updateComment?: (
599 input: ProviderRepositoryRef & {
600 readonly number: number;
601 readonly commentId: string;
602 readonly kind: "issue-comment" | "review-comment";
603 readonly body: string;
604 },
605 ) => Effect.Effect<void, PullRequestProviderError>;
606​
607 /**
608 * Sends a whole review at once. Only called for a verdict the host declared in
609 * `capabilities.review.verdicts`, and with line comments only where it declared
610 * `inlineComment`.
611 */
612 readonly submitReview: (
613 input: ProviderRepositoryRef & {
614 readonly number: number;
615 readonly verdict: PullRequestReviewVerdict;
616 readonly body: string;
617 readonly comments: ReadonlyArray<PullRequestReviewCommentDraft>;
618 },
619 ) => Effect.Effect<void, PullRequestProviderError>;
620​
621 /**
622 * The people this viewer may ask for a review, with whoever has already been asked marked as
623 * such. Only called when `capabilities.reviewers.listCandidates` is true.
624 *
625 * The author is left out by each provider rather than by the caller, because only the provider
626 * knows how the host spells the same person in a candidate list and on a pull request.
627 */
628 readonly listReviewerCandidates: (
629 input: ProviderRepositoryRef & { readonly number: number },
630 ) => Effect.Effect<PullRequestReviewerCandidateList, PullRequestProviderError>;
631​
632 /**
633 * Asks for a review, or takes the request back. Only called when
634 * `capabilities.reviewers.request` is true.
635 *
636 * One call for both directions, because that is what every host does with them: GitHub posts and
637 * deletes the same collection, and GitLab and Bitbucket write the whole reviewer set either way.
638 * Asking again somebody who has already reviewed is a request like any other — which is how a
639 * re-request is made.
640 */
641 readonly setReviewerRequest: (
642 input: ProviderRepositoryRef & {
643 readonly number: number;
644 readonly reviewers: ReadonlyArray<{
645 readonly id: string;
646 readonly kind: PullRequestReviewerKind;
647 }>;
648 readonly requested: boolean;
649 },
650 ) => Effect.Effect<void, PullRequestProviderError>;
651​
652 /**
653 * The repository's labels, with the ones already on the change request marked. Present with
654 * `setLabels` only where `capabilities.labels` is true; the service refuses both without it.
655 */
656 readonly listLabelCandidates?: (
657 input: ProviderRepositoryRef & { readonly number: number },
658 ) => Effect.Effect<PullRequestLabelCandidateList, PullRequestProviderError>;
659​
660 /** Puts labels on the change request, or takes them off. One call for both directions. */
661 readonly setLabels?: (
662 input: ProviderRepositoryRef & {
663 readonly number: number;
664 readonly labels: ReadonlyArray<string>;
665 readonly applied: boolean;
666 },
667 ) => Effect.Effect<void, PullRequestProviderError>;
668​
669 /** Only called when `capabilities.review.reply` is true. */
670 readonly replyToThread: (
671 input: ProviderRepositoryRef & {
672 readonly number: number;
673 readonly threadId: string;
674 readonly body: string;
675 },
676 ) => Effect.Effect<void, PullRequestProviderError>;
677​
678 /**
679 * Adds a reaction, or takes it back. Only called when `capabilities.reactions` is true.
680 *
681 * `subjectId` is a remark's id as the conversation carried it; absent means the change request
682 * itself, whose reactions sit on its description. Whatever a host needs to address either of
683 * them is worked out here, because the id a conversation travels with is the one the reader has.
684 */
685 readonly setReaction: (
686 input: ProviderRepositoryRef & {
687 readonly number: number;
688 readonly subjectId?: string | undefined;
689 readonly content: PullRequestReactionContent;
690 readonly reacted: boolean;
691 },
692 ) => Effect.Effect<void, PullRequestProviderError>;
693​
694 /** Only called when `capabilities.review.resolve` is true. */
695 readonly setThreadResolution: (
696 input: ProviderRepositoryRef & {
697 readonly number: number;
698 readonly threadId: string;
699 readonly resolved: boolean;
700 },
701 ) => Effect.Effect<void, PullRequestProviderError>;