/**
 * 文档导入请求参数
 */
export type AddDocumentRequest = {
    /**
     * 知识库名称
     */
    collection_name?: string;

    /**
     * 知识库所属项目
     */
    project?: string;

    /**
     * 知识库唯一id
     */
    resource_id?: string;

} & (AddDocumentRequestUrl | AddDocumentRequestLark | AddDocumentRequestTos) & AddDocumentRequestDedup

export type AddDocumentRequestDocType = "ppt" | "txt" | 'doc' | 'docx' | 'pdf' | 'markdown' | 'md' | 'faq.xlsx' | 'pptx' | 'xlsx' | 'csv' | 'jsonl' | 'wiki' | 'html'
export type AddDocumentRequestUrl = {

    add_type: 'url';
    doc_id: string;
    doc_name: string;
    doc_type: AddDocumentRequestDocType
    url: string;
} & AddDocumentRequestMeta;

export type AddDocumentRequestTos = {
    add_type: 'tos';
    tos_path: string;
}

export type AddDocumentRequestLark = {
    add_type: 'lark';
    doc_id?: string;
    doc_type?: 'wiki' | 'docx' | 'sheet' | string;
    lark_file: {
        url: string;
        include_childe?: boolean;
    } | {
        obj_type: 'docx' | 'sheet' | 'wiki' | 'folder' | 'space' | string;
        obj_token: string;
        include_childe?: boolean;
    },
}

export type AddDocumentRequestMeta = {
    /**
     * Meta信息
     */
    meta?: Array<{
        field_name: string;
        field_type: "int64" | "float32" | "string" | "bool" | "list<string>";
        field_value: any;
    }>;
}

export type AddDocumentRequestDedup = {
    /**
     * 去重配置
     */
    dedup?: {
        content_dedup?: boolean;
        doc_name_dedup?: boolean;
        auto_skip?: boolean;
    };
}

/**
 * 文档导入响应数据
 */
export interface AddDocumentResponse {
    collection_name: string;
    resource_id: string;
    project: string;
    doc_id: string;
}

/**
 * 文档信息请求参数
 */
export type InfoDocumentRequest = {
    /**
     * 知识库名称
     */
    collection_name?: string;

    /**
     * 知识库所属项目
     */
    project?: string;

    /**
     * 知识库唯一id
     */
    resource_id?: string;

    /**
     * 文档ID
     */
    doc_id: string;
};

/**
 * 文档列表请求参数
 */
export type ListDocumentRequest = {
    /**
     * 知识库名称
     */
    collection_name?: string;

    /**
     * 知识库所属项目
     */
    project?: string;

    /**
     * 知识库唯一id
     */
    resource_id?: string;

    /**
     * 查询起始位置
     */
    offset?: number;

    /**
     * 查询数量限制
     */
    limit?: number;

    /**
     * 文档类型筛选
     */
    doc_type?: string[];

    return_token_usage?: boolean;
};

/**
 * 文档信息
 */
export interface DocumentInfo {
    collection_name: string;
    doc_name: string;
    doc_id: string;
    add_type: 'url' | 'tos' | 'lark';
    doc_type?: string;
    create_time: number;
    added_by: string;
    update_time: number;
    url?: string;
    tos_path?: string;
    point_num: number;
    status: {
        process_status: number;
    };
    meta?: Array<{
        field_name: string;
        field_type: "int64" | "float32" | "string" | "bool" | "list<string>";
        field_value: any;
    }>;
}

/**
 * 文档列表响应数据
 */
export interface ListDocumentResponse {
    collection_name: string;
    total_num: number;
    count: number;
    doc_list: DocumentInfo[];
}

/**
 * 文档信息响应数据
 */
export interface InfoDocumentResponse extends DocumentInfo {
}

/**
 * 文档删除请求参数
 */
export type DeleteDocumentRequest = {
    /**
     * 知识库名称
     */
    collection_name?: string;

    /**
     * 知识库所属项目
     */
    project?: string;

    /**
     * 知识库唯一id
     */
    resource_id?: string;

    /**
     * 文档ID
     */
    doc_id: string;
};

/**
 * 文档元数据更新请求参数
 */
export type UpdateDocumentMetaRequest = {
    /**
     * 知识库名称
     */
    collection_name?: string;

    /**
     * 知识库所属项目
     */
    project?: string;

    /**
     * 知识库唯一id
     */
    resource_id?: string;

    /**
     * 文档ID
     */
    doc_id: string;

    /**
     * Meta信息
     */
    meta?: Array<{
        field_name: string;
        field_type: "int64" | "float32" | "string" | "bool" | "list<string>";
        field_value: any;
    }>;
};

