git-contribution-stats
Version:
High-performance library to generate GitHub contribution reports with timeout controls, circuit breakers, and selective processing for AWS Lambda and background jobs
82 lines (81 loc) • 2.64 kB
TypeScript
import { Logger } from "./logger";
export interface GitHubActivityConfig {
app_id: number;
private_key: string;
days_to_look_back?: number;
logger?: Logger;
timeout_per_installation?: number;
max_total_timeout?: number;
max_repositories_per_installation?: number;
max_branches_per_repository?: number;
skip_large_installations?: boolean;
installation_size_threshold?: number;
target_installations?: string[];
exclude_installations?: string[];
priority_mode?: 'smallest_first' | 'largest_first' | 'sequential';
continue_on_error?: boolean;
retry_failed_installations?: number;
partial_results_on_timeout?: boolean;
}
export interface ProgressCallback {
onInstallationStart?: (installation: any, index: number, total: number) => void;
onInstallationComplete?: (installation: any, stats: any) => void;
onInstallationError?: (installation: any, error: Error) => void;
onRepositoryStart?: (repo: any, installation: any) => void;
onTimeout?: (installation: any, elapsed: number) => void;
}
export interface UserStat {
name: string;
user_id: string | null;
total_commits: number;
total_prs_opened: number;
total_prs_closed: number;
repo_contributions: RepoContribution[];
}
export interface CommitInfo {
id: string;
message: string;
date: string;
}
export interface RepoContribution {
repo_name: string;
commits: number;
prs_opened: number;
prs_closed: number;
commit_details: CommitInfo[];
}
export interface InstallationStats {
installation_id: number;
account: string;
account_type: string;
period_days: number;
user_id: number;
user_stats: UserStat[];
}
export interface InstallationError {
id: number;
account: string;
error: string;
timestamp?: number;
}
export interface GitHubReportResult {
success: boolean;
total_installations: number;
processed_installations: number;
failed_installations: string[];
partial_timeout: boolean;
execution_time: number;
summary: string;
detailed_results: (InstallationStats | InstallationError)[];
errors: Array<{
installation_id: string;
error: string;
timestamp: number;
}>;
}
export interface GitHubActivityResult {
summary: string;
detailed_results: (InstallationStats | InstallationError)[];
}
export declare function generateGitHubReport(config: GitHubActivityConfig, progressCallback?: ProgressCallback): Promise<GitHubReportResult>;
export declare function generateGitHubReportLegacy(config: GitHubActivityConfig): Promise<GitHubActivityResult>;