/** * Type definitions for Forgejo API service layer */ export interface ValidationRule { field: string; type: "required" | "minLength" | "maxLength" | "pattern" | "custom"; value?: number | string | RegExp; message: string; validate?: (value: unknown) => boolean; } export interface ValidationResult { valid: boolean; errors: ValidationError[]; } export interface Repository { id: number; name: string; fullName: string; description: string; htmlUrl: string; cloneUrl: string; createdAt: Date; updatedAt: Date; owner: User; } /** * Represents a Forgejo issue with enhanced metadata and validation support */ export interface Issue { id: number; number: number; title: string; body: string; state: IssueState; htmlUrl: string; createdAt: Date; updatedAt: Date; user: User; labels: Label[]; lastModifiedBy?: User; assignees: User[]; milestone?: Milestone; comments: number; locked: boolean; lastUpdated: Date; updateInProgress?: boolean; updateError?: string; validationRules: ValidationRule[]; } /** * Represents a milestone in the issue tracking system */ export interface Milestone { id: number; number: number; title: string; description: string; dueDate?: Date; state: "open" | "closed"; createdAt: Date; updatedAt: Date; } export interface User { id: number; login: string; fullName: string; email: string; avatarUrl: string; htmlUrl: string; createdAt: Date; } export interface Label { id: number; name: string; color: string; description?: string; } export interface CreateIssueData { title: string; body: string; labels?: string[]; } /** * Data required to update an issue */ export interface UpdateIssueData { title?: string; body?: string; state?: IssueState; labels?: string[]; assignees?: string[]; milestone?: number | null; locked?: boolean; } export declare const isIssue: (value: unknown) => value is Issue; export declare const isValidationRule: (value: unknown) => value is ValidationRule; export declare const isMilestone: (value: unknown) => value is Milestone; export interface ListIssueOptions { state?: IssueState; labels?: string[]; sort?: "created" | "updated" | "comments"; direction?: "asc" | "desc"; page?: number; perPage?: number; } export declare enum IssueState { Open = "open", Closed = "closed", All = "all" } export interface ForgejoConfig { baseUrl: string; token: string; timeout?: number; maxRetries?: number; } export declare class ForgejoError extends Error { code: string; context?: unknown | undefined; constructor(message: string, code: string, context?: unknown | undefined); } export declare class ApiError extends ForgejoError { statusCode: number; constructor(message: string, statusCode: number, context?: unknown); } export declare class InvalidRepositoryDataError extends ApiError { constructor(message?: string, statusCode?: number, context?: unknown); } export declare class InvalidUserDataError extends ApiError { constructor(message?: string, statusCode?: number, context?: unknown); } export declare class ValidationError extends ForgejoError { constructor(message: string, context?: unknown); } export declare class NetworkError extends ForgejoError { constructor(message: string, context?: unknown); } export interface IForgejoService { updateTitle(owner: string, repo: string, number: number, newTitle: string, options?: { optimistic?: boolean; }): Promise; listRepositories(owner: string): Promise; getRepository(owner: string, name: string): Promise; listIssues(owner: string, repo: string, options?: ListIssueOptions): Promise; getIssue(owner: string, repo: string, number: number, options?: { includeMetadata?: boolean; forceFresh?: boolean; }): Promise; createIssue(owner: string, repo: string, data: CreateIssueData): Promise; updateIssue(owner: string, repo: string, number: number, data: UpdateIssueData): Promise; getUser(username: string): Promise; getCurrentUser(): Promise; } export interface IErrorHandler { handleApiError(error: unknown): never; handleToolError(error: unknown): ToolResponse; shouldRetry(error: unknown): boolean; getRetryDelay(attempt: number): number; } export interface ILogger { debug(message: string, context?: Record): void; info(message: string, context?: Record): void; warn(message: string, context?: Record): void; error(message: string, error?: Error, context?: Record): void; } export interface ICacheManager { get(key: string): Promise; set(key: string, value: T, ttlSeconds: number): Promise; delete(key: string): Promise; clear(): Promise; } export interface ToolResponse { content: Array<{ type: string; text: string; }>; }