import * as Schema from "effect/Schema"; import * as HttpServerRespondable from "effect/http/HttpServerRespondable"; import * as HttpServerResponse from "effect/http/HttpServerResponse"; import { IsoDateTime, NonNegativeInt, PositiveInt, ProjectId, ThreadId, TrimmedNonEmptyString, } from "./baseSchemas.ts"; import { PullRequestActor, PullRequestLabel, PullRequestReaction, PullRequestReactionContent, PullRequestState, } from "./pullRequest.ts"; /** * Which tracker an issue lives in. Git hosts reuse their `SourceControlProviderKind` spelling * (`github`, `gitlab`); standalone trackers get their own (`linear`, `jira`). Branded apart from * the source control kind because the two sets are not the same: Bitbucket is a git host with no * tracker, and Linear is a tracker with no git host. */ export const IssueTrackerKind = TrimmedNonEmptyString.check( Schema.isMaxLength(64), Schema.isPattern(/^[a-z][a-z0-9-]*$/), ).pipe(Schema.brand("IssueTrackerKind")); export type IssueTrackerKind = typeof IssueTrackerKind.Type; /** * One saved account of a standalone tracker. A tracker's first account has none: it predates * accounts, and keeps its credential and bindings unchanged. */ export const IssueTrackerAccountId = TrimmedNonEmptyString.check( Schema.isMaxLength(64), Schema.isPattern(/^[a-z0-9][a-z0-9-]*$/), ).pipe(Schema.brand("IssueTrackerAccountId")); export type IssueTrackerAccountId = typeof IssueTrackerAccountId.Type; export const IssueActor = PullRequestActor; export type IssueActor = typeof IssueActor.Type; export const IssueLabel = PullRequestLabel; export type IssueLabel = typeof IssueLabel.Type; /** * Where an issue stands: the tracker's own name for the state ("In Review", "Closed as not * planned"), which is what people read and what a move is asked for by, and the category every * tracker has, which only filters and colours key off. Nothing moves an issue to "open" or * "closed": it moves to one of the states its `IssueDetail.states` lists. */ export const IssueStateCategory = Schema.Literals(["open", "closed"]); export type IssueStateCategory = typeof IssueStateCategory.Type; export const IssueState = Schema.Struct({ category: IssueStateCategory, name: TrimmedNonEmptyString, /** How a closed state ended, where the tracker says: `completed`, or its word for not done. */ closeReason: Schema.optional(TrimmedNonEmptyString), }); export type IssueState = typeof IssueState.Type; /** What a listing asks for: either category, or both. */ export const IssueListState = Schema.Literals(["all", "open", "closed"]); export type IssueListState = typeof IssueListState.Type; export const IssueInvolvement = Schema.Literals(["all", "assigned", "authored", "mentioned"]); export type IssueInvolvement = typeof IssueInvolvement.Type; /** Newest first by the named date. */ export const IssueListSort = Schema.Literals(["updated", "created"]); export type IssueListSort = typeof IssueListSort.Type; export const IssueReactionContent = PullRequestReactionContent; export type IssueReactionContent = typeof IssueReactionContent.Type; export const IssueReaction = PullRequestReaction; export type IssueReaction = typeof IssueReaction.Type; /** * Addresses one issue: `scope` is the tracker's own container (`owner/repo`, a team key) and * `key` the issue's native id in it. `host` is absent for the kind's public host. `projectId` * names the project whose credentials serve the read, which need not own the issue. */ export const IssueRef = Schema.Struct({ projectId: ProjectId, tracker: IssueTrackerKind, host: Schema.optional(TrimmedNonEmptyString), scope: TrimmedNonEmptyString, key: TrimmedNonEmptyString, }); export type IssueRef = typeof IssueRef.Type; /** A scope with no issue in it, for reads about the container itself: templates, candidates. */ export const IssueScopeRef = Schema.Struct({ projectId: ProjectId, tracker: IssueTrackerKind, host: Schema.optional(TrimmedNonEmptyString), scope: TrimmedNonEmptyString, }); export type IssueScopeRef = typeof IssueScopeRef.Type; /** One row of a listing. Carries everything a list needs and nothing a detail needs. */ export const IssueSummary = Schema.Struct({ tracker: IssueTrackerKind, host: TrimmedNonEmptyString, scope: TrimmedNonEmptyString, key: TrimmedNonEmptyString, /** How the tracker writes the key for people: `#123` on a git host, `ENG-123` on Linear. */ displayKey: TrimmedNonEmptyString, title: TrimmedNonEmptyString, url: TrimmedNonEmptyString, author: Schema.NullOr(IssueActor), state: IssueState, createdAt: IsoDateTime, updatedAt: IsoDateTime, closedAt: Schema.NullOr(IsoDateTime), assignees: Schema.Array(IssueActor), labels: Schema.Array(IssueLabel), commentCount: NonNegativeInt, }); export type IssueSummary = typeof IssueSummary.Type; export const IssueListEntry = Schema.Struct({ ...IssueSummary.fields, projectId: ProjectId, projectTitle: TrimmedNonEmptyString, }); export type IssueListEntry = typeof IssueListEntry.Type; export const IssueComment = Schema.Struct({ id: TrimmedNonEmptyString, author: Schema.NullOr(IssueActor), body: Schema.String, createdAt: IsoDateTime, url: Schema.NullOr(Schema.String), /** Absent from a tracker with no reactions, which differs from none on this comment. */ reactions: Schema.optional(Schema.Array(IssueReaction)), }); export type IssueComment = typeof IssueComment.Type; /** * Something that happened to an issue that nobody wrote words for: it was closed, labelled, * assigned, renamed. Kinds are the common vocabulary; a tracker drops what it cannot map rather * than guessing. */ export const IssueEventKind = Schema.Literals([ "closed", "reopened", "labeled", "unlabeled", "assigned", "unassigned", "renamed", "referenced", "state-changed", ]); export type IssueEventKind = typeof IssueEventKind.Type; export const IssueEvent = Schema.Struct({ id: TrimmedNonEmptyString, kind: IssueEventKind, actor: Schema.NullOr(IssueActor), createdAt: IsoDateTime, /** What the event was about, where it has a subject: a label name, a login, a new title. */ detail: Schema.NullOr(TrimmedNonEmptyString), }); export type IssueEvent = typeof IssueEvent.Type; /** A change request the tracker says closes or mentions this issue. */ export const IssueLinkedPullRequest = Schema.Struct({ repository: TrimmedNonEmptyString, number: PositiveInt, title: TrimmedNonEmptyString, url: TrimmedNonEmptyString, state: PullRequestState, isDraft: Schema.Boolean, /** Merging it closes this issue, rather than only citing it. */ closesIssue: Schema.Boolean, }); export type IssueLinkedPullRequest = typeof IssueLinkedPullRequest.Type; /** * What a tracker can do at all, so a surface never offers an action that would fail. The * service refuses a call outside these before it reaches the driver. */ export const IssueCapabilities = Schema.Struct({ create: Schema.Boolean, /** Title and body can be rewritten after filing. */ edit: Schema.Boolean, comment: Schema.Boolean, labels: Schema.Boolean, assignees: Schema.Boolean, /** Reactions can be read and written on the issue and its comments. */ reactions: Schema.Boolean, /** The scope offers starting points for a new issue. */ templates: Schema.Boolean, /** The tracker reports linked change requests of its own accord. */ linkedPullRequests: Schema.Boolean, /** State changes arrive as events beside the comments, not only as comments. */ events: Schema.Boolean, /** The tracker narrows a listing by free text itself. */ search: Schema.Boolean, }); export type IssueCapabilities = typeof IssueCapabilities.Type; /** * What the signed-in account may do with this issue, which `capabilities` says nothing about. * A permission the tracker reports nothing about is granted, so a refusal comes from the * tracker, which says why, rather than from a missing control. */ export const IssueViewerPermissions = Schema.Struct({ setState: Schema.Boolean, comment: Schema.Boolean, edit: Schema.Boolean, labels: Schema.Boolean, assignees: Schema.Boolean, }); export type IssueViewerPermissions = typeof IssueViewerPermissions.Type; export const IssueDetail = Schema.Struct({ ...IssueSummary.fields, projectId: ProjectId, projectTitle: TrimmedNonEmptyString, /** False for an issue outside every project's scope, which is read-only through this server. */ writable: Schema.Boolean, capabilities: IssueCapabilities, viewerPermissions: IssueViewerPermissions, /** * Every state this issue can be in, in the tracker's workflow order, its current one included. * Empty means its state cannot be changed from here. */ states: Schema.Array(IssueState), /** The signed-in account, so a comment edit is offered only on the viewer's own remarks. */ viewer: Schema.NullOr(TrimmedNonEmptyString), body: Schema.String, reactions: Schema.optional(Schema.Array(IssueReaction)), comments: Schema.Array(IssueComment), /** Where older comments carry on; null once the conversation is whole. */ commentsCursor: Schema.NullOr(TrimmedNonEmptyString), events: Schema.Array(IssueEvent), linkedPullRequests: Schema.Array(IssueLinkedPullRequest), }); export type IssueDetail = typeof IssueDetail.Type; /** Older comments, one page past a cursor the detail or a previous page handed over. */ export const IssueCommentsPageInput = Schema.Struct({ ...IssueRef.fields, cursor: TrimmedNonEmptyString.check(Schema.isMaxLength(4_096)), }); export type IssueCommentsPageInput = typeof IssueCommentsPageInput.Type; export const IssueCommentsPage = Schema.Struct({ comments: Schema.Array(IssueComment), nextCursor: Schema.NullOr(TrimmedNonEmptyString), }); export type IssueCommentsPage = typeof IssueCommentsPage.Type; /** Where each scope a listing already reached carries on, keyed `" "`. */ export const IssueListCursors = Schema.Record( TrimmedNonEmptyString, TrimmedNonEmptyString.check(Schema.isMaxLength(4_096)), ); export type IssueListCursors = typeof IssueListCursors.Type; export const IssueListInput = Schema.Struct({ state: IssueListState, involvement: Schema.optional(IssueInvolvement), projectId: Schema.optional(ProjectId), /** Narrows to one host, named as the host itself. Absent means every host the workspace has. */ host: Schema.optional(TrimmedNonEmptyString), /** Rows per scope, which with a continuation is rows per slice. */ limit: Schema.optional(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 200 }))), /** Carry on from an earlier answer: only the scopes named here are read, one slice each. */ cursors: Schema.optional(IssueListCursors), /** An explicit refresh of the first page may also refresh tracker metadata. */ refresh: Schema.optional(Schema.Boolean), /** Free text the trackers themselves are asked to match. */ query: Schema.optional(TrimmedNonEmptyString.check(Schema.isMaxLength(200))), /** Label names an issue must carry, every one of them. */ labels: Schema.optional( Schema.Array(TrimmedNonEmptyString.check(Schema.isMaxLength(200))).check( Schema.isMaxLength(20), ), ), /** An assignee's `login`, as an issue of that tracker names them. */ assignee: Schema.optional(TrimmedNonEmptyString.check(Schema.isMaxLength(320))), /** Absent means `updated`. */ sort: Schema.optional(IssueListSort), }); export type IssueListInput = typeof IssueListInput.Type; /** One tracker account the workspace has projects on, and whether it can be read right now. */ export const IssueTrackerSummary = Schema.Struct({ tracker: IssueTrackerKind, host: TrimmedNonEmptyString, projectCount: PositiveInt, capabilities: Schema.NullOr(IssueCapabilities), /** False when the tracker's tool or credentials are missing, with `detail` saying which. */ configured: Schema.Boolean, detail: Schema.NullOr(TrimmedNonEmptyString), }); export type IssueTrackerSummary = typeof IssueTrackerSummary.Type; export const IssueListProjectError = Schema.Struct({ projectId: ProjectId, projectTitle: TrimmedNonEmptyString, message: TrimmedNonEmptyString, }); export type IssueListProjectError = typeof IssueListProjectError.Type; export const IssueListResult = Schema.Struct({ /** The signed-in account per host that involvement compared against. Empty for `all`. */ viewers: Schema.Record(TrimmedNonEmptyString, TrimmedNonEmptyString), trackers: Schema.Array(IssueTrackerSummary), /** By update, newest first, across every scope this answer covers. */ entries: Schema.Array(IssueListEntry), errors: Schema.Array(IssueListProjectError), /** Where each scope carries on, sent straight back as `cursors`. Absent once a scope is done. */ nextCursors: IssueListCursors, /** * Every scope the listing covers, matched or not, with one project that reads it. A Linear team * bound in settings is named nowhere else. Absent from servers that predate it. */ scopes: Schema.optional(Schema.Array(IssueScopeRef)), }); export type IssueListResult = typeof IssueListResult.Type; const IssueTitle = TrimmedNonEmptyString.check(Schema.isMaxLength(1024)); // Not trimmed: a body is markdown, where leading spaces open a code block. The bound keeps // oversized payloads off the wire; the service rejects a comment that is only whitespace. const IssueBody = Schema.String.check(Schema.isMaxLength(65_536)); const CommentBody = Schema.String.check(Schema.isNonEmpty()).check(Schema.isMaxLength(65_536)); export const IssueCreateInput = Schema.Struct({ ...IssueScopeRef.fields, title: IssueTitle, /** May be empty: an issue with a title and nothing else is a legitimate one. */ body: IssueBody, labels: Schema.Array(TrimmedNonEmptyString).check(Schema.isMaxLength(50)), assignees: Schema.Array(TrimmedNonEmptyString).check(Schema.isMaxLength(25)), }); export type IssueCreateInput = typeof IssueCreateInput.Type; export const IssueCreateResult = Schema.Struct({ key: TrimmedNonEmptyString, displayKey: TrimmedNonEmptyString, url: TrimmedNonEmptyString, }); export type IssueCreateResult = typeof IssueCreateResult.Type; export const IssueCommentInput = Schema.Struct({ ...IssueRef.fields, body: CommentBody, }); export type IssueCommentInput = typeof IssueCommentInput.Type; /** * Rewrites the issue's own fields. Every field is optional and only the present ones are * written; `labels` and `assignees` are the whole set, which is how every tracker writes them. * The service refuses a request with nothing present. */ export const IssueUpdateInput = Schema.Struct({ ...IssueRef.fields, title: Schema.optional(IssueTitle), body: Schema.optional(IssueBody), labels: Schema.optional(Schema.Array(TrimmedNonEmptyString).check(Schema.isMaxLength(50))), assignees: Schema.optional(Schema.Array(TrimmedNonEmptyString).check(Schema.isMaxLength(25))), }); export type IssueUpdateInput = typeof IssueUpdateInput.Type; /** Moves the issue to one of the states the tracker declared in `capabilities.states`. */ export const IssueSetStateInput = Schema.Struct({ ...IssueRef.fields, /** The name of one of the issue's `states`. */ state: TrimmedNonEmptyString, }); export type IssueSetStateInput = typeof IssueSetStateInput.Type; export const IssueReactionInput = Schema.Struct({ ...IssueRef.fields, /** Absent reacts to the issue itself; present names a comment id as the detail carried it. */ subjectId: Schema.optional(TrimmedNonEmptyString), content: IssueReactionContent, reacted: Schema.Boolean, }); export type IssueReactionInput = typeof IssueReactionInput.Type; /** * One starting point a scope offers for a new issue. Only the body-shaped kind travels here: * GitHub's typed issue forms are flattened to a body by the driver, so a composer on any * tracker is one text box with a draft in it. */ export const IssueTemplate = Schema.Struct({ key: TrimmedNonEmptyString, name: TrimmedNonEmptyString, about: Schema.String, title: Schema.String, body: Schema.String, labels: Schema.Array(TrimmedNonEmptyString), assignees: Schema.Array(TrimmedNonEmptyString), }); export type IssueTemplate = typeof IssueTemplate.Type; /** A starting point only the tracker's own site can render: Linear's form and rich templates. */ export const IssueExternalTemplate = Schema.Struct({ name: TrimmedNonEmptyString, about: Schema.String, /** Opens the exact template on the tracker, ready to fill in. */ url: TrimmedNonEmptyString, }); export type IssueExternalTemplate = typeof IssueExternalTemplate.Type; export const IssueTemplateList = Schema.Struct({ templates: Schema.Array(IssueTemplate), /** Absent from a tracker whose every template is body-shaped. */ externalTemplates: Schema.optional(Schema.Array(IssueExternalTemplate)), /** False where the scope's config forbids an issue filed from nothing. */ blankIssuesEnabled: Schema.Boolean, }); export type IssueTemplateList = typeof IssueTemplateList.Type; export const IssueLabelCandidate = Schema.Struct({ ...IssueLabel.fields, description: Schema.NullOr(Schema.String), }); export type IssueLabelCandidate = typeof IssueLabelCandidate.Type; export const IssueAssigneeCandidate = Schema.Struct({ ...IssueActor.fields, /** How the tracker addresses this person on a write, which is not always the login. */ id: TrimmedNonEmptyString, }); export type IssueAssigneeCandidate = typeof IssueAssigneeCandidate.Type; /** The labels and people a scope offers, read when a picker opens rather than with every issue. */ export const IssueCandidates = Schema.Struct({ labels: Schema.Array(IssueLabelCandidate), assignees: Schema.Array(IssueAssigneeCandidate), /** The tracker has more than were read, so somebody missing is not necessarily ineligible. */ truncated: Schema.Boolean, }); export type IssueCandidates = typeof IssueCandidates.Type; export const IssueUnavailableReason = Schema.Literals([ "tool-missing", "unauthenticated", "tracker-unsupported", ]); export type IssueUnavailableReason = typeof IssueUnavailableReason.Type; /** The tracker cannot be read at all for this project, as opposed to one request failing. */ export class IssueUnavailableError extends Schema.TaggedError()( "IssueUnavailableError", { reason: IssueUnavailableReason, tracker: Schema.optional(IssueTrackerKind), cause: Schema.optional(Schema.Defect()), }, { httpApiStatus: 503 }, ) { [HttpServerRespondable.symbol]() { return HttpServerResponse.schemaJson(IssueUnavailableError)(this, { status: 503 }); } override get message(): string { switch (this.reason) { case "tool-missing": return "The tool this tracker is read through is not installed or set up."; case "unauthenticated": return "This tracker has no working credentials."; case "tracker-unsupported": return "Issues cannot be browsed for this project yet."; } } } export class IssueOperationError extends Schema.TaggedError()( "IssueOperationError", { operation: Schema.String, detail: TrimmedNonEmptyString, reason: Schema.optional(Schema.Literals(["not-found", "read-only", "rate-limited"])), retryAt: Schema.optional(Schema.Number), cause: Schema.optional(Schema.Defect()), }, { httpApiStatus: 502 }, ) { [HttpServerRespondable.symbol]() { return HttpServerResponse.schemaJson(IssueOperationError)(this, { status: 502 }); } override get message(): string { return `Issue operation ${this.operation} failed: ${this.detail}`; } } export type IssueError = IssueUnavailableError | IssueOperationError; /** Who created a thread ↔ issue link. */ export const ThreadIssueLinkSource = Schema.Literals(["manual", "agent"]); export type ThreadIssueLinkSource = typeof ThreadIssueLinkSource.Type; /** * Identity of an issue as a thread link sees it: tracker-level, so the same issue linked through * two projects compares equal. `host` is always written here, unlike `IssueRef`, because a link * outlives the project whose binding supplied the default. */ export const ThreadIssueKey = Schema.Struct({ tracker: IssueTrackerKind, host: TrimmedNonEmptyString, scope: TrimmedNonEmptyString, key: TrimmedNonEmptyString, }); export type ThreadIssueKey = typeof ThreadIssueKey.Type; /** * An issue linked to a thread. `projectId` is the project the issue is read through, which the * detail panel needs; `url` is what the agent or user handed over. */ export const ThreadIssueLink = Schema.Struct({ ...ThreadIssueKey.fields, projectId: ProjectId, url: TrimmedNonEmptyString, source: ThreadIssueLinkSource, linkedAt: IsoDateTime, /** As the tracker named the issue when it was linked; opening it reads the live state. */ displayKey: TrimmedNonEmptyString, title: TrimmedNonEmptyString, }); export type ThreadIssueLink = typeof ThreadIssueLink.Type; export function threadIssueKeyOf(key: ThreadIssueKey): string { return `${key.tracker}\u0000${key.host.trim().toLowerCase()}\u0000${key.scope.trim().toLowerCase()}\u0000${key.key.trim()}`; } export function threadIssueKeysEqual(left: ThreadIssueKey, right: ThreadIssueKey): boolean { return threadIssueKeyOf(left) === threadIssueKeyOf(right); } /** The threads an issue is linked to, most recently active first. */ export const IssueLinkedThreadsResult = Schema.Struct({ threads: Schema.Array( Schema.Struct({ id: ThreadId, projectId: ProjectId, title: Schema.String, archivedAt: Schema.NullOr(IsoDateTime), settled: Schema.Boolean, }), ), }); export type IssueLinkedThreadsResult = typeof IssueLinkedThreadsResult.Type; /** * A tracker that is not a git host: it is reached with its own credential rather than a * checkout's, and a project opts into it by binding one of the tracker's scopes. Everything a * client needs to draw the connect flow for any such tracker without knowing which one it is. */ export const StandaloneIssueTrackerDescriptor = Schema.Struct({ tracker: IssueTrackerKind, displayName: TrimmedNonEmptyString, /** Where the tracker is served from; what `IssueRef.host` carries for its issues. */ host: TrimmedNonEmptyString, /** What the tracker calls its container, in the singular: "team" on Linear, "project" on Jira. */ scopeNoun: TrimmedNonEmptyString, credential: Schema.Struct({ /** What the tracker calls the credential: "Personal API key", "API token". */ label: TrimmedNonEmptyString, /** Where to mint one, or null when the tracker has no stable page for it. */ helpUrl: Schema.NullOr(TrimmedNonEmptyString), }), }); export type StandaloneIssueTrackerDescriptor = typeof StandaloneIssueTrackerDescriptor.Type; /** Which standalone tracker scope a project's issues come from, beside its git host's own. */ export const IssueTrackerProjectBinding = Schema.Struct({ tracker: IssueTrackerKind, /** The account the scope is read with; absent for the tracker's first account. */ accountId: Schema.optional(IssueTrackerAccountId), scope: TrimmedNonEmptyString, }); export type IssueTrackerProjectBinding = typeof IssueTrackerProjectBinding.Type; /** One container the connected account can read, offered when a project is bound. */ export const IssueTrackerScope = Schema.Struct({ key: TrimmedNonEmptyString, name: TrimmedNonEmptyString, }); export type IssueTrackerScope = typeof IssueTrackerScope.Type; /** * A standalone tracker as the settings page sees it: the descriptor, whether a credential is * stored and still works, and the scopes it can reach. `scopes` is empty until connected. */ export const IssueTrackerConnection = Schema.Struct({ ...StandaloneIssueTrackerDescriptor.fields, /** Which of the tracker's accounts this is; absent for its first. */ accountId: Schema.optional(IssueTrackerAccountId), /** A credential is stored. It may still be rejected, which `account` being null reports. */ connected: Schema.Boolean, /** Who the credential signs in as, or null when there is none or it was refused. */ account: Schema.NullOr(TrimmedNonEmptyString), /** Why a stored credential did not work, when it did not. */ detail: Schema.NullOr(TrimmedNonEmptyString), /** The workspace the credential reaches, as its issue URLs name it; links elsewhere are foreign. */ workspace: Schema.optional(TrimmedNonEmptyString), scopes: Schema.Array(IssueTrackerScope), }); export type IssueTrackerConnection = typeof IssueTrackerConnection.Type; export const IssueTrackerConnectionList = Schema.Struct({ /** Each standalone tracker's first account. */ trackers: Schema.Array(IssueTrackerConnection), /** The accounts added beside a tracker's first, oldest first. Absent from older servers. */ accounts: Schema.optional(Schema.Array(IssueTrackerConnection)), /** * Which standalone tracker scope each project bound with a tracker's first account reads. A * project bound with an added account is in `accountBindings` instead, so older clients never * read another account's team as the first account's. */ bindings: Schema.Record(ProjectId, IssueTrackerProjectBinding), /** Projects bound with an added account. Absent from older servers. */ accountBindings: Schema.optional(Schema.Record(ProjectId, IssueTrackerProjectBinding)), }); export type IssueTrackerConnectionList = typeof IssueTrackerConnectionList.Type; /** * A credential for one standalone tracker account; `null` disconnects it and unbinds its * projects. `addAccount` saves the credential as a new account beside the existing ones. */ export const IssueTrackerConnectInput = Schema.Struct({ tracker: IssueTrackerKind, accountId: Schema.optional(IssueTrackerAccountId), addAccount: Schema.optional(Schema.Boolean), token: Schema.NullOr(TrimmedNonEmptyString.check(Schema.isMaxLength(4_096))), }); export type IssueTrackerConnectInput = typeof IssueTrackerConnectInput.Type; export const IssueTrackerBindProjectInput = Schema.Struct({ projectId: ProjectId, /** Null unbinds. */ binding: Schema.NullOr(IssueTrackerProjectBinding), }); export type IssueTrackerBindProjectInput = typeof IssueTrackerBindProjectInput.Type; /** * A standalone tracker the connect flow could not reach or that refused the credential, or a * binding that could not be saved. */ export class IssueTrackerConnectionError extends Schema.TaggedError()( "IssueTrackerConnectionError", { tracker: IssueTrackerKind, reason: Schema.Literals(["unknown-tracker", "rejected", "failed"]), detail: TrimmedNonEmptyString, cause: Schema.optional(Schema.Defect()), }, { httpApiStatus: 502 }, ) { [HttpServerRespondable.symbol]() { return HttpServerResponse.schemaJson(IssueTrackerConnectionError)(this, { status: 502 }); } override get message(): string { return `${this.tracker} connection failed: ${this.detail}`; } }