deepsource-mcp-server
Version:
Model Context Protocol server for DeepSource
134 lines (133 loc) • 5.21 kB
TypeScript
/**
* @fileoverview AnalysisRun repository implementation
*
* Concrete implementation of IAnalysisRunRepository using DeepSource API.
*/
import { IAnalysisRunRepository } from '../../domain/aggregates/analysis-run/analysis-run.repository.js';
import { AnalysisRun } from '../../domain/aggregates/analysis-run/analysis-run.aggregate.js';
import { RunId, ProjectKey, BranchName, CommitOid } from '../../types/branded.js';
import { RunStatus } from '../../domain/aggregates/analysis-run/analysis-run.types.js';
import { PaginationOptions, PaginatedResult } from '../../domain/shared/repository.interface.js';
import { DeepSourceClient } from '../../deepsource.js';
/**
* Concrete implementation of IAnalysisRunRepository using DeepSource API
*
* This repository provides access to AnalysisRun aggregates by fetching data
* from the DeepSource API and mapping it to domain models.
*
* Note: The DeepSource API doesn't support querying individual runs by ID,
* so some methods need to fetch and filter runs locally. This ensures fresh
* data retrieval on every request as per requirements.
*/
export declare class AnalysisRunRepository implements IAnalysisRunRepository {
private readonly client;
constructor(client: DeepSourceClient);
/**
* Finds a run by its unique identifier
*
* Note: DeepSource API doesn't support direct run lookup by ID,
* so this method is not efficiently implementable.
*
* @param id - The run ID
* @returns The run if found, null otherwise
*/
findById(id: RunId): Promise<AnalysisRun | null>;
/**
* Finds a run by its unique ID
*
* Note: Since the API doesn't support direct lookup, this searches
* through all projects to find the run.
*
* @param id - The run ID
* @returns The run if found, null otherwise
*/
findByRunId(id: RunId): Promise<AnalysisRun | null>;
/**
* Finds runs for a specific project with pagination
*
* @param projectKey - The project key
* @param options - Pagination options
* @returns Paginated analysis runs
*/
findByProject(projectKey: ProjectKey, options: PaginationOptions): Promise<PaginatedResult<AnalysisRun>>;
/**
* Finds the most recent run for a project
*
* @param projectKey - The project key
* @param branch - Optional branch filter
* @returns The most recent run if found, null otherwise
*/
findMostRecent(projectKey: ProjectKey, branch?: BranchName): Promise<AnalysisRun | null>;
/**
* Finds a run by commit OID
*
* @param projectKey - The project key
* @param commitOid - The commit OID
* @returns The run if found, null otherwise
*/
findByCommit(projectKey: ProjectKey, commitOid: CommitOid): Promise<AnalysisRun | null>;
/**
* Finds runs by status
*
* @param projectKey - The project key
* @param status - The run status
* @param options - Pagination options
* @returns Paginated analysis runs
*/
findByStatus(projectKey: ProjectKey, status: RunStatus, options: PaginationOptions): Promise<PaginatedResult<AnalysisRun>>;
/**
* Finds runs within a date range
*
* @param projectKey - The project key
* @param startDate - Start date (inclusive)
* @param endDate - End date (inclusive)
* @param options - Pagination options
* @returns Paginated analysis runs
*/
findByDateRange(projectKey: ProjectKey, startDate: Date, endDate: Date, options: PaginationOptions): Promise<PaginatedResult<AnalysisRun>>;
/**
* Counts runs for a project
*
* @param projectKey - The project key
* @returns The total number of runs
*/
countByProject(projectKey: ProjectKey): Promise<number>;
/**
* Counts runs by status for a project
*
* @param projectKey - The project key
* @param status - The run status
* @returns The number of runs with the given status
*/
countByStatus(projectKey: ProjectKey, status: RunStatus): Promise<number>;
/**
* Checks if a run exists for a commit
*
* @param projectKey - The project key
* @param commitOid - The commit OID
* @returns True if a run exists, false otherwise
*/
existsForCommit(projectKey: ProjectKey, commitOid: CommitOid): Promise<boolean>;
/**
* Saves an analysis run
*
* Note: The DeepSource API doesn't support creating/updating runs
* through the GraphQL API. This method is implemented to satisfy the
* interface but will throw an error indicating the operation is not supported.
*
* @param run - The run to save
* @throws Error indicating the operation is not supported
*/
save(run: AnalysisRun): Promise<void>;
/**
* Deletes an analysis run
*
* Note: The DeepSource API doesn't support deleting runs
* through the GraphQL API. This method is implemented to satisfy the
* interface but will throw an error indicating the operation is not supported.
*
* @param id - The run ID to delete
* @throws Error indicating the operation is not supported
*/
delete(id: RunId): Promise<void>;
}