

export interface DocInfo {
    doc_id: string;
    doc_name: string;
    doc_type?: string;
    doc_meta?: any;
    create_time: number;
    source: string;
    title?: string;
    original_coordinate?: any;
    status?: {
        process_status: number;
    }
}

export interface ListPointRequest {
    collection_name?: string;
    project?: string;
    resource_id?: string;
    offset?: number;
    limit?: number;
    doc_ids?: string[];
}

export interface PointInfo {
    collection_name: string;
    point_id: string;
    process_time: number;
    content: string;
    chunk_id: number;
    doc_info: DocInfo;
    chunk_type: string;
    table_chunk_fields?: Array<{
        field_name: string;
        field_value: string;
    }>;
}

export interface ListPointResponse {
    collection_name: string;
    total_num: number;
    count: number;
    point_list: PointInfo[];
}

/**
 * 更新切片内容请求参数
 */
export interface InfoPointRequest {
    /**
     * 知识库名称
     */
    collection_name?: string;

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

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

    /**
     * 要查询的切片id
     */
    point_id: string;

    /**
     * 是否获取切片中图片的临时下载链接
     */
    get_attachment_link?: boolean;
}

export interface InfoPointResponse {
    collection_name: string;
    point_id: string;
    process_time: number;
    content: string;
    chunk_id: number;
    doc_info: DocInfo;
    chunk_type: string;
    chunk_title?: string;
    table_chunk_fields?: Array<{
        field_name: string;
        field_value: string;
    }>;
    chunk_attachment?: Array<{
        uuid: string;
        caption: string;
        type: string;
        link?: string;
    }>;
    update_time?: number;
    chunk_source?: string;
}

export type AddPointRequest = {
    /**
     * 知识库名称
     */
    collection_name?: string;

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

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

    /**
     * 新增切片所属的文档id
     */
    doc_id: string;

} & ({
    chunk_type: 'structured';
    fields: Array<{
        field_name: string;
        field_value: any;
    }>;
} | {
    chunk_type: 'text';
    content: string;
} | {
    chunk_type: 'faq';
    question: string;
    content: string;
})

export interface AddPointResponse {
    collection_name: string;
    resource_id: string;
    project: string;
    doc_id: string;
    chunk_id: number;
    point_id: string;
}

export interface DeletePointRequest {
    /**
     * 知识库名称
     */
    collection_name?: string;

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

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

    /**
     * 要删除的切片id
     */
    point_id: string;
}

export type UpdatePointRequest = {
    /**
     * 知识库名称
     */
    collection_name?: string;

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

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

    /**
     * 要更新的切片id
     */
    point_id: string;

    /**
     * 要更新的非结构化faq文档切片的问题字段
     */
    question?: string;
} & ({
    content: string;
} | {
    fields: Array<{
        field_name: string;
        field_value: any;
    }>;
})