Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
[rust]: config flowy-workspace crate struct
appflowyf35b756459f2
diff --git a/backend/Cargo.toml b/backend/Cargo.tomlindex 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.pngnew file mode 100644index 0000000000..e69de29bb2diff --git a/backend/src/entities/workspace.rs b/backend/src/entities/workspace.rsindex 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.rsindex 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.rsindex 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<Uuid, ServerError> {fn make_records(identifiers: TrashIdentifiers) -> Result<Vec<(Uuid, i32)>, 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.rsindex 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.rsindex 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<App, ServerError> {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<View, ServerError> {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.tomlindex 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 cratebincode = { 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.tomlindex 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.tomlindex 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 filediff --git a/rust-lib/flowy-workspace/Flowy.toml b/rust-lib/flowy-workspace/Flowy.tomlindex 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 filediff --git a/rust-lib/flowy-workspace/src/entities/app/app_create.rs b/rust-lib/flowy-workspace/src/entities/app/app_create.rsindex 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<CreateAppParams> 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<AppColorStyle> 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.rsindex 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<UpdateAppParams> 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.rsindex 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 @@-pub use app_create::*;-pub use app_update::*;-+#[cfg(feature = "flowy_client_sdk")]mod app_create;+#[cfg(feature = "flowy_client_sdk")]mod app_query;+#[cfg(feature = "flowy_client_sdk")]mod app_update;-pub mod parser;+#[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::*;++pub mod parser;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.rsindex 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<AppColorStyle, String> {+ pub fn parse(theme_color: String) -> Result<AppColorStyle, String> {// TODO: verify the color style format- Ok(Self(color_style))+ Ok(AppColorStyle { theme_color })}}--impl AsRef<ColorStyle> 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.rsindex 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.rsindex 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.rsindex 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.rsdeleted file mode 100644index 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<i32, String> {- let _ = TrashType::try_from(value)?;- Ok(value)- }-}--impl AsRef<i32> 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.rsindex 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.rsindex 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.rsindex 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.rsindex 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.rsindex 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<dyn WorkspaceUser>,diff --git a/rust-lib/flowy-workspace/src/handlers/app_handler.rs b/rust-lib/flowy-workspace/src/services/handlers/app_handler.rssimilarity index 100%rename from rust-lib/flowy-workspace/src/handlers/app_handler.rsrename to rust-lib/flowy-workspace/src/services/handlers/app_handler.rsdiff --git a/rust-lib/flowy-workspace/src/handlers/mod.rs b/rust-lib/flowy-workspace/src/services/handlers/mod.rssimilarity index 100%rename from rust-lib/flowy-workspace/src/handlers/mod.rsrename to rust-lib/flowy-workspace/src/services/handlers/mod.rsdiff --git a/rust-lib/flowy-workspace/src/handlers/trash_handler.rs b/rust-lib/flowy-workspace/src/services/handlers/trash_handler.rssimilarity index 100%rename from rust-lib/flowy-workspace/src/handlers/trash_handler.rsrename to rust-lib/flowy-workspace/src/services/handlers/trash_handler.rsdiff --git a/rust-lib/flowy-workspace/src/handlers/view_handler.rs b/rust-lib/flowy-workspace/src/services/handlers/view_handler.rssimilarity index 100%rename from rust-lib/flowy-workspace/src/handlers/view_handler.rsrename to rust-lib/flowy-workspace/src/services/handlers/view_handler.rsdiff --git a/rust-lib/flowy-workspace/src/handlers/workspace_handler.rs b/rust-lib/flowy-workspace/src/services/handlers/workspace_handler.rssimilarity index 100%rename from rust-lib/flowy-workspace/src/handlers/workspace_handler.rsrename to rust-lib/flowy-workspace/src/services/handlers/workspace_handler.rsdiff --git a/rust-lib/flowy-workspace/src/services/mod.rs b/rust-lib/flowy-workspace/src/services/mod.rsindex 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.rssimilarity index 100%rename from rust-lib/flowy-workspace/src/notify/mod.rsrename to rust-lib/flowy-workspace/src/services/notify/mod.rsdiff --git a/rust-lib/flowy-workspace/src/notify/observable.rs b/rust-lib/flowy-workspace/src/services/notify/observable.rssimilarity index 100%rename from rust-lib/flowy-workspace/src/notify/observable.rsrename to rust-lib/flowy-workspace/src/services/notify/observable.rsdiff --git a/rust-lib/flowy-workspace/src/services/server/middleware.rs b/rust-lib/flowy-workspace/src/services/server/middleware.rsindex 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<WorkspaceMiddleware> = 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<WorkspaceMiddleware> = 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.rssimilarity index 97%rename from rust-lib/flowy-workspace/src/sql_tables/app/app_sql.rsrename to rust-lib/flowy-workspace/src/services/sql_tables/app/app_sql.rsindex 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.rssimilarity index 97%rename from rust-lib/flowy-workspace/src/sql_tables/app/app_table.rsrename to rust-lib/flowy-workspace/src/services/sql_tables/app/app_table.rsindex 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.rssimilarity index 100%rename from rust-lib/flowy-workspace/src/sql_tables/app/mod.rsrename to rust-lib/flowy-workspace/src/services/sql_tables/app/mod.rsdiff --git a/rust-lib/flowy-workspace/src/sql_tables/mod.rs b/rust-lib/flowy-workspace/src/services/sql_tables/mod.rssimilarity index 100%rename from rust-lib/flowy-workspace/src/sql_tables/mod.rsrename to rust-lib/flowy-workspace/src/services/sql_tables/mod.rsdiff --git a/rust-lib/flowy-workspace/src/sql_tables/trash/mod.rs b/rust-lib/flowy-workspace/src/services/sql_tables/trash/mod.rssimilarity index 100%rename from rust-lib/flowy-workspace/src/sql_tables/trash/mod.rsrename to rust-lib/flowy-workspace/src/services/sql_tables/trash/mod.rsdiff --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.rssimilarity index 93%rename from rust-lib/flowy-workspace/src/sql_tables/trash/trash_sql.rsrename to rust-lib/flowy-workspace/src/services/sql_tables/trash/trash_sql.rsindex 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.rssimilarity index 100%rename from rust-lib/flowy-workspace/src/sql_tables/trash/trash_table.rsrename to rust-lib/flowy-workspace/src/services/sql_tables/trash/trash_table.rsdiff --git a/rust-lib/flowy-workspace/src/sql_tables/view/mod.rs b/rust-lib/flowy-workspace/src/services/sql_tables/view/mod.rssimilarity index 100%rename from rust-lib/flowy-workspace/src/sql_tables/view/mod.rsrename to rust-lib/flowy-workspace/src/services/sql_tables/view/mod.rsdiff --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.rssimilarity index 98%rename from rust-lib/flowy-workspace/src/sql_tables/view/view_sql.rsrename to rust-lib/flowy-workspace/src/services/sql_tables/view/view_sql.rsindex 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.rssimilarity index 98%rename from rust-lib/flowy-workspace/src/sql_tables/view/view_table.rsrename to rust-lib/flowy-workspace/src/services/sql_tables/view/view_table.rsindex 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.rssimilarity index 100%rename from rust-lib/flowy-workspace/src/sql_tables/workspace/mod.rsrename to rust-lib/flowy-workspace/src/services/sql_tables/workspace/mod.rsdiff --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.rssimilarity index 95%rename from rust-lib/flowy-workspace/src/sql_tables/workspace/workspace_sql.rsrename to rust-lib/flowy-workspace/src/services/sql_tables/workspace/workspace_sql.rsindex 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.rssimilarity index 100%rename from rust-lib/flowy-workspace/src/sql_tables/workspace/workspace_table.rsrename to rust-lib/flowy-workspace/src/services/sql_tables/workspace/workspace_table.rsdiff --git a/rust-lib/flowy-workspace/src/services/trash_can.rs b/rust-lib/flowy-workspace/src/services/trash_can.rsindex 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<dyn WorkspaceDatabase>,diff --git a/rust-lib/flowy-workspace/src/services/view_controller.rs b/rust-lib/flowy-workspace/src/services/view_controller.rsindex 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<dyn WorkspaceUser>,diff --git a/rust-lib/flowy-workspace/src/services/workspace_controller.rs b/rust-lib/flowy-workspace/src/services/workspace_controller.rsindex 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<dyn WorkspaceUser>,