import type {BaseQuery} from '@/types/base';
import {ExternalSystemResponse} from "@/pages/Resource/External/List/types";
import {BaseResponse} from "@/types/base";
import type {ApplicationCategoryResponse} from "../Category/types";

export enum DevelopmentLanguageTypeEnum {
    JAVA = 'JAVA',
    NODE_JS = 'NODE_JS',
    PYTHON = 'PYTHON',
    GO = 'GO'
}

export interface Application extends BaseResponse {
    appCode: string;
    appName: string;
    appDesc?: string;
    language: DevelopmentLanguageTypeEnum;
    enabled: boolean;
    sort: number;
    teamCount?: number;
    applicationCategoryId: number;
    applicationCategory?: ApplicationCategoryResponse;
    externalSystemId?: number;
    externalSystem?: ExternalSystemResponse;
    repoProjectId?: number;
    repositoryProject?: RepositoryProject;
}

export interface RepositoryGroup extends BaseResponse {
    name: string;
    description?: string;
    repoGroupId: number;
    parentId?: number;
    path: string;
    fullName: string;
    fullPath: string;
    externalSystemId: number;
    avatarUrl?: string;
    webUrl?: string;
    visibility?: string;
    sort?: number;
}

export interface RepositoryProject extends BaseResponse {
    name: string;
    path: string;
    description: string;
    visibility: string;
    isDefaultBranch: string;
    webUrl: string;
    sshUrl: string;
    httpUrl: string;
    lastActivityAt: string;
    externalSystemId: number;
    projectId: number;
    repoGroupId: number;
    repoGroupName?: string; // 组别名称
    repoProjectId: number;
    branchCount?: number;
}

export type CreateApplicationRequest = Omit<Application, 'id' | keyof BaseResponse>;
export type UpdateApplicationRequest = Application;
export type ApplicationFormValues = CreateApplicationRequest;

export interface ApplicationQuery extends BaseQuery {
    appCode?: string;
    appName?: string;
    applicationCategoryId?: number;
    enabled?: boolean;
    language?: string;
}

export interface DevelopmentLanguageType {
    code: string;
    name: string;
}
