import type {BaseQuery} from '@/types/base';
import {ProjectGroup} from "@/pages/Deploy/ProjectGroup/List/types";
import {ExternalSystemResponse} from "@/pages/Deploy/External/types";
import {BaseResponse} from "@/types/base";

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;
    projectGroupId: number;
    projectGroup?: ProjectGroup;
    externalSystemId: number;
    externalSystem?: ExternalSystemResponse;
    repoGroupId: number;
    repositoryGroup?: RepositoryGroup;
    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;
    enabled?: boolean;
}

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;
    repoProjectId: number;
}

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

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

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