UNPKG

deepsource-mcp-server

Version:
148 lines (147 loc) 3.93 kB
/** * @fileoverview Project aggregate root * * This module defines the Project aggregate which represents a DeepSource project * with its repository information and configuration settings. */ import { AggregateRoot } from '../../shared/aggregate-root.js'; import { ProjectKey } from '../../../types/branded.js'; import { ProjectRepository, ProjectConfiguration, ProjectStatus, CreateProjectParams, UpdateProjectParams } from './project.types.js'; /** * Project aggregate root * * Represents a DeepSource project with its repository and configuration. * Enforces business rules and maintains consistency within the aggregate boundary. * * @example * ```typescript * const project = Project.create({ * key: asProjectKey('my-project'), * name: 'My Project', * repository: { * url: 'https://github.com/user/repo', * provider: 'GITHUB', * login: 'user', * isPrivate: false * } * }); * * project.activate(); * project.updateConfiguration({ autoFix: true }); * ``` */ export declare class Project extends AggregateRoot<ProjectKey> { private _name; private _repository; private _configuration; private _status; private _createdAt; private _updatedAt; private constructor(); /** * Creates a new Project aggregate * * @param params - Project creation parameters * @returns A new Project instance * @throws Error if validation fails */ static create(params: CreateProjectParams): Project; /** * Validates if a string is a valid URL */ private static isValidUrl; /** * Gets the project key */ get key(): ProjectKey; /** * Gets the project name */ get name(): string; /** * Gets the repository information */ get repository(): Readonly<ProjectRepository>; /** * Gets the configuration settings */ get configuration(): Readonly<ProjectConfiguration>; /** * Gets the project status */ get status(): ProjectStatus; /** * Gets the creation timestamp */ get createdAt(): Date; /** * Gets the last update timestamp */ get updatedAt(): Date; /** * Checks if the project is active */ get isActive(): boolean; /** * Activates the project * * @throws Error if the project is archived */ activate(): void; /** * Deactivates the project */ deactivate(): void; /** * Archives the project * * Archived projects cannot be reactivated and are kept for historical purposes. */ archive(): void; /** * Updates the project information * * @param params - Update parameters * @throws Error if the project is archived */ update(params: UpdateProjectParams): void; /** * Updates the project configuration * * @param configuration - Partial configuration to update */ updateConfiguration(configuration: Partial<ProjectConfiguration>): void; /** * Checks if the project can run analysis * * @returns True if analysis can be run, false otherwise */ canRunAnalysis(): boolean; /** * Reconstructs a Project from persisted data * * @param data - Persisted project data * @returns A reconstructed Project instance */ static fromPersistence(data: { key: ProjectKey; name: string; repository: ProjectRepository; configuration: ProjectConfiguration; status: ProjectStatus; createdAt: Date; updatedAt: Date; }): Project; /** * Converts the project to a persistence-friendly format */ toPersistence(): { key: ProjectKey; name: string; repository: ProjectRepository; configuration: ProjectConfiguration; status: ProjectStatus; createdAt: Date; updatedAt: Date; }; }