troutbot/src/types.ts
NotAShelf 7d8bc6943d
config: bind to localhost by default
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I00aca92a09291ce12f09da68917f56c06a6a6964
2026-02-01 17:17:33 +03:00

143 lines
2.5 KiB
TypeScript

export interface Config {
server: ServerConfig;
dashboard?: DashboardConfig;
repositories: RepoConfig[];
filters: FiltersConfig;
engine: EngineConfig;
response: ResponseConfig;
logging: LoggingConfig;
polling?: PollingConfig;
}
export interface PollingConfig {
enabled: boolean;
intervalMinutes: number;
lookbackMinutes: number;
}
export interface ServerConfig {
port: number;
host?: string;
rateLimit?: number;
}
export interface DashboardConfig {
enabled: boolean;
auth?: DashboardAuthConfig;
}
export interface DashboardAuthConfig {
type: 'basic' | 'token';
username?: string;
password?: string;
token?: string;
}
export interface RepoConfig {
owner: string;
repo: string;
}
export interface FiltersConfig {
labels: {
include: string[];
exclude: string[];
};
authors: {
include?: string[];
exclude: string[];
};
branches: {
include: string[];
};
}
export interface EngineConfig {
backends: BackendsConfig;
weights: BackendWeights;
confidenceThreshold: number;
}
export interface BackendsConfig {
checks: ChecksBackendConfig;
diff: DiffBackendConfig;
quality: QualityBackendConfig;
}
export interface ChecksBackendConfig {
enabled: boolean;
}
export interface DiffBackendConfig {
enabled: boolean;
maxChanges: number;
requireTests: boolean;
}
export interface QualityBackendConfig {
enabled: boolean;
minBodyLength: number;
}
export interface BackendWeights {
checks: number;
diff: number;
quality: number;
}
export interface ResponseConfig {
includeConfidence: boolean;
includeReasoning: boolean;
messages: {
positive: string[];
negative: string[];
neutral: string[];
};
commentMarker: string;
allowUpdates: boolean;
}
export interface LoggingConfig {
level: string;
file: string;
}
export type Impact = 'positive' | 'negative' | 'neutral';
export interface AnalysisResult {
impact: Impact;
confidence: number;
reasoning: string;
}
export interface EngineBackend {
name: string;
analyze(event: WebhookEvent): Promise<AnalysisResult>;
}
export interface WebhookEvent {
action: string;
type: 'issue' | 'pull_request';
number: number;
title: string;
body: string;
owner: string;
repo: string;
author: string;
labels: string[];
branch?: string;
sha?: string;
}
export interface CheckRun {
name: string;
status: string;
conclusion: string | null;
}
export interface PRFile {
filename: string;
additions: number;
deletions: number;
changes: number;
}