// What a run looks like, as data: every command maps its result to one of these and every renderer draws from it. import type { LinkTarget } from "@effected/cli-kit"; import type { DocumentDiff } from "@effected/engine/schema"; /** Who is reading: a person at a terminal, a person's pipe or a task runner, a CI log, or an agent. */ export type Setting = "terminal" | "plain" | "ci" | "agent"; /** How much to print. */ export type Level = "quiet" | "default" | "verbose"; /** Where a row is in its life. A settled view has no `pending` or `running` row unless the run stopped short. */ export type RowState = "pending" | "running" | "done" | "failed" | "skipped"; /** The colour a cell or a verdict takes where there is colour. */ export type Tone = "success" | "warning" | "error" | "muted"; /** One column of a row. */ export interface Cell { readonly text: string; readonly tone?: Tone; readonly link?: LinkTarget; } /** One step of a run: a pass, an entry, a schema, a file. */ export interface Row { /** Stable across the progress events that update the row. */ readonly id: string; readonly name: string; readonly state: RowState; readonly ms?: number; readonly cells: ReadonlyArray; /** Why the row failed or was held. */ readonly reason?: string; } /** What a group's rows came to. A delta is against the last successful recorded build, and absent when it is zero. */ export interface SizeTotal { readonly files?: number; readonly bytes: number; readonly gzip?: number; readonly deltaBytes?: number; } /** * Rows drawn together. A group with no title holds top-level rows (meta, validate, persist), one line each. * * @remarks * Compact, a titled group is one line naming each row and the total. With `list` it is a title and a line per row * instead, with the skipped rows counted under `skippedNoun` rather than listed: the shape for rows that are not * steps of one thing, such as schemas. */ export interface Group { readonly id: string; readonly title?: string; readonly rows: ReadonlyArray; readonly total?: SizeTotal; readonly list?: { readonly skippedNoun: string }; } /** One diagnostic. `source` is open: `api-extractor` gets the API block, and a `typescript` source needs no change. */ export interface Issue { readonly level: "error" | "warning"; readonly source: string; readonly code?: string; /** The rule's documentation, where it has a page. */ readonly codeUrl?: string; readonly file?: string; readonly line?: number; readonly column?: number; /** Where `file` is on disk, for a link: `file` itself is written as the report shows it. */ readonly link?: LinkTarget; readonly text: string; /** A warning that fails the build under CI. */ readonly ciFatal?: boolean; } /** A titled table shown at the verbose level: the resolved config, the files. */ export interface Block { readonly title: string; readonly rows: ReadonlyArray>; /** A CI log draws this block at the default level too, folded in a log group. */ readonly ci?: boolean; } /** The last line of every run. */ export interface Verdict { readonly tone: "success" | "warning" | "error"; /** `built`, `failed`, `check failed`, `current`. */ readonly label: string; readonly wallMs?: number; /** `0 errors, 15 warnings (1 fails CI), 5 suppressed`. Empty when there is nothing to count. */ readonly counts: string; /** Where the whole list of issues is. */ readonly issuesPath?: string; } /** One run, finished or in progress. */ export interface RunView { readonly command: string; readonly subject: string; readonly subjectLink?: LinkTarget; /** When the result was made, for a log: an old one marks a replayed cache hit. */ readonly timestamp?: string; /** Lines above the rows: a lock wait, a version mismatch, `--force`. */ readonly notices: ReadonlyArray; readonly groups: ReadonlyArray; readonly blocks: ReadonlyArray; readonly issues: ReadonlyArray; readonly suppressed: ReadonlyArray; readonly diffs: ReadonlyArray<{ readonly path: string; readonly diff: DocumentDiff }>; /** Present for a check, with no drift when the build matches. */ readonly check?: { readonly drift: ReadonlyArray<{ readonly target: string; readonly kind: string; readonly path: string }>; }; /** What to run next: `run: effected schema build`. */ readonly hints: ReadonlyArray; /** Why the run crashed. */ readonly failure?: string; readonly verdict: Verdict; }