import { ModifyDocumentApiParams, ModifyDocumentSettingApiParams } from '@/apis';

export type Record = {
    documentId: string,
    name: string,
    url: string,
    length: number,
    sentence_size: number,
    knowledge_type: number,
    custom_separator: string[],
    embedding_stat: number,
    word_num: number,
    parse_image: number
};

// 定义状态
export type State = {
    knowledge_id: string,
    listLoading: boolean,
    list: Record[],
    infoModalId: string,
    infoModalOpen: boolean,
    infoModalSettingId: string,
    infoModalSettingOpen: boolean,
    page: {
        page: number,
        size: number,
        total: number,
    },
};

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

// 修改状态
export type StateAction = {
    setknowledge_id(knowledge_id: string): unknown;
    setListLoading: (loading: State['listLoading']) => void,
    setList: (list: State['list']) => void,
    setInfoModalId: (id: State['infoModalId']) => void,
    setInfoModalOpen: (open: State['infoModalOpen']) => void,
    setInfoModalSettingId: (id: State['infoModalSettingId']) => void,
    setInfoModalSettingOpen: (open: State['infoModalSettingOpen']) => void,
    setPage: (page: State['page']) => void,
};

// 仓库类型
export type DocumentLibInfoStore = {
    state: ReadonlyState,
    init: (knowledgeId?: string) => void,
    onChangePagination: (page: number, size: number) => Promise<any>,
    onClickDocumentDetail: (knowledgeId?: string) => void,
    onClickModify: (id: string) => void,
    infoModalOnClickConfirm: (id: string, data: ModifyDocumentApiParams) => Promise<any>,
    infoModalOnClickCancel: () => void,
    onClickDelete: (id: string) => Promise<any>,
    onClickSettings: (id: string) => void,
    infoModalSettingOnClickConfirm: (id: string, data: ModifyDocumentSettingApiParams) => Promise<any>,
    infoModalSettingOnClickCancel: () => void,
    reset: () => void,
};