chore: merge with main

This commit is contained in:
Zack Fu Zi Xiang 2024-09-09 19:25:24 +08:00
commit 28a2d269e9
No known key found for this signature in database
10 changed files with 53 additions and 32 deletions

34
Cargo.lock generated
View File

@ -2089,7 +2089,7 @@ dependencies = [
[[package]] [[package]]
name = "collab" name = "collab"
version = "0.2.0" 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 = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -2114,13 +2114,14 @@ dependencies = [
[[package]] [[package]]
name = "collab-database" name = "collab-database"
version = "0.2.0" 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 = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
"chrono", "chrono",
"collab", "collab",
"collab-entity", "collab-entity",
"csv",
"dashmap 5.5.3", "dashmap 5.5.3",
"futures", "futures",
"getrandom 0.2.15", "getrandom 0.2.15",
@ -2143,7 +2144,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-document" name = "collab-document"
version = "0.2.0" 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 = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -2163,7 +2164,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-entity" name = "collab-entity"
version = "0.2.0" 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 = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -2182,7 +2183,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-folder" name = "collab-folder"
version = "0.2.0" 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 = [ dependencies = [
"anyhow", "anyhow",
"arc-swap", "arc-swap",
@ -2267,7 +2268,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-user" name = "collab-user"
version = "0.2.0" 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 = [ dependencies = [
"anyhow", "anyhow",
"collab", "collab",
@ -2624,6 +2625,27 @@ dependencies = [
"syn 2.0.72", "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]] [[package]]
name = "ctr" name = "ctr"
version = "0.9.2" version = "0.9.2"

View File

@ -287,12 +287,12 @@ debug = true
[patch.crates-io] [patch.crates-io]
# It's diffcult to resovle different version with the same crate used in AppFlowy Frontend and the Client-API crate. # 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. # So using patch to workaround this issue.
collab = { 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 = "47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac" } collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac" } collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac" } collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac" } collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "47dbd6c8033f8fd2999cb8d11f2d60ede121a0ac" } collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" }
[features] [features]
history = [] history = []

View File

@ -1,6 +1,6 @@
FROM golang as base FROM golang as base
WORKDIR /go/src/supabase 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 WORKDIR /go/src/supabase/gotrue
COPY docker/gotrue.patch . COPY docker/gotrue.patch .
RUN git apply gotrue.patch RUN git apply gotrue.patch

View File

@ -269,7 +269,7 @@ impl TestClient {
) )
.unwrap(); .unwrap();
UserAwareness::open(collab, None) UserAwareness::open(collab, None).unwrap()
} }
pub async fn try_update_workspace_member( pub async fn try_update_workspace_member(

View File

@ -43,7 +43,7 @@ impl GettingStartedTemplate {
// 2. create a new document with the getting started data // 2. create a new document with the getting started data
let data = tokio::task::spawn_blocking(move || { let data = tokio::task::spawn_blocking(move || {
let collab = Collab::new_with_origin(CollabOrigin::Empty, &object_id, vec![], false); 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()?; let encoded_collab = document.encode_collab()?;
Ok::<_, anyhow::Error>(TemplateData { Ok::<_, anyhow::Error>(TemplateData {
@ -366,7 +366,7 @@ impl WorkspaceTemplate for DocumentTemplate {
async fn create(&self, object_id: String) -> anyhow::Result<Vec<TemplateData>> { async fn create(&self, object_id: String) -> anyhow::Result<Vec<TemplateData>> {
let collab = Collab::new_with_origin(CollabOrigin::Empty, &object_id, vec![], false); 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()?; let data = document.encode_collab()?;
Ok(vec![TemplateData { Ok(vec![TemplateData {
template_id: TemplateObjectId::Document(object_id), template_id: TemplateObjectId::Document(object_id),

View File

@ -140,7 +140,7 @@ impl WorkspaceTemplateBuilder {
}; };
let collab = Collab::new_with_origin(CollabOrigin::Empty, &workspace_id, vec![], false); 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()?; let data = folder.encode_collab()?;
Ok::<_, anyhow::Error>(TemplateData { Ok::<_, anyhow::Error>(TemplateData {
template_id: TemplateObjectId::Folder(workspace_id), template_id: TemplateObjectId::Folder(workspace_id),

View File

@ -123,7 +123,7 @@ async fn create_user_awareness(
let collab = Collab::new_with_origin(CollabOrigin::Empty, object_id.clone(), vec![], false); let collab = Collab::new_with_origin(CollabOrigin::Empty, object_id.clone(), vec![], false);
// TODO(nathan): Maybe using hardcode encoded collab // 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 let encode_collab = user_awareness
.encode_collab_v1(|collab| collab_type.validate_require_data(collab)) .encode_collab_v1(|collab| collab_type.validate_require_data(collab))
.map_err(AppError::Internal)?; .map_err(AppError::Internal)?;

View File

@ -7,7 +7,7 @@ use collab::preclude::MapExt;
use collab_database::entity::FieldType; use collab_database::entity::FieldType;
use collab_database::rows::meta_id_from_row_id; use collab_database::rows::meta_id_from_row_id;
use collab_database::rows::RowMetaKey; use collab_database::rows::RowMetaKey;
use collab_database::views::ViewMap; use collab_database::views::DatabaseViews;
use collab_database::workspace_database::WorkspaceDatabaseBody; use collab_database::workspace_database::WorkspaceDatabaseBody;
use collab_document::blocks::DocumentData; use collab_document::blocks::DocumentData;
use collab_document::document::Document; use collab_document::document::Document;
@ -404,7 +404,7 @@ impl PublishCollabDuplicator {
// write modified doc_data back to storage // write modified doc_data back to storage
let empty_collab = collab_from_doc_state(vec![], &dup_view_id)?; let empty_collab = collab_from_doc_state(vec![], &dup_view_id)?;
let new_doc = tokio::task::spawn_blocking(move || { 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())) .map_err(|e| AppError::Unhandled(e.to_string()))
}) })
.await??; .await??;
@ -914,7 +914,7 @@ impl PublishCollabDuplicator {
.data .data
.get_with_path(&txn, ["database", "views"]) .get_with_path(&txn, ["database", "views"])
.ok_or_else(|| AppError::RecordNotFound("no views found in database".to_string()))?; .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 // create new database views based on published views

View File

@ -26,7 +26,7 @@ async fn test_document_indexing_and_search() {
vec![], vec![],
false, 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() document.encode_collab().unwrap()
}; };
test_client test_client

View File

@ -1,13 +1,20 @@
use app_error::ErrorCode;
use appflowy_cloud::biz::collab::folder_view::collab_folder_to_folder_view; use appflowy_cloud::biz::collab::folder_view::collab_folder_to_folder_view;
use appflowy_cloud::biz::workspace::publish_dup::{ use appflowy_cloud::biz::workspace::publish_dup::{
collab_from_doc_state, get_database_id_from_collab, 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::util::MapExt;
use collab_database::views::ViewMap; use collab_database::views::DatabaseViews;
use collab_database::workspace_database::WorkspaceDatabaseBody; use collab_database::workspace_database::WorkspaceDatabaseBody;
use collab_document::document::Document; use collab_document::document::Document;
use collab_entity::CollabType; use collab_entity::CollabType;
use collab_folder::{CollabOrigin, Folder}; use collab_folder::{CollabOrigin, Folder};
use itertools::Itertools;
use shared_entity::dto::publish_dto::PublishDatabaseData; use shared_entity::dto::publish_dto::PublishDatabaseData;
use shared_entity::dto::publish_dto::PublishViewMetaData; use shared_entity::dto::publish_dto::PublishViewMetaData;
use shared_entity::dto::workspace_dto::PublishedDuplicate; use shared_entity::dto::workspace_dto::PublishedDuplicate;
@ -17,14 +24,6 @@ use std::time::Duration;
use yrs::types::Map; use yrs::types::Map;
use yrs::MapRef; use yrs::MapRef;
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}; use crate::workspace::published_data::{self};
#[tokio::test] #[tokio::test]
@ -971,7 +970,7 @@ async fn duplicate_to_workspace_doc_inline_database() {
.data .data
.get_with_path(&txn, ["database", "views"]) .get_with_path(&txn, ["database", "views"])
.unwrap(); .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) { for db_view in view_map.get_all_views(&txn) {