import { LaneName } from "@usine/config/board"; import { AttemptId } from "@usine/core/attempt"; import { ReviewState } from "@usine/github/item-history"; import { type Brand, Schema } from "effect"; import { LabelView } from "../board.ts"; /** * A label that an Attempt's Agent added to the Run's Item, with GitHub's current label definition. */ export class LabelAddedView extends Schema.TaggedClass< LabelAddedView, Brand.Brand<"@usine/orchestrator/operator/github-changes/LabelAddedView"> >("@usine/orchestrator/LabelAddedView")("LabelAdded", { /** The change time as an ISO 8601 timestamp. */ at: Schema.String, /** The current GitHub label definition, including its name, color, and description. */ label: LabelView, }) {} /** * A label that an Attempt's Agent removed from the Run's Item, with GitHub's current label * definition. */ export class LabelRemovedView extends Schema.TaggedClass< LabelRemovedView, Brand.Brand<"@usine/orchestrator/operator/github-changes/LabelRemovedView"> >("@usine/orchestrator/LabelRemovedView")("LabelRemoved", { /** The change time as an ISO 8601 timestamp. */ at: Schema.String, /** The current GitHub label definition, including its name, color, and description. */ label: LabelView, }) {} /** A comment that an Attempt's Agent posted on the Run's Item. */ export class CommentedView extends Schema.TaggedClass< CommentedView, Brand.Brand<"@usine/orchestrator/operator/github-changes/CommentedView"> >("@usine/orchestrator/CommentedView")("Commented", { /** The change time as an ISO 8601 timestamp. */ at: Schema.String, /** The GitHub URL of the comment or review. */ url: Schema.String, }) {} /** A review that an Attempt's Agent submitted on the Run's pull request, with its current state. */ export class ReviewedView extends Schema.TaggedClass< ReviewedView, Brand.Brand<"@usine/orchestrator/operator/github-changes/ReviewedView"> >("@usine/orchestrator/ReviewedView")("Reviewed", { /** The change time as an ISO 8601 timestamp. */ at: Schema.String, /** The GitHub URL of the comment or review. */ url: Schema.String, /** The review state GitHub recorded, such as approved or changes requested. */ state: ReviewState, }) {} /** * An operator move of the Run's Item between Board lanes during an Attempt. `at` is when the * operator made the move. */ export class BoardMovedView extends Schema.TaggedClass< BoardMovedView, Brand.Brand<"@usine/orchestrator/operator/github-changes/BoardMovedView"> >("@usine/orchestrator/BoardMovedView")("BoardMoved", { /** The change time as an ISO 8601 timestamp. */ at: Schema.String, /** The lane name before the operator move. */ fromLane: LaneName, /** The lane name after the operator move. */ toLane: LaneName, }) {} /** * A change on the Run's GitHub Item during an Attempt: one made by the Agent, or an operator Board * move. */ export const GitHubChangeView = Schema.Union([ LabelAddedView, LabelRemovedView, CommentedView, ReviewedView, BoardMovedView, ]); /** * A change on the run's GitHub item during an attempt: one made by the agent, or an operator board * move. */ export type GitHubChangeView = typeof GitHubChangeView.Type; /** The changes on the Run's GitHub Item during one Attempt, oldest first. */ export class AttemptGitHubChangesView extends Schema.Class< AttemptGitHubChangesView, Brand.Brand<"@usine/orchestrator/operator/github-changes/AttemptGitHubChangesView"> >("@usine/orchestrator/AttemptGitHubChangesView")({ /** The attempt associated with this entry. */ attemptId: AttemptId, /** GitHub writes attributed to this attempt, in chronological order. */ changes: Schema.Array(GitHubChangeView), }) {} /** * The GitHub changes of each of a Run's Attempts, in Attempt order. Empty for a Run without a * GitHub Item, such as a schedule Run. */ export class RunGitHubChangesView extends Schema.Class< RunGitHubChangesView, Brand.Brand<"@usine/orchestrator/operator/github-changes/RunGitHubChangesView"> >("@usine/orchestrator/RunGitHubChangesView")({ /** Changes grouped by the run attempts. */ attempts: Schema.Array(AttemptGitHubChangesView), }) {}