import { get, post } from '@/request/index' import { type Ref } from 'vue' import type { Result } from '@/request/Result' export interface SampleCenterKB { id: string name: string parent_table: string child_table: string document_count: number status: number created_at: string created_by: string metadata_schema: Array<{ field_name_cn: string field_name_en: string field_type: string description: string }> } export interface SampleCenterKBDetail extends SampleCenterKB { description: string updated_at: string } export interface ImportTask { task_id: string task_no: string status: 'pending' | 'processing' | 'completed' | 'failed' progress?: { total: number processed: number succeeded: number failed: number } created_at?: string completed_at?: string } export interface ParentItem { index: number parent_id: string hierarchy?: string text: string metadata?: Record doc_id?: string tag_list?: string[] permission?: { visible_roles?: string[] visible_users?: string[] } } export interface ChildItem extends ParentItem { parent_id: string } export function getSampleCenterKBList( params: { base_url: string app_id: string app_secret: string page?: number page_size?: number }, loading?: Ref, ): Promise> { return get('workspace/sample-center/knowledge-bases', params, loading) } export function getSampleCenterKBDetail( params: { kb_id: string base_url: string app_id: string app_secret: string }, loading?: Ref, ): Promise> { return get('workspace/sample-center/knowledge-bases/detail', params, loading) } export function submitBatchImport( data: { kb_id: string base_url: string app_id: string app_secret: string parents: ParentItem[] children?: ChildItem[] callback_url?: string }, loading?: Ref, ): Promise> { return post('workspace/sample-center/knowledge-bases/batch-import', data, loading) } export function getImportTaskStatus( params: { task_id: string base_url: string app_id: string app_secret: string }, loading?: Ref, ): Promise> { return get('workspace/sample-center/batch-import/task', params, loading) }