/** * Tauri adapter for {@link ProjectGateway} (L2). Together with the sibling * adapters this is the *only* place that calls `invoke()`; components reach it * exclusively through the port. * * Commands and payload keys are camelCase, matching the backend DTO convention. */ import { invoke } from "@tauri-apps/api/core"; import type { OpenProjectRestoreState, Project, ProjectFileListing, RemoveProjectOutput, RestoreOpenProjectsOutput, } from "@/domain"; import type { ProjectGateway, ProjectSettings } from "@/ports"; export class TauriProjectGateway implements ProjectGateway { listProjects(): Promise { return invoke("list_projects"); } createProject(name: string, root: string): Promise { return invoke("create_project", { request: { name, root } }); } openProject(projectId: string): Promise { return invoke("open_project", { projectId }); } async closeProject(projectId: string): Promise { await invoke("close_project", { projectId }); } removeProject(projectId: string): Promise { return invoke("remove_project", { request: { projectId }, }); } restoreOpenProjects(): Promise { return invoke("restore_open_projects"); } retryOpenProjectRestore(projectId?: string): Promise { return invoke("retry_open_project_restore", { request: projectId === undefined ? {} : { projectId }, }); } removeProjectFromRestore(projectId: string): Promise { return invoke("remove_project_from_restore", { request: { projectId }, }); } saveOpenProjectRestoreOrder( orderedProjectIds: string[], ): Promise { return invoke("save_open_project_restore_order", { request: { orderedProjectIds }, }); } readOpenProjectRestoreState(): Promise { return invoke("read_open_project_restore_state"); } readProjectContext(projectId: string): Promise { return invoke("read_project_context", { projectId }); } async updateProjectContext(projectId: string, content: string): Promise { await invoke("update_project_context", { request: { projectId, content }, }); } readProjectSettings(projectId: string): Promise { return invoke("read_project_settings", { projectId }); } updateProjectSettings( projectId: string, settings: ProjectSettings, ): Promise { return invoke("update_project_settings", { request: { projectId, themeColor: settings.themeColor }, }); } async listProjectFiles(): Promise { throw new Error("Project files browsing is available in the web workspace only."); } async downloadProjectFile(): Promise { throw new Error("Project file download is available in the web workspace only."); } async downloadProjectDirectory(): Promise { throw new Error("Project directory download is available in the web workspace only."); } }