/* * @Author: 赵伟 * @Date: 2024-04-08 09:54:39 * @Description: 定义全局类型,比如无关联的页面都需要要的类型 */ import { ExperimentStatus, TensorBoardStatus } from '@/enums'; import type { Settings as LayoutSettings } from '@ant-design/pro-components'; // 单点登录的客户端信息 export type ClientInfo = { accessTokenUri: string; checkTokenUri: string; clientId: string; clientSecret: string; loginPage: string; logoutUri: string; redirectUri: string; userAuthorizationUri: string; }; // 全局初始状态类型 export type GlobalInitialState = { settings?: Partial; currentUser?: API.CurrentUser; fetchUserInfo?: () => Promise; loading?: boolean; collapsed?: boolean; clientInfo?: ClientInfo; }; export enum PipelineGlobalParamType { String = 1, Number = 2, Boolean = 3, } // 流水线全局参数 export type PipelineGlobalParam = { param_name: string; description: string; param_type: PipelineGlobalParamType; param_value: number | string | boolean; is_sensitive: number; }; // 实验实例 export type ExperimentInstance = { id: number; experiment_id: number; workflow_id: number; create_time: string; finish_time: string; update_time: string; status: string; argo_ins_name: string; argo_ins_ns: string; nodes_result: { [key: string]: any; }; node_status: string; nodes_status: string; global_param: PipelineGlobalParam[]; tensorBoardStatus?: TensorBoardStatus; tensorboardUrl?: string; }; // 流水线节点 export type PipelineNodeModel = { id: string; experimentStatus: ExperimentStatus; label: string; experimentStartTime: string; experimentEndTime?: string | null; control_strategy: Record; in_parameters: Record; task_info: Record; out_parameters: Record; component_label: string; icon_path: string; workflowId?: string; message?: string; }; // 流水线节点模型数据 export type PipelineNodeModelParameter = { type: string; item_type: string; label: string; value: any; require?: number; visible: boolean; placeholder?: string; describe?: string; editable?: boolean; showValue?: any; // 前端显示用 fromSelect?: boolean; // 前端显示用 activeTab?: string; // ResourceSelectorModal tab expandedKeys?: string[]; // ResourceSelectorModal expandedKeys checkedKeys?: string[]; // ResourceSelectorModal checkedKeys }; // 修改属性类型 export type ChangePropertyType = Omit & { [P in K]: NewType }; // 将属性名称首字母大写 export type PascalCaseType = { [K in keyof T as `${Capitalize}`]: T[K]; }; // 将属性名称下划线转换为驼峰 type ToCamelCase = S extends `${infer P}_${infer R}` ? `${P}${Capitalize>}` : S; export type KeysToCamelCase = { [K in keyof T as ToCamelCase]: T[K]; }; // 序列化后的流水线节点 export type PipelineNodeModelSerialize = PipelineNodeModel; // 资源规格 export type ComputingResource = { id: number; computing_resource: string; description: string; standard: string; create_by: string; }; // 实验运行节点状态 export type NodeStatus = { id: string; // workflow Id displayName: string; name: string; phase: ExperimentStatus; startedAt: string; finishedAt: string; }; // 应用响应 export type AppResponse = { code: number; msg: string; data: T; }; // 上传文件的响应 export type UploadFileRes = { fileName: string; fileSize: number; url: string; }; // 定义一个类型,取一个类型的有些字段必须的,其它的是可选 export type CustomPartial = Pick & Partial>;