UNPKG

deepsource-mcp-server

Version:
184 lines (183 loc) 4.86 kB
/** * @fileoverview AnalysisRun aggregate root * * This module defines the AnalysisRun aggregate which represents a code analysis * run with its issues and summary statistics. */ import { AggregateRoot } from '../../shared/aggregate-root.js'; import { RunId, ProjectKey, GraphQLNodeId } from '../../../types/branded.js'; import { RunStatus, CommitInfo, RunTimestamps, IssueOccurrence, RunSummary, CreateAnalysisRunParams } from './analysis-run.types.js'; /** * AnalysisRun aggregate root * * Represents a single analysis run on a repository commit. * Tracks the status, issues found, and summary statistics. * * @example * ```typescript * const run = AnalysisRun.create({ * runId: asRunId('550e8400-e29b-41d4-a716-446655440000'), * projectKey: asProjectKey('my-project'), * repositoryId: asGraphQLNodeId('repo123'), * commitInfo: { * oid: asCommitOid('abc123'), * branch: asBranchName('main'), * baseOid: asCommitOid('def456') * } * }); * * run.start(); * run.addIssue(issueOccurrence); * run.complete(); * ``` */ export declare class AnalysisRun extends AggregateRoot<RunId> { private _projectKey; private _repositoryId; private _commitInfo; private _status; private _timestamps; private _issues; private _summary; private constructor(); /** * Creates a new AnalysisRun aggregate * * @param params - Creation parameters * @returns A new AnalysisRun instance */ static create(params: CreateAnalysisRunParams): AnalysisRun; /** * Gets the run ID */ get runId(): RunId; /** * Gets the project key */ get projectKey(): ProjectKey; /** * Gets the repository ID */ get repositoryId(): GraphQLNodeId; /** * Gets the commit information */ get commitInfo(): Readonly<CommitInfo>; /** * Gets the current status */ get status(): RunStatus; /** * Gets the timestamps */ get timestamps(): Readonly<RunTimestamps>; /** * Gets the issues found */ get issues(): ReadonlyArray<IssueOccurrence>; /** * Gets the run summary */ get summary(): Readonly<RunSummary>; /** * Checks if the run is finished */ get isFinished(): boolean; /** * Checks if the run can be modified */ get canModify(): boolean; /** * Starts the analysis run * * @throws Error if the status transition is invalid */ start(): void; /** * Completes the analysis run successfully * * @throws Error if the status transition is invalid */ complete(): void; /** * Fails the analysis run * * @param reason - The reason for failure * @throws Error if the status transition is invalid */ fail(reason: string): void; /** * Times out the analysis run * * @throws Error if the status transition is invalid */ timeout(): void; /** * Cancels the analysis run * * @param reason - The reason for cancellation * @throws Error if the status transition is invalid */ cancel(reason: string): void; /** * Skips the analysis run * * @param reason - The reason for skipping * @throws Error if the status transition is invalid */ skip(reason: string): void; /** * Adds an issue to the run * * @param issue - The issue occurrence to add * @throws Error if the run is finished */ addIssue(issue: IssueOccurrence): void; /** * Removes an issue from the run * * @param issueId - The ID of the issue to remove * @throws Error if the run is finished */ removeIssue(issueId: string): void; /** * Transitions to a new status * * @param newStatus - The target status * @throws Error if the transition is invalid */ private transitionTo; /** * Updates the summary based on current issues */ private updateSummary; /** * Reconstructs an AnalysisRun from persisted data * * @param data - Persisted run data * @returns A reconstructed AnalysisRun instance */ static fromPersistence(data: { runId: RunId; projectKey: ProjectKey; repositoryId: GraphQLNodeId; commitInfo: CommitInfo; status: RunStatus; timestamps: RunTimestamps; issues: IssueOccurrence[]; summary: RunSummary; }): AnalysisRun; /** * Converts the run to a persistence-friendly format */ toPersistence(): { runId: RunId; projectKey: ProjectKey; repositoryId: GraphQLNodeId; commitInfo: CommitInfo; status: RunStatus; timestamps: RunTimestamps; issues: IssueOccurrence[]; summary: RunSummary; }; }