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

PullRequestProvider.ts

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