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

PullRequestProvider.ts

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