deepsource-mcp-server
Version:
Model Context Protocol server for DeepSource
98 lines (97 loc) • 3.36 kB
TypeScript
/**
* @fileoverview Project repository implementation
*
* Concrete implementation of IProjectRepository using DeepSource API.
*/
import { IProjectRepository } from '../../domain/aggregates/project/project.repository.js';
import { Project } from '../../domain/aggregates/project/project.aggregate.js';
import { ProjectKey } from '../../types/branded.js';
import { ProjectsClient } from '../../client/projects-client.js';
/**
* Concrete implementation of IProjectRepository using DeepSource API
*
* This repository provides access to Project aggregates by fetching data
* from the DeepSource API and mapping it to domain models.
*
* Note: Since the DeepSource API doesn't support individual project queries
* or persistence operations, some methods fetch all projects and filter locally.
* This ensures fresh data retrieval on every request as per requirements.
*/
export declare class ProjectRepository implements IProjectRepository {
private readonly projectsClient;
constructor(projectsClient: ProjectsClient);
/**
* Finds a project by its unique identifier
*
* @param id - The project key
* @returns The project if found, null otherwise
*/
findById(id: ProjectKey): Promise<Project | null>;
/**
* Finds a project by its unique key
*
* @param key - The project key
* @returns The project if found, null otherwise
*/
findByKey(key: ProjectKey): Promise<Project | null>;
/**
* Finds all projects
*
* @returns All projects in the repository
*/
findAll(): Promise<Project[]>;
/**
* Finds all active projects
*
* @returns All projects with ACTIVE status
*/
findActive(): Promise<Project[]>;
/**
* Finds projects by repository provider
*
* @param provider - The VCS provider (e.g., 'GITHUB', 'GITLAB')
* @returns Projects using the specified provider
*/
findByProvider(provider: string): Promise<Project[]>;
/**
* Checks if a project exists with the given key
*
* @param key - The project key to check
* @returns True if the project exists, false otherwise
*/
exists(key: ProjectKey): Promise<boolean>;
/**
* Counts the total number of projects
*
* @returns The total project count
*/
count(): Promise<number>;
/**
* Counts the number of active projects
*
* @returns The active project count
*/
countActive(): Promise<number>;
/**
* Saves a project
*
* Note: The DeepSource API doesn't support creating/updating projects
* through the GraphQL API. This method is implemented to satisfy the
* interface but will throw an error indicating the operation is not supported.
*
* @param project - The project to save
* @throws Error indicating the operation is not supported
*/
save(project: Project): Promise<void>;
/**
* Deletes a project
*
* Note: The DeepSource API doesn't support deleting projects
* through the GraphQL API. This method is implemented to satisfy the
* interface but will throw an error indicating the operation is not supported.
*
* @param key - The project key to delete
* @throws Error indicating the operation is not supported
*/
delete(key: ProjectKey): Promise<void>;
}