mod middleware; mod server_api; mod server_api_mock; pub use server_api::*; // TODO: ignore mock files in production pub use server_api_mock::*; use crate::{ entities::{ app::{App, AppIdentifier, CreateAppParams, DeleteAppParams, UpdateAppParams}, view::{CreateViewParams, DeleteViewParams, UpdateViewParams, View, ViewIdentifier}, workspace::{ CreateWorkspaceParams, DeleteWorkspaceParams, QueryWorkspaceParams, RepeatedWorkspace, UpdateWorkspaceParams, Workspace, }, }, errors::WorkspaceError, }; use flowy_infra::future::ResultFuture; use flowy_net::config::ServerConfig; use std::sync::Arc; pub(crate) type Server = Arc; pub trait WorkspaceServerAPI { // Workspace fn create_workspace(&self, token: &str, params: CreateWorkspaceParams) -> ResultFuture; fn read_workspace( &self, token: &str, params: QueryWorkspaceParams, ) -> ResultFuture; fn update_workspace(&self, token: &str, params: UpdateWorkspaceParams) -> ResultFuture<(), WorkspaceError>; fn delete_workspace(&self, token: &str, params: DeleteWorkspaceParams) -> ResultFuture<(), WorkspaceError>; // View fn create_view(&self, token: &str, params: CreateViewParams) -> ResultFuture; fn read_view(&self, token: &str, params: ViewIdentifier) -> ResultFuture, WorkspaceError>; fn delete_view(&self, token: &str, params: DeleteViewParams) -> ResultFuture<(), WorkspaceError>; fn update_view(&self, token: &str, params: UpdateViewParams) -> ResultFuture<(), WorkspaceError>; // App fn create_app(&self, token: &str, params: CreateAppParams) -> ResultFuture; fn read_app(&self, token: &str, params: AppIdentifier) -> ResultFuture, WorkspaceError>; fn update_app(&self, token: &str, params: UpdateAppParams) -> ResultFuture<(), WorkspaceError>; fn delete_app(&self, token: &str, params: DeleteAppParams) -> ResultFuture<(), WorkspaceError>; } pub(crate) fn construct_workspace_server(config: &ServerConfig) -> Arc { if cfg!(feature = "http_server") { Arc::new(WorkspaceServer::new(config.clone())) } else { Arc::new(WorkspaceServerMock {}) } }