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