import { invoke } from '@tauri-apps/api/core' import type { ProjectRecord, CreateProjectInput, AiScanResult } from './types' export const projectApi = { list(): Promise { return invoke('list_projects') }, create(input: CreateProjectInput): Promise { return invoke('create_project', { input }) }, get(id: string): Promise { return invoke('get_project', { id }) }, update(id: string, field: string, value: string): Promise { return invoke('update_project', { id, field, value }) }, delete(id: string): Promise { return invoke('delete_project', { id }) }, listDeleted(): Promise { return invoke('list_deleted_projects') }, restore(id: string): Promise { return invoke('restore_project', { id }) }, purge(id: string): Promise { return invoke('purge_project', { id }) }, /** 探测目录技术栈(选目录后实时预览) */ scanStack(path: string): Promise { return invoke('scan_project_stack', { path }) }, /** 检查目录是否已被其他项目绑定(防重复,excludeId 排除自身) */ checkBinding(path: string, excludeId?: string): Promise { return invoke('check_path_binding', { path, excludeId }) }, /** 重定位项目目录(校验+重探测 stack,返回最新记录) */ relocatePath(id: string, newPath: string): Promise { return invoke('relocate_project_path', { id, newPath }) }, /** 检查目录是否存在(详情页"目录是否还在") */ checkPathExists(path: string): Promise { return invoke('check_path_exists', { path }) }, /** AI 扫描目录,自动分析基础信息(description/stack/project_type) */ scanWithAi(path: string): Promise { return invoke('scan_project_with_ai', { path }) }, }