瀏覽代碼

[rust]: config flowy-workspace crate struct

appflowy 3 年之前
父節點
當前提交
f35b756459
共有 49 個文件被更改,包括 217 次插入153 次删除
  1. 2 2
      backend/Cargo.toml
  2. 0 0
      backend/graph.png
  3. 1 1
      backend/src/entities/workspace.rs
  4. 1 1
      backend/src/service/app/router.rs
  5. 6 6
      backend/src/service/trash/router.rs
  6. 1 1
      backend/src/service/trash/trash.rs
  7. 6 6
      backend/src/service/user/user_default.rs
  8. 1 2
      rust-lib/flowy-dispatch/Cargo.toml
  9. 1 1
      rust-lib/flowy-sdk/Cargo.toml
  10. 4 1
      rust-lib/flowy-workspace/Cargo.toml
  11. 1 1
      rust-lib/flowy-workspace/Flowy.toml
  12. 11 3
      rust-lib/flowy-workspace/src/entities/app/app_create.rs
  13. 2 2
      rust-lib/flowy-workspace/src/entities/app/app_update.rs
  14. 10 4
      rust-lib/flowy-workspace/src/entities/app/mod.rs
  15. 5 9
      rust-lib/flowy-workspace/src/entities/app/parser/app_color_style.rs
  16. 4 0
      rust-lib/flowy-workspace/src/entities/mod.rs
  17. 3 0
      rust-lib/flowy-workspace/src/entities/trash/mod.rs
  18. 0 2
      rust-lib/flowy-workspace/src/entities/trash/parser/mod.rs
  19. 0 16
      rust-lib/flowy-workspace/src/entities/trash/parser/trash_ty.rs
  20. 6 0
      rust-lib/flowy-workspace/src/entities/view/mod.rs
  21. 12 2
      rust-lib/flowy-workspace/src/entities/workspace/mod.rs
  22. 13 9
      rust-lib/flowy-workspace/src/lib.rs
  23. 14 8
      rust-lib/flowy-workspace/src/module.rs
  24. 14 6
      rust-lib/flowy-workspace/src/services/app_controller.rs
  25. 0 0
      rust-lib/flowy-workspace/src/services/handlers/app_handler.rs
  26. 0 0
      rust-lib/flowy-workspace/src/services/handlers/mod.rs
  27. 0 0
      rust-lib/flowy-workspace/src/services/handlers/trash_handler.rs
  28. 0 0
      rust-lib/flowy-workspace/src/services/handlers/view_handler.rs
  29. 0 0
      rust-lib/flowy-workspace/src/services/handlers/workspace_handler.rs
  30. 6 0
      rust-lib/flowy-workspace/src/services/mod.rs
  31. 0 0
      rust-lib/flowy-workspace/src/services/notify/mod.rs
  32. 0 0
      rust-lib/flowy-workspace/src/services/notify/observable.rs
  33. 9 6
      rust-lib/flowy-workspace/src/services/server/middleware.rs
  34. 5 4
      rust-lib/flowy-workspace/src/services/sql_tables/app/app_sql.rs
  35. 9 7
      rust-lib/flowy-workspace/src/services/sql_tables/app/app_table.rs
  36. 0 0
      rust-lib/flowy-workspace/src/services/sql_tables/app/mod.rs
  37. 0 0
      rust-lib/flowy-workspace/src/services/sql_tables/mod.rs
  38. 0 0
      rust-lib/flowy-workspace/src/services/sql_tables/trash/mod.rs
  39. 6 7
      rust-lib/flowy-workspace/src/services/sql_tables/trash/trash_sql.rs
  40. 0 0
      rust-lib/flowy-workspace/src/services/sql_tables/trash/trash_table.rs
  41. 0 0
      rust-lib/flowy-workspace/src/services/sql_tables/view/mod.rs
  42. 5 4
      rust-lib/flowy-workspace/src/services/sql_tables/view/view_sql.rs
  43. 6 4
      rust-lib/flowy-workspace/src/services/sql_tables/view/view_table.rs
  44. 0 0
      rust-lib/flowy-workspace/src/services/sql_tables/workspace/mod.rs
  45. 6 4
      rust-lib/flowy-workspace/src/services/sql_tables/workspace/workspace_sql.rs
  46. 0 0
      rust-lib/flowy-workspace/src/services/sql_tables/workspace/workspace_table.rs
  47. 13 8
      rust-lib/flowy-workspace/src/services/trash_can.rs
  48. 19 20
      rust-lib/flowy-workspace/src/services/view_controller.rs
  49. 15 6
      rust-lib/flowy-workspace/src/services/workspace_controller.rs

+ 2 - 2
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" }

+ 0 - 0
backend/graph.png


+ 1 - 1
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";

+ 1 - 1
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;
 

+ 6 - 6
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)
 }

+ 1 - 1
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;
 

+ 6 - 6
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(),

+ 1 - 2
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"]

+ 1 - 1
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" }

+ 4 - 1
rust-lib/flowy-workspace/Cargo.toml

@@ -45,4 +45,7 @@ serial_test = "0.5.1"
 
 
 [features]
-http_server = []
+default = ["flowy_client_sdk", "backend_service"]
+http_server = []
+flowy_client_sdk = []
+backend_service = []

+ 1 - 1
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"]

+ 11 - 3
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)]

+ 2 - 2
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(),
             ),
         };
 

+ 10 - 4
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;

+ 5 - 9
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 }
-}

+ 4 - 0
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::*};
+}

+ 3 - 0
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::*;

+ 0 - 2
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::*;

+ 0 - 16
rust-lib/flowy-workspace/src/entities/trash/parser/trash_ty.rs

@@ -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 }
-}

+ 6 - 0
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::*;

+ 12 - 2
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;

+ 13 - 9
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::*;
+}

+ 14 - 8
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 {}
 

+ 14 - 6
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>,

+ 0 - 0
rust-lib/flowy-workspace/src/handlers/app_handler.rs → rust-lib/flowy-workspace/src/services/handlers/app_handler.rs


+ 0 - 0
rust-lib/flowy-workspace/src/handlers/mod.rs → rust-lib/flowy-workspace/src/services/handlers/mod.rs


+ 0 - 0
rust-lib/flowy-workspace/src/handlers/trash_handler.rs → rust-lib/flowy-workspace/src/services/handlers/trash_handler.rs


+ 0 - 0
rust-lib/flowy-workspace/src/handlers/view_handler.rs → rust-lib/flowy-workspace/src/services/handlers/view_handler.rs


+ 0 - 0
rust-lib/flowy-workspace/src/handlers/workspace_handler.rs → rust-lib/flowy-workspace/src/services/handlers/workspace_handler.rs


+ 6 - 0
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;

+ 0 - 0
rust-lib/flowy-workspace/src/notify/mod.rs → rust-lib/flowy-workspace/src/services/notify/mod.rs


+ 0 - 0
rust-lib/flowy-workspace/src/notify/observable.rs → rust-lib/flowy-workspace/src/services/notify/observable.rs


+ 9 - 6
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 {

+ 5 - 4
rust-lib/flowy-workspace/src/sql_tables/app/app_sql.rs → 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 {

+ 9 - 7
rust-lib/flowy-workspace/src/sql_tables/app/app_table.rs → 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")]

+ 0 - 0
rust-lib/flowy-workspace/src/sql_tables/app/mod.rs → rust-lib/flowy-workspace/src/services/sql_tables/app/mod.rs


+ 0 - 0
rust-lib/flowy-workspace/src/sql_tables/mod.rs → rust-lib/flowy-workspace/src/services/sql_tables/mod.rs


+ 0 - 0
rust-lib/flowy-workspace/src/sql_tables/trash/mod.rs → rust-lib/flowy-workspace/src/services/sql_tables/trash/mod.rs


+ 6 - 7
rust-lib/flowy-workspace/src/sql_tables/trash/trash_sql.rs → 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 {

+ 0 - 0
rust-lib/flowy-workspace/src/sql_tables/trash/trash_table.rs → rust-lib/flowy-workspace/src/services/sql_tables/trash/trash_table.rs


+ 0 - 0
rust-lib/flowy-workspace/src/sql_tables/view/mod.rs → rust-lib/flowy-workspace/src/services/sql_tables/view/mod.rs


+ 5 - 4
rust-lib/flowy-workspace/src/sql_tables/view/view_sql.rs → 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 {

+ 6 - 4
rust-lib/flowy-workspace/src/sql_tables/view/view_table.rs → 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")]

+ 0 - 0
rust-lib/flowy-workspace/src/sql_tables/workspace/mod.rs → rust-lib/flowy-workspace/src/services/sql_tables/workspace/mod.rs


+ 6 - 4
rust-lib/flowy-workspace/src/sql_tables/workspace/workspace_sql.rs → 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 {

+ 0 - 0
rust-lib/flowy-workspace/src/sql_tables/workspace/workspace_table.rs → rust-lib/flowy-workspace/src/services/sql_tables/workspace/workspace_table.rs


+ 13 - 8
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>,

+ 19 - 20
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>,

+ 15 - 6
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>,