Upgrade Rust edition (Do not merge into 0.9.2 version) (#7925)

* chore: compile

* chore: bump rust edition

* chore: bump rust tool chain version

* chore: fix test

* chore: fmt

* chore: build target

* chore: clippy

* chore: fmt
This commit is contained in:
Nathan.fooo 2025-05-14 10:26:59 +08:00 committed by GitHub
parent 13fe4a2395
commit fed9d43fc5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
187 changed files with 442 additions and 462 deletions

View File

@ -19,7 +19,7 @@ on:
env:
CARGO_TERM_COLOR: always
FLUTTER_VERSION: "3.27.4"
RUST_TOOLCHAIN: "1.84.0"
RUST_TOOLCHAIN: "1.85.0"
CARGO_MAKE_VERSION: "0.37.18"
CLOUD_VERSION: 0.6.54-amd64

View File

@ -26,7 +26,7 @@ on:
env:
CARGO_TERM_COLOR: always
FLUTTER_VERSION: "3.27.4"
RUST_TOOLCHAIN: "1.84.0"
RUST_TOOLCHAIN: "1.85.0"
CARGO_MAKE_VERSION: "0.37.18"
CLOUD_VERSION: 0.9.49-amd64

View File

@ -19,7 +19,7 @@ on:
env:
FLUTTER_VERSION: "3.27.4"
RUST_TOOLCHAIN: "1.84.0"
RUST_TOOLCHAIN: "1.85.0"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}

View File

@ -7,7 +7,7 @@ on:
env:
FLUTTER_VERSION: "3.27.4"
RUST_TOOLCHAIN: "1.84.0"
RUST_TOOLCHAIN: "1.85.0"
jobs:
create-release:

View File

@ -19,7 +19,7 @@ on:
env:
CARGO_TERM_COLOR: always
CLOUD_VERSION: 0.9.49-amd64
RUST_TOOLCHAIN: "1.84.0"
RUST_TOOLCHAIN: "1.85.0"
jobs:
ubuntu-job:

View File

@ -11,7 +11,7 @@ on:
env:
CARGO_TERM_COLOR: always
FLUTTER_VERSION: "3.27.4"
RUST_TOOLCHAIN: "1.84.0"
RUST_TOOLCHAIN: "1.85.0"
jobs:
tests:

View File

@ -2226,7 +2226,6 @@ dependencies = [
"lopdf",
"notify",
"ollama-rs",
"pin-project",
"protobuf",
"pulldown-cmark 0.13.0",
"reqwest 0.11.27",

View File

@ -1,7 +1,7 @@
[package]
name = "flowy-codegen"
version = "0.1.0"
edition = "2021"
edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -8,12 +8,12 @@ use walkdir::WalkDir;
use flowy_ast::ASTResult;
use crate::ast::EventASTContext;
use crate::flowy_toml::{parse_crate_config_from, CrateConfig};
use crate::flowy_toml::{CrateConfig, parse_crate_config_from};
use crate::util::{is_crate_dir, is_hidden, path_string_with_component, read_file};
use super::event_template::*;
pub fn gen(crate_name: &str) {
pub fn r#gen(crate_name: &str) {
if std::env::var("CARGO_MAKE_WORKING_DIRECTORY").is_err() {
println!("CARGO_MAKE_WORKING_DIRECTORY was not set, skip generate dart pb");
return;

View File

@ -2,8 +2,8 @@
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(unused_results)]
use crate::protobuf_file::template::{EnumTemplate, StructTemplate, RUST_TYPE_MAP};
use crate::protobuf_file::{parse_crate_info_from_path, ProtoFile, ProtobufCrateContext};
use crate::protobuf_file::template::{EnumTemplate, RUST_TYPE_MAP, StructTemplate};
use crate::protobuf_file::{ProtoFile, ProtobufCrateContext, parse_crate_info_from_path};
use crate::util::*;
use fancy_regex::Regex;
use flowy_ast::*;

View File

@ -6,8 +6,8 @@ mod proto_gen;
mod proto_info;
mod template;
use crate::util::path_string_with_component;
use crate::Project;
use crate::util::path_string_with_component;
use itertools::Itertools;
use log::info;
pub use proto_gen::*;
@ -368,7 +368,7 @@ pub fn gen_proto_files(crate_name: &str) -> Vec<ProtobufCrate> {
.display()
.to_string();
let crate_context = ProtoGenerator::gen(crate_name, &crate_path);
let crate_context = ProtoGenerator::r#gen(crate_name, &crate_path);
let proto_crates = crate_context
.iter()
.map(|info| info.protobuf_crate.clone())

View File

@ -2,11 +2,11 @@
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(unused_results)]
use crate::ProtoCache;
use crate::protobuf_file::ProtoFile;
use crate::protobuf_file::ast::parse_protobuf_context_from;
use crate::protobuf_file::proto_info::ProtobufCrateContext;
use crate::protobuf_file::ProtoFile;
use crate::util::*;
use crate::ProtoCache;
use std::collections::HashMap;
use std::fs::File;
use std::path::Path;
@ -14,7 +14,7 @@ use std::{fs::OpenOptions, io::Write};
pub struct ProtoGenerator();
impl ProtoGenerator {
pub fn gen(crate_name: &str, crate_path: &str) -> Vec<ProtobufCrateContext> {
pub fn r#gen(crate_name: &str, crate_path: &str) -> Vec<ProtobufCrateContext> {
let crate_contexts = parse_protobuf_context_from(vec![crate_path.to_owned()]);
write_proto_files(&crate_contexts);
write_rust_crate_mod_file(&crate_contexts);

View File

@ -1,5 +1,5 @@
#![allow(dead_code)]
use crate::flowy_toml::{parse_crate_config_from, CrateConfig, FlowyConfig};
use crate::flowy_toml::{CrateConfig, FlowyConfig, parse_crate_config_from};
use crate::util::*;
use std::fs::OpenOptions;
use std::io::Write;

View File

@ -1,10 +1,10 @@
mod event_template;
use crate::Project;
use crate::ast::EventASTContext;
use crate::flowy_toml::{parse_crate_config_from, CrateConfig};
use crate::flowy_toml::{CrateConfig, parse_crate_config_from};
use crate::ts_event::event_template::{EventRenderContext, EventTemplate};
use crate::util::{is_crate_dir, is_hidden, path_string_with_component, read_file};
use crate::Project;
use flowy_ast::ASTResult;
use std::collections::HashSet;
use std::fs::File;
@ -13,7 +13,7 @@ use std::path::PathBuf;
use syn::Item;
use walkdir::WalkDir;
pub fn gen(dest_folder_name: &str, project: Project) {
pub fn r#gen(dest_folder_name: &str, project: Project) {
let root = project.event_root();
let backend_service_path = project.dst();

View File

@ -1,7 +1,7 @@
[package]
name = "collab-integrate"
version = "0.1.0"
edition = "2021"
edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]

View File

@ -3,7 +3,7 @@ use std::fmt::{Debug, Display};
use std::sync::{Arc, Weak};
use crate::CollabKVDB;
use anyhow::{anyhow, Error};
use anyhow::{Error, anyhow};
use arc_swap::{ArcSwap, ArcSwapOption};
use collab::core::collab::DataSource;
use collab::core::collab_plugin::CollabPersistence;
@ -28,9 +28,9 @@ use collab_plugins::local_storage::indexeddb::IndexeddbDiskPlugin;
pub use crate::plugin_provider::CollabCloudPluginProvider;
use collab::lock::RwLock;
use collab_plugins::local_storage::kv::doc::CollabKVAction;
use collab_plugins::local_storage::kv::KVTransactionDB;
use collab_plugins::local_storage::CollabPersistenceConfig;
use collab_plugins::local_storage::kv::KVTransactionDB;
use collab_plugins::local_storage::kv::doc::CollabKVAction;
use collab_user::core::{UserAwareness, UserAwarenessNotifier};
use crate::instant_indexed_data_provider::InstantIndexedDataWriter;
@ -379,9 +379,7 @@ impl AppFlowyCollabBuilder {
let write_txn = collab_db.write_txn();
trace!(
"flush workspace: {} {}:collab:{} to disk",
workspace_id,
collab_type,
object_id
workspace_id, collab_type, object_id
);
let collab: &Collab = collab.borrow();
let encode_collab =
@ -456,9 +454,7 @@ impl CollabPersistence for CollabPersistenceImpl {
Ok(update_count) => {
trace!(
"did load collab:{}-{} from disk, update_count:{}",
self.uid,
object_id,
update_count
self.uid, object_id, update_count
);
},
Err(err) => {

View File

@ -63,8 +63,10 @@ impl AWSDynamoDBConfig {
}
pub fn write_env(&self) {
std::env::set_var(AWS_ACCESS_KEY_ID, &self.access_key_id);
std::env::set_var(AWS_SECRET_ACCESS_KEY, &self.secret_access_key);
std::env::set_var(AWS_REGION, &self.region);
unsafe {
std::env::set_var(AWS_ACCESS_KEY_ID, &self.access_key_id);
std::env::set_var(AWS_SECRET_ACCESS_KEY, &self.secret_access_key);
std::env::set_var(AWS_REGION, &self.region);
}
}
}

View File

@ -1,6 +1,6 @@
pub use collab::preclude::Snapshot;
pub use collab_plugins::local_storage::CollabPersistenceConfig;
pub use collab_plugins::CollabKVDB;
pub use collab_plugins::local_storage::CollabPersistenceConfig;
pub mod collab_builder;
pub mod config;

View File

@ -1,7 +1,7 @@
[package]
name = "flowy-ai-pub"
version = "0.1.0"
edition = "2021"
edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -1,4 +1,5 @@
use crate::cloud::ai_dto::AvailableModel;
pub use client_api::entity::QuestionStreamValue;
pub use client_api::entity::ai_dto::{
AppFlowyOfflineAI, CompleteTextParams, CompletionMessage, CompletionMetadata, CompletionType,
CreateChatContext, CustomPrompt, LLMModel, LocalAIConfig, ModelInfo, ModelList, OutputContent,
@ -9,7 +10,6 @@ pub use client_api::entity::chat_dto::{
ChatMessage, ChatMessageType, ChatRAGData, ChatSettings, ContextLoader, MessageCursor,
RepeatedChatMessage, UpdateChatParams,
};
pub use client_api::entity::QuestionStreamValue;
pub use client_api::entity::*;
pub use client_api::error::{AppResponseError, ErrorCode as AppErrorCode};
use flowy_error::FlowyError;

View File

@ -1,5 +1,5 @@
use crate::cloud::workspace_dto::ViewIcon;
use crate::cloud::CollabType;
use crate::cloud::workspace_dto::ViewIcon;
use twox_hash::xxhash64::Hasher;
use uuid::Uuid;
pub const RAG_IDS: &str = "rag_ids";

View File

@ -1,14 +1,13 @@
use crate::cloud::chat_dto::ChatAuthorType;
use crate::cloud::MessageCursor;
use crate::cloud::chat_dto::ChatAuthorType;
use client_api::entity::chat_dto::ChatMessage;
use flowy_error::{FlowyError, FlowyResult};
use flowy_sqlite::upsert::excluded;
use flowy_sqlite::{
diesel, insert_into,
DBConnection, ExpressionMethods, Identifiable, Insertable, OptionalExtension, QueryResult,
Queryable, diesel, insert_into,
query_dsl::*,
schema::{chat_message_table, chat_message_table::dsl},
DBConnection, ExpressionMethods, Identifiable, Insertable, OptionalExtension, QueryResult,
Queryable,
};
#[derive(Queryable, Insertable, Identifiable, Debug)]

View File

@ -2,10 +2,10 @@ use diesel::sqlite::SqliteConnection;
use flowy_error::FlowyResult;
use flowy_sqlite::upsert::excluded;
use flowy_sqlite::{
AsChangeset, DBConnection, ExpressionMethods, Identifiable, Insertable, QueryResult, Queryable,
diesel,
query_dsl::*,
schema::{chat_table, chat_table::dsl},
AsChangeset, DBConnection, ExpressionMethods, Identifiable, Insertable, QueryResult, Queryable,
};
use lib_infra::util::timestamp;
use serde::{Deserialize, Serialize};

View File

@ -1,10 +1,9 @@
use diesel::upsert::excluded;
use flowy_error::{FlowyError, FlowyResult};
use flowy_sqlite::{
diesel, insert_into,
DBConnection, ExpressionMethods, Identifiable, Insertable, Queryable, diesel, insert_into,
query_dsl::*,
schema::{af_collab_metadata, af_collab_metadata::dsl},
DBConnection, ExpressionMethods, Identifiable, Insertable, Queryable,
};
use std::collections::HashMap;
use std::str::FromStr;

View File

@ -2,10 +2,9 @@ use diesel::sqlite::SqliteConnection;
use flowy_error::FlowyResult;
use flowy_sqlite::upsert::excluded;
use flowy_sqlite::{
diesel,
AsChangeset, ExpressionMethods, Identifiable, Insertable, Queryable, diesel,
query_dsl::*,
schema::{index_collab_record_table, index_collab_record_table::dsl},
AsChangeset, ExpressionMethods, Identifiable, Insertable, Queryable,
};
#[derive(Clone, Debug, Queryable, Insertable, AsChangeset, Identifiable)]

View File

@ -2,10 +2,9 @@ use diesel::sqlite::SqliteConnection;
use flowy_error::FlowyResult;
use flowy_sqlite::upsert::excluded;
use flowy_sqlite::{
diesel,
ExpressionMethods, Identifiable, Insertable, Queryable, diesel,
query_dsl::*,
schema::{local_ai_model_table, local_ai_model_table::dsl},
ExpressionMethods, Identifiable, Insertable, Queryable,
};
#[derive(Clone, Default, Queryable, Insertable, Identifiable)]

View File

@ -1,7 +1,7 @@
[package]
name = "flowy-ai"
version = "0.1.0"
edition = "2021"
edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -39,7 +39,6 @@ reqwest = { version = "0.11.27", features = ["json"] }
sha2 = "0.10.7"
base64 = "0.21.5"
futures-util = "0.3.30"
pin-project = "1.1.5"
flowy-storage-pub = { workspace = true }
ollama-rs.workspace = true
schemars = "0.8.22"

View File

@ -2,6 +2,6 @@ fn main() {
#[cfg(feature = "dart")]
{
flowy_codegen::protobuf_file::dart_gen(env!("CARGO_PKG_NAME"));
flowy_codegen::dart_event::gen(env!("CARGO_PKG_NAME"));
flowy_codegen::dart_event::r#gen(env!("CARGO_PKG_NAME"));
}
}

View File

@ -6,7 +6,7 @@ use crate::entities::{
use crate::local_ai::controller::{LocalAIController, LocalAISetting};
use crate::middleware::chat_service_mw::ChatServiceMiddleware;
use flowy_ai_pub::persistence::{
select_chat_metadata, select_chat_rag_ids, select_chat_summary, update_chat, ChatTableChangeset,
ChatTableChangeset, select_chat_metadata, select_chat_rag_ids, select_chat_summary, update_chat,
};
use std::collections::HashMap;
@ -16,12 +16,12 @@ use flowy_error::{ErrorCode, FlowyError, FlowyResult};
use flowy_sqlite::kv::KVStorePreferences;
use crate::model_select::{
LocalAiSource, LocalModelStorageImpl, ModelSelectionControl, ServerAiSource,
ServerModelStorageImpl, SourceKey, GLOBAL_ACTIVE_MODEL_KEY,
GLOBAL_ACTIVE_MODEL_KEY, LocalAiSource, LocalModelStorageImpl, ModelSelectionControl,
ServerAiSource, ServerModelStorageImpl, SourceKey,
};
use crate::notification::{chat_notification_builder, ChatNotification};
use crate::notification::{ChatNotification, chat_notification_builder};
use flowy_ai_pub::persistence::{
batch_insert_collab_metadata, batch_select_collab_metadata, AFCollabMetadata,
AFCollabMetadata, batch_insert_collab_metadata, batch_select_collab_metadata,
};
use flowy_ai_pub::user_service::AIUserService;
use flowy_sqlite::DBConnection;
@ -461,8 +461,7 @@ impl AIManager {
trace!(
"[Model Selection] notify sources: {:?}, model:{}, when disable local ai",
notify_source,
model.name
notify_source, model.name
);
for source in notify_source {
chat_notification_builder(&source, ChatNotification::DidUpdateSelectedModel)

View File

@ -1,4 +1,4 @@
use pulldown_cmark::{html, Options, Parser};
use pulldown_cmark::{Options, Parser, html};
use std::fs;
pub struct MdRead {

View File

@ -3,15 +3,15 @@ use crate::entities::{
RepeatedRelatedQuestionPB, StreamMessageParams,
};
use crate::middleware::chat_service_mw::ChatServiceMiddleware;
use crate::notification::{chat_notification_builder, ChatNotification};
use crate::notification::{ChatNotification, chat_notification_builder};
use crate::stream_message::{AIFollowUpData, StreamMessage};
use allo_isolate::Isolate;
use flowy_ai_pub::cloud::{
AIModel, ChatCloudService, ChatMessage, MessageCursor, QuestionStreamValue, ResponseFormat,
};
use flowy_ai_pub::persistence::{
select_answer_where_match_reply_message_id, select_chat_messages, upsert_chat_messages,
ChatMessageTable,
ChatMessageTable, select_answer_where_match_reply_message_id, select_chat_messages,
upsert_chat_messages,
};
use flowy_ai_pub::user_service::AIUserService;
use flowy_error::{ErrorCode, FlowyError, FlowyResult};
@ -19,8 +19,8 @@ use flowy_sqlite::DBConnection;
use futures::{SinkExt, StreamExt};
use lib_infra::isolate_stream::IsolateSink;
use std::path::PathBuf;
use std::sync::atomic::{AtomicBool, AtomicI64};
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, AtomicI64};
use tokio::sync::{Mutex, RwLock};
use tracing::{error, instrument, trace};
use uuid::Uuid;
@ -77,10 +77,7 @@ impl Chat {
) -> Result<ChatMessagePB, FlowyError> {
trace!(
"[Chat] stream chat message: chat_id={}, message={}, message_type={:?}, format={:?}",
self.chat_id,
params.message,
params.message_type,
params.format,
self.chat_id, params.message, params.message_type, params.format,
);
// clear
@ -329,9 +326,7 @@ impl Chat {
) -> Result<ChatMessageListPB, FlowyError> {
trace!(
"[Chat] Loading messages from disk: chat_id={}, limit={}, before_message_id={:?}",
self.chat_id,
limit,
before_message_id
self.chat_id, limit, before_message_id
);
let offset = before_message_id.map_or(MessageCursor::NextBack, MessageCursor::BeforeMessageId);
@ -377,9 +372,7 @@ impl Chat {
) -> Result<ChatMessageListPB, FlowyError> {
trace!(
"[Chat] Loading new messages: chat_id={}, limit={}, after_message_id={:?}",
self.chat_id,
limit,
after_message_id,
self.chat_id, limit, after_message_id,
);
let offset = after_message_id.map_or(MessageCursor::NextBack, MessageCursor::AfterMessageId);
let messages = self.load_local_chat_messages(limit, offset).await?;
@ -410,10 +403,7 @@ impl Chat {
) -> FlowyResult<()> {
trace!(
"[Chat] start loading messages from remote: chat_id={}, limit={}, before_message_id={:?}, after_message_id={:?}",
self.chat_id,
limit,
before_message_id,
after_message_id
self.chat_id, limit, before_message_id, after_message_id
);
let workspace_id = self.user_service.workspace_id()?;
let chat_id = self.chat_id;
@ -520,9 +510,7 @@ impl Chat {
trace!(
"[Chat] related messages: chat_id={}, message_id={}, messages:{:?}",
self.chat_id,
message_id,
resp.items
self.chat_id, message_id, resp.items
);
Ok(RepeatedRelatedQuestionPB::from(resp))
}
@ -531,8 +519,7 @@ impl Chat {
pub async fn generate_answer(&self, question_message_id: i64) -> FlowyResult<ChatMessagePB> {
trace!(
"[Chat] generate answer: chat_id={}, question_message_id={}",
self.chat_id,
question_message_id
self.chat_id, question_message_id
);
let workspace_id = self.user_service.workspace_id()?;
let answer = self
@ -552,9 +539,7 @@ impl Chat {
) -> Result<Vec<ChatMessagePB>, FlowyError> {
trace!(
"[Chat] Loading messages from disk: chat_id={}, limit={}, offset={:?}",
self.chat_id,
limit,
offset
self.chat_id, limit, offset
);
let conn = self.user_service.sqlite_connection(self.uid)?;
let rows = select_chat_messages(conn, &self.chat_id.to_string(), limit, offset)?.messages;
@ -590,8 +575,7 @@ impl Chat {
trace!(
"[Chat] index file: chat_id={}, file_path={:?}",
self.chat_id,
file_path
self.chat_id, file_path
);
self
.chat_service
@ -605,8 +589,7 @@ impl Chat {
trace!(
"[Chat] created index file record: chat_id={}, file_path={:?}",
self.chat_id,
file_path
self.chat_id, file_path
);
Ok(())

View File

@ -1,8 +1,8 @@
use crate::embeddings::indexer::EmbeddingModel;
use flowy_error::FlowyResult;
use ollama_rs::generation::embeddings::request::GenerateEmbeddingsRequest;
use ollama_rs::generation::embeddings::GenerateEmbeddingsResponse;
use ollama_rs::Ollama;
use ollama_rs::generation::embeddings::GenerateEmbeddingsResponse;
use ollama_rs::generation::embeddings::request::GenerateEmbeddingsRequest;
use std::sync::Arc;
#[derive(Debug, Clone)]

View File

@ -1,6 +1,6 @@
use crate::embeddings::embedder::{Embedder, OllamaEmbedder};
use crate::embeddings::indexer::IndexerProvider;
use crate::search::summary::{summarize_documents, LLMDocument};
use crate::search::summary::{LLMDocument, summarize_documents};
use flowy_ai_pub::cloud::search_dto::{
SearchContentType, SearchDocumentResponseItem, SearchResult, SearchSummaryResult, Summary,
};
@ -8,11 +8,11 @@ use flowy_ai_pub::entities::{EmbeddingRecord, UnindexedCollab, UnindexedData};
use flowy_error::{ErrorCode, FlowyError, FlowyResult};
use flowy_sqlite::internal::derives::multiconnection::chrono::Utc;
use flowy_sqlite_vec::db::VectorSqliteDB;
use ollama_rs::generation::embeddings::request::{EmbeddingsInput, GenerateEmbeddingsRequest};
use ollama_rs::Ollama;
use ollama_rs::generation::embeddings::request::{EmbeddingsInput, GenerateEmbeddingsRequest};
use std::sync::{Arc, Weak};
use tokio::select;
use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender};
use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender, unbounded_channel};
use tokio::sync::{broadcast, mpsc};
use tracing::{debug, error, info, trace, warn};
use uuid::Uuid;

View File

@ -3,7 +3,7 @@ use crate::completion::AICompletion;
use crate::entities::*;
use flowy_ai_pub::cloud::{AIModel, ChatMessageType};
use flowy_error::{ErrorCode, FlowyError, FlowyResult};
use lib_dispatch::prelude::{data_result_ok, AFPluginData, AFPluginState, DataResult};
use lib_dispatch::prelude::{AFPluginData, AFPluginState, DataResult, data_result_ok};
use std::fs;
use std::path::PathBuf;
use std::str::FromStr;

View File

@ -1,5 +1,5 @@
use crate::local_ai::chat::llm::LLMOllama;
use crate::SqliteVectorStore;
use crate::local_ai::chat::llm::LLMOllama;
use flowy_error::{FlowyError, FlowyResult};
use flowy_sqlite_vec::entities::EmbeddedContent;
use langchain_rust::language_models::llm::LLM;

View File

@ -1,10 +1,10 @@
use crate::SqliteVectorStore;
use crate::local_ai::chat::chains::context_question_chain::{
embedded_documents_to_context_str, ContextRelatedQuestionChain,
ContextRelatedQuestionChain, embedded_documents_to_context_str,
};
use crate::local_ai::chat::chains::related_question_chain::RelatedQuestionChain;
use crate::local_ai::chat::llm::LLMOllama;
use crate::local_ai::chat::retriever::AFRetriever;
use crate::SqliteVectorStore;
use arc_swap::ArcSwap;
use async_stream::stream;
use async_trait::async_trait;
@ -13,7 +13,7 @@ use flowy_ai_pub::entities::SOURCE_ID;
use flowy_error::{FlowyError, FlowyResult};
use flowy_sqlite_vec::entities::EmbeddedContent;
use futures::Stream;
use futures_util::{pin_mut, StreamExt};
use futures_util::{StreamExt, pin_mut};
use langchain_rust::chain::{
Chain, ChainError, CondenseQuestionGeneratorChain, CondenseQuestionPromptBuilder,
StuffDocumentBuilder, StuffQAPromptBuilder,
@ -23,7 +23,7 @@ use langchain_rust::memory::SimpleMemory;
use langchain_rust::prompt::{FormatPrompter, PromptArgs};
use langchain_rust::schemas::{BaseMemory, Document, Message, StreamData};
use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
use serde_json::{Value, json};
use std::{collections::HashMap, pin::Pin, sync::Arc};
use tokio::sync::Mutex;
use tokio_util::either::Either;

View File

@ -8,10 +8,10 @@ use std::pin::Pin;
use std::sync::Arc;
use tokio_stream::StreamExt;
use ollama_rs::Ollama;
use ollama_rs::generation::chat::request::ChatMessageRequest;
use ollama_rs::generation::parameters::FormatType;
use ollama_rs::models::ModelOptions;
use ollama_rs::Ollama;
#[derive(Debug, Clone)]
pub struct LLMOllama {

View File

@ -1,3 +1,5 @@
use crate::SqliteVectorStore;
use crate::local_ai::chat::LLMChatInfo;
use crate::local_ai::chat::chains::conversation_chain::{
ConversationalRetrieverChain, ConversationalRetrieverChainBuilder,
};
@ -7,8 +9,6 @@ use crate::local_ai::chat::retriever::multi_source_retriever::MultipleSourceRetr
use crate::local_ai::chat::retriever::sqlite_retriever::RetrieverOption;
use crate::local_ai::chat::retriever::{AFRetriever, MultipleSourceRetrieverStore};
use crate::local_ai::chat::summary_memory::SummaryMemory;
use crate::local_ai::chat::LLMChatInfo;
use crate::SqliteVectorStore;
use flowy_ai_pub::cloud::{QuestionStreamValue, ResponseFormat, StreamAnswer};
use flowy_ai_pub::entities::{RAG_IDS, SOURCE_ID, WORKSPACE_ID};
use flowy_ai_pub::user_service::AIUserService;
@ -199,8 +199,7 @@ fn create_retriever(
) -> Box<dyn AFRetriever> {
trace!(
"[VectorStore]: {} create retriever with rag_ids: {:?}",
workspace_id,
rag_ids,
workspace_id, rag_ids,
);
let mut stores: Vec<Arc<dyn MultipleSourceRetrieverStore>> = vec![];

View File

@ -5,13 +5,13 @@ pub mod llm_chat;
pub mod retriever;
mod summary_memory;
use crate::SqliteVectorStore;
use crate::local_ai::chat::llm::LLMOllama;
use crate::local_ai::chat::llm_chat::LLMChat;
use crate::local_ai::chat::retriever::MultipleSourceRetrieverStore;
use crate::local_ai::completion::chain::CompletionChain;
use crate::local_ai::database::summary::DatabaseSummaryChain;
use crate::local_ai::database::translate::DatabaseTranslateChain;
use crate::SqliteVectorStore;
use dashmap::{DashMap, Entry};
use flowy_ai_pub::cloud::ai_dto::{TranslateRowData, TranslateRowResponse};
use flowy_ai_pub::cloud::chat_dto::ChatAuthorType;

View File

@ -13,7 +13,7 @@ pub trait AFRetriever: Send + Sync + 'static {
fn set_rag_ids(&mut self, new_rag_ids: Vec<String>);
async fn retrieve_documents(&self, query: &str)
-> Result<Vec<LangchainDocument>, Box<dyn Error>>;
-> Result<Vec<LangchainDocument>, Box<dyn Error>>;
}
#[async_trait]

View File

@ -63,8 +63,7 @@ impl AFRetriever for MultipleSourceRetriever {
async fn retrieve_documents(&self, query: &str) -> Result<Vec<Document>, Box<dyn Error>> {
trace!(
"[VectorStore] filters: {:?}, retrieving documents for query: {}",
self.rag_ids,
query,
self.rag_ids, query,
);
// Create futures for each vector store search

View File

@ -3,7 +3,7 @@ use async_trait::async_trait;
use flowy_ai_pub::entities::RAG_IDS;
use langchain_rust::schemas::{Document, Retriever};
use langchain_rust::vectorstore::{VecStoreOptions, VectorStore};
use serde_json::{json, Value};
use serde_json::{Value, json};
use std::error::Error;
use tracing::trace;
@ -48,8 +48,7 @@ impl AFRetriever for SqliteVecRetriever {
async fn retrieve_documents(&self, query: &str) -> Result<Vec<Document>, Box<dyn Error>> {
trace!(
"[VectorStore] filters: {:?}, retrieving documents for query: {}",
self.options.filters,
query,
self.options.filters, query,
);
match self.vector_store.as_ref() {

View File

@ -1,8 +1,8 @@
use flowy_ai_pub::cloud::{CompletionStreamValue, CompletionType};
use futures_util::{stream, stream::BoxStream, Stream, StreamExt};
use futures_util::{Stream, StreamExt, stream, stream::BoxStream};
use langchain_rust::language_models::LLMError;
use langchain_rust::schemas::StreamData;
use serde_json::{json, Value};
use serde_json::{Value, json};
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use tracing::{debug, warn};

View File

@ -1,7 +1,7 @@
use crate::entities::LocalAIPB;
use crate::local_ai::resource::{LLMResourceService, LocalAIResourceController};
use crate::notification::{
chat_notification_builder, ChatNotification, APPFLOWY_AI_NOTIFICATION_KEY,
APPFLOWY_AI_NOTIFICATION_KEY, ChatNotification, chat_notification_builder,
};
use anyhow::Error;
use flowy_error::{FlowyError, FlowyResult};
@ -15,13 +15,13 @@ use crate::stream_message::StreamMessage;
use arc_swap::ArcSwapOption;
use flowy_ai_pub::cloud::AIModel;
use flowy_ai_pub::persistence::{
select_local_ai_model, upsert_local_ai_model, LocalAIModelTable, ModelType,
LocalAIModelTable, ModelType, select_local_ai_model, upsert_local_ai_model,
};
use flowy_ai_pub::user_service::AIUserService;
use futures_util::SinkExt;
use lib_infra::util::get_operating_system;
use ollama_rs::generation::embeddings::request::{EmbeddingsInput, GenerateEmbeddingsRequest};
use ollama_rs::Ollama;
use ollama_rs::generation::embeddings::request::{EmbeddingsInput, GenerateEmbeddingsRequest};
use serde::{Deserialize, Serialize};
use std::ops::Deref;
use std::path::PathBuf;

View File

@ -1,6 +1,6 @@
use anyhow::{anyhow, Result};
use base64::engine::general_purpose::STANDARD;
use anyhow::{Result, anyhow};
use base64::Engine;
use base64::engine::general_purpose::STANDARD;
use reqwest::{Client, Response, StatusCode};
use sha2::{Digest, Sha256};
use std::path::{Path, PathBuf};
@ -79,8 +79,7 @@ pub async fn download_model(
if calculated_sha256.as_slice() != header_sha256.as_slice() {
trace!(
"Header Sha256: {:?}, calculated Sha256:{:?}",
header_sha256,
calculated_sha256
header_sha256, calculated_sha256
);
fs::remove_file(&partial_path).await?;

View File

@ -4,7 +4,7 @@ use lib_infra::async_trait::async_trait;
use crate::entities::LackOfAIResourcePB;
use crate::notification::{
chat_notification_builder, ChatNotification, APPFLOWY_AI_NOTIFICATION_KEY,
APPFLOWY_AI_NOTIFICATION_KEY, ChatNotification, chat_notification_builder,
};
use flowy_ai_pub::user_service::AIUserService;
use lib_infra::util::get_operating_system;

View File

@ -364,7 +364,7 @@ impl ModelSource for ServerAiSource {
let now = timestamp();
let should_fetch = {
let cached = self.cached_models.read().await;
cached.models.is_empty() || cached.timestamp.map_or(true, |ts| now - ts >= 300)
cached.models.is_empty() || cached.timestamp.is_none_or(|ts| now - ts >= 300)
};
if !should_fetch {
return self.cached_models.read().await.models.clone();

View File

@ -4,8 +4,8 @@ use flowy_ai_pub::cloud::{
StreamAnswer, StreamComplete, UpdateChatParams,
};
use flowy_ai_pub::persistence::{
update_chat_is_sync, update_chat_message_is_sync, upsert_chat, upsert_chat_messages,
ChatMessageTable, ChatTable,
ChatMessageTable, ChatTable, update_chat_is_sync, update_chat_message_is_sync, upsert_chat,
upsert_chat_messages,
};
use flowy_ai_pub::user_service::AIUserService;
use flowy_error::FlowyError;

View File

@ -1,8 +1,8 @@
use flowy_error::FlowyError;
use ollama_rs::Ollama;
use ollama_rs::generation::chat::request::ChatMessageRequest;
use ollama_rs::generation::chat::{ChatMessage, MessageRole};
use ollama_rs::generation::parameters::{FormatType, JsonStructure};
use ollama_rs::Ollama;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_json::json;
@ -103,7 +103,7 @@ pub async fn summarize_documents(
#[cfg(test)]
mod tests {
use crate::search::summary::{summarize_documents, LLMDocument};
use crate::search::summary::{LLMDocument, summarize_documents};
use ollama_rs::Ollama;
#[tokio::test]

View File

@ -1,4 +1,4 @@
use crate::{collect_stream, load_asset_content, setup_log, TestContext};
use crate::{TestContext, collect_stream, load_asset_content, setup_log};
use flowy_ai::local_ai::chat::chains::conversation_chain::{
ANSWER_WITH_SUGGESTED_QUESTION, CAN_NOT_ANSWER_WITH_CONTEXT,
};
@ -53,12 +53,26 @@ async fn local_ollama_test_chat_with_multiple_docs_retrieve() {
let mut chat = context.create_chat(vec![]).await;
let mut ids = vec![];
for (doc, id) in [("Rust is a multiplayer survival game developed by Facepunch Studios, first released in early access in December 2013 and fully launched in February 2018. It has since become one of the most popular games in the survival genre, known for its harsh environment, intricate crafting system, and player-driven dynamics. The game is available on Windows, macOS, and PlayStation, with a community-driven approach to updates and content additions.", uuid::Uuid::new_v4()),
("Rust is a modern, system-level programming language designed with a focus on performance, safety, and concurrency. It was created by Mozilla and first released in 2010, with its 1.0 version launched in 2015. Rust is known for providing the control and performance of languages like C and C++, but with built-in safety features that prevent common programming errors, such as memory leaks, data races, and buffer overflows.", uuid::Uuid::new_v4()),
("Rust as a Natural Process (Oxidation) refers to the chemical reaction that occurs when metals, primarily iron, come into contact with oxygen and moisture (water) over time, leading to the formation of iron oxide, commonly known as rust. This process is a form of oxidation, where a substance reacts with oxygen in the air or water, resulting in the degradation of the metal.", uuid::Uuid::new_v4())] {
ids.push(id.to_string());
chat.embed_paragraphs(&id.to_string(), vec![doc.to_string()]).await.unwrap();
}
for (doc, id) in [
(
"Rust is a multiplayer survival game developed by Facepunch Studios, first released in early access in December 2013 and fully launched in February 2018. It has since become one of the most popular games in the survival genre, known for its harsh environment, intricate crafting system, and player-driven dynamics. The game is available on Windows, macOS, and PlayStation, with a community-driven approach to updates and content additions.",
uuid::Uuid::new_v4(),
),
(
"Rust is a modern, system-level programming language designed with a focus on performance, safety, and concurrency. It was created by Mozilla and first released in 2010, with its 1.0 version launched in 2015. Rust is known for providing the control and performance of languages like C and C++, but with built-in safety features that prevent common programming errors, such as memory leaks, data races, and buffer overflows.",
uuid::Uuid::new_v4(),
),
(
"Rust as a Natural Process (Oxidation) refers to the chemical reaction that occurs when metals, primarily iron, come into contact with oxygen and moisture (water) over time, leading to the formation of iron oxide, commonly known as rust. This process is a form of oxidation, where a substance reacts with oxygen in the air or water, resulting in the degradation of the metal.",
uuid::Uuid::new_v4(),
),
] {
ids.push(id.to_string());
chat
.embed_paragraphs(&id.to_string(), vec![doc.to_string()])
.await
.unwrap();
}
chat.set_rag_ids(ids.clone());
let all_docs = chat.get_all_embedded_documents().await.unwrap();
@ -95,11 +109,13 @@ async fn local_ollama_test_chat_with_multiple_docs_retrieve() {
assert!(!result.sources.is_empty());
assert!(result.sources[0].get(SOURCE_ID).unwrap().as_str().is_some());
assert!(result.sources[0].get(SOURCE).unwrap().as_str().is_some());
assert!(result.sources[0]
.get(SOURCE_NAME)
.unwrap()
.as_str()
.is_some());
assert!(
result.sources[0]
.get(SOURCE_NAME)
.unwrap()
.as_str()
.is_some()
);
let stream = chat
.stream_question("Japan ski resort", Default::default())

View File

@ -1,4 +1,4 @@
use crate::{collect_stream, load_asset_content, TestContext};
use crate::{TestContext, collect_stream, load_asset_content};
use uuid::Uuid;
#[tokio::test]

View File

@ -4,7 +4,7 @@ use flowy_ai::local_ai::completion::chain::CompletionChain;
use flowy_ai::local_ai::completion::stream_interpreter::stream_interpreter_for_completion;
use flowy_ai_pub::cloud::{CompletionStreamValue, CompletionType, OutputLayout, ResponseFormat};
use flowy_error::FlowyError;
use futures_util::{stream, stream::BoxStream, StreamExt};
use futures_util::{StreamExt, stream, stream::BoxStream};
use langchain_rust::language_models::LLMError;
use langchain_rust::schemas::StreamData;
use serde_json::json;
@ -487,7 +487,10 @@ async fn test_tiny_chunks_with_mixed_tag_formats() {
let (answer, comment) = collect_completion_results(result_stream).await;
assert_eq!(answer, "He starts work every day at **8:00 a.m.**");
assert_eq!(comment, "* \"everyday\" should be changed to \"every day\" as it is an adverb and should not be written with the suffix \"-day\".\n* Added colon after the time for correct formatting.\n* Added zeros for clarity in time notation.");
assert_eq!(
comment,
"* \"everyday\" should be changed to \"every day\" as it is an adverb and should not be written with the suffix \"-day\".\n* Added colon after the time for correct formatting.\n* Added zeros for clarity in time notation."
);
}
#[tokio::test]
@ -619,7 +622,10 @@ async fn test_format_tags_with_grammar_correction() {
// Assert the expected output - updated to match actual behavior
assert_eq!(answer, "He starts work every day at 8 a.m.");
assert_eq!(comment, "* The word \"everyday\" is being replaced with **`every day`**, as the first part should be hyphenated for clarity. However, in this case, it's more idiomatic to use **`every day`** without a space.\n* In British English, it's common to write out the time (e.g., \"eight o'clock\" or \"8 a.m.\"). Since the text already uses \"8 a.m.\", no correction is needed here.");
assert_eq!(
comment,
"* The word \"everyday\" is being replaced with **`every day`**, as the first part should be hyphenated for clarity. However, in this case, it's more idiomatic to use **`every day`** without a space.\n* In British English, it's common to write out the time (e.g., \"eight o'clock\" or \"8 a.m.\"). Since the text already uses \"8 a.m.\", no correction is needed here."
);
}
#[tokio::test]
@ -716,7 +722,10 @@ async fn test_everyday_correction_stream() {
let (answer, comment) = collect_completion_results(result_stream).await;
assert_eq!(answer, "He starts work every day at 8 a.m.");
assert_eq!(comment, "The error was in \"everyday\". In English, \"everyday\" is an adjective that means happening or done regularly. The correct word to use here is \"every day\", which is a noun phrase indicating a specific time period. I added a space between the two words for clarity and correctness.");
assert_eq!(
comment,
"The error was in \"everyday\". In English, \"everyday\" is an adjective that means happening or done regularly. The correct word to use here is \"every day\", which is a noun phrase indicating a specific time period. I added a space between the two words for clarity and correctness."
);
}
#[tokio::test]
@ -811,5 +820,8 @@ async fn test_basketball_improvement_stream() {
let (answer, comment) = collect_completion_results(result_stream).await;
assert_eq!(answer, "We enjoy playing basketball together as friends.");
assert_eq!(comment, "* Changed \"like\" to \"enjoy\", which is a more specific and engaging verb that conveys a stronger enthusiasm for the activity.\n* Modified the sentence structure to make it more concise and natural-sounding, using a more active voice (\"We enjoy...\") instead of a passive one (\"I like...\").");
assert_eq!(
comment,
"* Changed \"like\" to \"enjoy\", which is a more specific and engaging verb that conveys a stronger enthusiasm for the activity.\n* Modified the sentence structure to make it more concise and natural-sounding, using a more active voice (\"We enjoy...\") instead of a passive one (\"I like...\")."
);
}

View File

@ -3,9 +3,9 @@ mod complete_test;
mod summary_test;
mod translate_test;
use flowy_ai::local_ai::chat::llm_chat::LLMChat;
use flowy_ai::local_ai::chat::LLMChatInfo;
use flowy_ai::SqliteVectorStore;
use flowy_ai::local_ai::chat::LLMChatInfo;
use flowy_ai::local_ai::chat::llm_chat::LLMChat;
use flowy_ai_pub::cloud::{ContextSuggestedQuestion, QuestionStreamValue, StreamAnswer};
use flowy_sqlite_vec::db::VectorSqliteDB;
use langchain_rust::url::Url;
@ -14,9 +14,9 @@ use serde_json::Value;
use std::sync::{Arc, Once};
use tempfile::tempdir;
use tokio_stream::StreamExt;
use tracing_subscriber::EnvFilter;
use tracing_subscriber::fmt::Subscriber;
use tracing_subscriber::util::SubscriberInitExt;
use tracing_subscriber::EnvFilter;
use uuid::Uuid;
pub fn setup_log() {
@ -25,7 +25,9 @@ pub fn setup_log() {
let level = std::env::var("RUST_LOG").unwrap_or("trace".to_string());
let mut filters = vec![];
filters.push(format!("flowy_ai={}", level));
std::env::set_var("RUST_LOG", filters.join(","));
unsafe {
std::env::set_var("RUST_LOG", filters.join(","));
}
let subscriber = Subscriber::builder()
.with_ansi(true)

View File

@ -1,7 +1,7 @@
[package]
name = "flowy-database-pub"
version = "0.1.0"
edition = "2021"
edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -1,7 +1,7 @@
[package]
name = "flowy-database2"
version = "0.1.0"
edition = "2021"
edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,7 +2,7 @@ fn main() {
#[cfg(feature = "dart")]
{
flowy_codegen::protobuf_file::dart_gen(env!("CARGO_PKG_NAME"));
flowy_codegen::dart_event::gen(env!("CARGO_PKG_NAME"));
flowy_codegen::dart_event::r#gen(env!("CARGO_PKG_NAME"));
}
// #[cfg(feature = "ts")]

View File

@ -1,8 +1,8 @@
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
use flowy_error::ErrorCode;
use crate::entities::parser::NotEmptyStr;
use crate::entities::RowMetaPB;
use crate::entities::parser::NotEmptyStr;
use crate::services::setting::{CalendarLayout, CalendarLayoutSetting};
use super::CellIdPB;

View File

@ -5,8 +5,8 @@ use flowy_error::ErrorCode;
use lib_infra::validator_fn::required_not_empty_str;
use validator::Validate;
use crate::entities::parser::NotEmptyStr;
use crate::entities::FieldType;
use crate::entities::parser::NotEmptyStr;
#[derive(ProtoBuf, Default)]
pub struct CreateSelectOptionPayloadPB {

View File

@ -4,8 +4,8 @@ use lib_infra::validator_fn::required_not_empty_str;
use std::ops::Deref;
use validator::Validate;
use crate::entities::parser::NotEmptyStr;
use crate::entities::RepeatedFieldIdPB;
use crate::entities::parser::NotEmptyStr;
use crate::impl_into_field_visibility;
use crate::services::field_settings::FieldSettings;

View File

@ -6,14 +6,14 @@ use tokio::sync::oneshot;
use tracing::{info, instrument};
use flowy_error::{FlowyError, FlowyResult};
use lib_dispatch::prelude::{data_result_ok, AFPluginData, AFPluginState, DataResult};
use lib_dispatch::prelude::{AFPluginData, AFPluginState, DataResult, data_result_ok};
use crate::entities::*;
use crate::manager::DatabaseManager;
use crate::services::field::checklist_filter::ChecklistCellChangeset;
use crate::services::field::date_filter::DateCellChangeset;
use crate::services::field::{
type_option_data_from_pb, RelationCellChangeset, SelectOptionCellChangeset, TypeOptionCellExt,
RelationCellChangeset, SelectOptionCellChangeset, TypeOptionCellExt, type_option_data_from_pb,
};
use crate::services::group::GroupChangeset;
use crate::services::share::csv::CSVFormat;

View File

@ -31,7 +31,7 @@ use collab_integrate::{CollabKVAction, CollabKVDB};
use flowy_database_pub::cloud::{
DatabaseAIService, DatabaseCloudService, SummaryRowContent, TranslateItem, TranslateRowContent,
};
use flowy_error::{internal_error, FlowyError, FlowyResult};
use flowy_error::{FlowyError, FlowyResult, internal_error};
use lib_infra::box_any::BoxAny;
use lib_infra::priority_task::TaskDispatcher;
@ -614,8 +614,7 @@ impl DatabaseManager {
// Call the cloud service to summarize the row.
trace!(
"[AI]:summarize row:{}, content:{:?}",
row_id,
summary_row_content
row_id, summary_row_content
);
let response = self
.ai_service
@ -680,8 +679,7 @@ impl DatabaseManager {
// Call the cloud service to summarize the row.
trace!(
"[AI]:translate to {}, content:{:?}",
language,
translate_row_content
language, translate_row_content
);
let response = self
.ai_service
@ -841,8 +839,7 @@ impl DatabaseCollabService for WorkspaceDatabaseCollabServiceImpl {
{
trace!(
"build collab: {}:{} from local encode collab",
collab_type,
object_id
collab_type, object_id
);
CollabPersistenceImpl {
persistence: Some(self.persistence.clone()),
@ -1031,8 +1028,7 @@ impl DatabaseCollabPersistenceService for DatabasePersistenceImpl {
Ok(update_count) => {
trace!(
"[Database]: did load collab:{}, update_count:{}",
object_id,
update_count
object_id, update_count
);
},
Err(err) => {
@ -1175,8 +1171,7 @@ async fn open_database_with_retry(
for attempt in 1..=max_retries {
trace!(
"[Database]: attempt {} to open database:{}",
attempt,
database_id
attempt, database_id
);
let result = workspace_database_manager

View File

@ -1,5 +1,5 @@
use collab::preclude::encoding::serde::from_any;
use collab::preclude::Any;
use collab::preclude::encoding::serde::from_any;
use collab_database::views::{CalculationMap, CalculationMapBuilder};
use serde::Deserialize;

View File

@ -1,10 +1,10 @@
use std::collections::HashMap;
use std::str::FromStr;
use collab_database::fields::Field;
use collab_database::fields::media_type_option::MediaCellData;
use collab_database::fields::select_type_option::SelectOptionIds;
use collab_database::fields::Field;
use collab_database::rows::{get_field_type_from_cell, Cell, Cells};
use collab_database::rows::{Cell, Cells, get_field_type_from_cell};
use collab_database::template::relation_parse::RelationCellData;
use flowy_error::{FlowyError, FlowyResult};
use lib_infra::box_any::BoxAny;
@ -243,7 +243,9 @@ impl<'a> CellBuilder<'a> {
}
},
FieldType::LastEditedTime | FieldType::CreatedTime => {
tracing::warn!("Shouldn't insert cell data to cell whose field type is LastEditedTime or CreatedTime");
tracing::warn!(
"Shouldn't insert cell data to cell whose field type is LastEditedTime or CreatedTime"
);
},
FieldType::SingleSelect | FieldType::MultiSelect => {
if let Ok(ids) = SelectOptionIds::from_str(&cell_str) {

View File

@ -1,7 +1,7 @@
use bytes::Bytes;
use std::fmt::Display;
use flowy_error::{internal_error, FlowyResult};
use flowy_error::{FlowyResult, internal_error};
/// The data is encoded by protobuf or utf8. You should choose the corresponding decode struct to parse it.
///

View File

@ -1,7 +1,8 @@
use crate::DatabaseUser;
use crate::entities::*;
use crate::notification::{database_notification_builder, DatabaseNotification};
use crate::notification::{DatabaseNotification, database_notification_builder};
use crate::services::calculations::Calculation;
use crate::services::cell::{apply_cell_changeset, get_cell_protobuf, stringify_cell, CellCache};
use crate::services::cell::{CellCache, apply_cell_changeset, get_cell_protobuf, stringify_cell};
use crate::services::database::database_observe::*;
use crate::services::database::util::database_view_setting_pb_from_view;
use crate::services::database_view::{
@ -10,16 +11,15 @@ use crate::services::database_view::{
use crate::services::field::checklist_filter::ChecklistCellChangeset;
use crate::services::field::type_option_transform::transform_type_option;
use crate::services::field::{
default_type_option_data_from_type, select_type_option_from_field, type_option_data_from_pb,
SelectOptionCellChangeset, StringCellData, TypeOptionCellDataHandler, TypeOptionCellExt,
default_type_option_data_from_type, select_type_option_from_field, type_option_data_from_pb,
};
use crate::services::field_settings::{default_field_settings_by_layout_map, FieldSettings};
use crate::services::field_settings::{FieldSettings, default_field_settings_by_layout_map};
use crate::services::filter::{Filter, FilterChangeset};
use crate::services::group::{default_group_setting, GroupChangeset, GroupSetting};
use crate::services::group::{GroupChangeset, GroupSetting, default_group_setting};
use crate::services::share::csv::{CSVExport, CSVFormat};
use crate::services::sort::Sort;
use crate::utils::cache::AnyTypeCache;
use crate::DatabaseUser;
use arc_swap::ArcSwapOption;
use async_trait::async_trait;
use collab::core::collab_plugin::CollabPluginType;
@ -36,10 +36,10 @@ use collab_database::views::{
};
use collab_entity::CollabType;
use collab_integrate::collab_builder::{AppFlowyCollabBuilder, CollabBuilderConfig};
use flowy_error::{internal_error, ErrorCode, FlowyError, FlowyResult};
use flowy_error::{ErrorCode, FlowyError, FlowyResult, internal_error};
use flowy_notification::DebounceNotificationSender;
use futures::future::join_all;
use futures::{pin_mut, StreamExt};
use futures::{StreamExt, pin_mut};
use lib_infra::box_any::BoxAny;
use lib_infra::priority_task::TaskDispatcher;
use lib_infra::util::timestamp;
@ -48,8 +48,8 @@ use std::str::FromStr;
use std::sync::{Arc, Weak};
use std::time::Duration;
use tokio::select;
use tokio::sync::oneshot::Sender;
use tokio::sync::RwLock as TokioRwLock;
use tokio::sync::oneshot::Sender;
use tokio::sync::{broadcast, oneshot};
use tokio::task::yield_now;
use tokio_util::sync::CancellationToken;
@ -603,9 +603,7 @@ impl DatabaseEditor {
trace!(
"duplicate row: {:?} at index:{}, new row:{:?}",
row_id,
index,
row_order
row_id, index, row_order
);
Ok(())
@ -641,9 +639,7 @@ impl DatabaseEditor {
})?;
trace!(
"Move row:{} from group:{} to group:{}",
from_row,
from_group,
to_group
from_row, from_group, to_group
);
// when moving row between groups, the cells of the row should be updated

View File

@ -1,6 +1,6 @@
use crate::entities::{DatabaseSyncStatePB, DidFetchRowPB, RowsChangePB};
use crate::notification::{
database_notification_builder, DatabaseNotification, DATABASE_OBSERVABLE_SOURCE,
DATABASE_OBSERVABLE_SOURCE, DatabaseNotification, database_notification_builder,
};
use crate::services::database::{DatabaseEditor, UpdatedRow};
use crate::services::database_view::DatabaseViewEditor;
@ -52,8 +52,7 @@ pub(crate) async fn observe_rows_change(
while let Ok(row_change) = row_change.recv().await {
trace!(
"[Database Observe]: {} row change:{:?}",
database_id,
row_change
database_id, row_change
);
if let Some(database) = weak_database.upgrade() {
match row_change {
@ -99,8 +98,7 @@ pub(crate) async fn observe_field_change(database_id: &str, database: &Arc<RwLoc
trace!(
"[Database Observe]: {} field change:{:?}",
database_id,
field_change
database_id, field_change
);
match field_change {
FieldChange::DidUpdateField { .. } => {},
@ -127,8 +125,7 @@ pub(crate) async fn observe_view_change(database_id: &Uuid, database_editor: &Ar
while let Ok(view_change) = view_change.recv().await {
trace!(
"[Database View Observe]: {} view change:{:?}",
database_id,
view_change
database_id, view_change
);
match weak_database_editor.upgrade() {
None => break,
@ -216,9 +213,7 @@ async fn handle_did_update_row_orders(
{
trace!(
"[RowOrder]: insert row:{} at index:{}, is_local:{}",
row_order.id,
index,
is_local_change
row_order.id, index, is_local_change
);
// insert row order in database view cache
@ -259,10 +254,7 @@ async fn handle_did_update_row_orders(
if let Some(row) = view_editor.row_by_row_id.get(lazy_row.id.as_str()) {
trace!(
"[RowOrder]: delete row:{} at index:{}, is_move_row: {}, is_local:{}",
row.id,
index,
row_change.is_move_row,
is_local_change
row.id, index, row_change.is_move_row, is_local_change
);
view_editor
.v_did_delete_row(&row, row_change.is_move_row, is_local_change)
@ -306,8 +298,7 @@ pub(crate) async fn observe_block_event(database_id: &Uuid, database_editor: &Ar
trace!(
"[Database Observe]: {} block event: {:?}",
database_id,
event
database_id, event
);
match event {
BlockEvent::DidFetchRow(row_details) => {

View File

@ -2,10 +2,10 @@ use crate::entities::FieldType;
use crate::services::field_settings::default_field_settings_by_layout_map;
use crate::services::setting::{BoardLayoutSetting, CalendarLayoutSetting};
use collab::lock::RwLock;
use collab_database::database::{gen_field_id, Database};
use collab_database::database::{Database, gen_field_id};
use collab_database::fields::Field;
use collab_database::fields::date_type_option::DateTypeOption;
use collab_database::fields::select_type_option::SingleSelectTypeOption;
use collab_database::fields::Field;
use collab_database::views::{
DatabaseLayout, FieldSettingsByFieldIdMap, LayoutSetting, OrderObjectPosition,
};

View File

@ -4,7 +4,7 @@ use crate::entities::{
GroupChangesPB, GroupRowsNotificationPB, ReorderAllRowsPB, ReorderSingleRowPB,
RowsVisibilityChangePB, SortChangesetNotificationPB,
};
use crate::notification::{database_notification_builder, DatabaseNotification};
use crate::notification::{DatabaseNotification, database_notification_builder};
use crate::services::filter::FilterResultNotification;
use crate::services::sort::{ReorderAllRowsResult, ReorderSingleRowResult};
use async_stream::stream;

View File

@ -9,7 +9,7 @@ use crate::services::calculations::{
};
use crate::services::database_view::{
gen_handler_id, DatabaseViewChangedNotifier, DatabaseViewOperation,
DatabaseViewChangedNotifier, DatabaseViewOperation, gen_handler_id,
};
pub async fn make_calculations_controller(

View File

@ -2,7 +2,7 @@ use std::borrow::Cow;
use std::collections::HashMap;
use std::sync::Arc;
use super::{notify_did_update_calculation, DatabaseViewChanged};
use super::{DatabaseViewChanged, notify_did_update_calculation};
use crate::entities::{
CalculationChangesetNotificationPB, CalendarEventPB, CreateRowPayloadPB, DatabaseLayoutMetaPB,
DatabaseLayoutSettingPB, DeleteSortPayloadPB, FieldSettingsChangesetPB, FieldType,
@ -10,19 +10,19 @@ use crate::entities::{
RemoveCalculationChangesetPB, ReorderSortPayloadPB, RowMetaPB, RowsChangePB,
SortChangesetNotificationPB, SortPB, UpdateCalculationChangesetPB, UpdateSortPayloadPB,
};
use crate::notification::{database_notification_builder, DatabaseNotification};
use crate::notification::{DatabaseNotification, database_notification_builder};
use crate::services::calculations::{Calculation, CalculationChangeset, CalculationsController};
use crate::services::cell::{CellBuilder, CellCache};
use crate::services::database::{database_view_setting_pb_from_view, DatabaseRowEvent, UpdatedRow};
use crate::services::database::{DatabaseRowEvent, UpdatedRow, database_view_setting_pb_from_view};
use crate::services::database_view::view_calculations::make_calculations_controller;
use crate::services::database_view::view_filter::make_filter_controller;
use crate::services::database_view::view_group::{get_cell_for_row, new_group_controller};
use crate::services::database_view::view_operation::DatabaseViewOperation;
use crate::services::database_view::view_sort::make_sort_controller;
use crate::services::database_view::{
DatabaseLayoutDepsResolver, DatabaseViewChangedNotifier, DatabaseViewChangedReceiverRunner,
notify_did_update_filter, notify_did_update_group_rows, notify_did_update_num_of_groups,
notify_did_update_setting, notify_did_update_sort, DatabaseLayoutDepsResolver,
DatabaseViewChangedNotifier, DatabaseViewChangedReceiverRunner,
notify_did_update_setting, notify_did_update_sort,
};
use crate::services::field_settings::FieldSettings;
use crate::services::filter::{Filter, FilterChangeset, FilterController};
@ -40,7 +40,7 @@ use dashmap::DashMap;
use flowy_error::{FlowyError, FlowyResult};
use lib_infra::util::timestamp;
use tokio::sync::{broadcast, RwLock};
use tokio::sync::{RwLock, broadcast};
use tracing::{error, instrument, trace, warn};
pub struct DatabaseViewEditor {

View File

@ -3,7 +3,7 @@ use std::sync::Arc;
use crate::services::cell::CellCache;
use crate::services::database_view::{
gen_handler_id, DatabaseViewChangedNotifier, DatabaseViewOperation,
DatabaseViewChangedNotifier, DatabaseViewOperation, gen_handler_id,
};
use crate::services::filter::{Filter, FilterController, FilterDelegate, FilterTaskHandler};
use collab_database::fields::Field;

View File

@ -11,8 +11,8 @@ use crate::services::database_view::DatabaseViewOperation;
use crate::services::field::RowSingleCellData;
use crate::services::filter::FilterController;
use crate::services::group::{
make_group_controller, GroupContextDelegate, GroupController, GroupControllerDelegate,
GroupSetting,
GroupContextDelegate, GroupController, GroupControllerDelegate, GroupSetting,
make_group_controller,
};
pub async fn new_group_controller(

View File

@ -7,7 +7,7 @@ use tokio::sync::RwLock;
use crate::services::cell::CellCache;
use crate::services::database_view::{
gen_handler_id, DatabaseViewChangedNotifier, DatabaseViewOperation,
DatabaseViewChangedNotifier, DatabaseViewOperation, gen_handler_id,
};
use crate::services::filter::FilterController;
use crate::services::sort::{Sort, SortController, SortDelegate, SortTaskHandler};

View File

@ -2,6 +2,7 @@ use crate::entities::FieldType;
use crate::services::field::TypeOptionTransform;
use async_trait::async_trait;
use collab_database::database::Database;
use collab_database::fields::TypeOptionData;
use collab_database::fields::checkbox_type_option::CheckboxTypeOption;
use collab_database::fields::checklist_type_option::ChecklistTypeOption;
use collab_database::fields::date_type_option::{DateTypeOption, TimeTypeOption};
@ -14,7 +15,6 @@ use collab_database::fields::text_type_option::RichTextTypeOption;
use collab_database::fields::timestamp_type_option::TimestampTypeOption;
use collab_database::fields::translate_type_option::TranslateTypeOption;
use collab_database::fields::url_type_option::URLTypeOption;
use collab_database::fields::TypeOptionData;
pub async fn transform_type_option(
view_id: &str,

View File

@ -7,8 +7,8 @@ mod tests {
use crate::entities::CheckboxCellDataPB;
use crate::entities::FieldType;
use crate::services::cell::CellDataDecoder;
use crate::services::field::type_options::checkbox_type_option::*;
use crate::services::field::FieldBuilder;
use crate::services::field::type_options::checkbox_type_option::*;
use collab_database::fields::checkbox_type_option::CheckboxTypeOption;
use collab_database::template::util::ToCellString;

View File

@ -1,8 +1,8 @@
use std::cmp::Ordering;
use std::str::FromStr;
use collab_database::fields::checkbox_type_option::CheckboxTypeOption;
use collab_database::fields::Field;
use collab_database::fields::checkbox_type_option::CheckboxTypeOption;
use collab_database::rows::Cell;
use collab_database::template::util::ToCellString;
use flowy_error::FlowyResult;

View File

@ -2,13 +2,13 @@ use std::str::FromStr;
use bytes::Bytes;
use collab::util::AnyMapExt;
use collab_database::rows::{new_cell_builder, Cell};
use collab_database::rows::{Cell, new_cell_builder};
use collab_database::template::util::ToCellString;
use flowy_error::{FlowyError, FlowyResult};
use crate::entities::{CheckboxCellDataPB, FieldType};
use crate::services::cell::CellProtobufBlobParser;
use crate::services::field::{TypeOptionCellData, CELL_DATA};
use crate::services::field::{CELL_DATA, TypeOptionCellData};
pub const CHECK: &str = "Yes";
pub const UNCHECK: &str = "No";

View File

@ -2,8 +2,8 @@ use crate::entities::ChecklistCellDataChangesetPB;
use crate::entities::{ChecklistFilterConditionPB, ChecklistFilterPB};
use crate::services::filter::PreFillCellsWithFilter;
use collab_database::fields::select_type_option::SelectOption;
use collab_database::fields::Field;
use collab_database::fields::select_type_option::SelectOption;
use collab_database::rows::Cell;
use collab_database::template::check_list_parse::ChecklistCellData;

View File

@ -1,13 +1,13 @@
use crate::entities::{ChecklistCellDataPB, ChecklistFilterPB, SelectOptionPB};
use crate::services::cell::{CellDataChangeset, CellDataDecoder};
use crate::services::field::checklist_filter::{checklist_from_options, ChecklistCellChangeset};
use crate::services::field::checklist_filter::{ChecklistCellChangeset, checklist_from_options};
use crate::services::field::{
CellDataProtobufEncoder, TypeOption, TypeOptionCellDataCompare, TypeOptionCellDataFilter,
TypeOptionTransform,
};
use crate::services::sort::SortCondition;
use collab_database::fields::checklist_type_option::ChecklistTypeOption;
use collab_database::fields::select_type_option::{SelectOption, SELECTION_IDS_SEPARATOR};
use collab_database::fields::select_type_option::{SELECTION_IDS_SEPARATOR, SelectOption};
use collab_database::rows::Cell;
use collab_database::template::check_list_parse::ChecklistCellData;
use collab_database::template::util::TypeOptionCellData;

View File

@ -4,11 +4,11 @@ use crate::services::filter::PreFillCellsWithFilter;
use bytes::Bytes;
use chrono::{Duration, Local, NaiveDate, TimeZone};
use collab_database::fields::date_type_option::DateCellData;
use collab_database::fields::Field;
use collab_database::fields::date_type_option::DateCellData;
use collab_database::rows::Cell;
use collab_database::template::timestamp_parse::TimestampCellData;
use flowy_error::{internal_error, FlowyResult};
use flowy_error::{FlowyResult, internal_error};
use crate::entities::DateCellDataPB;
use crate::services::cell::CellProtobufBlobParser;

View File

@ -14,8 +14,8 @@ use crate::entities::{DateCellDataPB, DateFilterPB, FieldType};
use crate::services::cell::{CellDataChangeset, CellDataDecoder};
use crate::services::field::date_type_option::date_filter::DateCellChangeset;
use crate::services::field::{
default_order, CellDataProtobufEncoder, TypeOption, TypeOptionCellDataCompare,
TypeOptionCellDataFilter, TypeOptionTransform, CELL_DATA,
CELL_DATA, CellDataProtobufEncoder, TypeOption, TypeOptionCellDataCompare,
TypeOptionCellDataFilter, TypeOptionTransform, default_order,
};
use crate::services::sort::SortCondition;

View File

@ -3,8 +3,8 @@ use crate::{
services::{
cell::{CellDataChangeset, CellDataDecoder},
field::{
default_order, CellDataProtobufEncoder, TypeOption, TypeOptionCellData,
TypeOptionCellDataCompare, TypeOptionCellDataFilter, TypeOptionTransform,
CellDataProtobufEncoder, TypeOption, TypeOptionCellData, TypeOptionCellDataCompare,
TypeOptionCellDataFilter, TypeOptionTransform, default_order,
},
sort::SortCondition,
},

View File

@ -1,7 +1,7 @@
use std::str::FromStr;
use collab_database::fields::number_type_option::NumberCellFormat;
use collab_database::fields::Field;
use collab_database::fields::number_type_option::NumberCellFormat;
use collab_database::rows::Cell;
use rust_decimal::Decimal;

View File

@ -10,8 +10,8 @@ use flowy_error::FlowyResult;
use crate::entities::{RelationCellDataPB, RelationFilterPB};
use crate::services::cell::{CellDataChangeset, CellDataDecoder};
use crate::services::field::{
default_order, CellDataProtobufEncoder, TypeOption, TypeOptionCellDataCompare,
TypeOptionCellDataFilter, TypeOptionTransform,
CellDataProtobufEncoder, TypeOption, TypeOptionCellDataCompare, TypeOptionCellDataFilter,
TypeOptionTransform, default_order,
};
use crate::services::sort::SortCondition;

View File

@ -1,15 +1,15 @@
use crate::entities::{FieldType, SelectOptionCellDataPB, SelectOptionFilterPB};
use crate::services::cell::CellDataChangeset;
use crate::services::field::{
default_order, CellDataProtobufEncoder, SelectOptionCellChangeset, SelectTypeOptionSharedAction,
TypeOption, TypeOptionCellDataCompare, TypeOptionCellDataFilter,
CellDataProtobufEncoder, SelectOptionCellChangeset, SelectTypeOptionSharedAction, TypeOption,
TypeOptionCellDataCompare, TypeOptionCellDataFilter, default_order,
};
use crate::services::sort::SortCondition;
use collab_database::fields::TypeOptionData;
use collab_database::fields::select_type_option::{
MultiSelectTypeOption, SelectOption, SelectOptionIds,
};
use collab_database::fields::TypeOptionData;
use collab_database::rows::Cell;
use flowy_error::FlowyResult;

View File

@ -1,5 +1,5 @@
use collab_database::fields::select_type_option::SelectOption;
use collab_database::fields::Field;
use collab_database::fields::select_type_option::SelectOption;
use collab_database::rows::Cell;
use crate::entities::{SelectOptionFilterConditionPB, SelectOptionFilterPB};

View File

@ -8,13 +8,13 @@ use async_trait::async_trait;
use bytes::Bytes;
use collab_database::database::Database;
use collab_database::fields::select_type_option::{
MultiSelectTypeOption, SelectOption, SelectOptionColor, SelectOptionIds, SingleSelectTypeOption,
SELECTION_IDS_SEPARATOR,
MultiSelectTypeOption, SELECTION_IDS_SEPARATOR, SelectOption, SelectOptionColor, SelectOptionIds,
SingleSelectTypeOption,
};
use collab_database::fields::{Field, TypeOptionData};
use collab_database::rows::Cell;
use collab_database::template::util::ToCellString;
use flowy_error::{internal_error, ErrorCode, FlowyResult};
use flowy_error::{ErrorCode, FlowyResult, internal_error};
use std::str::FromStr;
/// Defines the shared actions used by SingleSelect or Multi-Select.

View File

@ -1,16 +1,16 @@
use crate::entities::{FieldType, SelectOptionCellDataPB, SelectOptionFilterPB};
use crate::services::cell::CellDataChangeset;
use crate::services::field::{
default_order, CellDataProtobufEncoder, TypeOption, TypeOptionCellDataCompare,
TypeOptionCellDataFilter,
CellDataProtobufEncoder, TypeOption, TypeOptionCellDataCompare, TypeOptionCellDataFilter,
default_order,
};
use crate::services::field::{SelectOptionCellChangeset, SelectTypeOptionSharedAction};
use crate::services::sort::SortCondition;
use collab_database::fields::TypeOptionData;
use collab_database::fields::select_type_option::{
SelectOption, SelectOptionIds, SingleSelectTypeOption,
};
use collab_database::fields::TypeOptionData;
use collab_database::rows::Cell;
use flowy_error::FlowyResult;

View File

@ -1,12 +1,12 @@
use crate::entities::FieldType;
use crate::services::cell::CellDataDecoder;
use crate::services::field::{SelectTypeOptionSharedAction, TypeOption, CHECK, UNCHECK};
use crate::services::field::{CHECK, SelectTypeOptionSharedAction, TypeOption, UNCHECK};
use collab_database::database::Database;
use collab_database::fields::TypeOptionData;
use collab_database::fields::select_type_option::{
SelectOption, SelectOptionColor, SelectOptionIds, SelectTypeOption, SELECTION_IDS_SEPARATOR,
SELECTION_IDS_SEPARATOR, SelectOption, SelectOptionColor, SelectOptionIds, SelectTypeOption,
};
use collab_database::fields::text_type_option::RichTextTypeOption;
use collab_database::fields::TypeOptionData;
use collab_database::template::option_parse::build_options_from_cells;
use tracing::info;

View File

@ -1,18 +1,18 @@
use collab::util::AnyMapExt;
use std::cmp::Ordering;
use collab_database::fields::text_type_option::RichTextTypeOption;
use collab_database::fields::Field;
use collab_database::rows::{new_cell_builder, Cell};
use collab_database::fields::text_type_option::RichTextTypeOption;
use collab_database::rows::{Cell, new_cell_builder};
use collab_database::template::util::ToCellString;
use flowy_error::{FlowyError, FlowyResult};
use crate::entities::{FieldType, TextFilterPB};
use crate::services::cell::{stringify_cell, CellDataChangeset, CellDataDecoder};
use crate::services::cell::{CellDataChangeset, CellDataDecoder, stringify_cell};
use crate::services::field::type_options::util::ProtobufStr;
use crate::services::field::{
CellDataProtobufEncoder, TypeOption, TypeOptionCellData, TypeOptionCellDataCompare,
TypeOptionCellDataFilter, TypeOptionTransform, CELL_DATA,
CELL_DATA, CellDataProtobufEncoder, TypeOption, TypeOptionCellData, TypeOptionCellDataCompare,
TypeOptionCellDataFilter, TypeOptionTransform,
};
use crate::services::sort::SortCondition;

View File

@ -1,8 +1,8 @@
use crate::entities::{DateFilterPB, TimestampCellDataPB};
use crate::services::cell::{CellDataChangeset, CellDataDecoder};
use crate::services::field::{
default_order, CellDataProtobufEncoder, TypeOption, TypeOptionCellDataCompare,
TypeOptionCellDataFilter, TypeOptionTransform,
CellDataProtobufEncoder, TypeOption, TypeOptionCellDataCompare, TypeOptionCellDataFilter,
TypeOptionTransform, default_order,
};
use crate::services::sort::SortCondition;
use collab_database::fields::timestamp_type_option::TimestampTypeOption;

View File

@ -6,6 +6,7 @@ use crate::services::field::{
};
use crate::services::sort::SortCondition;
use collab::preclude::Any;
use collab_database::fields::Field;
use collab_database::fields::checkbox_type_option::CheckboxTypeOption;
use collab_database::fields::checklist_type_option::ChecklistTypeOption;
use collab_database::fields::date_type_option::{DateTypeOption, TimeTypeOption};
@ -18,13 +19,12 @@ use collab_database::fields::text_type_option::RichTextTypeOption;
use collab_database::fields::timestamp_type_option::TimestampTypeOption;
use collab_database::fields::translate_type_option::TranslateTypeOption;
use collab_database::fields::url_type_option::URLTypeOption;
use collab_database::fields::Field;
use collab_database::rows::{get_field_type_from_cell, Cell, RowId};
use collab_database::rows::{Cell, RowId, get_field_type_from_cell};
use flowy_error::FlowyResult;
use lib_infra::box_any::BoxAny;
use std::cmp::Ordering;
use std::collections::hash_map::DefaultHasher;
use std::collections::HashMap;
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
pub const CELL_DATA: &str = "data";

View File

@ -2,7 +2,7 @@ use bytes::Bytes;
use collab_database::fields::url_type_option::URLCellData;
use flowy_error::{internal_error, FlowyResult};
use flowy_error::{FlowyResult, internal_error};
use crate::entities::URLCellDataPB;
use crate::services::cell::CellProtobufBlobParser;

View File

@ -7,7 +7,7 @@ use std::collections::HashMap;
use strum::IntoEnumIterator;
use crate::entities::FieldVisibility;
use crate::services::field_settings::{FieldSettings, DEFAULT_WIDTH, VISIBILITY};
use crate::services::field_settings::{DEFAULT_WIDTH, FieldSettings, VISIBILITY};
/// Helper struct to create a new field setting
pub struct FieldSettingsBuilder {

View File

@ -5,8 +5,8 @@ use std::sync::Arc;
use collab_database::fields::Field;
use indexmap::IndexMap;
use serde::de::DeserializeOwned;
use serde::Serialize;
use serde::de::DeserializeOwned;
use tracing::event;
use flowy_error::{FlowyError, FlowyResult};
@ -14,7 +14,7 @@ use flowy_error::{FlowyError, FlowyResult};
use crate::entities::{GroupChangesPB, GroupPB, InsertedGroupPB};
use crate::services::field::RowSingleCellData;
use crate::services::group::{
default_group_setting, GeneratedGroups, Group, GroupChangeset, GroupData, GroupSetting,
GeneratedGroups, Group, GroupChangeset, GroupData, GroupSetting, default_group_setting,
};
#[async_trait]
@ -24,7 +24,7 @@ pub trait GroupContextDelegate: Send + Sync + 'static {
async fn get_configuration_cells(&self, view_id: &str, field_id: &str) -> Vec<RowSingleCellData>;
async fn save_configuration(&self, view_id: &str, group_setting: GroupSetting)
-> FlowyResult<()>;
-> FlowyResult<()>;
}
impl<T> std::fmt::Display for GroupControllerContext<T> {
@ -463,7 +463,7 @@ impl MergeGroupResult {
mod tests {
use crate::services::group::Group;
use super::{merge_groups, MergeGroupResult};
use super::{MergeGroupResult, merge_groups};
#[test]
fn merge_groups_test() {

View File

@ -5,15 +5,15 @@ use std::sync::Arc;
use collab_database::fields::{Field, TypeOptionData};
use collab_database::rows::{Cells, Row, RowId};
use flowy_error::{FlowyError, FlowyResult};
use serde::de::DeserializeOwned;
use serde::Serialize;
use serde::de::DeserializeOwned;
use tracing::trace;
use crate::entities::{
FieldType, GroupPB, GroupRowsNotificationPB, InsertedGroupPB, InsertedRowPB, RowMetaPB,
};
use crate::services::cell::{get_cell_protobuf, CellProtobufBlobParser};
use crate::services::field::{default_type_option_data_from_type, TypeOption, TypeOptionCellData};
use crate::services::cell::{CellProtobufBlobParser, get_cell_protobuf};
use crate::services::field::{TypeOption, TypeOptionCellData, default_type_option_data_from_type};
use crate::services::group::action::{
DidMoveGroupRowResult, DidUpdateGroupRowResult, GroupController, GroupCustomize,
};

View File

@ -1,18 +1,18 @@
use async_trait::async_trait;
use collab_database::fields::checkbox_type_option::CheckboxTypeOption;
use collab_database::fields::{Field, TypeOptionData};
use collab_database::rows::{new_cell_builder, Cell, Cells, Row};
use collab_database::rows::{Cell, Cells, Row, new_cell_builder};
use flowy_error::FlowyResult;
use serde::{Deserialize, Serialize};
use crate::entities::{FieldType, GroupPB, GroupRowsNotificationPB, InsertedRowPB, RowMetaPB};
use crate::services::cell::insert_checkbox_cell;
use crate::services::field::{CheckboxCellDataParser, TypeOption, CHECK, UNCHECK};
use crate::services::field::{CHECK, CheckboxCellDataParser, TypeOption, UNCHECK};
use crate::services::group::action::GroupCustomize;
use crate::services::group::configuration::GroupControllerContext;
use crate::services::group::controller::BaseGroupController;
use crate::services::group::{
move_group_row, GeneratedGroups, Group, GroupsBuilder, MoveGroupRowContext,
GeneratedGroups, Group, GroupsBuilder, MoveGroupRowContext, move_group_row,
};
#[derive(Default, Serialize, Deserialize)]

View File

@ -3,8 +3,8 @@ use chrono::{DateTime, Datelike, Days, Duration, Local};
use collab_database::database::timestamp;
use collab_database::fields::date_type_option::{DateCellData, DateTypeOption};
use collab_database::fields::{Field, TypeOptionData};
use collab_database::rows::{new_cell_builder, Cell, Cells, Row};
use flowy_error::{internal_error, FlowyResult};
use collab_database::rows::{Cell, Cells, Row, new_cell_builder};
use flowy_error::{FlowyResult, internal_error};
use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};
@ -12,13 +12,13 @@ use crate::entities::{
FieldType, GroupPB, GroupRowsNotificationPB, InsertedGroupPB, InsertedRowPB, RowMetaPB,
};
use crate::services::cell::insert_date_cell;
use crate::services::field::date_filter::DateCellDataParser;
use crate::services::field::TypeOption;
use crate::services::field::date_filter::DateCellDataParser;
use crate::services::group::action::GroupCustomize;
use crate::services::group::configuration::GroupControllerContext;
use crate::services::group::controller::BaseGroupController;
use crate::services::group::{
make_no_status_group, move_group_row, GeneratedGroups, Group, GroupsBuilder, MoveGroupRowContext,
GeneratedGroups, Group, GroupsBuilder, MoveGroupRowContext, make_no_status_group, move_group_row,
};
#[derive(Default, Serialize, Deserialize)]
@ -342,9 +342,9 @@ fn date_time_from_timestamp(timestamp: Option<i64>) -> DateTime<Local> {
#[cfg(test)]
mod tests {
use crate::services::group::controller_impls::date_controller::{
get_date_group_id, GROUP_ID_DATE_FORMAT,
GROUP_ID_DATE_FORMAT, get_date_group_id,
};
use chrono::{offset, Days, Duration};
use chrono::{Days, Duration, offset};
use collab_database::fields::date_type_option::{DateCellData, DateTypeOption};
#[test]

View File

@ -116,8 +116,7 @@ impl GroupController for DefaultGroupController {
if self.group.contains_row(&row.id) {
trace!(
"[RowOrder]: delete row:{} from group: {}",
row.id,
self.group.id
row.id, self.group.id
);
self.group.remove_row(&row.id);
changeset.deleted_rows.push(row.id.clone().into_inner());

View File

@ -1,7 +1,7 @@
use async_trait::async_trait;
use collab_database::fields::select_type_option::{MultiSelectTypeOption, SelectOption};
use collab_database::fields::{Field, TypeOptionData};
use collab_database::rows::{new_cell_builder, Cell, Cells, Row};
use collab_database::rows::{Cell, Cells, Row, new_cell_builder};
use flowy_error::{FlowyError, FlowyResult};
use serde::{Deserialize, Serialize};
@ -13,9 +13,9 @@ use crate::services::field::{
use crate::services::group::action::GroupCustomize;
use crate::services::group::controller::BaseGroupController;
use crate::services::group::{
add_or_remove_select_option_row, generate_select_option_groups, make_no_status_group,
move_group_row, remove_select_option_row, GeneratedGroups, Group, GroupChangeset,
GroupControllerContext, GroupsBuilder, MoveGroupRowContext,
GeneratedGroups, Group, GroupChangeset, GroupControllerContext, GroupsBuilder,
MoveGroupRowContext, add_or_remove_select_option_row, generate_select_option_groups,
make_no_status_group, move_group_row, remove_select_option_row,
};
#[derive(Default, Serialize, Deserialize)]

Some files were not shown because too many files have changed in this diff Show More