diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 3ac7fced1e..0b947f3b44 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -61,7 +61,7 @@ byteorder = {version = "1.3.4"} async-stream = "0.3.2" flowy-user = { path = "../rust-lib/flowy-user" } -flowy-workspace = { path = "../rust-lib/flowy-workspace" } +flowy-workspace = { path = "../rust-lib/flowy-workspace", default-features = false, features = ["backend_service"]} flowy-document = { path = "../rust-lib/flowy-document" } flowy-ws = { path = "../rust-lib/flowy-ws" } flowy-ot = { path = "../rust-lib/flowy-ot" } @@ -100,7 +100,7 @@ once_cell = "1.7.2" linkify = "0.5.0" backend = { path = ".", features = ["flowy_test"]} flowy-user = { path = "../rust-lib/flowy-user", features = ["http_server"] } -flowy-workspace = { path = "../rust-lib/flowy-workspace", features = ["http_server"] } +flowy-workspace = { path = "../rust-lib/flowy-workspace", default-features = false, features = ["http_server", "backend_service"] } flowy-ws = { path = "../rust-lib/flowy-ws" } flowy-sdk = { path = "../rust-lib/flowy-sdk" } flowy-test = { path = "../rust-lib/flowy-test" } diff --git a/backend/graph.png b/backend/graph.png new file mode 100644 index 0000000000..e69de29bb2 diff --git a/backend/src/entities/workspace.rs b/backend/src/entities/workspace.rs index bf2ecc5f1a..1017e1a7a7 100644 --- a/backend/src/entities/workspace.rs +++ b/backend/src/entities/workspace.rs @@ -1,5 +1,5 @@ use chrono::Utc; -use flowy_workspace::protobuf::{App, RepeatedView, Trash, TrashType, View, ViewType}; +use flowy_workspace::backend_service::{App, RepeatedView, Trash, TrashType, View, ViewType}; use protobuf::ProtobufEnum; pub(crate) const WORKSPACE_TABLE: &'static str = "workspace_table"; diff --git a/backend/src/service/app/router.rs b/backend/src/service/app/router.rs index 7bebfd6305..583d4bf3a2 100644 --- a/backend/src/service/app/router.rs +++ b/backend/src/service/app/router.rs @@ -3,7 +3,7 @@ use actix_web::{ HttpResponse, }; use flowy_net::errors::{invalid_params, ServerError}; -use flowy_workspace::protobuf::{AppIdentifier, CreateAppParams, DeleteAppParams, UpdateAppParams}; +use flowy_workspace::backend_service::{AppIdentifier, CreateAppParams, DeleteAppParams, UpdateAppParams}; use protobuf::Message; use sqlx::PgPool; diff --git a/backend/src/service/trash/router.rs b/backend/src/service/trash/router.rs index 3e0b324b6c..c7a495e94c 100644 --- a/backend/src/service/trash/router.rs +++ b/backend/src/service/trash/router.rs @@ -13,10 +13,7 @@ use flowy_net::{ errors::{invalid_params, ServerError}, response::FlowyResponse, }; -use flowy_workspace::{ - entities::trash::parser::{TrashId, TrashTypeParser}, - protobuf::TrashIdentifiers, -}; +use flowy_workspace::{backend_service::TrashType, entities::trash::parser::TrashId, protobuf::TrashIdentifiers}; use sqlx::PgPool; use uuid::Uuid; @@ -95,8 +92,11 @@ fn check_trash_id(id: String) -> Result { fn make_records(identifiers: TrashIdentifiers) -> Result, ServerError> { let mut records = vec![]; for identifier in identifiers.items { - let ty = TrashTypeParser::parse(identifier.ty.value()).map_err(invalid_params)?; - records.push((check_trash_id(identifier.id.to_owned())?, ty)); + // match TrashType::from_i32(identifier.ty.value()) { + // None => {} + // Some(ty) => {} + // } + records.push((check_trash_id(identifier.id.to_owned())?, identifier.ty.value())); } Ok(records) } diff --git a/backend/src/service/trash/trash.rs b/backend/src/service/trash/trash.rs index d460852e65..ba354f397a 100644 --- a/backend/src/service/trash/trash.rs +++ b/backend/src/service/trash/trash.rs @@ -9,7 +9,7 @@ use crate::{ }; use ::protobuf::ProtobufEnum; use flowy_net::errors::ServerError; -use flowy_workspace::protobuf::{RepeatedTrash, Trash, TrashType}; +use flowy_workspace::backend_service::{RepeatedTrash, Trash, TrashType}; use sqlx::{postgres::PgArguments, Postgres, Row}; use uuid::Uuid; diff --git a/backend/src/service/user/user_default.rs b/backend/src/service/user/user_default.rs index ad98a78822..affa0f6bcb 100644 --- a/backend/src/service/user/user_default.rs +++ b/backend/src/service/user/user_default.rs @@ -9,7 +9,7 @@ use crate::{ use flowy_document::services::doc::doc_initial_string; use flowy_net::errors::ServerError; -use flowy_workspace::protobuf::{App, CreateViewParams, View, ViewType, Workspace}; +use flowy_workspace::backend_service::{App, CreateViewParams, View, ViewType, Workspace}; pub async fn create_default_workspace( transaction: &mut DBTransaction<'_>, @@ -42,8 +42,8 @@ async fn create_app( workspace: &Workspace, ) -> Result { let (sql, args, app) = AppBuilder::new(user_id, &workspace.id) - .name("DefaultApp") - .desc("App created by AppFlowy") + .name("Getting Started") + .desc("") .build()?; let _ = sqlx::query_with(&sql, args) @@ -57,9 +57,9 @@ async fn create_app( async fn create_default_view(transaction: &mut DBTransaction<'_>, app: &App) -> Result { let params = CreateViewParams { belong_to_id: app.id.clone(), - name: "DefaultView".to_string(), - desc: "View created by AppFlowy".to_string(), - thumbnail: "123.png".to_string(), + name: "Read Me".to_string(), + desc: "".to_string(), + thumbnail: "".to_string(), view_type: ViewType::Doc, data: doc_initial_string(), unknown_fields: Default::default(), diff --git a/rust-lib/flowy-dispatch/Cargo.toml b/rust-lib/flowy-dispatch/Cargo.toml index 36743cd158..b38e1fe3bc 100644 --- a/rust-lib/flowy-dispatch/Cargo.toml +++ b/rust-lib/flowy-dispatch/Cargo.toml @@ -29,7 +29,7 @@ dashmap = "4.0" #optional crate bincode = { version = "1.3", optional = true} protobuf = {version = "2.24.1", optional = true} -tracing = { version = "0.1", optional = true} +tracing = { version = "0.1"} [dev-dependencies] tokio = { version = "1", features = ["full"] } @@ -39,4 +39,3 @@ futures-util = "0.3.15" default = ["use_protobuf"] use_serde = ["bincode"] use_protobuf= ["protobuf"] -use_tracing= ["tracing"] diff --git a/rust-lib/flowy-sdk/Cargo.toml b/rust-lib/flowy-sdk/Cargo.toml index ae30495463..a86a7f2f9d 100644 --- a/rust-lib/flowy-sdk/Cargo.toml +++ b/rust-lib/flowy-sdk/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -flowy-dispatch = { path = "../flowy-dispatch", features = ["use_tracing"]} +flowy-dispatch = { path = "../flowy-dispatch"} flowy-log = { path = "../flowy-log" } flowy-user = { path = "../flowy-user" } flowy-infra = { path = "../flowy-infra" } diff --git a/rust-lib/flowy-workspace/Cargo.toml b/rust-lib/flowy-workspace/Cargo.toml index 33f650adc8..72c59918d0 100644 --- a/rust-lib/flowy-workspace/Cargo.toml +++ b/rust-lib/flowy-workspace/Cargo.toml @@ -45,4 +45,7 @@ serial_test = "0.5.1" [features] -http_server = [] \ No newline at end of file +default = ["flowy_client_sdk", "backend_service"] +http_server = [] +flowy_client_sdk = [] +backend_service = [] \ No newline at end of file diff --git a/rust-lib/flowy-workspace/Flowy.toml b/rust-lib/flowy-workspace/Flowy.toml index 152585acd5..48a7e675f4 100644 --- a/rust-lib/flowy-workspace/Flowy.toml +++ b/rust-lib/flowy-workspace/Flowy.toml @@ -1,3 +1,3 @@ -proto_crates = ["src/entities", "src/event.rs", "src/errors.rs", "src/notify"] +proto_crates = ["src/entities", "src/event.rs", "src/errors.rs", "src/services/notify"] event_files = ["src/event.rs"] \ No newline at end of file diff --git a/rust-lib/flowy-workspace/src/entities/app/app_create.rs b/rust-lib/flowy-workspace/src/entities/app/app_create.rs index 9d9401b4be..4f4abb9488 100644 --- a/rust-lib/flowy-workspace/src/entities/app/app_create.rs +++ b/rust-lib/flowy-workspace/src/entities/app/app_create.rs @@ -55,18 +55,26 @@ impl TryInto for CreateAppRequest { let id = WorkspaceId::parse(self.workspace_id).map_err(|e| WorkspaceError::workspace_id().context(e))?; - let color_style = - AppColorStyle::parse(self.color_style).map_err(|e| WorkspaceError::color_style().context(e))?; + let color_style = AppColorStyle::parse(self.color_style.theme_color.clone()) + .map_err(|e| WorkspaceError::color_style().context(e))?; Ok(CreateAppParams { workspace_id: id.0, name: name.0, desc: self.desc, - color_style: color_style.0, + color_style: color_style.into(), }) } } +impl std::convert::From for ColorStyle { + fn from(data: AppColorStyle) -> Self { + ColorStyle { + theme_color: data.theme_color, + } + } +} + #[derive(PartialEq, ProtoBuf, Default, Debug, Clone)] pub struct App { #[pb(index = 1)] diff --git a/rust-lib/flowy-workspace/src/entities/app/app_update.rs b/rust-lib/flowy-workspace/src/entities/app/app_update.rs index 678392d78d..1f519a787f 100644 --- a/rust-lib/flowy-workspace/src/entities/app/app_update.rs +++ b/rust-lib/flowy-workspace/src/entities/app/app_update.rs @@ -88,9 +88,9 @@ impl TryInto for UpdateAppRequest { let color_style = match self.color_style { None => None, Some(color_style) => Some( - AppColorStyle::parse(color_style) + AppColorStyle::parse(color_style.theme_color.clone()) .map_err(|e| WorkspaceError::color_style().context(e))? - .0, + .into(), ), }; diff --git a/rust-lib/flowy-workspace/src/entities/app/mod.rs b/rust-lib/flowy-workspace/src/entities/app/mod.rs index 8c51f2be1a..e11d72e49a 100644 --- a/rust-lib/flowy-workspace/src/entities/app/mod.rs +++ b/rust-lib/flowy-workspace/src/entities/app/mod.rs @@ -1,9 +1,15 @@ +#[cfg(feature = "flowy_client_sdk")] +mod app_create; +#[cfg(feature = "flowy_client_sdk")] +mod app_query; +#[cfg(feature = "flowy_client_sdk")] +mod app_update; + +#[cfg(feature = "flowy_client_sdk")] pub use app_create::*; +#[cfg(feature = "flowy_client_sdk")] +pub use app_query::*; +#[cfg(feature = "flowy_client_sdk")] pub use app_update::*; -mod app_create; -mod app_query; -mod app_update; pub mod parser; - -pub use app_query::*; diff --git a/rust-lib/flowy-workspace/src/entities/app/parser/app_color_style.rs b/rust-lib/flowy-workspace/src/entities/app/parser/app_color_style.rs index 9038c2f68a..23f1e56fdf 100644 --- a/rust-lib/flowy-workspace/src/entities/app/parser/app_color_style.rs +++ b/rust-lib/flowy-workspace/src/entities/app/parser/app_color_style.rs @@ -1,15 +1,11 @@ -use crate::entities::app::ColorStyle; - #[derive(Debug)] -pub struct AppColorStyle(pub ColorStyle); +pub struct AppColorStyle { + pub theme_color: String, +} impl AppColorStyle { - pub fn parse(color_style: ColorStyle) -> Result { + pub fn parse(theme_color: String) -> Result { // TODO: verify the color style format - Ok(Self(color_style)) + Ok(AppColorStyle { theme_color }) } } - -impl AsRef for AppColorStyle { - fn as_ref(&self) -> &ColorStyle { &self.0 } -} diff --git a/rust-lib/flowy-workspace/src/entities/mod.rs b/rust-lib/flowy-workspace/src/entities/mod.rs index 3ee0f4b591..70972f0352 100644 --- a/rust-lib/flowy-workspace/src/entities/mod.rs +++ b/rust-lib/flowy-workspace/src/entities/mod.rs @@ -2,3 +2,7 @@ pub mod app; pub mod trash; pub mod view; pub mod workspace; + +pub mod parser { + pub use crate::entities::{app::parser::*, trash::parser::*, view::parser::*, workspace::parser::*}; +} diff --git a/rust-lib/flowy-workspace/src/entities/trash/mod.rs b/rust-lib/flowy-workspace/src/entities/trash/mod.rs index fcc84e4f3f..b6f1a8028b 100644 --- a/rust-lib/flowy-workspace/src/entities/trash/mod.rs +++ b/rust-lib/flowy-workspace/src/entities/trash/mod.rs @@ -1,4 +1,7 @@ pub mod parser; + +#[cfg(feature = "flowy_client_sdk")] mod trash_create; +#[cfg(feature = "flowy_client_sdk")] pub use trash_create::*; diff --git a/rust-lib/flowy-workspace/src/entities/trash/parser/mod.rs b/rust-lib/flowy-workspace/src/entities/trash/parser/mod.rs index 4e69372030..ddb6a3b91e 100644 --- a/rust-lib/flowy-workspace/src/entities/trash/parser/mod.rs +++ b/rust-lib/flowy-workspace/src/entities/trash/parser/mod.rs @@ -1,5 +1,3 @@ mod trash_id; -mod trash_ty; pub use trash_id::*; -pub use trash_ty::*; diff --git a/rust-lib/flowy-workspace/src/entities/trash/parser/trash_ty.rs b/rust-lib/flowy-workspace/src/entities/trash/parser/trash_ty.rs deleted file mode 100644 index 5535635b5a..0000000000 --- a/rust-lib/flowy-workspace/src/entities/trash/parser/trash_ty.rs +++ /dev/null @@ -1,16 +0,0 @@ -use crate::entities::trash::TrashType; -use std::convert::TryFrom; - -#[derive(Debug)] -pub struct TrashTypeParser(pub i32); - -impl TrashTypeParser { - pub fn parse(value: i32) -> Result { - let _ = TrashType::try_from(value)?; - Ok(value) - } -} - -impl AsRef for TrashTypeParser { - fn as_ref(&self) -> &i32 { &self.0 } -} diff --git a/rust-lib/flowy-workspace/src/entities/view/mod.rs b/rust-lib/flowy-workspace/src/entities/view/mod.rs index c0f793db13..a0cd9ccfdd 100644 --- a/rust-lib/flowy-workspace/src/entities/view/mod.rs +++ b/rust-lib/flowy-workspace/src/entities/view/mod.rs @@ -1,8 +1,14 @@ pub mod parser; +#[cfg(feature = "flowy_client_sdk")] mod view_create; +#[cfg(feature = "flowy_client_sdk")] mod view_query; +#[cfg(feature = "flowy_client_sdk")] mod view_update; +#[cfg(feature = "flowy_client_sdk")] pub use view_create::*; +#[cfg(feature = "flowy_client_sdk")] pub use view_query::*; +#[cfg(feature = "flowy_client_sdk")] pub use view_update::*; diff --git a/rust-lib/flowy-workspace/src/entities/workspace/mod.rs b/rust-lib/flowy-workspace/src/entities/workspace/mod.rs index 28a1b28446..785fcf9353 100644 --- a/rust-lib/flowy-workspace/src/entities/workspace/mod.rs +++ b/rust-lib/flowy-workspace/src/entities/workspace/mod.rs @@ -1,13 +1,23 @@ +#[cfg(feature = "flowy_client_sdk")] pub use workspace_create::*; +#[cfg(feature = "flowy_client_sdk")] +pub use workspace_delete::*; +#[cfg(feature = "flowy_client_sdk")] pub use workspace_query::*; +#[cfg(feature = "flowy_client_sdk")] pub use workspace_update::*; +#[cfg(feature = "flowy_client_sdk")] pub use workspace_user_detail::*; -pub mod parser; +#[cfg(feature = "flowy_client_sdk")] mod workspace_create; +#[cfg(feature = "flowy_client_sdk")] mod workspace_delete; +#[cfg(feature = "flowy_client_sdk")] mod workspace_query; +#[cfg(feature = "flowy_client_sdk")] mod workspace_update; +#[cfg(feature = "flowy_client_sdk")] mod workspace_user_detail; -pub use workspace_delete::*; +pub mod parser; diff --git a/rust-lib/flowy-workspace/src/lib.rs b/rust-lib/flowy-workspace/src/lib.rs index a8c79eaaa8..3e133634bc 100644 --- a/rust-lib/flowy-workspace/src/lib.rs +++ b/rust-lib/flowy-workspace/src/lib.rs @@ -1,13 +1,11 @@ -mod handlers; -mod notify; -mod services; -mod sql_tables; - pub mod entities; -pub mod errors; + +#[cfg(feature = "flowy_client_sdk")] pub mod event; +#[cfg(feature = "flowy_client_sdk")] pub mod module; -pub mod protobuf; +#[cfg(feature = "flowy_client_sdk")] +mod services; #[macro_use] mod macros; @@ -15,9 +13,10 @@ mod macros; #[macro_use] extern crate flowy_database; -// #[macro_use] -// extern crate flowy_dispatch; +pub mod errors; +pub mod protobuf; +#[cfg(feature = "flowy_client_sdk")] pub mod prelude { pub use crate::{ entities::{app::*, trash::*, view::*, workspace::*}, @@ -26,3 +25,8 @@ pub mod prelude { services::*, }; } + +#[cfg(feature = "backend_service")] +pub mod backend_service { + pub use crate::protobuf::*; +} diff --git a/rust-lib/flowy-workspace/src/module.rs b/rust-lib/flowy-workspace/src/module.rs index 167a187266..6611076050 100644 --- a/rust-lib/flowy-workspace/src/module.rs +++ b/rust-lib/flowy-workspace/src/module.rs @@ -1,17 +1,23 @@ -use crate::{ - errors::WorkspaceError, - event::WorkspaceEvent, - handlers::*, - services::{server::construct_workspace_server, AppController, ViewController, WorkspaceController}, -}; +use std::sync::Arc; -use crate::services::TrashCan; use flowy_database::DBConnection; use flowy_dispatch::prelude::*; use flowy_document::module::FlowyDocument; use flowy_net::config::ServerConfig; use flowy_sqlite::ConnectionPool; -use std::sync::Arc; + +use crate::{ + errors::WorkspaceError, + event::WorkspaceEvent, + services::{ + handlers::*, + server::construct_workspace_server, + AppController, + TrashCan, + ViewController, + WorkspaceController, + }, +}; pub trait WorkspaceDeps: WorkspaceUser + WorkspaceDatabase {} diff --git a/rust-lib/flowy-workspace/src/services/app_controller.rs b/rust-lib/flowy-workspace/src/services/app_controller.rs index a6921d379e..f3d4216253 100644 --- a/rust-lib/flowy-workspace/src/services/app_controller.rs +++ b/rust-lib/flowy-workspace/src/services/app_controller.rs @@ -1,3 +1,9 @@ +use std::{collections::HashSet, sync::Arc}; + +use futures::{FutureExt, StreamExt}; + +use flowy_database::SqliteConnection; + use crate::{ entities::{ app::{App, CreateAppParams, *}, @@ -5,13 +11,15 @@ use crate::{ }, errors::*, module::{WorkspaceDatabase, WorkspaceUser}, - notify::*, - services::{helper::spawn, server::Server, TrashCan, TrashEvent}, - sql_tables::app::{AppTable, AppTableChangeset, AppTableSql}, + services::{ + helper::spawn, + notify::*, + server::Server, + sql_tables::app::{AppTable, AppTableChangeset, AppTableSql}, + TrashCan, + TrashEvent, + }, }; -use flowy_database::SqliteConnection; -use futures::{FutureExt, StreamExt}; -use std::{collections::HashSet, sync::Arc}; pub(crate) struct AppController { user: Arc, diff --git a/rust-lib/flowy-workspace/src/handlers/app_handler.rs b/rust-lib/flowy-workspace/src/services/handlers/app_handler.rs similarity index 100% rename from rust-lib/flowy-workspace/src/handlers/app_handler.rs rename to rust-lib/flowy-workspace/src/services/handlers/app_handler.rs diff --git a/rust-lib/flowy-workspace/src/handlers/mod.rs b/rust-lib/flowy-workspace/src/services/handlers/mod.rs similarity index 100% rename from rust-lib/flowy-workspace/src/handlers/mod.rs rename to rust-lib/flowy-workspace/src/services/handlers/mod.rs diff --git a/rust-lib/flowy-workspace/src/handlers/trash_handler.rs b/rust-lib/flowy-workspace/src/services/handlers/trash_handler.rs similarity index 100% rename from rust-lib/flowy-workspace/src/handlers/trash_handler.rs rename to rust-lib/flowy-workspace/src/services/handlers/trash_handler.rs diff --git a/rust-lib/flowy-workspace/src/handlers/view_handler.rs b/rust-lib/flowy-workspace/src/services/handlers/view_handler.rs similarity index 100% rename from rust-lib/flowy-workspace/src/handlers/view_handler.rs rename to rust-lib/flowy-workspace/src/services/handlers/view_handler.rs diff --git a/rust-lib/flowy-workspace/src/handlers/workspace_handler.rs b/rust-lib/flowy-workspace/src/services/handlers/workspace_handler.rs similarity index 100% rename from rust-lib/flowy-workspace/src/handlers/workspace_handler.rs rename to rust-lib/flowy-workspace/src/services/handlers/workspace_handler.rs diff --git a/rust-lib/flowy-workspace/src/services/mod.rs b/rust-lib/flowy-workspace/src/services/mod.rs index 328cf047ab..3e0b6914cf 100644 --- a/rust-lib/flowy-workspace/src/services/mod.rs +++ b/rust-lib/flowy-workspace/src/services/mod.rs @@ -5,8 +5,14 @@ pub use workspace_controller::*; mod app_controller; mod database; +#[cfg(feature = "flowy_client_sdk")] +pub mod handlers; mod helper; +#[cfg(feature = "flowy_client_sdk")] +mod notify; pub mod server; +#[cfg(feature = "flowy_client_sdk")] +mod sql_tables; mod trash_can; mod util; mod view_controller; diff --git a/rust-lib/flowy-workspace/src/notify/mod.rs b/rust-lib/flowy-workspace/src/services/notify/mod.rs similarity index 100% rename from rust-lib/flowy-workspace/src/notify/mod.rs rename to rust-lib/flowy-workspace/src/services/notify/mod.rs diff --git a/rust-lib/flowy-workspace/src/notify/observable.rs b/rust-lib/flowy-workspace/src/services/notify/observable.rs similarity index 100% rename from rust-lib/flowy-workspace/src/notify/observable.rs rename to rust-lib/flowy-workspace/src/services/notify/observable.rs diff --git a/rust-lib/flowy-workspace/src/services/server/middleware.rs b/rust-lib/flowy-workspace/src/services/server/middleware.rs index 5cb6205f05..f10668708e 100644 --- a/rust-lib/flowy-workspace/src/services/server/middleware.rs +++ b/rust-lib/flowy-workspace/src/services/server/middleware.rs @@ -1,14 +1,17 @@ -use lazy_static::lazy_static; use std::sync::Arc; -lazy_static! { - pub(crate) static ref MIDDLEWARE: Arc = Arc::new(WorkspaceMiddleware {}); -} + +use lazy_static::lazy_static; + +use flowy_net::{request::ResponseMiddleware, response::FlowyResponse}; use crate::{ errors::{ErrorCode, WorkspaceError}, - notify::*, + services::notify::*, }; -use flowy_net::{request::ResponseMiddleware, response::FlowyResponse}; + +lazy_static! { + pub(crate) static ref MIDDLEWARE: Arc = Arc::new(WorkspaceMiddleware {}); +} pub(crate) struct WorkspaceMiddleware {} impl ResponseMiddleware for WorkspaceMiddleware { diff --git a/rust-lib/flowy-workspace/src/sql_tables/app/app_sql.rs b/rust-lib/flowy-workspace/src/services/sql_tables/app/app_sql.rs similarity index 97% rename from rust-lib/flowy-workspace/src/sql_tables/app/app_sql.rs rename to rust-lib/flowy-workspace/src/services/sql_tables/app/app_sql.rs index d3d623c598..fa535774ac 100644 --- a/rust-lib/flowy-workspace/src/sql_tables/app/app_sql.rs +++ b/rust-lib/flowy-workspace/src/services/sql_tables/app/app_sql.rs @@ -1,13 +1,14 @@ -use crate::{ - errors::WorkspaceError, - sql_tables::app::{AppTable, AppTableChangeset}, -}; use flowy_database::{ prelude::*, schema::{app_table, app_table::dsl}, SqliteConnection, }; +use crate::{ + errors::WorkspaceError, + services::sql_tables::app::{AppTable, AppTableChangeset}, +}; + pub struct AppTableSql {} impl AppTableSql { diff --git a/rust-lib/flowy-workspace/src/sql_tables/app/app_table.rs b/rust-lib/flowy-workspace/src/services/sql_tables/app/app_table.rs similarity index 97% rename from rust-lib/flowy-workspace/src/sql_tables/app/app_table.rs rename to rust-lib/flowy-workspace/src/services/sql_tables/app/app_table.rs index 5e37ae0394..2777e75bd2 100644 --- a/rust-lib/flowy-workspace/src/sql_tables/app/app_table.rs +++ b/rust-lib/flowy-workspace/src/services/sql_tables/app/app_table.rs @@ -1,16 +1,18 @@ +use std::convert::TryInto; + +use diesel::sql_types::Binary; +use serde::{Deserialize, Serialize, __private::TryFrom}; + +use flowy_database::schema::app_table; + use crate::{ entities::{ app::{App, ColorStyle, UpdateAppParams}, + trash::{Trash, TrashType}, view::RepeatedView, }, - sql_tables::workspace::WorkspaceTable, + services::sql_tables::workspace::WorkspaceTable, }; -use diesel::sql_types::Binary; -use flowy_database::schema::app_table; - -use crate::entities::trash::{Trash, TrashType}; -use serde::{Deserialize, Serialize, __private::TryFrom}; -use std::convert::TryInto; #[derive(PartialEq, Clone, Debug, Queryable, Identifiable, Insertable, Associations)] #[belongs_to(WorkspaceTable, foreign_key = "workspace_id")] diff --git a/rust-lib/flowy-workspace/src/sql_tables/app/mod.rs b/rust-lib/flowy-workspace/src/services/sql_tables/app/mod.rs similarity index 100% rename from rust-lib/flowy-workspace/src/sql_tables/app/mod.rs rename to rust-lib/flowy-workspace/src/services/sql_tables/app/mod.rs diff --git a/rust-lib/flowy-workspace/src/sql_tables/mod.rs b/rust-lib/flowy-workspace/src/services/sql_tables/mod.rs similarity index 100% rename from rust-lib/flowy-workspace/src/sql_tables/mod.rs rename to rust-lib/flowy-workspace/src/services/sql_tables/mod.rs diff --git a/rust-lib/flowy-workspace/src/sql_tables/trash/mod.rs b/rust-lib/flowy-workspace/src/services/sql_tables/trash/mod.rs similarity index 100% rename from rust-lib/flowy-workspace/src/sql_tables/trash/mod.rs rename to rust-lib/flowy-workspace/src/services/sql_tables/trash/mod.rs diff --git a/rust-lib/flowy-workspace/src/sql_tables/trash/trash_sql.rs b/rust-lib/flowy-workspace/src/services/sql_tables/trash/trash_sql.rs similarity index 93% rename from rust-lib/flowy-workspace/src/sql_tables/trash/trash_sql.rs rename to rust-lib/flowy-workspace/src/services/sql_tables/trash/trash_sql.rs index 382b403d15..117f92a302 100644 --- a/rust-lib/flowy-workspace/src/sql_tables/trash/trash_sql.rs +++ b/rust-lib/flowy-workspace/src/services/sql_tables/trash/trash_sql.rs @@ -1,16 +1,15 @@ -use crate::{ - entities::trash::RepeatedTrash, - errors::WorkspaceError, - sql_tables::trash::{TrashTable, TrashTableChangeset}, -}; - -use crate::entities::trash::Trash; use flowy_database::{ prelude::*, schema::{trash_table, trash_table::dsl}, SqliteConnection, }; +use crate::{ + entities::trash::{RepeatedTrash, Trash}, + errors::WorkspaceError, + services::sql_tables::trash::{TrashTable, TrashTableChangeset}, +}; + pub struct TrashTableSql {} impl TrashTableSql { diff --git a/rust-lib/flowy-workspace/src/sql_tables/trash/trash_table.rs b/rust-lib/flowy-workspace/src/services/sql_tables/trash/trash_table.rs similarity index 100% rename from rust-lib/flowy-workspace/src/sql_tables/trash/trash_table.rs rename to rust-lib/flowy-workspace/src/services/sql_tables/trash/trash_table.rs diff --git a/rust-lib/flowy-workspace/src/sql_tables/view/mod.rs b/rust-lib/flowy-workspace/src/services/sql_tables/view/mod.rs similarity index 100% rename from rust-lib/flowy-workspace/src/sql_tables/view/mod.rs rename to rust-lib/flowy-workspace/src/services/sql_tables/view/mod.rs diff --git a/rust-lib/flowy-workspace/src/sql_tables/view/view_sql.rs b/rust-lib/flowy-workspace/src/services/sql_tables/view/view_sql.rs similarity index 98% rename from rust-lib/flowy-workspace/src/sql_tables/view/view_sql.rs rename to rust-lib/flowy-workspace/src/services/sql_tables/view/view_sql.rs index 39784b6a1d..ca55fa1691 100644 --- a/rust-lib/flowy-workspace/src/sql_tables/view/view_sql.rs +++ b/rust-lib/flowy-workspace/src/services/sql_tables/view/view_sql.rs @@ -1,13 +1,14 @@ -use crate::{ - errors::WorkspaceError, - sql_tables::view::{ViewTable, ViewTableChangeset}, -}; use flowy_database::{ prelude::*, schema::{view_table, view_table::dsl}, SqliteConnection, }; +use crate::{ + errors::WorkspaceError, + services::sql_tables::view::{ViewTable, ViewTableChangeset}, +}; + pub struct ViewTableSql {} impl ViewTableSql { diff --git a/rust-lib/flowy-workspace/src/sql_tables/view/view_table.rs b/rust-lib/flowy-workspace/src/services/sql_tables/view/view_table.rs similarity index 98% rename from rust-lib/flowy-workspace/src/sql_tables/view/view_table.rs rename to rust-lib/flowy-workspace/src/services/sql_tables/view/view_table.rs index 50a7971ba9..9b67205b07 100644 --- a/rust-lib/flowy-workspace/src/sql_tables/view/view_table.rs +++ b/rust-lib/flowy-workspace/src/services/sql_tables/view/view_table.rs @@ -1,13 +1,15 @@ +use diesel::sql_types::Integer; + +use flowy_database::schema::view_table; +use flowy_infra::timestamp; + use crate::{ entities::{ trash::{Trash, TrashType}, view::{RepeatedView, UpdateViewParams, View, ViewType}, }, - sql_tables::app::AppTable, + services::sql_tables::app::AppTable, }; -use diesel::sql_types::Integer; -use flowy_database::schema::view_table; -use flowy_infra::timestamp; #[derive(PartialEq, Clone, Debug, Queryable, Identifiable, Insertable, Associations)] #[belongs_to(AppTable, foreign_key = "belong_to_id")] diff --git a/rust-lib/flowy-workspace/src/sql_tables/workspace/mod.rs b/rust-lib/flowy-workspace/src/services/sql_tables/workspace/mod.rs similarity index 100% rename from rust-lib/flowy-workspace/src/sql_tables/workspace/mod.rs rename to rust-lib/flowy-workspace/src/services/sql_tables/workspace/mod.rs diff --git a/rust-lib/flowy-workspace/src/sql_tables/workspace/workspace_sql.rs b/rust-lib/flowy-workspace/src/services/sql_tables/workspace/workspace_sql.rs similarity index 95% rename from rust-lib/flowy-workspace/src/sql_tables/workspace/workspace_sql.rs rename to rust-lib/flowy-workspace/src/services/sql_tables/workspace/workspace_sql.rs index 811d96c529..9ef70dfc25 100644 --- a/rust-lib/flowy-workspace/src/sql_tables/workspace/workspace_sql.rs +++ b/rust-lib/flowy-workspace/src/services/sql_tables/workspace/workspace_sql.rs @@ -1,13 +1,15 @@ -use crate::{ - errors::WorkspaceError, - sql_tables::workspace::{WorkspaceTable, WorkspaceTableChangeset}, -}; use diesel::SqliteConnection; + use flowy_database::{ prelude::*, schema::{workspace_table, workspace_table::dsl}, }; +use crate::{ + errors::WorkspaceError, + services::sql_tables::workspace::{WorkspaceTable, WorkspaceTableChangeset}, +}; + pub(crate) struct WorkspaceTableSql {} impl WorkspaceTableSql { diff --git a/rust-lib/flowy-workspace/src/sql_tables/workspace/workspace_table.rs b/rust-lib/flowy-workspace/src/services/sql_tables/workspace/workspace_table.rs similarity index 100% rename from rust-lib/flowy-workspace/src/sql_tables/workspace/workspace_table.rs rename to rust-lib/flowy-workspace/src/services/sql_tables/workspace/workspace_table.rs diff --git a/rust-lib/flowy-workspace/src/services/trash_can.rs b/rust-lib/flowy-workspace/src/services/trash_can.rs index 5f12729c9c..d9709655fc 100644 --- a/rust-lib/flowy-workspace/src/services/trash_can.rs +++ b/rust-lib/flowy-workspace/src/services/trash_can.rs @@ -1,16 +1,21 @@ +use std::{fmt::Formatter, sync::Arc}; + +use crossbeam_utils::thread; +use tokio::sync::{broadcast, mpsc}; + +use flowy_database::SqliteConnection; + use crate::{ entities::trash::{RepeatedTrash, Trash, TrashIdentifier, TrashIdentifiers, TrashType}, errors::{WorkspaceError, WorkspaceResult}, module::{WorkspaceDatabase, WorkspaceUser}, - notify::{send_anonymous_dart_notification, WorkspaceNotification}, - services::{helper::spawn, server::Server}, - sql_tables::trash::TrashTableSql, + services::{ + helper::spawn, + notify::{send_anonymous_dart_notification, WorkspaceNotification}, + server::Server, + sql_tables::trash::TrashTableSql, + }, }; -use crossbeam_utils::thread; -use flowy_database::SqliteConnection; - -use std::{fmt::Formatter, sync::Arc}; -use tokio::sync::{broadcast, mpsc}; pub struct TrashCan { pub database: Arc, diff --git a/rust-lib/flowy-workspace/src/services/view_controller.rs b/rust-lib/flowy-workspace/src/services/view_controller.rs index aab2c71ed2..a2d25cbea2 100644 --- a/rust-lib/flowy-workspace/src/services/view_controller.rs +++ b/rust-lib/flowy-workspace/src/services/view_controller.rs @@ -1,30 +1,29 @@ -use crate::{ - entities::view::{CreateViewParams, UpdateViewParams, View}, - errors::WorkspaceError, - module::WorkspaceDatabase, - notify::send_dart_notification, - services::{helper::spawn, server::Server}, - sql_tables::view::{ViewTable, ViewTableChangeset, ViewTableSql}, -}; +use std::{collections::HashSet, sync::Arc}; + +use futures::{FutureExt, StreamExt}; -use crate::{ - entities::view::{RepeatedView, ViewIdentifier}, - errors::internal_error, - module::WorkspaceUser, - notify::WorkspaceNotification, - services::{TrashCan, TrashEvent}, -}; use flowy_database::SqliteConnection; use flowy_document::{ entities::doc::{DocDelta, DocIdentifier}, module::FlowyDocument, }; -use crate::{entities::trash::TrashType, errors::WorkspaceResult}; - -use crate::entities::trash::TrashIdentifiers; -use futures::{FutureExt, StreamExt}; -use std::{collections::HashSet, sync::Arc}; +use crate::{ + entities::{ + trash::{TrashIdentifiers, TrashType}, + view::{CreateViewParams, RepeatedView, UpdateViewParams, View, ViewIdentifier}, + }, + errors::{internal_error, WorkspaceError, WorkspaceResult}, + module::{WorkspaceDatabase, WorkspaceUser}, + services::{ + helper::spawn, + notify::{send_dart_notification, WorkspaceNotification}, + server::Server, + sql_tables::view::{ViewTable, ViewTableChangeset, ViewTableSql}, + TrashCan, + TrashEvent, + }, +}; pub(crate) struct ViewController { user: Arc, diff --git a/rust-lib/flowy-workspace/src/services/workspace_controller.rs b/rust-lib/flowy-workspace/src/services/workspace_controller.rs index 2f43fe6092..a7e98b4de3 100644 --- a/rust-lib/flowy-workspace/src/services/workspace_controller.rs +++ b/rust-lib/flowy-workspace/src/services/workspace_controller.rs @@ -1,14 +1,23 @@ +use std::sync::Arc; + +use flowy_database::SqliteConnection; +use flowy_infra::kv::KV; + use crate::{ entities::{app::RepeatedApp, workspace::*}, errors::*, module::{WorkspaceDatabase, WorkspaceUser}, - notify::*, - services::{helper::spawn, read_local_workspace_apps, server::Server, AppController, TrashCan, ViewController}, - sql_tables::workspace::{WorkspaceTable, WorkspaceTableChangeset, WorkspaceTableSql}, + services::{ + helper::spawn, + notify::*, + read_local_workspace_apps, + server::Server, + sql_tables::workspace::{WorkspaceTable, WorkspaceTableChangeset, WorkspaceTableSql}, + AppController, + TrashCan, + ViewController, + }, }; -use flowy_database::SqliteConnection; -use flowy_infra::kv::KV; -use std::sync::Arc; pub struct WorkspaceController { pub user: Arc,