From e8484fdc1e5718d331acbd31ce1e26371c077a32 Mon Sep 17 00:00:00 2001 From: Matteo Pietro Dazzi Date: Sat, 7 Sep 2024 12:22:30 +0200 Subject: [PATCH 1/2] fix: auth --- docker/gotrue.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/gotrue.Dockerfile b/docker/gotrue.Dockerfile index 193f5d63..7c2fe8bd 100644 --- a/docker/gotrue.Dockerfile +++ b/docker/gotrue.Dockerfile @@ -1,6 +1,6 @@ FROM golang as base WORKDIR /go/src/supabase -RUN git clone https://github.com/supabase/gotrue.git --depth 1 --branch v2.159.1 +RUN git clone https://github.com/supabase/auth.git --depth 1 --branch v2.159.1 WORKDIR /go/src/supabase/gotrue COPY docker/gotrue.patch . RUN git apply gotrue.patch From 3f59c650f4fb38171310607d709f57836418ee7f Mon Sep 17 00:00:00 2001 From: "Nathan.fooo" <86001920+appflowy@users.noreply.github.com> Date: Mon, 9 Sep 2024 18:50:47 +0800 Subject: [PATCH 2/2] chore: bump appflowy collab (#805) * chore: bump appflowy collab * chore: fix test * chore: bump collab --- Cargo.lock | 34 +++++++++++++++---- Cargo.toml | 12 +++---- libs/client-api-test/src/test_client.rs | 2 +- .../src/document/getting_started.rs | 4 +-- libs/workspace-template/src/lib.rs | 2 +- src/biz/user/user_init.rs | 2 +- src/biz/workspace/publish_dup.rs | 6 ++-- tests/search/document_search.rs | 2 +- tests/workspace/publish.rs | 19 +++++------ 9 files changed, 52 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 343621fb..1ea230e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2089,7 +2089,7 @@ dependencies = [ [[package]] name = "collab" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac#47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=5f3e7163e3a408a08423d079eb41068fb86e562b#5f3e7163e3a408a08423d079eb41068fb86e562b" dependencies = [ "anyhow", "arc-swap", @@ -2114,13 +2114,14 @@ dependencies = [ [[package]] name = "collab-database" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac#47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=5f3e7163e3a408a08423d079eb41068fb86e562b#5f3e7163e3a408a08423d079eb41068fb86e562b" dependencies = [ "anyhow", "async-trait", "chrono", "collab", "collab-entity", + "csv", "dashmap 5.5.3", "futures", "getrandom 0.2.15", @@ -2143,7 +2144,7 @@ dependencies = [ [[package]] name = "collab-document" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac#47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=5f3e7163e3a408a08423d079eb41068fb86e562b#5f3e7163e3a408a08423d079eb41068fb86e562b" dependencies = [ "anyhow", "arc-swap", @@ -2163,7 +2164,7 @@ dependencies = [ [[package]] name = "collab-entity" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac#47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=5f3e7163e3a408a08423d079eb41068fb86e562b#5f3e7163e3a408a08423d079eb41068fb86e562b" dependencies = [ "anyhow", "bytes", @@ -2182,7 +2183,7 @@ dependencies = [ [[package]] name = "collab-folder" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac#47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=5f3e7163e3a408a08423d079eb41068fb86e562b#5f3e7163e3a408a08423d079eb41068fb86e562b" dependencies = [ "anyhow", "arc-swap", @@ -2267,7 +2268,7 @@ dependencies = [ [[package]] name = "collab-user" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac#47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=5f3e7163e3a408a08423d079eb41068fb86e562b#5f3e7163e3a408a08423d079eb41068fb86e562b" dependencies = [ "anyhow", "collab", @@ -2624,6 +2625,27 @@ dependencies = [ "syn 2.0.72", ] +[[package]] +name = "csv" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac574ff4d437a7b5ad237ef331c17ccca63c46479e5b5453eb8e10bb99a759fe" +dependencies = [ + "csv-core", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "csv-core" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5efa2b3d7902f4b634a20cae3c9c4e6209dc4779feb6863329607560143efa70" +dependencies = [ + "memchr", +] + [[package]] name = "ctr" version = "0.9.2" diff --git a/Cargo.toml b/Cargo.toml index eaf18d98..cda39260 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -287,12 +287,12 @@ debug = true [patch.crates-io] # It's diffcult to resovle different version with the same crate used in AppFlowy Frontend and the Client-API crate. # So using patch to workaround this issue. -collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac" } -collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac" } -collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac" } -collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac" } -collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac" } -collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac" } +collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" } +collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" } +collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" } +collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" } +collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" } +collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" } [features] history = [] diff --git a/libs/client-api-test/src/test_client.rs b/libs/client-api-test/src/test_client.rs index ad8d688b..aa32d614 100644 --- a/libs/client-api-test/src/test_client.rs +++ b/libs/client-api-test/src/test_client.rs @@ -237,7 +237,7 @@ impl TestClient { ) .unwrap(); - UserAwareness::open(collab, None) + UserAwareness::open(collab, None).unwrap() } pub async fn try_update_workspace_member( diff --git a/libs/workspace-template/src/document/getting_started.rs b/libs/workspace-template/src/document/getting_started.rs index 636f028c..b31b1ce1 100644 --- a/libs/workspace-template/src/document/getting_started.rs +++ b/libs/workspace-template/src/document/getting_started.rs @@ -43,7 +43,7 @@ impl GettingStartedTemplate { // 2. create a new document with the getting started data let data = tokio::task::spawn_blocking(move || { let collab = Collab::new_with_origin(CollabOrigin::Empty, &object_id, vec![], false); - let document = Document::open_with(collab, Some(document_data))?; + let document = Document::create_with_data(collab, document_data)?; let encoded_collab = document.encode_collab()?; Ok::<_, anyhow::Error>(TemplateData { @@ -366,7 +366,7 @@ impl WorkspaceTemplate for DocumentTemplate { async fn create(&self, object_id: String) -> anyhow::Result> { let collab = Collab::new_with_origin(CollabOrigin::Empty, &object_id, vec![], false); - let document = Document::open_with(collab, Some(self.0.clone()))?; + let document = Document::create_with_data(collab, self.0.clone())?; let data = document.encode_collab()?; Ok(vec![TemplateData { template_id: TemplateObjectId::Document(object_id), diff --git a/libs/workspace-template/src/lib.rs b/libs/workspace-template/src/lib.rs index 135074e0..30c3a69f 100644 --- a/libs/workspace-template/src/lib.rs +++ b/libs/workspace-template/src/lib.rs @@ -140,7 +140,7 @@ impl WorkspaceTemplateBuilder { }; let collab = Collab::new_with_origin(CollabOrigin::Empty, &workspace_id, vec![], false); - let folder = Folder::open_with(uid, collab, None, Some(folder_data)); + let folder = Folder::create(uid, collab, None, folder_data); let data = folder.encode_collab()?; Ok::<_, anyhow::Error>(TemplateData { template_id: TemplateObjectId::Folder(workspace_id), diff --git a/src/biz/user/user_init.rs b/src/biz/user/user_init.rs index f319c3a5..46de113d 100644 --- a/src/biz/user/user_init.rs +++ b/src/biz/user/user_init.rs @@ -123,7 +123,7 @@ async fn create_user_awareness( let collab = Collab::new_with_origin(CollabOrigin::Empty, object_id.clone(), vec![], false); // TODO(nathan): Maybe using hardcode encoded collab - let user_awareness = UserAwareness::open(collab, None); + let user_awareness = UserAwareness::create(collab, None)?; let encode_collab = user_awareness .encode_collab_v1(|collab| collab_type.validate_require_data(collab)) .map_err(AppError::Internal)?; diff --git a/src/biz/workspace/publish_dup.rs b/src/biz/workspace/publish_dup.rs index a84350b5..3e0a12dc 100644 --- a/src/biz/workspace/publish_dup.rs +++ b/src/biz/workspace/publish_dup.rs @@ -4,7 +4,7 @@ use collab::core::collab::DataSource; use collab::preclude::Collab; use collab::preclude::MapExt; -use collab_database::views::ViewMap; +use collab_database::views::DatabaseViews; use collab_database::workspace_database::WorkspaceDatabaseBody; use collab_document::blocks::DocumentData; use collab_document::document::Document; @@ -389,7 +389,7 @@ impl PublishCollabDuplicator { // write modified doc_data back to storage let empty_collab = collab_from_doc_state(vec![], &new_view_id)?; let new_doc = tokio::task::spawn_blocking(move || { - Document::open_with(empty_collab, Some(doc_data)) + Document::create_with_data(empty_collab, doc_data) .map_err(|e| AppError::Unhandled(e.to_string())) }) .await??; @@ -720,7 +720,7 @@ impl PublishCollabDuplicator { .data .get_with_path(&txn, ["database", "views"]) .ok_or_else(|| AppError::RecordNotFound("no views found in database".to_string()))?; - ViewMap::new(map_ref, tokio::sync::broadcast::channel(1).0) + DatabaseViews::new(CollabOrigin::Empty, map_ref, None) }; // create new database views based on published views diff --git a/tests/search/document_search.rs b/tests/search/document_search.rs index 259e1aeb..0b62ca9b 100644 --- a/tests/search/document_search.rs +++ b/tests/search/document_search.rs @@ -26,7 +26,7 @@ async fn test_document_indexing_and_search() { vec![], false, ); - let document = Document::open_with(collab, Some(document_data)).unwrap(); + let document = Document::create_with_data(collab, document_data).unwrap(); document.encode_collab().unwrap() }; test_client diff --git a/tests/workspace/publish.rs b/tests/workspace/publish.rs index c7f5c108..710706a7 100644 --- a/tests/workspace/publish.rs +++ b/tests/workspace/publish.rs @@ -1,13 +1,20 @@ +use app_error::ErrorCode; use appflowy_cloud::biz::collab::folder_view::collab_folder_to_folder_view; use appflowy_cloud::biz::workspace::publish_dup::{ collab_from_doc_state, get_database_id_from_collab, }; +use client_api::entity::{ + AFRole, GlobalComment, PublishCollabItem, PublishCollabMetadata, QueryCollab, QueryCollabParams, +}; +use client_api_test::TestClient; +use client_api_test::{generate_unique_registered_user_client, localhost_client}; use collab::util::MapExt; -use collab_database::views::ViewMap; +use collab_database::views::DatabaseViews; use collab_database::workspace_database::WorkspaceDatabaseBody; use collab_document::document::Document; use collab_entity::CollabType; use collab_folder::{CollabOrigin, Folder}; +use itertools::Itertools; use shared_entity::dto::publish_dto::PublishDatabaseData; use shared_entity::dto::publish_dto::PublishViewMetaData; use shared_entity::dto::workspace_dto::PublishedDuplicate; @@ -15,14 +22,6 @@ use std::collections::{HashMap, HashSet}; use std::thread::sleep; use std::time::Duration; -use app_error::ErrorCode; -use client_api::entity::{ - AFRole, GlobalComment, PublishCollabItem, PublishCollabMetadata, QueryCollab, QueryCollabParams, -}; -use client_api_test::TestClient; -use client_api_test::{generate_unique_registered_user_client, localhost_client}; -use itertools::Itertools; - use crate::workspace::published_data::{self}; #[tokio::test] @@ -969,7 +968,7 @@ async fn duplicate_to_workspace_doc_inline_database() { .data .get_with_path(&txn, ["database", "views"]) .unwrap(); - ViewMap::new(map_ref, tokio::sync::broadcast::channel(1).0) + DatabaseViews::new(CollabOrigin::Empty, map_ref, None) }; for db_view in view_map.get_all_views(&txn) {