ds-sfcoe-ailabs
Version:
AI-powered code review tool with static analysis integration for comprehensive code quality assessment.
84 lines (83 loc) • 2.56 kB
TypeScript
import { PullRequestComment } from './index.js';
/**
* Abstract class representing a Git provider for interacting with Git hosting services
* Provides common functionality for posting comments and managing repository interactions
*/
export default abstract class GitProvider {
private token;
private owner;
private repo;
/**
* Creates a new Git provider instance
*
* @param token - The authentication token for the Git provider
* @param owner - The repository owner/organization name
* @param repo - The repository name
* @example
* ```typescript
* class MyGitProvider extends GitProvider {
* constructor() {
* super('token123', 'myorg', 'myrepo');
* }
* }
* ```
*/
constructor(token: string, owner: string, repo: string);
/**
* Gets the repository owner
*
* @returns The repository owner name
* @example
* ```typescript
* const owner = gitProvider.getOwner();
* console.log(owner); // 'myorg'
* ```
*/
protected getOwner(): string;
/**
* Gets the repository name
*
* @returns The repository name
* @example
* ```typescript
* const repo = gitProvider.getRepo();
* console.log(repo); // 'myrepo'
* ```
*/
protected getRepo(): string;
/**
* Gets the authentication token
*
* @returns The authentication token
* @example
* ```typescript
* const token = gitProvider.getToken();
* console.log(token); // 'token123'
* ```
*/
protected getToken(): string;
/**
* Upserts a comment to a pull request (creates new or updates existing)
*
* @param prCommentRequest - The pull request comment data
* @returns Promise that resolves when the comment is upserted
* @throws Error if the operation fails
* @example
* ```typescript
* await gitProvider.upsertPRComment({
* pullRequestId: 123,
* comment: 'Review complete',
* commitSha: 'abc123'
* });
* ```
*/
abstract upsertPRComment(prCommentRequest: PullRequestComment): Promise<void>;
/**
* Delete an existing bot comment from a pull request
*
* @param prNumber - Pull request number
* @param isGeneralComment - Whether to look for general or line-specific comments
* @returns Promise that resolves to true if comment was deleted, false otherwise
*/
abstract deleteBotComment(prNumber: string, isGeneralComment?: boolean): Promise<void>;
}