import { CreateOrModifyKnowledgeLibApiParams } from '@/apis';

export type Record = {
    [x: string]: any;
    knowledgeId: string,
    name: string,// 知识库名称
    length: number,// 使用空间
    wordNum: number,// 字符数量
    documentSize: number,// 文件数量
    createTime: string,// 创建时间
    updateTime: string,// 更新时间
};

// 定义状态
export type State = {
    listLoading: boolean,
    list: Record[],
    infoModalId: string,
    classificationType?: string,
    name?: string,
    infoModalOpen: boolean,
    page: {
        pageNum: number,
        pageSize: number,
        total: number,
    },
};

// 只读状态
export type ReadonlyState = Readonly<State>;

// 修改状态
export type StateAction = {
    setListLoading: (loading: State['listLoading']) => void,
    setList: (list: State['list']) => void,
    setInfoModalId: (id: State['infoModalId']) => void,
    setInfoModalOpen: (open: State['infoModalOpen']) => void,
    setPage: (page: State['page']) => void,
    setClassificationType: (data?: string) => void,
    setName: (name?: string) => void,
};

// 仓库类型
export type KnowledgeLibListStore = {
    state: ReadonlyState,
    onChangePagination: (pageNum: number, pageSize: number) => Promise<any>,
    onClickCreate: () => void,
    onClickModify: (knowledgeId: string) => void,
    infoModalOnClickConfirm: (knowledgeId: string, data: CreateOrModifyKnowledgeLibApiParams) => Promise<any>,
    infoModalOnClickCancel: () => void,
    onClickDelete: (knowledgeId: string) => Promise<any>,
    init: () => Promise<any>,
    reset: () => void,
    handleModeChange: (data:State['classificationType']) => void,
    handleNameChange: (name?: string) => void,
    handFetchExportKnowledgeSliceExport: (record?: any) => void,
    exportKnowledgeMarkDown: (record: any) => Promise<void>,
    exportKnowledgeFile: (record: any) => Promise<void>,
};