import { CreateOrModifyKnowledgeLibApiParams } from '@/apis';

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

// 定义状态
export type State = {
    listLoading: boolean,
    list: Record[],
    infoModalId: string,
    infoModalOpen: boolean,
    page: {
        pageNumber: 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,
};

// 仓库类型
export type KnowledgeLibListStore = {
    state: ReadonlyState,
    onChangePagination: (pageNumber: 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,
};