Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: Migrate type option (#6395)

Nathan.fooo7e1b77f87202
diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/field/type_option_editor/date/date_time_format.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/field/type_option_editor/date/date_time_format.dart
index c04bcab92b..d969e73c91 100644
--- a/frontend/appflowy_flutter/lib/plugins/database/widgets/field/type_option_editor/date/date_time_format.dart
+++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/field/type_option_editor/date/date_time_format.dart
@@ -74,7 +74,9 @@ class DateFormatList extends StatelessWidget {
@override
Widget build(BuildContext context) {
- final cells = DateFormatPB.values.map((format) {
+ final cells = DateFormatPB.values
+ .where((value) => value != DateFormatPB.FriendlyFull)
+ .map((format) {
return DateFormatCell(
dateFormat: format,
onSelected: onSelected,
@@ -144,6 +146,8 @@ extension DateFormatExtension on DateFormatPB {
return LocaleKeys.grid_field_dateFormatUS.tr();
case DateFormatPB.DayMonthYear:
return LocaleKeys.grid_field_dateFormatDayMonthYear.tr();
+ case DateFormatPB.FriendlyFull:
+ return LocaleKeys.grid_field_dateFormatFriendly.tr();
default:
throw UnimplementedError;
}
diff --git a/frontend/appflowy_flutter/pubspec.lock b/frontend/appflowy_flutter/pubspec.lock
index ebc9e09bfc..5c14ff904c 100644
--- a/frontend/appflowy_flutter/pubspec.lock
+++ b/frontend/appflowy_flutter/pubspec.lock
@@ -1559,10 +1559,10 @@ packages:
dependency: transitive
description:
name: platform
- sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65"
+ sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
url: "https://pub.dev"
source: hosted
- version: "3.1.5"
+ version: "3.1.4"
plugin_platform_interface:
dependency: "direct dev"
description:
@@ -1989,10 +1989,10 @@ packages:
dependency: transitive
description:
name: string_scanner
- sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3"
+ sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.dev"
source: hosted
- version: "1.3.0"
+ version: "1.2.0"
string_validator:
dependency: "direct main"
description:
@@ -2311,10 +2311,10 @@ packages:
dependency: transitive
description:
name: vm_service
- sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
+ sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
url: "https://pub.dev"
source: hosted
- version: "14.2.5"
+ version: "14.2.1"
watcher:
dependency: transitive
description:
diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.lock b/frontend/appflowy_tauri/src-tauri/Cargo.lock
index 39c2559f3f..887dabb399 100644
--- a/frontend/appflowy_tauri/src-tauri/Cargo.lock
+++ b/frontend/appflowy_tauri/src-tauri/Cargo.lock
@@ -172,7 +172,7 @@ checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
[[package]]
name = "app-error"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"bincode",
@@ -192,7 +192,7 @@ dependencies = [
[[package]]
name = "appflowy-ai-client"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"bytes",
@@ -219,7 +219,7 @@ dependencies = [
"tokio-stream",
"tokio-util",
"tracing",
- "zip 2.1.3",
+ "zip",
"zip-extensions",
]
@@ -302,6 +302,17 @@ dependencies = [
"pin-project-lite",
]
+[[package]]
+name = "async-recursion"
+version = "1.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.47",
+]
+
[[package]]
name = "async-stream"
version = "0.3.5"
@@ -410,12 +421,6 @@ version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
-[[package]]
-name = "base64ct"
-version = "1.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
-
[[package]]
name = "bincode"
version = "1.3.3"
@@ -510,47 +515,26 @@ dependencies = [
[[package]]
name = "borsh"
-version = "0.10.3"
+version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b"
+checksum = "26d4d6dafc1a3bb54687538972158f07b2c948bc57d5890df22c0739098b3028"
dependencies = [
"borsh-derive",
- "hashbrown 0.12.3",
+ "cfg_aliases",
]
[[package]]
name = "borsh-derive"
-version = "0.10.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7"
-dependencies = [
- "borsh-derive-internal",
- "borsh-schema-derive-internal",
- "proc-macro-crate 0.1.5",
- "proc-macro2",
- "syn 1.0.109",
-]
-
-[[package]]
-name = "borsh-derive-internal"
-version = "0.10.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn 1.0.109",
-]
-
-[[package]]
-name = "borsh-schema-derive-internal"
-version = "0.10.3"
+version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd"
+checksum = "bf4918709cc4dd777ad2b6303ed03cb37f3ca0ccede8c1b0d28ac6db8f4710e0"
dependencies = [
+ "once_cell",
+ "proc-macro-crate 2.0.2",
"proc-macro2",
"quote",
- "syn 1.0.109",
+ "syn 2.0.47",
+ "syn_derive",
]
[[package]]
@@ -754,11 +738,17 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+[[package]]
+name = "cfg_aliases"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
+
[[package]]
name = "chrono"
-version = "0.4.33"
+version = "0.4.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb"
+checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
dependencies = [
"android-tzdata",
"iana-time-zone",
@@ -791,6 +781,17 @@ dependencies = [
"phf 0.11.2",
]
+[[package]]
+name = "chrono-tz"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cd6dd8046d00723a59a2f8c5f295c515b9bb9a331ee4f8f3d4dd49e428acd3b6"
+dependencies = [
+ "chrono",
+ "chrono-tz-build 0.4.0",
+ "phf 0.11.2",
+]
+
[[package]]
name = "chrono-tz-build"
version = "0.0.2"
@@ -813,6 +814,16 @@ dependencies = [
"phf_codegen 0.11.2",
]
+[[package]]
+name = "chrono-tz-build"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e94fea34d77a245229e7746bd2beb786cd2a896f306ff491fb8cecb3074b10a7"
+dependencies = [
+ "parse-zoneinfo",
+ "phf_codegen 0.11.2",
+]
+
[[package]]
name = "cipher"
version = "0.4.4"
@@ -837,7 +848,7 @@ dependencies = [
[[package]]
name = "client-api"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"again",
"anyhow",
@@ -889,7 +900,7 @@ dependencies = [
[[package]]
name = "client-api-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"collab-entity",
"collab-rt-entity",
@@ -902,7 +913,7 @@ dependencies = [
[[package]]
name = "client-websocket"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"futures-channel",
"futures-util",
@@ -976,7 +987,7 @@ dependencies = [
[[package]]
name = "collab"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87d1f8b086ab4005ce2fbd4e13d355a48e95763d#87d1f8b086ab4005ce2fbd4e13d355a48e95763d"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
dependencies = [
"anyhow",
"arc-swap",
@@ -1001,24 +1012,31 @@ dependencies = [
[[package]]
name = "collab-database"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87d1f8b086ab4005ce2fbd4e13d355a48e95763d#87d1f8b086ab4005ce2fbd4e13d355a48e95763d"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
dependencies = [
"anyhow",
"async-trait",
+ "base64 0.22.1",
"chrono",
+ "chrono-tz 0.10.0",
"collab",
"collab-entity",
"csv",
"dashmap 5.5.3",
+ "fancy-regex 0.13.0",
"futures",
"getrandom 0.2.10",
"js-sys",
"lazy_static",
"nanoid",
+ "percent-encoding",
"rayon",
+ "rust_decimal",
+ "rusty-money",
"serde",
"serde_json",
"serde_repr",
+ "sha2",
"strum",
"strum_macros 0.25.2",
"thiserror",
@@ -1033,7 +1051,7 @@ dependencies = [
[[package]]
name = "collab-document"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87d1f8b086ab4005ce2fbd4e13d355a48e95763d#87d1f8b086ab4005ce2fbd4e13d355a48e95763d"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
dependencies = [
"anyhow",
"arc-swap",
@@ -1054,7 +1072,7 @@ dependencies = [
[[package]]
name = "collab-entity"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87d1f8b086ab4005ce2fbd4e13d355a48e95763d#87d1f8b086ab4005ce2fbd4e13d355a48e95763d"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
dependencies = [
"anyhow",
"bytes",
@@ -1074,7 +1092,7 @@ dependencies = [
[[package]]
name = "collab-folder"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87d1f8b086ab4005ce2fbd4e13d355a48e95763d#87d1f8b086ab4005ce2fbd4e13d355a48e95763d"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
dependencies = [
"anyhow",
"arc-swap",
@@ -1092,6 +1110,37 @@ dependencies = [
"tracing",
]
+[[package]]
+name = "collab-importer"
+version = "0.1.0"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
+dependencies = [
+ "anyhow",
+ "async-recursion",
+ "base64 0.22.1",
+ "chrono",
+ "collab",
+ "collab-database",
+ "collab-document",
+ "collab-entity",
+ "collab-folder",
+ "fancy-regex 0.13.0",
+ "fxhash",
+ "hex",
+ "markdown",
+ "percent-encoding",
+ "rayon",
+ "serde",
+ "serde_json",
+ "sha2",
+ "thiserror",
+ "tokio",
+ "tracing",
+ "uuid",
+ "walkdir",
+ "zip",
+]
+
[[package]]
name = "collab-integrate"
version = "0.1.0"
@@ -1117,7 +1166,7 @@ dependencies = [
[[package]]
name = "collab-plugins"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87d1f8b086ab4005ce2fbd4e13d355a48e95763d#87d1f8b086ab4005ce2fbd4e13d355a48e95763d"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
dependencies = [
"anyhow",
"async-stream",
@@ -1155,7 +1204,7 @@ dependencies = [
[[package]]
name = "collab-rt-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"bincode",
@@ -1180,7 +1229,7 @@ dependencies = [
[[package]]
name = "collab-rt-protocol"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"async-trait",
@@ -1197,7 +1246,7 @@ dependencies = [
[[package]]
name = "collab-user"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87d1f8b086ab4005ce2fbd4e13d355a48e95763d#87d1f8b086ab4005ce2fbd4e13d355a48e95763d"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
dependencies = [
"anyhow",
"collab",
@@ -1250,12 +1299,6 @@ dependencies = [
"winapi",
]
-[[package]]
-name = "constant_time_eq"
-version = "0.1.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
-
[[package]]
name = "constant_time_eq"
version = "0.3.0"
@@ -1577,7 +1620,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]]
name = "database-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"app-error",
@@ -1607,9 +1650,9 @@ dependencies = [
[[package]]
name = "deflate64"
-version = "0.1.8"
+version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "83ace6c86376be0b6cdcf3fb41882e81d94b31587573d1cfa9d01cd06bba210d"
+checksum = "da692b8d1080ea3045efaab14434d40468c3d8657e42abddfffca87b428f4c1b"
[[package]]
name = "delegate-display"
@@ -1943,6 +1986,17 @@ dependencies = [
"regex",
]
+[[package]]
+name = "fancy-regex"
+version = "0.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "531e46835a22af56d1e3b66f04844bed63158bc094a628bec1d321d9b4c44bf2"
+dependencies = [
+ "bit-set",
+ "regex-automata 0.4.7",
+ "regex-syntax 0.8.4",
+]
+
[[package]]
name = "fancy_constructor"
version = "1.2.2"
@@ -2056,7 +2110,7 @@ dependencies = [
"tracing",
"uuid",
"validator",
- "zip 2.1.3",
+ "zip",
"zip-extensions",
]
@@ -2319,7 +2373,7 @@ dependencies = [
"base64 0.21.5",
"getrandom 0.2.10",
"hmac",
- "pbkdf2 0.12.2",
+ "pbkdf2",
"rand 0.8.5",
"sha2",
]
@@ -2557,6 +2611,7 @@ dependencies = [
"async-trait",
"bytes",
"chrono",
+ "collab-importer",
"dashmap 6.0.1",
"flowy-codegen",
"flowy-derive",
@@ -3131,7 +3186,7 @@ dependencies = [
[[package]]
name = "gotrue"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"futures-util",
@@ -3148,7 +3203,7 @@ dependencies = [
[[package]]
name = "gotrue-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"app-error",
@@ -3580,7 +3635,7 @@ dependencies = [
[[package]]
name = "infra"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"bytes",
@@ -3879,7 +3934,7 @@ dependencies = [
"tracing",
"validator",
"walkdir",
- "zip 0.6.6",
+ "zip",
]
[[package]]
@@ -4099,9 +4154,9 @@ dependencies = [
[[package]]
name = "markdown"
-version = "1.0.0-alpha.20"
+version = "1.0.0-alpha.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "911a8325e6fb87b89890cd4529a2ab34c2669c026279e61c26b7140a3d821ccb"
+checksum = "a6491e6c702bf7e3b24e769d800746d5f2c06a6c6a2db7992612e0f429029e81"
dependencies = [
"unicode-id",
]
@@ -4767,35 +4822,12 @@ dependencies = [
"regex",
]
-[[package]]
-name = "password-hash"
-version = "0.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700"
-dependencies = [
- "base64ct",
- "rand_core 0.6.4",
- "subtle",
-]
-
[[package]]
name = "pathdiff"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd"
-[[package]]
-name = "pbkdf2"
-version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917"
-dependencies = [
- "digest",
- "hmac",
- "password-hash",
- "sha2",
-]
-
[[package]]
name = "pbkdf2"
version = "0.12.2"
@@ -5136,21 +5168,22 @@ dependencies = [
[[package]]
name = "proc-macro-crate"
-version = "0.1.5"
+version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785"
+checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919"
dependencies = [
- "toml 0.5.11",
+ "once_cell",
+ "toml_edit 0.19.11",
]
[[package]]
name = "proc-macro-crate"
-version = "1.3.1"
+version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919"
+checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24"
dependencies = [
- "once_cell",
- "toml_edit",
+ "toml_datetime",
+ "toml_edit 0.20.2",
]
[[package]]
@@ -5780,14 +5813,12 @@ dependencies = [
[[package]]
name = "rust_decimal"
-version = "1.30.0"
+version = "1.36.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d0446843641c69436765a35a5a77088e28c2e6a12da93e84aa3ab1cd4aa5a042"
+checksum = "b082d80e3e3cc52b2ed634388d436fe1f4de6af5786cc2de9ba9737527bdf555"
dependencies = [
"arrayvec",
"borsh",
- "bytecheck",
- "byteorder",
"bytes",
"num-traits",
"rand 0.8.5",
@@ -6060,18 +6091,18 @@ dependencies = [
[[package]]
name = "serde"
-version = "1.0.203"
+version = "1.0.210"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094"
+checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.203"
+version = "1.0.210"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba"
+checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
dependencies = [
"proc-macro2",
"quote",
@@ -6091,11 +6122,12 @@ dependencies = [
[[package]]
name = "serde_json"
-version = "1.0.118"
+version = "1.0.128"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d947f6b3163d8857ea16c4fa0dd4840d52f3041039a85decd46867eb1abef2e4"
+checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8"
dependencies = [
"itoa 1.0.6",
+ "memchr",
"ryu",
"serde",
]
@@ -6220,9 +6252,9 @@ checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012"
[[package]]
name = "sha2"
-version = "0.10.7"
+version = "0.10.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8"
+checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8"
dependencies = [
"cfg-if",
"cpufeatures",
@@ -6241,7 +6273,7 @@ dependencies = [
[[package]]
name = "shared-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"app-error",
@@ -6541,6 +6573,18 @@ dependencies = [
"unicode-ident",
]
+[[package]]
+name = "syn_derive"
+version = "0.1.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b"
+dependencies = [
+ "proc-macro-error",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.47",
+]
+
[[package]]
name = "sync_wrapper"
version = "0.1.2"
@@ -6733,7 +6777,7 @@ dependencies = [
"tantivy-bitpacker",
"tantivy-common",
"tantivy-fst",
- "zstd 0.13.2",
+ "zstd",
]
[[package]]
@@ -7106,18 +7150,18 @@ checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c"
[[package]]
name = "thiserror"
-version = "1.0.61"
+version = "1.0.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709"
+checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
-version = "1.0.61"
+version = "1.0.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533"
+checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3"
dependencies = [
"proc-macro2",
"quote",
@@ -7319,7 +7363,7 @@ dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
- "toml_edit",
+ "toml_edit 0.19.11",
]
[[package]]
@@ -7341,7 +7385,18 @@ dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
- "winnow",
+ "winnow 0.4.7",
+]
+
+[[package]]
+name = "toml_edit"
+version = "0.20.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338"
+dependencies = [
+ "indexmap 2.1.0",
+ "toml_datetime",
+ "winnow 0.5.40",
]
[[package]]
@@ -7808,9 +7863,9 @@ dependencies = [
[[package]]
name = "walkdir"
-version = "2.4.0"
+version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee"
+checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
dependencies = [
"same-file",
"winapi-util",
@@ -8428,6 +8483,15 @@ dependencies = [
"memchr",
]
+[[package]]
+name = "winnow"
+version = "0.5.40"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876"
+dependencies = [
+ "memchr",
+]
+
[[package]]
name = "winreg"
version = "0.11.0"
@@ -8596,34 +8660,14 @@ dependencies = [
[[package]]
name = "zip"
-version = "0.6.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261"
-dependencies = [
- "aes",
- "byteorder",
- "bzip2",
- "constant_time_eq 0.1.5",
- "crc32fast",
- "crossbeam-utils",
- "flate2",
- "hmac",
- "pbkdf2 0.11.0",
- "sha1",
- "time",
- "zstd 0.11.2+zstd.1.5.2",
-]
-
-[[package]]
-name = "zip"
-version = "2.1.3"
+version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "775a2b471036342aa69bc5a602bc889cb0a06cda00477d0c69566757d5553d39"
+checksum = "dc5e4288ea4057ae23afc69a4472434a87a2495cafce6632fd1c4ec9f5cf3494"
dependencies = [
"aes",
"arbitrary",
"bzip2",
- "constant_time_eq 0.3.0",
+ "constant_time_eq",
"crc32fast",
"crossbeam-utils",
"deflate64",
@@ -8633,14 +8677,14 @@ dependencies = [
"indexmap 2.1.0",
"lzma-rs",
"memchr",
- "pbkdf2 0.12.2",
+ "pbkdf2",
"rand 0.8.5",
"sha1",
"thiserror",
"time",
"zeroize",
"zopfli",
- "zstd 0.13.2",
+ "zstd",
]
[[package]]
@@ -8649,7 +8693,7 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb0a99499b3497d765525c5d05e3ade9ca4a731c184365c19472c3fd6ba86341"
dependencies = [
- "zip 2.1.3",
+ "zip",
]
[[package]]
@@ -8666,32 +8710,13 @@ dependencies = [
"simd-adler32",
]
-[[package]]
-name = "zstd"
-version = "0.11.2+zstd.1.5.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4"
-dependencies = [
- "zstd-safe 5.0.2+zstd.1.5.2",
-]
-
[[package]]
name = "zstd"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcf2b778a664581e31e389454a7072dab1647606d44f7feea22cd5abb9c9f3f9"
dependencies = [
- "zstd-safe 7.2.0",
-]
-
-[[package]]
-name = "zstd-safe"
-version = "5.0.2+zstd.1.5.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db"
-dependencies = [
- "libc",
- "zstd-sys",
+ "zstd-safe",
]
[[package]]
diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.toml b/frontend/appflowy_tauri/src-tauri/Cargo.toml
index ec3433ebd5..dfebd257f8 100644
--- a/frontend/appflowy_tauri/src-tauri/Cargo.toml
+++ b/frontend/appflowy_tauri/src-tauri/Cargo.toml
@@ -34,7 +34,7 @@ tokio = "1.34.0"
tokio-stream = "0.1.14"
async-trait = "0.1.74"
chrono = { version = "0.4.31", default-features = false, features = ["clock"] }
-zip = "2.1.3"
+zip = "2.2.0"
yrs = "0.19.1"
# Please use the following script to update collab.
# Working directory: frontend
@@ -59,7 +59,7 @@ collab-importer = { version = "0.1" }
# Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
-client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "4c54481d704bf2f1b5118b4f36add7fb953c0cfc" }
+client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "b023e2f5118897a107f3a6023eb15b2f75389252" }
[dependencies]
serde_json.workspace = true
@@ -120,14 +120,14 @@ custom-protocol = ["tauri/custom-protocol"]
# To switch to the local path, run:
# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
-collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
-collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
-collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
-collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
-collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
-collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
-collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
-collab-importer = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
+collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
+collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
+collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
+collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
+collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
+collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
+collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
+collab-importer = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
# Working directory: frontend
diff --git a/frontend/appflowy_web_app/src-tauri/Cargo.lock b/frontend/appflowy_web_app/src-tauri/Cargo.lock
index cabdfbe436..65b8e66f21 100644
--- a/frontend/appflowy_web_app/src-tauri/Cargo.lock
+++ b/frontend/appflowy_web_app/src-tauri/Cargo.lock
@@ -163,7 +163,7 @@ checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
[[package]]
name = "app-error"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"bincode",
@@ -183,7 +183,7 @@ dependencies = [
[[package]]
name = "appflowy-ai-client"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"bytes",
@@ -210,7 +210,7 @@ dependencies = [
"tokio-stream",
"tokio-util",
"tracing",
- "zip 2.1.3",
+ "zip",
"zip-extensions",
]
@@ -312,6 +312,17 @@ dependencies = [
"pin-project-lite",
]
+[[package]]
+name = "async-recursion"
+version = "1.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.55",
+]
+
[[package]]
name = "async-stream"
version = "0.3.5"
@@ -420,12 +431,6 @@ version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
-[[package]]
-name = "base64ct"
-version = "1.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
-
[[package]]
name = "bincode"
version = "1.3.3"
@@ -752,9 +757,9 @@ checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
[[package]]
name = "chrono"
-version = "0.4.35"
+version = "0.4.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a"
+checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
dependencies = [
"android-tzdata",
"iana-time-zone",
@@ -772,7 +777,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d59ae0466b83e838b81a54256c39d5d7c20b9d7daa10510a242d9b75abd5936e"
dependencies = [
"chrono",
- "chrono-tz-build",
+ "chrono-tz-build 0.2.1",
+ "phf 0.11.2",
+]
+
+[[package]]
+name = "chrono-tz"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cd6dd8046d00723a59a2f8c5f295c515b9bb9a331ee4f8f3d4dd49e428acd3b6"
+dependencies = [
+ "chrono",
+ "chrono-tz-build 0.4.0",
"phf 0.11.2",
]
@@ -787,6 +803,16 @@ dependencies = [
"phf_codegen 0.11.2",
]
+[[package]]
+name = "chrono-tz-build"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e94fea34d77a245229e7746bd2beb786cd2a896f306ff491fb8cecb3074b10a7"
+dependencies = [
+ "parse-zoneinfo",
+ "phf_codegen 0.11.2",
+]
+
[[package]]
name = "cipher"
version = "0.4.4"
@@ -811,7 +837,7 @@ dependencies = [
[[package]]
name = "client-api"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"again",
"anyhow",
@@ -863,7 +889,7 @@ dependencies = [
[[package]]
name = "client-api-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"collab-entity",
"collab-rt-entity",
@@ -876,7 +902,7 @@ dependencies = [
[[package]]
name = "client-websocket"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"futures-channel",
"futures-util",
@@ -959,7 +985,7 @@ dependencies = [
[[package]]
name = "collab"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87d1f8b086ab4005ce2fbd4e13d355a48e95763d#87d1f8b086ab4005ce2fbd4e13d355a48e95763d"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
dependencies = [
"anyhow",
"arc-swap",
@@ -984,24 +1010,31 @@ dependencies = [
[[package]]
name = "collab-database"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87d1f8b086ab4005ce2fbd4e13d355a48e95763d#87d1f8b086ab4005ce2fbd4e13d355a48e95763d"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
dependencies = [
"anyhow",
"async-trait",
+ "base64 0.22.1",
"chrono",
+ "chrono-tz 0.10.0",
"collab",
"collab-entity",
"csv",
"dashmap 5.5.3",
+ "fancy-regex 0.13.0",
"futures",
"getrandom 0.2.12",
"js-sys",
"lazy_static",
"nanoid",
+ "percent-encoding",
"rayon",
+ "rust_decimal",
+ "rusty-money",
"serde",
"serde_json",
"serde_repr",
+ "sha2",
"strum",
"strum_macros 0.25.3",
"thiserror",
@@ -1016,7 +1049,7 @@ dependencies = [
[[package]]
name = "collab-document"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87d1f8b086ab4005ce2fbd4e13d355a48e95763d#87d1f8b086ab4005ce2fbd4e13d355a48e95763d"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
dependencies = [
"anyhow",
"arc-swap",
@@ -1037,7 +1070,7 @@ dependencies = [
[[package]]
name = "collab-entity"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87d1f8b086ab4005ce2fbd4e13d355a48e95763d#87d1f8b086ab4005ce2fbd4e13d355a48e95763d"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
dependencies = [
"anyhow",
"bytes",
@@ -1057,7 +1090,7 @@ dependencies = [
[[package]]
name = "collab-folder"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87d1f8b086ab4005ce2fbd4e13d355a48e95763d#87d1f8b086ab4005ce2fbd4e13d355a48e95763d"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
dependencies = [
"anyhow",
"arc-swap",
@@ -1075,6 +1108,37 @@ dependencies = [
"tracing",
]
+[[package]]
+name = "collab-importer"
+version = "0.1.0"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
+dependencies = [
+ "anyhow",
+ "async-recursion",
+ "base64 0.22.1",
+ "chrono",
+ "collab",
+ "collab-database",
+ "collab-document",
+ "collab-entity",
+ "collab-folder",
+ "fancy-regex 0.13.0",
+ "fxhash",
+ "hex",
+ "markdown",
+ "percent-encoding",
+ "rayon",
+ "serde",
+ "serde_json",
+ "sha2",
+ "thiserror",
+ "tokio",
+ "tracing",
+ "uuid",
+ "walkdir",
+ "zip",
+]
+
[[package]]
name = "collab-integrate"
version = "0.1.0"
@@ -1100,7 +1164,7 @@ dependencies = [
[[package]]
name = "collab-plugins"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87d1f8b086ab4005ce2fbd4e13d355a48e95763d#87d1f8b086ab4005ce2fbd4e13d355a48e95763d"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
dependencies = [
"anyhow",
"async-stream",
@@ -1138,7 +1202,7 @@ dependencies = [
[[package]]
name = "collab-rt-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"bincode",
@@ -1163,7 +1227,7 @@ dependencies = [
[[package]]
name = "collab-rt-protocol"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"async-trait",
@@ -1180,7 +1244,7 @@ dependencies = [
[[package]]
name = "collab-user"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=87d1f8b086ab4005ce2fbd4e13d355a48e95763d#87d1f8b086ab4005ce2fbd4e13d355a48e95763d"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
dependencies = [
"anyhow",
"collab",
@@ -1233,12 +1297,6 @@ dependencies = [
"winapi",
]
-[[package]]
-name = "constant_time_eq"
-version = "0.1.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
-
[[package]]
name = "constant_time_eq"
version = "0.3.0"
@@ -1567,7 +1625,7 @@ checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5"
[[package]]
name = "database-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"app-error",
@@ -1597,9 +1655,9 @@ dependencies = [
[[package]]
name = "deflate64"
-version = "0.1.8"
+version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "83ace6c86376be0b6cdcf3fb41882e81d94b31587573d1cfa9d01cd06bba210d"
+checksum = "da692b8d1080ea3045efaab14434d40468c3d8657e42abddfffca87b428f4c1b"
[[package]]
name = "delegate-display"
@@ -1973,6 +2031,17 @@ dependencies = [
"regex",
]
+[[package]]
+name = "fancy-regex"
+version = "0.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "531e46835a22af56d1e3b66f04844bed63158bc094a628bec1d321d9b4c44bf2"
+dependencies = [
+ "bit-set",
+ "regex-automata 0.4.6",
+ "regex-syntax 0.8.2",
+]
+
[[package]]
name = "fancy_constructor"
version = "1.2.2"
@@ -2086,7 +2155,7 @@ dependencies = [
"tracing",
"uuid",
"validator",
- "zip 2.1.3",
+ "zip",
"zip-extensions",
]
@@ -2224,7 +2293,7 @@ dependencies = [
"async-trait",
"bytes",
"chrono",
- "chrono-tz",
+ "chrono-tz 0.8.6",
"collab",
"collab-database",
"collab-entity",
@@ -2349,7 +2418,7 @@ dependencies = [
"base64 0.21.7",
"getrandom 0.2.12",
"hmac",
- "pbkdf2 0.12.2",
+ "pbkdf2",
"rand 0.8.5",
"sha2",
]
@@ -2587,6 +2656,7 @@ dependencies = [
"async-trait",
"bytes",
"chrono",
+ "collab-importer",
"dashmap 6.0.1",
"flowy-codegen",
"flowy-derive",
@@ -3198,7 +3268,7 @@ dependencies = [
[[package]]
name = "gotrue"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"futures-util",
@@ -3215,7 +3285,7 @@ dependencies = [
[[package]]
name = "gotrue-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"app-error",
@@ -3652,7 +3722,7 @@ dependencies = [
[[package]]
name = "infra"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"bytes",
@@ -3956,7 +4026,7 @@ dependencies = [
"tracing",
"validator",
"walkdir",
- "zip 0.6.6",
+ "zip",
]
[[package]]
@@ -4184,9 +4254,9 @@ dependencies = [
[[package]]
name = "markdown"
-version = "1.0.0-alpha.20"
+version = "1.0.0-alpha.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "911a8325e6fb87b89890cd4529a2ab34c2669c026279e61c26b7140a3d821ccb"
+checksum = "a6491e6c702bf7e3b24e769d800746d5f2c06a6c6a2db7992612e0f429029e81"
dependencies = [
"unicode-id",
]
@@ -4829,35 +4899,12 @@ dependencies = [
"regex",
]
-[[package]]
-name = "password-hash"
-version = "0.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700"
-dependencies = [
- "base64ct",
- "rand_core 0.6.4",
- "subtle",
-]
-
[[package]]
name = "pathdiff"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd"
-[[package]]
-name = "pbkdf2"
-version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917"
-dependencies = [
- "digest",
- "hmac",
- "password-hash",
- "sha2",
-]
-
[[package]]
name = "pbkdf2"
version = "0.12.2"
@@ -5849,9 +5896,9 @@ dependencies = [
[[package]]
name = "rust_decimal"
-version = "1.34.3"
+version = "1.36.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b39449a79f45e8da28c57c341891b69a183044b29518bb8f86dbac9df60bb7df"
+checksum = "b082d80e3e3cc52b2ed634388d436fe1f4de6af5786cc2de9ba9737527bdf555"
dependencies = [
"arrayvec",
"borsh",
@@ -6121,18 +6168,18 @@ dependencies = [
[[package]]
name = "serde"
-version = "1.0.202"
+version = "1.0.210"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395"
+checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.202"
+version = "1.0.210"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838"
+checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
dependencies = [
"proc-macro2",
"quote",
@@ -6152,12 +6199,13 @@ dependencies = [
[[package]]
name = "serde_json"
-version = "1.0.118"
+version = "1.0.128"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d947f6b3163d8857ea16c4fa0dd4840d52f3041039a85decd46867eb1abef2e4"
+checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8"
dependencies = [
"indexmap 2.2.6",
"itoa 1.0.10",
+ "memchr",
"ryu",
"serde",
]
@@ -6305,7 +6353,7 @@ dependencies = [
[[package]]
name = "shared-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"app-error",
@@ -6806,7 +6854,7 @@ dependencies = [
"tantivy-bitpacker",
"tantivy-common",
"tantivy-fst",
- "zstd 0.13.2",
+ "zstd",
]
[[package]]
@@ -7146,7 +7194,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "970dff17c11e884a4a09bc76e3a17ef71e01bb13447a11e85226e254fe6d10b8"
dependencies = [
"chrono",
- "chrono-tz",
+ "chrono-tz 0.8.6",
"globwalk",
"humansize",
"lazy_static",
@@ -7188,18 +7236,18 @@ checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c"
[[package]]
name = "thiserror"
-version = "1.0.62"
+version = "1.0.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f2675633b1499176c2dff06b0856a27976a8f9d436737b4cf4f312d4d91d8bbb"
+checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
-version = "1.0.62"
+version = "1.0.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d20468752b09f49e909e55a5d338caa8bedf615594e9d80bc4c565d30faf798c"
+checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3"
dependencies = [
"proc-macro2",
"quote",
@@ -8854,34 +8902,14 @@ dependencies = [
[[package]]
name = "zip"
-version = "0.6.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261"
-dependencies = [
- "aes",
- "byteorder",
- "bzip2",
- "constant_time_eq 0.1.5",
- "crc32fast",
- "crossbeam-utils",
- "flate2",
- "hmac",
- "pbkdf2 0.11.0",
- "sha1",
- "time",
- "zstd 0.11.2+zstd.1.5.2",
-]
-
-[[package]]
-name = "zip"
-version = "2.1.3"
+version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "775a2b471036342aa69bc5a602bc889cb0a06cda00477d0c69566757d5553d39"
+checksum = "dc5e4288ea4057ae23afc69a4472434a87a2495cafce6632fd1c4ec9f5cf3494"
dependencies = [
"aes",
"arbitrary",
"bzip2",
- "constant_time_eq 0.3.0",
+ "constant_time_eq",
"crc32fast",
"crossbeam-utils",
"deflate64",
@@ -8891,14 +8919,14 @@ dependencies = [
"indexmap 2.2.6",
"lzma-rs",
"memchr",
- "pbkdf2 0.12.2",
+ "pbkdf2",
"rand 0.8.5",
"sha1",
"thiserror",
"time",
"zeroize",
"zopfli",
- "zstd 0.13.2",
+ "zstd",
]
[[package]]
@@ -8907,7 +8935,7 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb0a99499b3497d765525c5d05e3ade9ca4a731c184365c19472c3fd6ba86341"
dependencies = [
- "zip 2.1.3",
+ "zip",
]
[[package]]
@@ -8924,32 +8952,13 @@ dependencies = [
"simd-adler32",
]
-[[package]]
-name = "zstd"
-version = "0.11.2+zstd.1.5.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4"
-dependencies = [
- "zstd-safe 5.0.2+zstd.1.5.2",
-]
-
[[package]]
name = "zstd"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcf2b778a664581e31e389454a7072dab1647606d44f7feea22cd5abb9c9f3f9"
dependencies = [
- "zstd-safe 7.2.0",
-]
-
-[[package]]
-name = "zstd-safe"
-version = "5.0.2+zstd.1.5.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db"
-dependencies = [
- "libc",
- "zstd-sys",
+ "zstd-safe",
]
[[package]]
diff --git a/frontend/appflowy_web_app/src-tauri/Cargo.toml b/frontend/appflowy_web_app/src-tauri/Cargo.toml
index 0ff4c0f7ab..81722ebfa9 100644
--- a/frontend/appflowy_web_app/src-tauri/Cargo.toml
+++ b/frontend/appflowy_web_app/src-tauri/Cargo.toml
@@ -58,7 +58,7 @@ collab-importer = { version = "0.1" }
# Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
-client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "4c54481d704bf2f1b5118b4f36add7fb953c0cfc" }
+client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "b023e2f5118897a107f3a6023eb15b2f75389252" }
[dependencies]
serde_json.workspace = true
@@ -118,14 +118,14 @@ custom-protocol = ["tauri/custom-protocol"]
# To switch to the local path, run:
# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
-collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
-collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
-collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
-collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
-collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
-collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
-collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
-collab-importer = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
+collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
+collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
+collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
+collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
+collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
+collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
+collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
+collab-importer = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
# Working directory: frontend
diff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lock
index 07b13f849e..3a8bfec138 100644
--- a/frontend/rust-lib/Cargo.lock
+++ b/frontend/rust-lib/Cargo.lock
@@ -163,7 +163,7 @@ checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
[[package]]
name = "app-error"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"bincode",
@@ -183,7 +183,7 @@ dependencies = [
[[package]]
name = "appflowy-ai-client"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"bytes",
@@ -210,7 +210,7 @@ dependencies = [
"tokio-stream",
"tokio-util",
"tracing",
- "zip 2.1.3",
+ "zip",
"zip-extensions",
]
@@ -276,6 +276,17 @@ dependencies = [
"pin-project-lite",
]
+[[package]]
+name = "async-recursion"
+version = "1.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.47",
+]
+
[[package]]
name = "async-stream"
version = "0.3.5"
@@ -405,12 +416,6 @@ version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
-[[package]]
-name = "base64ct"
-version = "1.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
-
[[package]]
name = "bincode"
version = "1.3.3"
@@ -499,47 +504,26 @@ dependencies = [
[[package]]
name = "borsh"
-version = "0.10.3"
+version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b"
+checksum = "a6362ed55def622cddc70a4746a68554d7b687713770de539e59a739b249f8ed"
dependencies = [
"borsh-derive",
- "hashbrown 0.13.2",
+ "cfg_aliases",
]
[[package]]
name = "borsh-derive"
-version = "0.10.3"
+version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7"
+checksum = "c3ef8005764f53cd4dca619f5bf64cafd4664dada50ece25e4d81de54c80cc0b"
dependencies = [
- "borsh-derive-internal",
- "borsh-schema-derive-internal",
+ "once_cell",
"proc-macro-crate",
- "proc-macro2",
- "syn 1.0.109",
-]
-
-[[package]]
-name = "borsh-derive-internal"
-version = "0.10.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn 1.0.109",
-]
-
-[[package]]
-name = "borsh-schema-derive-internal"
-version = "0.10.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd"
-dependencies = [
"proc-macro2",
"quote",
- "syn 1.0.109",
+ "syn 2.0.47",
+ "syn_derive",
]
[[package]]
@@ -668,11 +652,17 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+[[package]]
+name = "cfg_aliases"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
+
[[package]]
name = "chrono"
-version = "0.4.33"
+version = "0.4.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb"
+checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
dependencies = [
"android-tzdata",
"iana-time-zone",
@@ -690,7 +680,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1369bc6b9e9a7dfdae2055f6ec151fe9c554a9d23d357c0237cee2e25eaabb7"
dependencies = [
"chrono",
- "chrono-tz-build",
+ "chrono-tz-build 0.2.0",
+ "phf 0.11.2",
+]
+
+[[package]]
+name = "chrono-tz"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cd6dd8046d00723a59a2f8c5f295c515b9bb9a331ee4f8f3d4dd49e428acd3b6"
+dependencies = [
+ "chrono",
+ "chrono-tz-build 0.4.0",
"phf 0.11.2",
]
@@ -705,6 +706,16 @@ dependencies = [
"phf_codegen 0.11.2",
]
+[[package]]
+name = "chrono-tz-build"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e94fea34d77a245229e7746bd2beb786cd2a896f306ff491fb8cecb3074b10a7"
+dependencies = [
+ "parse-zoneinfo",
+ "phf_codegen 0.11.2",
+]
+
[[package]]
name = "cipher"
version = "0.4.4"
@@ -729,7 +740,7 @@ dependencies = [
[[package]]
name = "client-api"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"again",
"anyhow",
@@ -781,7 +792,7 @@ dependencies = [
[[package]]
name = "client-api-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"collab-entity",
"collab-rt-entity",
@@ -794,7 +805,7 @@ dependencies = [
[[package]]
name = "client-websocket"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"futures-channel",
"futures-util",
@@ -837,7 +848,7 @@ dependencies = [
[[package]]
name = "collab"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=37a48f51c889adf1482a189400c8ce15ed77b25d#37a48f51c889adf1482a189400c8ce15ed77b25d"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
dependencies = [
"anyhow",
"arc-swap",
@@ -862,24 +873,31 @@ dependencies = [
[[package]]
name = "collab-database"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=37a48f51c889adf1482a189400c8ce15ed77b25d#37a48f51c889adf1482a189400c8ce15ed77b25d"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
dependencies = [
"anyhow",
"async-trait",
+ "base64 0.22.1",
"chrono",
+ "chrono-tz 0.10.0",
"collab",
"collab-entity",
"csv",
"dashmap 5.5.3",
+ "fancy-regex 0.13.0",
"futures",
"getrandom 0.2.10",
"js-sys",
"lazy_static",
"nanoid",
+ "percent-encoding",
"rayon",
+ "rust_decimal",
+ "rusty-money",
"serde",
"serde_json",
"serde_repr",
+ "sha2",
"strum",
"strum_macros 0.25.2",
"thiserror",
@@ -894,7 +912,7 @@ dependencies = [
[[package]]
name = "collab-document"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=37a48f51c889adf1482a189400c8ce15ed77b25d#37a48f51c889adf1482a189400c8ce15ed77b25d"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
dependencies = [
"anyhow",
"arc-swap",
@@ -915,7 +933,7 @@ dependencies = [
[[package]]
name = "collab-entity"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=37a48f51c889adf1482a189400c8ce15ed77b25d#37a48f51c889adf1482a189400c8ce15ed77b25d"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
dependencies = [
"anyhow",
"bytes",
@@ -935,7 +953,7 @@ dependencies = [
[[package]]
name = "collab-folder"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=37a48f51c889adf1482a189400c8ce15ed77b25d#37a48f51c889adf1482a189400c8ce15ed77b25d"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
dependencies = [
"anyhow",
"arc-swap",
@@ -956,9 +974,10 @@ dependencies = [
[[package]]
name = "collab-importer"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=37a48f51c889adf1482a189400c8ce15ed77b25d#37a48f51c889adf1482a189400c8ce15ed77b25d"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
dependencies = [
"anyhow",
+ "async-recursion",
"base64 0.22.1",
"chrono",
"collab",
@@ -980,6 +999,7 @@ dependencies = [
"tracing",
"uuid",
"walkdir",
+ "zip",
]
[[package]]
@@ -1007,7 +1027,7 @@ dependencies = [
[[package]]
name = "collab-plugins"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=37a48f51c889adf1482a189400c8ce15ed77b25d#37a48f51c889adf1482a189400c8ce15ed77b25d"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
dependencies = [
"anyhow",
"async-stream",
@@ -1045,7 +1065,7 @@ dependencies = [
[[package]]
name = "collab-rt-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"bincode",
@@ -1070,7 +1090,7 @@ dependencies = [
[[package]]
name = "collab-rt-protocol"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"async-trait",
@@ -1087,7 +1107,7 @@ dependencies = [
[[package]]
name = "collab-user"
version = "0.2.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=37a48f51c889adf1482a189400c8ce15ed77b25d#37a48f51c889adf1482a189400c8ce15ed77b25d"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=381da6a30c61e0bb7f350703b2538c477b645276#381da6a30c61e0bb7f350703b2538c477b645276"
dependencies = [
"anyhow",
"collab",
@@ -1161,12 +1181,6 @@ dependencies = [
"tracing-subscriber",
]
-[[package]]
-name = "constant_time_eq"
-version = "0.1.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
-
[[package]]
name = "constant_time_eq"
version = "0.3.0"
@@ -1316,7 +1330,7 @@ dependencies = [
"cssparser-macros",
"dtoa-short",
"itoa",
- "phf 0.11.2",
+ "phf 0.8.0",
"smallvec",
]
@@ -1430,7 +1444,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]]
name = "database-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"app-error",
@@ -1460,9 +1474,9 @@ dependencies = [
[[package]]
name = "deflate64"
-version = "0.1.8"
+version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "83ace6c86376be0b6cdcf3fb41882e81d94b31587573d1cfa9d01cd06bba210d"
+checksum = "da692b8d1080ea3045efaab14434d40468c3d8657e42abddfffca87b428f4c1b"
[[package]]
name = "delegate-display"
@@ -1736,7 +1750,7 @@ dependencies = [
"tracing",
"uuid",
"walkdir",
- "zip 2.1.3",
+ "zip",
]
[[package]]
@@ -1921,7 +1935,7 @@ dependencies = [
"tracing-subscriber",
"uuid",
"validator",
- "zip 2.1.3",
+ "zip",
"zip-extensions",
]
@@ -2060,7 +2074,7 @@ dependencies = [
"async-trait",
"bytes",
"chrono",
- "chrono-tz",
+ "chrono-tz 0.8.3",
"collab",
"collab-database",
"collab-entity",
@@ -2189,7 +2203,7 @@ dependencies = [
"base64 0.21.5",
"getrandom 0.2.10",
"hmac",
- "pbkdf2 0.12.2",
+ "pbkdf2",
"rand 0.8.5",
"sha2",
]
@@ -2851,7 +2865,7 @@ dependencies = [
[[package]]
name = "gotrue"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"futures-util",
@@ -2868,7 +2882,7 @@ dependencies = [
[[package]]
name = "gotrue-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"app-error",
@@ -2907,15 +2921,6 @@ dependencies = [
"ahash 0.7.6",
]
-[[package]]
-name = "hashbrown"
-version = "0.13.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
-dependencies = [
- "ahash 0.8.6",
-]
-
[[package]]
name = "hashbrown"
version = "0.14.3"
@@ -3233,7 +3238,7 @@ dependencies = [
[[package]]
name = "infra"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"bytes",
@@ -3435,7 +3440,7 @@ dependencies = [
"tracing",
"validator",
"walkdir",
- "zip 0.6.6",
+ "zip",
]
[[package]]
@@ -3634,9 +3639,9 @@ dependencies = [
[[package]]
name = "markdown"
-version = "1.0.0-alpha.20"
+version = "1.0.0-alpha.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "911a8325e6fb87b89890cd4529a2ab34c2669c026279e61c26b7140a3d821ccb"
+checksum = "a6491e6c702bf7e3b24e769d800746d5f2c06a6c6a2db7992612e0f429029e81"
dependencies = [
"unicode-id",
]
@@ -4119,29 +4124,6 @@ dependencies = [
"regex",
]
-[[package]]
-name = "password-hash"
-version = "0.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700"
-dependencies = [
- "base64ct",
- "rand_core 0.6.4",
- "subtle",
-]
-
-[[package]]
-name = "pbkdf2"
-version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917"
-dependencies = [
- "digest",
- "hmac",
- "password-hash",
- "sha2",
-]
-
[[package]]
name = "pbkdf2"
version = "0.12.2"
@@ -4228,7 +4210,7 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12"
dependencies = [
- "phf_macros 0.8.0",
+ "phf_macros",
"phf_shared 0.8.0",
"proc-macro-hack",
]
@@ -4248,7 +4230,6 @@ version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc"
dependencies = [
- "phf_macros 0.11.2",
"phf_shared 0.11.2",
]
@@ -4316,19 +4297,6 @@ dependencies = [
"syn 1.0.109",
]
-[[package]]
-name = "phf_macros"
-version = "0.11.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b"
-dependencies = [
- "phf_generator 0.11.2",
- "phf_shared 0.11.2",
- "proc-macro2",
- "quote",
- "syn 2.0.47",
-]
-
[[package]]
name = "phf_shared"
version = "0.8.0"
@@ -4474,11 +4442,11 @@ dependencies = [
[[package]]
name = "proc-macro-crate"
-version = "0.1.5"
+version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785"
+checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284"
dependencies = [
- "toml 0.5.11",
+ "toml_edit 0.21.1",
]
[[package]]
@@ -5142,9 +5110,9 @@ dependencies = [
[[package]]
name = "rust_decimal"
-version = "1.32.0"
+version = "1.36.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a4c4216490d5a413bc6d10fa4742bd7d4955941d062c0ef873141d6b0e7b30fd"
+checksum = "b082d80e3e3cc52b2ed634388d436fe1f4de6af5786cc2de9ba9737527bdf555"
dependencies = [
"arrayvec",
"borsh",
@@ -5526,7 +5494,7 @@ dependencies = [
[[package]]
name = "shared-entity"
version = "0.1.0"
-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=4c54481d704bf2f1b5118b4f36add7fb953c0cfc#4c54481d704bf2f1b5118b4f36add7fb953c0cfc"
+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=b023e2f5118897a107f3a6023eb15b2f75389252#b023e2f5118897a107f3a6023eb15b2f75389252"
dependencies = [
"anyhow",
"app-error",
@@ -5803,6 +5771,18 @@ dependencies = [
"unicode-ident",
]
+[[package]]
+name = "syn_derive"
+version = "0.1.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b"
+dependencies = [
+ "proc-macro-error",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.47",
+]
+
[[package]]
name = "sync_wrapper"
version = "0.1.2"
@@ -5969,7 +5949,7 @@ dependencies = [
"tantivy-bitpacker",
"tantivy-common",
"tantivy-fst",
- "zstd 0.13.2",
+ "zstd",
]
[[package]]
@@ -6038,7 +6018,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "970dff17c11e884a4a09bc76e3a17ef71e01bb13447a11e85226e254fe6d10b8"
dependencies = [
"chrono",
- "chrono-tz",
+ "chrono-tz 0.8.3",
"globwalk",
"humansize",
"lazy_static",
@@ -6065,18 +6045,18 @@ dependencies = [
[[package]]
name = "thiserror"
-version = "1.0.61"
+version = "1.0.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709"
+checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
-version = "1.0.61"
+version = "1.0.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533"
+checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3"
dependencies = [
"proc-macro2",
"quote",
@@ -6309,7 +6289,7 @@ dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
- "toml_edit",
+ "toml_edit 0.19.15",
]
[[package]]
@@ -6334,6 +6314,17 @@ dependencies = [
"winnow",
]
+[[package]]
+name = "toml_edit"
+version = "0.21.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1"
+dependencies = [
+ "indexmap 2.1.0",
+ "toml_datetime",
+ "winnow",
+]
+
[[package]]
name = "tonic"
version = "0.10.2"
@@ -7257,34 +7248,14 @@ dependencies = [
[[package]]
name = "zip"
-version = "0.6.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261"
-dependencies = [
- "aes",
- "byteorder",
- "bzip2",
- "constant_time_eq 0.1.5",
- "crc32fast",
- "crossbeam-utils",
- "flate2",
- "hmac",
- "pbkdf2 0.11.0",
- "sha1",
- "time",
- "zstd 0.11.2+zstd.1.5.2",
-]
-
-[[package]]
-name = "zip"
-version = "2.1.3"
+version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "775a2b471036342aa69bc5a602bc889cb0a06cda00477d0c69566757d5553d39"
+checksum = "dc5e4288ea4057ae23afc69a4472434a87a2495cafce6632fd1c4ec9f5cf3494"
dependencies = [
"aes",
"arbitrary",
"bzip2",
- "constant_time_eq 0.3.0",
+ "constant_time_eq",
"crc32fast",
"crossbeam-utils",
"deflate64",
@@ -7294,14 +7265,14 @@ dependencies = [
"indexmap 2.1.0",
"lzma-rs",
"memchr",
- "pbkdf2 0.12.2",
+ "pbkdf2",
"rand 0.8.5",
"sha1",
"thiserror",
"time",
"zeroize",
"zopfli",
- "zstd 0.13.2",
+ "zstd",
]
[[package]]
@@ -7310,7 +7281,7 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb0a99499b3497d765525c5d05e3ade9ca4a731c184365c19472c3fd6ba86341"
dependencies = [
- "zip 2.1.3",
+ "zip",
]
[[package]]
@@ -7327,32 +7298,13 @@ dependencies = [
"simd-adler32",
]
-[[package]]
-name = "zstd"
-version = "0.11.2+zstd.1.5.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4"
-dependencies = [
- "zstd-safe 5.0.2+zstd.1.5.2",
-]
-
[[package]]
name = "zstd"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcf2b778a664581e31e389454a7072dab1647606d44f7feea22cd5abb9c9f3f9"
dependencies = [
- "zstd-safe 7.2.0",
-]
-
-[[package]]
-name = "zstd-safe"
-version = "5.0.2+zstd.1.5.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db"
-dependencies = [
- "libc",
- "zstd-sys",
+ "zstd-safe",
]
[[package]]
diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.toml
index 4ccf244d2d..a980702d2e 100644
--- a/frontend/rust-lib/Cargo.toml
+++ b/frontend/rust-lib/Cargo.toml
@@ -98,7 +98,7 @@ collab-importer = { version = "0.1" }
yrs = "0.21.0"
validator = { version = "0.16.1", features = ["derive"] }
tokio-util = "0.7.11"
-zip = "2.1.3"
+zip = "2.2.0"
dashmap = "6.0.1"
# Please using the following command to update the revision id
@@ -106,8 +106,8 @@ dashmap = "6.0.1"
# Run the script.add_workspace_members:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
-client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "4c54481d704bf2f1b5118b4f36add7fb953c0cfc" }
-client-api-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "4c54481d704bf2f1b5118b4f36add7fb953c0cfc" }
+client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "b023e2f5118897a107f3a6023eb15b2f75389252" }
+client-api-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "b023e2f5118897a107f3a6023eb15b2f75389252" }
[profile.dev]
opt-level = 0
@@ -142,14 +142,14 @@ rocksdb = { git = "https://github.com/rust-rocksdb/rust-rocksdb", rev = "1710120
# To switch to the local path, run:
# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
-collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
-collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
-collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
-collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
-collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
-collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
-collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
-collab-importer = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "37a48f51c889adf1482a189400c8ce15ed77b25d" }
+collab = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
+collab-entity = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
+collab-folder = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
+collab-document = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
+collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
+collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
+collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
+collab-importer = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "381da6a30c61e0bb7f350703b2538c477b645276" }
# Working directory: frontend
# To update the commit ID, run:
diff --git a/frontend/rust-lib/event-integration-test/src/database_event.rs b/frontend/rust-lib/event-integration-test/src/database_event.rs
index 43ecb1c1ce..3aecfba5d7 100644
--- a/frontend/rust-lib/event-integration-test/src/database_event.rs
+++ b/frontend/rust-lib/event-integration-test/src/database_event.rs
@@ -3,13 +3,14 @@ use std::convert::TryFrom;
use bytes::Bytes;
use collab_database::database::timestamp;
-use collab_database::entity::SelectOption;
+use collab_database::fields::select_type_option::{
+ MultiSelectTypeOption, SelectOption, SingleSelectTypeOption,
+};
use collab_database::fields::Field;
use collab_database::rows::{Row, RowId};
use flowy_database2::entities::*;
use flowy_database2::event_map::DatabaseEvent;
use flowy_database2::services::cell::CellBuilder;
-use flowy_database2::services::field::{MultiSelectTypeOption, SingleSelectTypeOption};
use flowy_database2::services::share::csv::CSVFormat;
use flowy_folder::entities::*;
use flowy_folder::event_map::FolderEvent;
@@ -624,7 +625,8 @@ impl<'a> TestRowBuilder<'a> {
let single_select_field = self.field_with_type(&FieldType::SingleSelect);
let type_option = single_select_field
.get_type_option::<SingleSelectTypeOption>(FieldType::SingleSelect)
- .unwrap();
+ .unwrap()
+ .0;
let option = f(type_option.options);
self
.cell_build
@@ -640,7 +642,8 @@ impl<'a> TestRowBuilder<'a> {
let multi_select_field = self.field_with_type(&FieldType::MultiSelect);
let type_option = multi_select_field
.get_type_option::<MultiSelectTypeOption>(FieldType::MultiSelect)
- .unwrap();
+ .unwrap()
+ .0;
let options = f(type_option.options);
let ops_ids = options
.iter()
diff --git a/frontend/rust-lib/event-integration-test/tests/database/af_cloud/util.rs b/frontend/rust-lib/event-integration-test/tests/database/af_cloud/util.rs
index 92d17c2805..962d5dd268 100644
--- a/frontend/rust-lib/event-integration-test/tests/database/af_cloud/util.rs
+++ b/frontend/rust-lib/event-integration-test/tests/database/af_cloud/util.rs
@@ -1,16 +1,18 @@
use collab_database::database::{gen_database_id, gen_database_view_id, gen_row_id, DatabaseData};
-use collab_database::entity::{DatabaseView, SelectOption, SelectOptionColor};
+use collab_database::entity::DatabaseView;
use collab_database::views::DatabaseLayout;
use event_integration_test::database_event::TestRowBuilder;
+use collab_database::fields::number_type_option::{NumberFormat, NumberTypeOption};
+use collab_database::fields::select_type_option::{
+ SelectOption, SelectOptionColor, SingleSelectTypeOption,
+};
use collab_database::fields::Field;
use collab_database::rows::Row;
use flowy_database2::entities::FieldType;
use flowy_database2::services::field::summary_type_option::summary::SummarizationTypeOption;
use flowy_database2::services::field::translate_type_option::translate::TranslateTypeOption;
-use flowy_database2::services::field::{
- FieldBuilder, NumberFormat, NumberTypeOption, SingleSelectTypeOption,
-};
+use flowy_database2::services::field::FieldBuilder;
use flowy_database2::services::field_settings::default_field_settings_for_fields;
use strum::IntoEnumIterator;
@@ -29,7 +31,7 @@ pub fn make_test_summary_grid() -> DatabaseData {
.type_options
.get(&FieldType::SingleSelect.to_string())
.cloned()
- .map(|t| SingleSelectTypeOption::from(t).options)
+ .map(|t| SingleSelectTypeOption::from(t).0.options)
.unwrap();
let rows = create_rows(&database_id, &fields, options);
diff --git a/frontend/rust-lib/flowy-ai/src/chat.rs b/frontend/rust-lib/flowy-ai/src/chat.rs
index 494a8f3980..9042642a9d 100644
--- a/frontend/rust-lib/flowy-ai/src/chat.rs
+++ b/frontend/rust-lib/flowy-ai/src/chat.rs
@@ -158,7 +158,7 @@ impl Chat {
match message {
Ok(message) => {
if stop_stream.load(std::sync::atomic::Ordering::Relaxed) {
- trace!("[Chat] stop streaming message");
+ trace!("[Chat] client stop streaming message");
break;
}
match message {
@@ -190,7 +190,7 @@ impl Chat {
}
},
Err(err) => {
- error!("[Chat] failed to stream answer: {}", err);
+ error!("[Chat] failed to start streaming: {}", err);
if err.is_ai_response_limit_exceeded() {
let _ = answer_sink.send("AI_RESPONSE_LIMIT".to_string()).await;
} else {
diff --git a/frontend/rust-lib/flowy-database2/src/entities/file_entities.rs b/frontend/rust-lib/flowy-database2/src/entities/file_entities.rs
index 191d4bb614..6c2b0bd5ec 100644
--- a/frontend/rust-lib/flowy-database2/src/entities/file_entities.rs
+++ b/frontend/rust-lib/flowy-database2/src/entities/file_entities.rs
@@ -1,4 +1,5 @@
use collab_database::entity::FileUploadType;
+use collab_database::fields::media_type_option::MediaUploadType;
use flowy_derive::ProtoBuf_Enum;
use serde::{Deserialize, Serialize};
@@ -11,6 +12,26 @@ pub enum FileUploadTypePB {
CloudFile = 2,
}
+impl From<FileUploadTypePB> for MediaUploadType {
+ fn from(file_upload_type: FileUploadTypePB) -> Self {
+ match file_upload_type {
+ FileUploadTypePB::LocalFile => MediaUploadType::Local,
+ FileUploadTypePB::NetworkFile => MediaUploadType::Network,
+ FileUploadTypePB::CloudFile => MediaUploadType::Cloud,
+ }
+ }
+}
+
+impl From<MediaUploadType> for FileUploadTypePB {
+ fn from(file_upload_type: MediaUploadType) -> Self {
+ match file_upload_type {
+ MediaUploadType::Local => FileUploadTypePB::LocalFile,
+ MediaUploadType::Network => FileUploadTypePB::NetworkFile,
+ MediaUploadType::Cloud => FileUploadTypePB::CloudFile,
+ }
+ }
+}
+
impl From<FileUploadType> for FileUploadTypePB {
fn from(data: FileUploadType) -> Self {
match data {
diff --git a/frontend/rust-lib/flowy-database2/src/entities/filter_entities/select_option_filter.rs b/frontend/rust-lib/flowy-database2/src/entities/filter_entities/select_option_filter.rs
index 1643116ccb..3c1c5f9a3e 100644
--- a/frontend/rust-lib/flowy-database2/src/entities/filter_entities/select_option_filter.rs
+++ b/frontend/rust-lib/flowy-database2/src/entities/filter_entities/select_option_filter.rs
@@ -1,9 +1,9 @@
-use std::str::FromStr;
-
+use collab_database::fields::select_type_option::SelectOptionIds;
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
use flowy_error::ErrorCode;
+use std::str::FromStr;
-use crate::services::{field::SelectOptionIds, filter::ParseFilterData};
+use crate::services::filter::ParseFilterData;
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone)]
pub struct SelectOptionFilterPB {
diff --git a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/checkbox_entities.rs b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/checkbox_entities.rs
index d6d4f84a8a..3df44f4ec0 100644
--- a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/checkbox_entities.rs
+++ b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/checkbox_entities.rs
@@ -1,4 +1,4 @@
-use crate::services::field::CheckboxTypeOption;
+use collab_database::fields::checkbox_type_option::CheckboxTypeOption;
use flowy_derive::ProtoBuf;
#[derive(Default, Debug, Clone, ProtoBuf)]
@@ -28,6 +28,6 @@ impl From<CheckboxTypeOption> for CheckboxTypeOptionPB {
impl From<CheckboxTypeOptionPB> for CheckboxTypeOption {
fn from(_type_option: CheckboxTypeOptionPB) -> Self {
- Self()
+ CheckboxTypeOption
}
}
diff --git a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/checklist_entities.rs b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/checklist_entities.rs
index 64f0acdecb..fe9c665223 100644
--- a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/checklist_entities.rs
+++ b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/checklist_entities.rs
@@ -1,4 +1,4 @@
-use collab_database::entity::SelectOption;
+use collab_database::fields::select_type_option::SelectOption;
use collab_database::rows::RowId;
use flowy_derive::ProtoBuf;
diff --git a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/date_entities.rs b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/date_entities.rs
index 5fdb0195ef..3085e74aff 100644
--- a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/date_entities.rs
+++ b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/date_entities.rs
@@ -1,11 +1,13 @@
#![allow(clippy::upper_case_acronyms)]
+use collab_database::fields::date_type_option::{
+ DateCellData, DateFormat, DateTypeOption, TimeFormat,
+};
use strum_macros::EnumIter;
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
use crate::entities::CellIdPB;
-use crate::services::field::{DateFormat, DateTypeOption, TimeFormat};
#[derive(Clone, Debug, Default, ProtoBuf)]
pub struct DateCellDataPB {
@@ -36,6 +38,17 @@ pub struct DateCellDataPB {
#[pb(index = 9)]
pub reminder_id: String,
}
+impl From<&DateCellDataPB> for DateCellData {
+ fn from(data: &DateCellDataPB) -> Self {
+ Self {
+ timestamp: Some(data.timestamp),
+ end_timestamp: Some(data.end_timestamp),
+ include_time: data.include_time,
+ is_range: data.is_range,
+ reminder_id: data.reminder_id.to_owned(),
+ }
+ }
+}
#[derive(Clone, Debug, Default, ProtoBuf)]
pub struct DateCellChangesetPB {
@@ -108,6 +121,7 @@ pub enum DateFormatPB {
#[default]
Friendly = 3,
DayMonthYear = 4,
+ FriendlyFull = 5,
}
impl From<DateFormatPB> for DateFormat {
@@ -118,6 +132,7 @@ impl From<DateFormatPB> for DateFormat {
DateFormatPB::ISO => DateFormat::ISO,
DateFormatPB::Friendly => DateFormat::Friendly,
DateFormatPB::DayMonthYear => DateFormat::DayMonthYear,
+ DateFormatPB::FriendlyFull => DateFormat::FriendlyFull,
}
}
}
@@ -130,6 +145,7 @@ impl From<DateFormat> for DateFormatPB {
DateFormat::ISO => DateFormatPB::ISO,
DateFormat::Friendly => DateFormatPB::Friendly,
DateFormat::DayMonthYear => DateFormatPB::DayMonthYear,
+ DateFormat::FriendlyFull => DateFormatPB::FriendlyFull,
}
}
}
diff --git a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/media_entities.rs b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/media_entities.rs
index b85eab1e93..e337dca57a 100644
--- a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/media_entities.rs
+++ b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/media_entities.rs
@@ -1,9 +1,9 @@
+use collab_database::fields::media_type_option::{
+ MediaCellData, MediaFile, MediaFileType, MediaTypeOption,
+};
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
-use crate::{
- entities::{CellIdPB, FileUploadTypePB},
- services::field::{MediaCellData, MediaFile, MediaFileType},
-};
+use crate::entities::{CellIdPB, FileUploadTypePB};
#[derive(Debug, Clone, Default, ProtoBuf)]
pub struct MediaCellDataPB {
@@ -33,6 +33,22 @@ pub struct MediaTypeOptionPB {
pub hide_file_names: bool,
}
+impl From<MediaTypeOption> for MediaTypeOptionPB {
+ fn from(value: MediaTypeOption) -> Self {
+ Self {
+ hide_file_names: value.hide_file_names,
+ }
+ }
+}
+
+impl From<MediaTypeOptionPB> for MediaTypeOption {
+ fn from(value: MediaTypeOptionPB) -> Self {
+ Self {
+ hide_file_names: value.hide_file_names,
+ }
+ }
+}
+
#[derive(Debug, Clone, Default, ProtoBuf)]
pub struct MediaFilePB {
#[pb(index = 1)]
diff --git a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/number_entities.rs b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/number_entities.rs
index 3b7a301851..bb34178cd7 100644
--- a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/number_entities.rs
+++ b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/number_entities.rs
@@ -1,4 +1,4 @@
-use crate::services::field::{NumberFormat, NumberTypeOption};
+use collab_database::fields::number_type_option::{NumberFormat, NumberTypeOption};
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
// Number
diff --git a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/select_option_entities.rs b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/select_option_entities.rs
index 367cad385d..7f8fb55485 100644
--- a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/select_option_entities.rs
+++ b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/select_option_entities.rs
@@ -1,8 +1,9 @@
use crate::entities::parser::NotEmptyStr;
use crate::entities::{CellIdPB, CellIdParams};
use crate::services::field::checklist_type_option::ChecklistTypeOption;
-use crate::services::field::{MultiSelectTypeOption, SingleSelectTypeOption};
-use collab_database::entity::{SelectOption, SelectOptionColor};
+use collab_database::fields::select_type_option::{
+ MultiSelectTypeOption, SelectOption, SelectOptionColor, SelectTypeOption, SingleSelectTypeOption,
+};
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
use flowy_error::ErrorCode;
@@ -211,8 +212,8 @@ pub struct SingleSelectTypeOptionPB {
pub disable_color: bool,
}
-impl From<SingleSelectTypeOption> for SingleSelectTypeOptionPB {
- fn from(data: SingleSelectTypeOption) -> Self {
+impl From<SelectTypeOption> for SingleSelectTypeOptionPB {
+ fn from(data: SelectTypeOption) -> Self {
Self {
options: data
.options
@@ -226,14 +227,14 @@ impl From<SingleSelectTypeOption> for SingleSelectTypeOptionPB {
impl From<SingleSelectTypeOptionPB> for SingleSelectTypeOption {
fn from(data: SingleSelectTypeOptionPB) -> Self {
- Self {
+ SingleSelectTypeOption(SelectTypeOption {
options: data
.options
.into_iter()
.map(|option| option.into())
.collect(),
disable_color: data.disable_color,
- }
+ })
}
}
@@ -246,8 +247,8 @@ pub struct MultiSelectTypeOptionPB {
pub disable_color: bool,
}
-impl From<MultiSelectTypeOption> for MultiSelectTypeOptionPB {
- fn from(data: MultiSelectTypeOption) -> Self {
+impl From<SelectTypeOption> for MultiSelectTypeOptionPB {
+ fn from(data: SelectTypeOption) -> Self {
Self {
options: data
.options
@@ -261,14 +262,14 @@ impl From<MultiSelectTypeOption> for MultiSelectTypeOptionPB {
impl From<MultiSelectTypeOptionPB> for MultiSelectTypeOption {
fn from(data: MultiSelectTypeOptionPB) -> Self {
- Self {
+ MultiSelectTypeOption(SelectTypeOption {
options: data
.options
.into_iter()
.map(|option| option.into())
.collect(),
disable_color: data.disable_color,
- }
+ })
}
}
diff --git a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/text_entities.rs b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/text_entities.rs
index cce32dc64a..5a61fe5410 100644
--- a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/text_entities.rs
+++ b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/text_entities.rs
@@ -1,4 +1,4 @@
-use crate::services::field::RichTextTypeOption;
+use collab_database::fields::text_type_option::RichTextTypeOption;
use flowy_derive::ProtoBuf;
#[derive(Debug, Clone, Default, ProtoBuf)]
@@ -8,13 +8,15 @@ pub struct RichTextTypeOptionPB {
}
impl From<RichTextTypeOption> for RichTextTypeOptionPB {
- fn from(data: RichTextTypeOption) -> Self {
- Self { data: data.inner }
+ fn from(_data: RichTextTypeOption) -> Self {
+ RichTextTypeOptionPB {
+ data: "".to_string(),
+ }
}
}
impl From<RichTextTypeOptionPB> for RichTextTypeOption {
- fn from(data: RichTextTypeOptionPB) -> Self {
- Self { inner: data.data }
+ fn from(_data: RichTextTypeOptionPB) -> Self {
+ RichTextTypeOption
}
}
diff --git a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/time_entities.rs b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/time_entities.rs
index fdb3bdb6fd..c699b1ca67 100644
--- a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/time_entities.rs
+++ b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/time_entities.rs
@@ -1,4 +1,4 @@
-use crate::services::field::TimeTypeOption;
+use collab_database::fields::date_type_option::TimeTypeOption;
use flowy_derive::ProtoBuf;
#[derive(Clone, Debug, Default, ProtoBuf)]
diff --git a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/timestamp_entities.rs b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/timestamp_entities.rs
index b4afcadaf4..16cc1b2bbf 100644
--- a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/timestamp_entities.rs
+++ b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/timestamp_entities.rs
@@ -1,7 +1,7 @@
+use collab_database::fields::timestamp_type_option::TimestampTypeOption;
use flowy_derive::ProtoBuf;
use crate::entities::{DateFormatPB, FieldType, TimeFormatPB};
-use crate::services::field::TimestampTypeOption;
#[derive(Clone, Debug, Default, ProtoBuf)]
pub struct TimestampCellDataPB {
@@ -33,7 +33,7 @@ impl From<TimestampTypeOption> for TimestampTypeOptionPB {
date_format: data.date_format.into(),
time_format: data.time_format.into(),
include_time: data.include_time,
- field_type: data.field_type,
+ field_type: data.field_type.into(),
}
}
}
@@ -44,7 +44,7 @@ impl From<TimestampTypeOptionPB> for TimestampTypeOption {
date_format: data.date_format.into(),
time_format: data.time_format.into(),
include_time: data.include_time,
- field_type: data.field_type,
+ field_type: data.field_type.into(),
}
}
}
diff --git a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/url_entities.rs b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/url_entities.rs
index 1a14299d01..727c4ce759 100644
--- a/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/url_entities.rs
+++ b/frontend/rust-lib/flowy-database2/src/entities/type_option_entities/url_entities.rs
@@ -1,4 +1,4 @@
-use crate::services::field::URLTypeOption;
+use collab_database::fields::url_type_option::URLTypeOption;
use flowy_derive::ProtoBuf;
#[derive(Clone, Debug, Default, ProtoBuf)]
diff --git a/frontend/rust-lib/flowy-database2/src/event_handler.rs b/frontend/rust-lib/flowy-database2/src/event_handler.rs
index 18df36e875..6aaa11f830 100644
--- a/frontend/rust-lib/flowy-database2/src/event_handler.rs
+++ b/frontend/rust-lib/flowy-database2/src/event_handler.rs
@@ -1,3 +1,4 @@
+use collab_database::fields::media_type_option::MediaCellData;
use collab_database::rows::{Cell, CoverType, RowCover, RowId};
use lib_infra::box_any::BoxAny;
use std::sync::{Arc, Weak};
@@ -10,8 +11,8 @@ use lib_dispatch::prelude::{af_spawn, data_result_ok, AFPluginData, AFPluginStat
use crate::entities::*;
use crate::manager::DatabaseManager;
use crate::services::field::{
- type_option_data_from_pb, ChecklistCellChangeset, DateCellChangeset, MediaCellData,
- RelationCellChangeset, SelectOptionCellChangeset, TypeOptionCellExt,
+ type_option_data_from_pb, ChecklistCellChangeset, DateCellChangeset, RelationCellChangeset,
+ SelectOptionCellChangeset, TypeOptionCellExt,
};
use crate::services::group::GroupChangeset;
use crate::services::share::csv::CSVFormat;
@@ -1352,6 +1353,7 @@ pub(crate) async fn update_media_cell_handler(
let row_meta = database_editor
.get_row_meta(&cell_id.view_id, &cell_id.row_id)
.await;
+
if let (Some(row_meta), Some(file)) = (row_meta, image_file) {
let row_meta = row_meta.clone();
if row_meta.cover.is_none() {
@@ -1445,7 +1447,7 @@ pub(crate) async fn rename_media_cell_file_handler(
&cell_id.view_id,
&cell_id.row_id,
&cell_id.field_id,
- Cell::from(&new_data),
+ Cell::from(new_data),
)
.await;
diff --git a/frontend/rust-lib/flowy-database2/src/services/cell/cell_operation.rs b/frontend/rust-lib/flowy-database2/src/services/cell/cell_operation.rs
index dd60832681..be608749d4 100644
--- a/frontend/rust-lib/flowy-database2/src/services/cell/cell_operation.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/cell/cell_operation.rs
@@ -1,6 +1,8 @@
use std::collections::HashMap;
use std::str::FromStr;
+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};
@@ -260,7 +262,7 @@ impl<'a> CellBuilder<'a> {
cells.insert(field_id, (&RelationCellData::from(cell_str)).into());
},
FieldType::Media => {
- cells.insert(field_id, (&MediaCellData::from(cell_str)).into());
+ cells.insert(field_id, MediaCellData::from(cell_str).into());
},
}
}
diff --git a/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs b/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs
index e96366b5a0..134740d672 100644
--- a/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs
@@ -10,9 +10,8 @@ use crate::services::database_view::{
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,
- ChecklistCellChangeset, MediaCellData, RelationTypeOption, SelectOptionCellChangeset,
- StringCellData, TimestampCellData, TimestampCellDataWrapper, TypeOptionCellDataHandler,
- TypeOptionCellExt,
+ ChecklistCellChangeset, RelationTypeOption, SelectOptionCellChangeset, StringCellData,
+ TimestampCellData, TimestampCellDataWrapper, TypeOptionCellDataHandler, TypeOptionCellExt,
};
use crate::services::field_settings::{default_field_settings_by_layout_map, FieldSettings};
use crate::services::filter::{Filter, FilterChangeset};
@@ -27,6 +26,7 @@ use collab::core::collab_plugin::CollabPluginType;
use collab::lock::RwLock;
use collab_database::database::Database;
use collab_database::entity::DatabaseView;
+use collab_database::fields::media_type_option::MediaCellData;
use collab_database::fields::{Field, TypeOptionData};
use collab_database::rows::{Cell, Cells, DatabaseRow, Row, RowCell, RowDetail, RowId, RowUpdate};
use collab_database::views::{
diff --git a/frontend/rust-lib/flowy-database2/src/services/database_view/layout_deps.rs b/frontend/rust-lib/flowy-database2/src/services/database_view/layout_deps.rs
index fa2d58fbae..9316726663 100644
--- a/frontend/rust-lib/flowy-database2/src/services/database_view/layout_deps.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/database_view/layout_deps.rs
@@ -1,16 +1,16 @@
+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::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,
};
use std::sync::Arc;
-use crate::entities::FieldType;
-use crate::services::field::{DateTypeOption, SingleSelectTypeOption};
-use crate::services::field_settings::default_field_settings_by_layout_map;
-use crate::services::setting::{BoardLayoutSetting, CalendarLayoutSetting};
-
/// When creating a database, we need to resolve the dependencies of the views.
/// Different database views have different dependencies. For example, a board
/// view depends on a field that can be used to group rows while a calendar view
@@ -151,27 +151,3 @@ impl DatabaseLayoutDepsResolver {
.with_type_option_data(field_type, default_select_type_option.into())
}
}
-
-// pub async fn v_get_layout_settings(&self, layout_ty: &DatabaseLayout) -> LayoutSettingParams {
-// let mut layout_setting = LayoutSettingParams::default();
-// match layout_ty {
-// DatabaseLayout::Grid => {},
-// DatabaseLayout::Board => {},
-// DatabaseLayout::Calendar => {
-// if let Some(value) = self.delegate.get_layout_setting(&self.view_id, layout_ty) {
-// let calendar_setting = CalendarLayoutSetting::from(value);
-// // Check the field exist or not
-// if let Some(field) = self.delegate.get_field(&calendar_setting.field_id).await {
-// let field_type = FieldType::from(field.field_type);
-//
-// // Check the type of field is Datetime or not
-// if field_type == FieldType::DateTime {
-// layout_setting.calendar = Some(calendar_setting);
-// }
-// }
-// }
-// },
-// }
-//
-// layout_setting
-// }
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/field_operation.rs b/frontend/rust-lib/flowy-database2/src/services/field/field_operation.rs
index 758b32dfa5..b5f4841393 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/field_operation.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/field_operation.rs
@@ -1,10 +1,10 @@
-use std::sync::Arc;
-
+use collab_database::fields::select_type_option::{MultiSelectTypeOption, SingleSelectTypeOption};
use flowy_error::{FlowyError, FlowyResult};
+use std::sync::Arc;
use crate::entities::FieldType;
use crate::services::database::DatabaseEditor;
-use crate::services::field::{MultiSelectTypeOption, SingleSelectTypeOption, TypeOption};
+use crate::services::field::TypeOption;
pub async fn edit_field_type_option<T: TypeOption>(
field_id: &str,
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_option_transform.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_option_transform.rs
index 2b359983c4..f630738807 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_option_transform.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_option_transform.rs
@@ -1,13 +1,17 @@
use crate::entities::FieldType;
use crate::services::field::summary_type_option::summary::SummarizationTypeOption;
use crate::services::field::translate_type_option::translate::TranslateTypeOption;
-use crate::services::field::{
- CheckboxTypeOption, ChecklistTypeOption, DateTypeOption, MediaTypeOption, MultiSelectTypeOption,
- NumberTypeOption, RelationTypeOption, RichTextTypeOption, SingleSelectTypeOption, TimeTypeOption,
- TimestampTypeOption, TypeOptionTransform, URLTypeOption,
-};
+use crate::services::field::{ChecklistTypeOption, RelationTypeOption, TypeOptionTransform};
use async_trait::async_trait;
use collab_database::database::Database;
+use collab_database::fields::checkbox_type_option::CheckboxTypeOption;
+use collab_database::fields::date_type_option::{DateTypeOption, TimeTypeOption};
+use collab_database::fields::media_type_option::MediaTypeOption;
+use collab_database::fields::number_type_option::NumberTypeOption;
+use collab_database::fields::select_type_option::{MultiSelectTypeOption, SingleSelectTypeOption};
+use collab_database::fields::text_type_option::RichTextTypeOption;
+use collab_database::fields::timestamp_type_option::TimestampTypeOption;
+use collab_database::fields::url_type_option::URLTypeOption;
use collab_database::fields::TypeOptionData;
pub async fn transform_type_option(
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/checkbox_type_option/checkbox_tests.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/checkbox_type_option/checkbox_tests.rs
index 3003357dea..2746658e3a 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/checkbox_type_option/checkbox_tests.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/checkbox_type_option/checkbox_tests.rs
@@ -9,10 +9,11 @@ mod tests {
use crate::services::cell::CellDataDecoder;
use crate::services::field::type_options::checkbox_type_option::*;
use crate::services::field::FieldBuilder;
+ use collab_database::fields::checkbox_type_option::CheckboxTypeOption;
#[test]
fn checkout_box_description_test() {
- let type_option = CheckboxTypeOption::default();
+ let type_option = CheckboxTypeOption;
let field_type = FieldType::Checkbox;
let field_rev = FieldBuilder::from_field_type(field_type).build();
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/checkbox_type_option/checkbox_type_option.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/checkbox_type_option/checkbox_type_option.rs
index ea448d76aa..4029f5f3c7 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/checkbox_type_option/checkbox_type_option.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/checkbox_type_option/checkbox_type_option.rs
@@ -1,9 +1,9 @@
use std::cmp::Ordering;
use std::str::FromStr;
-use collab_database::fields::{Field, TypeOptionData, TypeOptionDataBuilder};
+use collab_database::fields::checkbox_type_option::CheckboxTypeOption;
+use collab_database::fields::Field;
use collab_database::rows::Cell;
-use serde::{Deserialize, Serialize};
use flowy_error::FlowyResult;
@@ -15,9 +15,6 @@ use crate::services::field::{
};
use crate::services::sort::SortCondition;
-#[derive(Debug, Clone, Serialize, Deserialize, Default)]
-pub struct CheckboxTypeOption();
-
impl TypeOption for CheckboxTypeOption {
type CellData = CheckboxCellDataPB;
type CellChangeset = CheckboxCellChangeset;
@@ -27,18 +24,6 @@ impl TypeOption for CheckboxTypeOption {
impl TypeOptionTransform for CheckboxTypeOption {}
-impl From<TypeOptionData> for CheckboxTypeOption {
- fn from(_data: TypeOptionData) -> Self {
- Self()
- }
-}
-
-impl From<CheckboxTypeOption> for TypeOptionData {
- fn from(_data: CheckboxTypeOption) -> Self {
- TypeOptionDataBuilder::new()
- }
-}
-
impl TypeOptionCellDataSerde for CheckboxTypeOption {
fn protobuf_encode(
&self,
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/checklist_type_option/checklist.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/checklist_type_option/checklist.rs
index e6fa1ecc87..70106ab453 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/checklist_type_option/checklist.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/checklist_type_option/checklist.rs
@@ -1,17 +1,16 @@
-use collab_database::entity::SelectOption;
-use collab_database::fields::{TypeOptionData, TypeOptionDataBuilder};
-use collab_database::rows::Cell;
-use flowy_error::FlowyResult;
-use std::cmp::Ordering;
-
use crate::entities::{ChecklistCellDataPB, ChecklistFilterPB, SelectOptionPB};
use crate::services::cell::{CellDataChangeset, CellDataDecoder};
use crate::services::field::checklist_type_option::{ChecklistCellChangeset, ChecklistCellData};
use crate::services::field::{
TypeOption, TypeOptionCellData, TypeOptionCellDataCompare, TypeOptionCellDataFilter,
- TypeOptionCellDataSerde, TypeOptionTransform, SELECTION_IDS_SEPARATOR,
+ TypeOptionCellDataSerde, TypeOptionTransform,
};
use crate::services::sort::SortCondition;
+use collab_database::fields::select_type_option::{SelectOption, SELECTION_IDS_SEPARATOR};
+use collab_database::fields::{TypeOptionData, TypeOptionDataBuilder};
+use collab_database::rows::Cell;
+use flowy_error::FlowyResult;
+use std::cmp::Ordering;
#[derive(Debug, Clone, Default)]
pub struct ChecklistTypeOption;
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/checklist_type_option/checklist_entities.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/checklist_type_option/checklist_entities.rs
index 2aeb061469..938e16e25d 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/checklist_type_option/checklist_entities.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/checklist_type_option/checklist_entities.rs
@@ -1,7 +1,7 @@
use crate::entities::FieldType;
use crate::services::field::{TypeOptionCellData, CELL_DATA};
use collab::util::AnyMapExt;
-use collab_database::entity::SelectOption;
+use collab_database::fields::select_type_option::SelectOption;
use collab_database::rows::{new_cell_builder, Cell};
use serde::{Deserialize, Serialize};
use std::fmt::Debug;
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/checklist_type_option/checklist_filter.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/checklist_type_option/checklist_filter.rs
index b05753207f..71372b90c9 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/checklist_type_option/checklist_filter.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/checklist_type_option/checklist_filter.rs
@@ -1,4 +1,4 @@
-use collab_database::entity::SelectOption;
+use collab_database::fields::select_type_option::SelectOption;
use collab_database::fields::Field;
use collab_database::rows::Cell;
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_filter.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_filter.rs
index 42a0300e18..9d888e5f7c 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_filter.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_filter.rs
@@ -1,9 +1,9 @@
use crate::entities::{DateFilterConditionPB, DateFilterPB};
use crate::services::cell::insert_date_cell;
-use crate::services::field::DateCellData;
use crate::services::filter::PreFillCellsWithFilter;
-use chrono::{Duration, NaiveDate, NaiveDateTime};
+use chrono::{Duration, NaiveDate};
+use collab_database::fields::date_type_option::DateCellData;
use collab_database::fields::Field;
use collab_database::rows::Cell;
@@ -32,7 +32,7 @@ impl DateFilterPB {
#[inline]
fn naive_date_from_timestamp(timestamp: i64) -> Option<NaiveDate> {
- NaiveDateTime::from_timestamp_opt(timestamp, 0).map(|date_time: NaiveDateTime| date_time.date())
+ chrono::DateTime::from_timestamp(timestamp, 0).map(|date| date.naive_utc().date())
}
enum DateFilterStrategy {
@@ -106,17 +106,21 @@ impl PreFillCellsWithFilter for DateFilterPB {
| DateFilterConditionPB::DateOnOrAfter => self.timestamp,
DateFilterConditionPB::DateBefore => self
.timestamp
- .and_then(|timestamp| NaiveDateTime::from_timestamp_opt(timestamp, 0))
+ .and_then(|timestamp| {
+ chrono::DateTime::from_timestamp(timestamp, 0).map(|date| date.naive_utc())
+ })
.map(|date_time| {
let answer = date_time - Duration::days(1);
- answer.timestamp()
+ answer.and_utc().timestamp()
}),
DateFilterConditionPB::DateAfter => self
.timestamp
- .and_then(|timestamp| NaiveDateTime::from_timestamp_opt(timestamp, 0))
+ .and_then(|timestamp| {
+ chrono::DateTime::from_timestamp(timestamp, 0).map(|date| date.naive_utc())
+ })
.map(|date_time| {
let answer = date_time + Duration::days(1);
- answer.timestamp()
+ answer.and_utc().timestamp()
}),
DateFilterConditionPB::DateWithIn => self.start,
_ => None,
@@ -134,7 +138,7 @@ impl PreFillCellsWithFilter for DateFilterPB {
#[cfg(test)]
mod tests {
use crate::entities::{DateFilterConditionPB, DateFilterPB};
- use crate::services::field::DateCellData;
+ use collab_database::fields::date_type_option::DateCellData;
fn to_cell_data(timestamp: i32) -> DateCellData {
DateCellData::new(timestamp as i64, false, false, "".to_string())
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_tests.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_tests.rs
index 8c67f8bc5c..8342e3d776 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_tests.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_tests.rs
@@ -1,20 +1,19 @@
#[cfg(test)]
mod tests {
use chrono::format::strftime::StrftimeItems;
- use chrono::{FixedOffset, NaiveDateTime};
+ use chrono::FixedOffset;
use collab_database::fields::Field;
use collab_database::rows::Cell;
use strum::IntoEnumIterator;
use crate::entities::FieldType;
use crate::services::cell::{CellDataChangeset, CellDataDecoder};
- use crate::services::field::{
- DateCellChangeset, DateFormat, DateTypeOption, FieldBuilder, TimeFormat,
- };
+ use crate::services::field::{DateCellChangeset, FieldBuilder};
+ use collab_database::fields::date_type_option::{DateFormat, DateTypeOption, TimeFormat};
#[test]
fn date_type_option_date_format_test() {
- let mut type_option = DateTypeOption::test();
+ let mut type_option = DateTypeOption::default_utc();
let field = FieldBuilder::from_field_type(FieldType::DateTime).build();
for date_format in DateFormat::iter() {
type_option.date_format = date_format;
@@ -89,13 +88,27 @@ mod tests {
"14/03/2022",
);
},
+ DateFormat::FriendlyFull => {
+ assert_date(
+ &type_option,
+ &field,
+ DateCellChangeset {
+ date: Some(1647251762),
+ time: None,
+ include_time: None,
+ ..Default::default()
+ },
+ None,
+ "March 14, 2022",
+ );
+ },
}
}
}
#[test]
fn date_type_option_different_time_format_test() {
- let mut type_option = DateTypeOption::test();
+ let mut type_option = DateTypeOption::default_utc();
let field = FieldBuilder::from_field_type(FieldType::DateTime).build();
for time_format in TimeFormat::iter() {
@@ -185,7 +198,7 @@ mod tests {
#[should_panic]
fn date_type_option_invalid_include_time_str_test() {
let field_type = FieldType::DateTime;
- let type_option = DateTypeOption::test();
+ let type_option = DateTypeOption::default_utc();
let field = FieldBuilder::from_field_type(field_type).build();
assert_date(
@@ -206,7 +219,7 @@ mod tests {
#[should_panic]
fn date_type_option_empty_include_time_str_test() {
let field_type = FieldType::DateTime;
- let type_option = DateTypeOption::test();
+ let type_option = DateTypeOption::default_utc();
let field = FieldBuilder::from_field_type(field_type).build();
assert_date(
@@ -226,7 +239,7 @@ mod tests {
#[test]
fn date_type_midnight_include_time_str_test() {
let field_type = FieldType::DateTime;
- let type_option = DateTypeOption::test();
+ let type_option = DateTypeOption::default_utc();
let field = FieldBuilder::from_field_type(field_type).build();
assert_date(
&type_option,
@@ -247,7 +260,7 @@ mod tests {
#[test]
#[should_panic]
fn date_type_option_twelve_hours_include_time_str_in_twenty_four_hours_format() {
- let type_option = DateTypeOption::test();
+ let type_option = DateTypeOption::default_utc();
let field = FieldBuilder::from_field_type(FieldType::DateTime).build();
assert_date(
&type_option,
@@ -269,7 +282,7 @@ mod tests {
#[should_panic]
fn date_type_option_twenty_four_hours_include_time_str_in_twelve_hours_format() {
let field_type = FieldType::DateTime;
- let mut type_option = DateTypeOption::test();
+ let mut type_option = DateTypeOption::default_utc();
type_option.time_format = TimeFormat::TwelveHour;
let field = FieldBuilder::from_field_type(field_type).build();
@@ -290,7 +303,9 @@ mod tests {
#[test]
fn utc_to_native_test() {
let native_timestamp = 1647251762;
- let native = NaiveDateTime::from_timestamp_opt(native_timestamp, 0).unwrap();
+ let native = chrono::DateTime::from_timestamp(native_timestamp, 0)
+ .unwrap()
+ .naive_utc();
let utc = chrono::DateTime::<chrono::Utc>::from_naive_utc_and_offset(native, chrono::Utc);
// utc_timestamp doesn't carry timezone
@@ -320,7 +335,7 @@ mod tests {
#[test]
#[should_panic]
fn update_date_keep_time() {
- let type_option = DateTypeOption::test();
+ let type_option = DateTypeOption::default_utc();
let field = FieldBuilder::from_field_type(FieldType::DateTime).build();
let old_cell_data = initialize_date_cell(
@@ -348,7 +363,7 @@ mod tests {
#[test]
fn update_time_keep_date() {
- let type_option = DateTypeOption::test();
+ let type_option = DateTypeOption::default_utc();
let field = FieldBuilder::from_field_type(FieldType::DateTime).build();
let old_cell_data = initialize_date_cell(
@@ -376,7 +391,7 @@ mod tests {
#[test]
fn clear_date() {
- let type_option = DateTypeOption::test();
+ let type_option = DateTypeOption::default_utc();
let field = FieldBuilder::from_field_type(FieldType::DateTime).build();
let old_cell_data = initialize_date_cell(
@@ -405,7 +420,7 @@ mod tests {
#[test]
fn end_date_time_test() {
- let type_option = DateTypeOption::test();
+ let type_option = DateTypeOption::default_utc();
let field = FieldBuilder::from_field_type(FieldType::DateTime).build();
assert_date(
@@ -456,7 +471,7 @@ mod tests {
#[test]
fn turn_on_date_range() {
- let type_option = DateTypeOption::test();
+ let type_option = DateTypeOption::default_utc();
let field = FieldBuilder::from_field_type(FieldType::DateTime).build();
let old_cell_data = initialize_date_cell(
@@ -482,7 +497,7 @@ mod tests {
#[test]
fn add_an_end_time() {
- let type_option = DateTypeOption::test();
+ let type_option = DateTypeOption::default_utc();
let field = FieldBuilder::from_field_type(FieldType::DateTime).build();
let old_cell_data = initialize_date_cell(
@@ -514,7 +529,7 @@ mod tests {
#[test]
#[should_panic]
fn end_date_with_no_start_date() {
- let type_option = DateTypeOption::test();
+ let type_option = DateTypeOption::default_utc();
let field = FieldBuilder::from_field_type(FieldType::DateTime).build();
assert_date(
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option.rs
index ad51716310..1c2b481f28 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option.rs
@@ -1,34 +1,23 @@
use async_trait::async_trait;
-use chrono::{DateTime, FixedOffset, Local, NaiveDateTime, NaiveTime, Offset, TimeZone};
-use chrono_tz::Tz;
-use collab::preclude::Any;
use collab::util::AnyMapExt;
use collab_database::database::Database;
-use collab_database::fields::{Field, TypeOptionData, TypeOptionDataBuilder};
+use collab_database::fields::date_type_option::{DateCellData, DateTypeOption};
+use collab_database::fields::{Field, TypeOptionData};
use collab_database::rows::Cell;
use collab_database::template::date_parse::cast_string_to_timestamp;
-use flowy_error::{ErrorCode, FlowyError, FlowyResult};
-use serde::{Deserialize, Serialize};
+use flowy_error::FlowyResult;
+
use std::cmp::Ordering;
-use std::str::FromStr;
+
use tracing::info;
use crate::entities::{DateCellDataPB, DateFilterPB, FieldType};
use crate::services::cell::{CellDataChangeset, CellDataDecoder};
use crate::services::field::{
- default_order, DateCellChangeset, DateCellData, DateFormat, TimeFormat, TypeOption,
- TypeOptionCellDataCompare, TypeOptionCellDataFilter, TypeOptionCellDataSerde,
- TypeOptionTransform, CELL_DATA,
+ default_order, DateCellChangeset, TypeOption, TypeOptionCellDataCompare,
+ TypeOptionCellDataFilter, TypeOptionCellDataSerde, TypeOptionTransform, CELL_DATA,
};
use crate::services::sort::SortCondition;
-
-#[derive(Clone, Debug, Serialize, Deserialize, Default)]
-pub struct DateTypeOption {
- pub date_format: DateFormat,
- pub time_format: TimeFormat,
- pub timezone_id: String,
-}
-
impl TypeOption for DateTypeOption {
type CellData = DateCellData;
type CellChangeset = DateCellChangeset;
@@ -36,35 +25,6 @@ impl TypeOption for DateTypeOption {
type CellFilter = DateFilterPB;
}
-impl From<TypeOptionData> for DateTypeOption {
- fn from(data: TypeOptionData) -> Self {
- let date_format = data
- .get_as::<i64>("date_format")
- .map(DateFormat::from)
- .unwrap_or_default();
- let time_format = data
- .get_as::<i64>("time_format")
- .map(TimeFormat::from)
- .unwrap_or_default();
- let timezone_id: String = data.get_as("timezone_id").unwrap_or_default();
- Self {
- date_format,
- time_format,
- timezone_id,
- }
- }
-}
-
-impl From<DateTypeOption> for TypeOptionData {
- fn from(data: DateTypeOption) -> Self {
- TypeOptionDataBuilder::from([
- ("date_format".into(), Any::BigInt(data.date_format.value())),
- ("time_format".into(), Any::BigInt(data.time_format.value())),
- ("timezone_id".into(), data.timezone_id.into()),
- ])
- }
-}
-
impl TypeOptionCellDataSerde for DateTypeOption {
fn protobuf_encode(
&self,
@@ -99,106 +59,6 @@ impl TypeOptionCellDataSerde for DateTypeOption {
}
}
-impl DateTypeOption {
- pub fn new() -> Self {
- Self::default()
- }
-
- pub fn test() -> Self {
- Self {
- timezone_id: "Etc/UTC".to_owned(),
- ..Self::default()
- }
- }
-
- fn formatted_date_time_from_timestamp(&self, timestamp: &Option<i64>) -> (String, String) {
- if let Some(timestamp) = timestamp {
- let naive = chrono::NaiveDateTime::from_timestamp_opt(*timestamp, 0).unwrap();
- let offset = self.get_timezone_offset(naive);
- let date_time = DateTime::<Local>::from_naive_utc_and_offset(naive, offset);
-
- let fmt = self.date_format.format_str();
- let date = format!("{}", date_time.format(fmt));
- let fmt = self.time_format.format_str();
- let time = format!("{}", date_time.format(fmt));
- (date, time)
- } else {
- ("".to_owned(), "".to_owned())
- }
- }
-
- fn naive_time_from_time_string(
- &self,
- include_time: bool,
- time_str: Option<String>,
- ) -> FlowyResult<Option<NaiveTime>> {
- match (include_time, time_str) {
- (true, Some(time_str)) => {
- let result = NaiveTime::parse_from_str(&time_str, self.time_format.format_str());
- match result {
- Ok(time) => Ok(Some(time)),
- Err(_e) => {
- let msg = format!("Parse {} failed", time_str);
- Err(FlowyError::new(ErrorCode::InvalidDateTimeFormat, msg))
- },
- }
- },
- _ => Ok(None),
- }
- }
-
- /// combine the changeset_timestamp and parsed_time if provided. if
- /// changeset_timestamp is None, fallback to previous_timestamp
- fn timestamp_from_parsed_time_previous_and_new_timestamp(
- &self,
- parsed_time: Option<NaiveTime>,
- previous_timestamp: Option<i64>,
- changeset_timestamp: Option<i64>,
- ) -> Option<i64> {
- if let Some(time) = parsed_time {
- // a valid time is provided, so we replace the time component of old timestamp
- // (or new timestamp if provided) with it.
- let utc_date = changeset_timestamp
- .or(previous_timestamp)
- .map(|timestamp| NaiveDateTime::from_timestamp_opt(timestamp, 0).unwrap())
- .unwrap();
- let offset = self.get_timezone_offset(utc_date);
-
- let local_date = changeset_timestamp.or(previous_timestamp).map(|timestamp| {
- offset
- .from_utc_datetime(&NaiveDateTime::from_timestamp_opt(timestamp, 0).unwrap())
- .date_naive()
- });
-
- match local_date {
- Some(date) => {
- let local_datetime = offset
- .from_local_datetime(&NaiveDateTime::new(date, time))
- .unwrap();
-
- Some(local_datetime.timestamp())
- },
- None => None,
- }
- } else {
- changeset_timestamp.or(previous_timestamp)
- }
- }
-
- /// returns offset of Tz timezone if provided or of the local timezone otherwise
- fn get_timezone_offset(&self, date_time: NaiveDateTime) -> FixedOffset {
- let current_timezone_offset = Local::now().offset().fix();
- if self.timezone_id.is_empty() {
- current_timezone_offset
- } else {
- match Tz::from_str(&self.timezone_id) {
- Ok(timezone) => timezone.offset_from_utc_datetime(&date_time).fix(),
- Err(_) => current_timezone_offset,
- }
- }
- }
-}
-
#[async_trait]
impl TypeOptionTransform for DateTypeOption {
async fn transform_type_option(
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option_entities.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option_entities.rs
index 831481f257..3cf6e7474b 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option_entities.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option_entities.rs
@@ -1,18 +1,12 @@
#![allow(clippy::upper_case_acronyms)]
use bytes::Bytes;
-use collab::util::AnyMapExt;
-use collab_database::rows::{new_cell_builder, Cell};
-use serde::de::Visitor;
-use serde::{Deserialize, Serialize};
-use std::fmt;
-use strum_macros::EnumIter;
-
+use collab_database::fields::date_type_option::DateCellData;
use flowy_error::{internal_error, FlowyResult};
-use crate::entities::{DateCellDataPB, FieldType};
+use crate::entities::DateCellDataPB;
use crate::services::cell::CellProtobufBlobParser;
-use crate::services::field::{TypeOptionCellData, CELL_DATA};
+use crate::services::field::TypeOptionCellData;
#[derive(Clone, Debug, Default)]
pub struct DateCellChangeset {
@@ -26,271 +20,11 @@ pub struct DateCellChangeset {
pub reminder_id: Option<String>,
}
-#[derive(Default, Clone, Debug, Serialize)]
-pub struct DateCellData {
- pub timestamp: Option<i64>,
- pub end_timestamp: Option<i64>,
- #[serde(default)]
- pub include_time: bool,
- #[serde(default)]
- pub is_range: bool,
- pub reminder_id: String,
-}
-
-impl DateCellData {
- pub fn new(timestamp: i64, include_time: bool, is_range: bool, reminder_id: String) -> Self {
- Self {
- timestamp: Some(timestamp),
- end_timestamp: None,
- include_time,
- is_range,
- reminder_id,
- }
- }
-
- pub fn from_timestamp(timestamp: i64) -> Self {
- Self {
- timestamp: Some(timestamp),
- end_timestamp: None,
- include_time: false,
- is_range: false,
- reminder_id: String::new(),
- }
- }
-}
-
impl TypeOptionCellData for DateCellData {
fn is_cell_empty(&self) -> bool {
self.timestamp.is_none()
}
}
-
-impl From<&Cell> for DateCellData {
- fn from(cell: &Cell) -> Self {
- let timestamp = cell
- .get_as::<String>(CELL_DATA)
- .and_then(|data| data.parse::<i64>().ok());
- let end_timestamp = cell
- .get_as::<String>("end_timestamp")
- .and_then(|data| data.parse::<i64>().ok());
- let include_time: bool = cell.get_as("include_time").unwrap_or_default();
- let is_range: bool = cell.get_as("is_range").unwrap_or_default();
- let reminder_id: String = cell.get_as("reminder_id").unwrap_or_default();
-
- Self {
- timestamp,
- end_timestamp,
- include_time,
- is_range,
- reminder_id,
- }
- }
-}
-
-impl From<&DateCellDataPB> for DateCellData {
- fn from(data: &DateCellDataPB) -> Self {
- Self {
- timestamp: Some(data.timestamp),
- end_timestamp: Some(data.end_timestamp),
- include_time: data.include_time,
- is_range: data.is_range,
- reminder_id: data.reminder_id.to_owned(),
- }
- }
-}
-
-impl From<&DateCellData> for Cell {
- fn from(cell_data: &DateCellData) -> Self {
- let timestamp_string = match cell_data.timestamp {
- Some(timestamp) => timestamp.to_string(),
- None => "".to_owned(),
- };
- let end_timestamp_string = match cell_data.end_timestamp {
- Some(timestamp) => timestamp.to_string(),
- None => "".to_owned(),
- };
- // Most of the case, don't use these keys in other places. Otherwise, we should define
- // constants for them.
- let mut cell = new_cell_builder(FieldType::DateTime);
- cell.insert(CELL_DATA.into(), timestamp_string.into());
- cell.insert("end_timestamp".into(), end_timestamp_string.into());
- cell.insert("include_time".into(), cell_data.include_time.into());
- cell.insert("is_range".into(), cell_data.is_range.into());
- cell.insert(
- "reminder_id".into(),
- cell_data.reminder_id.to_owned().into(),
- );
- cell
- }
-}
-
-impl<'de> serde::Deserialize<'de> for DateCellData {
- fn deserialize<D>(deserializer: D) -> core::result::Result<Self, D::Error>
- where
- D: serde::Deserializer<'de>,
- {
- struct DateCellVisitor();
-
- impl<'de> Visitor<'de> for DateCellVisitor {
- type Value = DateCellData;
-
- fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str(
- "DateCellData with type: str containing either an integer timestamp or the JSON representation",
- )
- }
-
- fn visit_i64<E>(self, value: i64) -> Result<Self::Value, E>
- where
- E: serde::de::Error,
- {
- Ok(DateCellData {
- timestamp: Some(value),
- end_timestamp: None,
- include_time: false,
- is_range: false,
- reminder_id: String::new(),
- })
- }
-
- fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E>
- where
- E: serde::de::Error,
- {
- self.visit_i64(value as i64)
- }
-
- fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
- where
- M: serde::de::MapAccess<'de>,
- {
- let mut timestamp: Option<i64> = None;
- let mut end_timestamp: Option<i64> = None;
- let mut include_time: Option<bool> = None;
- let mut is_range: Option<bool> = None;
- let mut reminder_id: Option<String> = None;
-
- while let Some(key) = map.next_key()? {
- match key {
- "timestamp" => {
- timestamp = map.next_value()?;
- },
- "end_timestamp" => {
- end_timestamp = map.next_value()?;
- },
- "include_time" => {
- include_time = map.next_value()?;
- },
- "is_range" => {
- is_range = map.next_value()?;
- },
- "reminder_id" => {
- reminder_id = map.next_value()?;
- },
- _ => {},
- }
- }
-
- let include_time = include_time.unwrap_or_default();
- let is_range = is_range.unwrap_or_default();
- let reminder_id = reminder_id.unwrap_or_default();
-
- Ok(DateCellData {
- timestamp,
- end_timestamp,
- include_time,
- is_range,
- reminder_id,
- })
- }
- }
-
- deserializer.deserialize_any(DateCellVisitor())
- }
-}
-
-impl ToString for DateCellData {
- fn to_string(&self) -> String {
- serde_json::to_string(self).unwrap()
- }
-}
-
-#[derive(Clone, Debug, Copy, EnumIter, Serialize, Deserialize, Default)]
-pub enum DateFormat {
- Local = 0,
- US = 1,
- ISO = 2,
- #[default]
- Friendly = 3,
- DayMonthYear = 4,
-}
-
-impl std::convert::From<i64> for DateFormat {
- fn from(value: i64) -> Self {
- match value {
- 0 => DateFormat::Local,
- 1 => DateFormat::US,
- 2 => DateFormat::ISO,
- 3 => DateFormat::Friendly,
- 4 => DateFormat::DayMonthYear,
- _ => {
- tracing::error!("Unsupported date format, fallback to friendly");
- DateFormat::Friendly
- },
- }
- }
-}
-
-impl DateFormat {
- pub fn value(&self) -> i64 {
- *self as i64
- }
- // https://docs.rs/chrono/0.4.19/chrono/format/strftime/index.html
- pub fn format_str(&self) -> &'static str {
- match self {
- DateFormat::Local => "%m/%d/%Y",
- DateFormat::US => "%Y/%m/%d",
- DateFormat::ISO => "%Y-%m-%d",
- DateFormat::Friendly => "%b %d, %Y",
- DateFormat::DayMonthYear => "%d/%m/%Y",
- }
- }
-}
-
-#[derive(Clone, Copy, PartialEq, Eq, EnumIter, Debug, Hash, Serialize, Deserialize, Default)]
-pub enum TimeFormat {
- TwelveHour = 0,
- #[default]
- TwentyFourHour = 1,
-}
-
-impl std::convert::From<i64> for TimeFormat {
- fn from(value: i64) -> Self {
- match value {
- 0 => TimeFormat::TwelveHour,
- 1 => TimeFormat::TwentyFourHour,
- _ => {
- tracing::error!("Unsupported time format, fallback to TwentyFourHour");
- TimeFormat::TwentyFourHour
- },
- }
- }
-}
-
-impl TimeFormat {
- pub fn value(&self) -> i64 {
- *self as i64
- }
-
- // https://docs.rs/chrono/0.4.19/chrono/format/strftime/index.html
- pub fn format_str(&self) -> &'static str {
- match self {
- TimeFormat::TwelveHour => "%I:%M %p",
- TimeFormat::TwentyFourHour => "%R",
- }
- }
-}
-
pub struct DateCellDataParser();
impl CellProtobufBlobParser for DateCellDataParser {
type Object = DateCellDataPB;
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/mod.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/mod.rs
index ff0c344957..13191ec686 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/mod.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/mod.rs
@@ -4,5 +4,4 @@ mod date_tests;
mod date_type_option;
mod date_type_option_entities;
-pub use date_type_option::*;
pub use date_type_option_entities::*;
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/media_type_option/media_type_option.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/media_type_option/media_type_option.rs
index c7f797bdec..ae892aefac 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/media_type_option/media_type_option.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/media_type_option/media_type_option.rs
@@ -1,107 +1,26 @@
-use std::{cmp::Ordering, sync::Arc};
-
-use collab::{preclude::Any, util::AnyMapExt};
-use collab_database::{
- fields::{Field, TypeOptionData, TypeOptionDataBuilder},
- rows::{new_cell_builder, Cell},
-};
+use collab_database::fields::media_type_option::{MediaCellData, MediaTypeOption};
+use collab_database::{fields::Field, rows::Cell};
use flowy_error::FlowyResult;
-use serde::{Deserialize, Serialize};
+use std::cmp::Ordering;
use crate::{
- entities::{FieldType, MediaCellChangeset, MediaCellDataPB, MediaFilterPB, MediaTypeOptionPB},
+ entities::{FieldType, MediaCellChangeset, MediaCellDataPB, MediaFilterPB},
services::{
cell::{CellDataChangeset, CellDataDecoder},
field::{
default_order, StringCellData, TypeOption, TypeOptionCellData, TypeOptionCellDataCompare,
- TypeOptionCellDataFilter, TypeOptionCellDataSerde, TypeOptionTransform, CELL_DATA,
+ TypeOptionCellDataFilter, TypeOptionCellDataSerde, TypeOptionTransform,
},
sort::SortCondition,
},
};
-use super::MediaFile;
-
-#[derive(Clone, Debug, Default, Serialize)]
-pub struct MediaCellData {
- pub files: Vec<MediaFile>,
-}
-
-impl From<&Cell> for MediaCellData {
- fn from(cell: &Cell) -> Self {
- let files = match cell.get(CELL_DATA) {
- Some(Any::Array(array)) => array
- .iter()
- .flat_map(|item| {
- if let Any::String(string) = item {
- Some(serde_json::from_str::<MediaFile>(string).unwrap_or_default())
- } else {
- None
- }
- })
- .collect(),
- _ => vec![],
- };
-
- Self { files }
- }
-}
-
-impl From<&MediaCellData> for Cell {
- fn from(value: &MediaCellData) -> Self {
- let data = Any::Array(Arc::from(
- value
- .files
- .clone()
- .into_iter()
- .map(|file| Any::String(Arc::from(serde_json::to_string(&file).unwrap_or_default())))
- .collect::<Vec<_>>(),
- ));
-
- let mut cell = new_cell_builder(FieldType::Media);
- cell.insert(CELL_DATA.into(), data);
- cell
- }
-}
-
-impl From<String> for MediaCellData {
- fn from(s: String) -> Self {
- if s.is_empty() {
- return MediaCellData { files: vec![] };
- }
-
- let files = s
- .split(", ")
- .map(|file: &str| serde_json::from_str::<MediaFile>(file).unwrap_or_default())
- .collect::<Vec<_>>();
-
- MediaCellData { files }
- }
-}
-
impl TypeOptionCellData for MediaCellData {
fn is_cell_empty(&self) -> bool {
self.files.is_empty()
}
}
-impl ToString for MediaCellData {
- fn to_string(&self) -> String {
- self
- .files
- .iter()
- .map(|file| file.to_string())
- .collect::<Vec<_>>()
- .join(", ")
- }
-}
-
-#[derive(Debug, Clone, Default, Serialize, Deserialize)]
-pub struct MediaTypeOption {
- #[serde(default)]
- pub hide_file_names: bool,
-}
-
impl TypeOption for MediaTypeOption {
type CellData = MediaCellData;
type CellChangeset = MediaCellChangeset;
@@ -109,38 +28,6 @@ impl TypeOption for MediaTypeOption {
type CellFilter = MediaFilterPB;
}
-impl From<TypeOptionData> for MediaTypeOption {
- fn from(data: TypeOptionData) -> Self {
- data
- .get_as::<String>("content")
- .map(|s| serde_json::from_str::<MediaTypeOption>(&s).unwrap_or_default())
- .unwrap_or_default()
- }
-}
-
-impl From<MediaTypeOption> for TypeOptionData {
- fn from(data: MediaTypeOption) -> Self {
- let content = serde_json::to_string(&data).unwrap_or_default();
- TypeOptionDataBuilder::from([("content".into(), content.into())])
- }
-}
-
-impl From<MediaTypeOption> for MediaTypeOptionPB {
- fn from(value: MediaTypeOption) -> Self {
- Self {
- hide_file_names: value.hide_file_names,
- }
- }
-}
-
-impl From<MediaTypeOptionPB> for MediaTypeOption {
- fn from(value: MediaTypeOptionPB) -> Self {
- Self {
- hide_file_names: value.hide_file_names,
- }
- }
-}
-
impl TypeOptionTransform for MediaTypeOption {}
impl TypeOptionCellDataSerde for MediaTypeOption {
@@ -205,7 +92,7 @@ impl CellDataChangeset for MediaTypeOption {
let cell_data = MediaCellData {
files: changeset.inserted_files,
};
- return Ok(((&cell_data).into(), cell_data));
+ return Ok((cell_data.clone().into(), cell_data));
}
let cell_data: MediaCellData = MediaCellData::from(&cell.unwrap());
@@ -224,7 +111,7 @@ impl CellDataChangeset for MediaTypeOption {
let cell_data = MediaCellData { files };
- Ok((Cell::from(&cell_data), cell_data))
+ Ok((Cell::from(cell_data.clone()), cell_data))
}
}
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/media_type_option/mod.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/media_type_option/mod.rs
index 5fae403f53..b9bd6e471a 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/media_type_option/mod.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/media_type_option/mod.rs
@@ -1,7 +1,4 @@
#![allow(clippy::module_inception)]
-mod media_file;
+// mod media_file;
mod media_filter;
mod media_type_option;
-
-pub use media_file::*;
-pub use media_type_option::*;
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/mod.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/mod.rs
index 3464ae6cfe..b23bcdf1d9 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/mod.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/mod.rs
@@ -18,7 +18,7 @@ mod util;
pub use checkbox_type_option::*;
pub use checklist_type_option::*;
pub use date_type_option::*;
-pub use media_type_option::*;
+
pub use number_type_option::*;
pub use relation_type_option::*;
pub use selection_type_option::*;
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/format.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/format.rs
deleted file mode 100644
index 5a4727984b..0000000000
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/format.rs
+++ /dev/null
@@ -1,498 +0,0 @@
-#![allow(clippy::upper_case_acronyms)]
-
-use lazy_static::lazy_static;
-use rusty_money::define_currency_set;
-use serde::{Deserialize, Serialize};
-use strum::IntoEnumIterator;
-use strum_macros::EnumIter;
-
-lazy_static! {
- pub static ref CURRENCY_SYMBOL: Vec<String> = NumberFormat::iter()
- .map(|format| format.symbol())
- .collect::<Vec<String>>();
-}
-
-#[derive(Clone, Copy, Debug, PartialEq, Eq, EnumIter, Serialize, Deserialize, Default)]
-pub enum NumberFormat {
- #[default]
- Num = 0,
- USD = 1,
- CanadianDollar = 2,
- EUR = 4,
- Pound = 5,
- Yen = 6,
- Ruble = 7,
- Rupee = 8,
- Won = 9,
- Yuan = 10,
- Real = 11,
- Lira = 12,
- Rupiah = 13,
- Franc = 14,
- HongKongDollar = 15,
- NewZealandDollar = 16,
- Krona = 17,
- NorwegianKrone = 18,
- MexicanPeso = 19,
- Rand = 20,
- NewTaiwanDollar = 21,
- DanishKrone = 22,
- Baht = 23,
- Forint = 24,
- Koruna = 25,
- Shekel = 26,
- ChileanPeso = 27,
- PhilippinePeso = 28,
- Dirham = 29,
- ColombianPeso = 30,
- Riyal = 31,
- Ringgit = 32,
- Leu = 33,
- ArgentinePeso = 34,
- UruguayanPeso = 35,
- Percent = 36,
-}
-
-impl NumberFormat {
- pub fn value(&self) -> i64 {
- *self as i64
- }
-}
-
-impl From<i64> for NumberFormat {
- fn from(value: i64) -> Self {
- match value {
- 0 => NumberFormat::Num,
- 1 => NumberFormat::USD,
- 2 => NumberFormat::CanadianDollar,
- 4 => NumberFormat::EUR,
- 5 => NumberFormat::Pound,
- 6 => NumberFormat::Yen,
- 7 => NumberFormat::Ruble,
- 8 => NumberFormat::Rupee,
- 9 => NumberFormat::Won,
- 10 => NumberFormat::Yuan,
- 11 => NumberFormat::Real,
- 12 => NumberFormat::Lira,
- 13 => NumberFormat::Rupiah,
- 14 => NumberFormat::Franc,
- 15 => NumberFormat::HongKongDollar,
- 16 => NumberFormat::NewZealandDollar,
- 17 => NumberFormat::Krona,
- 18 => NumberFormat::NorwegianKrone,
- 19 => NumberFormat::MexicanPeso,
- 20 => NumberFormat::Rand,
- 21 => NumberFormat::NewTaiwanDollar,
- 22 => NumberFormat::DanishKrone,
- 23 => NumberFormat::Baht,
- 24 => NumberFormat::Forint,
- 25 => NumberFormat::Koruna,
- 26 => NumberFormat::Shekel,
- 27 => NumberFormat::ChileanPeso,
- 28 => NumberFormat::PhilippinePeso,
- 29 => NumberFormat::Dirham,
- 30 => NumberFormat::ColombianPeso,
- 31 => NumberFormat::Riyal,
- 32 => NumberFormat::Ringgit,
- 33 => NumberFormat::Leu,
- 34 => NumberFormat::ArgentinePeso,
- 35 => NumberFormat::UruguayanPeso,
- 36 => NumberFormat::Percent,
- _ => NumberFormat::Num,
- }
- }
-}
-
-define_currency_set!(
- number_currency {
- NUMBER : {
- code: "",
- exponent: 2,
- locale: EnEu,
- minor_units: 1,
- name: "number",
- symbol: "RUB",
- symbol_first: false,
- },
- PERCENT : {
- code: "",
- exponent: 2,
- locale: EnIn,
- minor_units: 1,
- name: "percent",
- symbol: "%",
- symbol_first: false,
- },
- USD : {
- code: "USD",
- exponent: 2,
- locale: EnUs,
- minor_units: 1,
- name: "United States Dollar",
- symbol: "$",
- symbol_first: true,
- },
- CANADIAN_DOLLAR : {
- code: "USD",
- exponent: 2,
- locale: EnUs,
- minor_units: 1,
- name: "Canadian Dollar",
- symbol: "CA$",
- symbol_first: true,
- },
- NEW_TAIWAN_DOLLAR : {
- code: "USD",
- exponent: 2,
- locale: EnUs,
- minor_units: 1,
- name: "NewTaiwan Dollar",
- symbol: "NT$",
- symbol_first: true,
- },
- HONG_KONG_DOLLAR : {
- code: "USD",
- exponent: 2,
- locale: EnUs,
- minor_units: 1,
- name: "HongKong Dollar",
- symbol: "HZ$",
- symbol_first: true,
- },
- NEW_ZEALAND_DOLLAR : {
- code: "USD",
- exponent: 2,
- locale: EnUs,
- minor_units: 1,
- name: "NewZealand Dollar",
- symbol: "NZ$",
- symbol_first: true,
- },
- EUR : {
- code: "EUR",
- exponent: 2,
- locale: EnEu,
- minor_units: 1,
- name: "Euro",
- symbol: "€",
- symbol_first: true,
- },
- GIP : {
- code: "GIP",
- exponent: 2,
- locale: EnUs,
- minor_units: 1,
- name: "Gibraltar Pound",
- symbol: "£",
- symbol_first: true,
- },
- CNY : {
- code: "CNY",
- exponent: 2,
- locale: EnUs,
- minor_units: 1,
- name: "Chinese Renminbi Yuan",
- symbol: "¥",
- symbol_first: true,
- },
- YUAN : {
- code: "CNY",
- exponent: 2,
- locale: EnUs,
- minor_units: 1,
- name: "Chinese Renminbi Yuan",
- symbol: "CN¥",
- symbol_first: true,
- },
- RUB : {
- code: "RUB",
- exponent: 2,
- locale: EnEu,
- minor_units: 1,
- name: "Russian Ruble",
- symbol: "RUB",
- symbol_first: false,
- },
- INR : {
- code: "INR",
- exponent: 2,
- locale: EnIn,
- minor_units: 50,
- name: "Indian Rupee",
- symbol: "₹",
- symbol_first: true,
- },
- KRW : {
- code: "KRW",
- exponent: 0,
- locale: EnUs,
- minor_units: 1,
- name: "South Korean Won",
- symbol: "₩",
- symbol_first: true,
- },
- BRL : {
- code: "BRL",
- exponent: 2,
- locale: EnUs,
- minor_units: 5,
- name: "Brazilian real",
- symbol: "R$",
- symbol_first: true,
- },
- TRY : {
- code: "TRY",
- exponent: 2,
- locale: EnEu,
- minor_units: 1,
- name: "Turkish Lira",
- // symbol: "₺",
- symbol: "TRY",
- symbol_first: true,
- },
- IDR : {
- code: "IDR",
- exponent: 2,
- locale: EnUs,
- minor_units: 5000,
- name: "Indonesian Rupiah",
- // symbol: "Rp",
- symbol: "IDR",
- symbol_first: true,
- },
- CHF : {
- code: "CHF",
- exponent: 2,
- locale: EnUs,
- minor_units: 5,
- name: "Swiss Franc",
- // symbol: "Fr",
- symbol: "CHF",
- symbol_first: true,
- },
- SEK : {
- code: "SEK",
- exponent: 2,
- locale: EnBy,
- minor_units: 100,
- name: "Swedish Krona",
- // symbol: "kr",
- symbol: "SEK",
- symbol_first: false,
- },
- NOK : {
- code: "NOK",
- exponent: 2,
- locale: EnUs,
- minor_units: 100,
- name: "Norwegian Krone",
- // symbol: "kr",
- symbol: "NOK",
- symbol_first: false,
- },
- MEXICAN_PESO : {
- code: "USD",
- exponent: 2,
- locale: EnUs,
- minor_units: 1,
- name: "Mexican Peso",
- symbol: "MX$",
- symbol_first: true,
- },
- ZAR : {
- code: "ZAR",
- exponent: 2,
- locale: EnUs,
- minor_units: 10,
- name: "South African Rand",
- // symbol: "R",
- symbol: "ZAR",
- symbol_first: true,
- },
- DKK : {
- code: "DKK",
- exponent: 2,
- locale: EnEu,
- minor_units: 50,
- name: "Danish Krone",
- // symbol: "kr.",
- symbol: "DKK",
- symbol_first: false,
- },
- THB : {
- code: "THB",
- exponent: 2,
- locale: EnUs,
- minor_units: 1,
- name: "Thai Baht",
- // symbol: "฿",
- symbol: "THB",
- symbol_first: true,
- },
- HUF : {
- code: "HUF",
- exponent: 0,
- locale: EnBy,
- minor_units: 5,
- name: "Hungarian Forint",
- // symbol: "Ft",
- symbol: "HUF",
- symbol_first: false,
- },
- KORUNA : {
- code: "CZK",
- exponent: 2,
- locale: EnBy,
- minor_units: 100,
- name: "Czech Koruna",
- // symbol: "Kč",
- symbol: "CZK",
- symbol_first: false,
- },
- SHEKEL : {
- code: "CZK",
- exponent: 2,
- locale: EnBy,
- minor_units: 100,
- name: "Czech Koruna",
- symbol: "Kč",
- symbol_first: false,
- },
- CLP : {
- code: "CLP",
- exponent: 0,
- locale: EnEu,
- minor_units: 1,
- name: "Chilean Peso",
- // symbol: "$",
- symbol: "CLP",
- symbol_first: true,
- },
- PHP : {
- code: "PHP",
- exponent: 2,
- locale: EnUs,
- minor_units: 1,
- name: "Philippine Peso",
- symbol: "₱",
- symbol_first: true,
- },
- AED : {
- code: "AED",
- exponent: 2,
- locale: EnUs,
- minor_units: 25,
- name: "United Arab Emirates Dirham",
- // symbol: "د.إ",
- symbol: "AED",
- symbol_first: false,
- },
- COP : {
- code: "COP",
- exponent: 2,
- locale: EnEu,
- minor_units: 20,
- name: "Colombian Peso",
- // symbol: "$",
- symbol: "COP",
- symbol_first: true,
- },
- SAR : {
- code: "SAR",
- exponent: 2,
- locale: EnUs,
- minor_units: 5,
- name: "Saudi Riyal",
- // symbol: "ر.س",
- symbol: "SAR",
- symbol_first: true,
- },
- MYR : {
- code: "MYR",
- exponent: 2,
- locale: EnUs,
- minor_units: 5,
- name: "Malaysian Ringgit",
- // symbol: "RM",
- symbol: "MYR",
- symbol_first: true,
- },
- RON : {
- code: "RON",
- exponent: 2,
- locale: EnEu,
- minor_units: 1,
- name: "Romanian Leu",
- // symbol: "ر.ق",
- symbol: "RON",
- symbol_first: false,
- },
- ARS : {
- code: "ARS",
- exponent: 2,
- locale: EnEu,
- minor_units: 1,
- name: "Argentine Peso",
- // symbol: "$",
- symbol: "ARS",
- symbol_first: true,
- },
- UYU : {
- code: "UYU",
- exponent: 2,
- locale: EnEu,
- minor_units: 100,
- name: "Uruguayan Peso",
- // symbol: "$U",
- symbol: "UYU",
- symbol_first: true,
- }
- }
-);
-
-impl NumberFormat {
- pub fn currency(&self) -> &'static number_currency::Currency {
- match self {
- NumberFormat::Num => number_currency::NUMBER,
- NumberFormat::USD => number_currency::USD,
- NumberFormat::CanadianDollar => number_currency::CANADIAN_DOLLAR,
- NumberFormat::EUR => number_currency::EUR,
- NumberFormat::Pound => number_currency::GIP,
- NumberFormat::Yen => number_currency::CNY,
- NumberFormat::Ruble => number_currency::RUB,
- NumberFormat::Rupee => number_currency::INR,
- NumberFormat::Won => number_currency::KRW,
- NumberFormat::Yuan => number_currency::YUAN,
- NumberFormat::Real => number_currency::BRL,
- NumberFormat::Lira => number_currency::TRY,
- NumberFormat::Rupiah => number_currency::IDR,
- NumberFormat::Franc => number_currency::CHF,
- NumberFormat::HongKongDollar => number_currency::HONG_KONG_DOLLAR,
- NumberFormat::NewZealandDollar => number_currency::NEW_ZEALAND_DOLLAR,
- NumberFormat::Krona => number_currency::SEK,
- NumberFormat::NorwegianKrone => number_currency::NOK,
- NumberFormat::MexicanPeso => number_currency::MEXICAN_PESO,
- NumberFormat::Rand => number_currency::ZAR,
- NumberFormat::NewTaiwanDollar => number_currency::NEW_TAIWAN_DOLLAR,
- NumberFormat::DanishKrone => number_currency::DKK,
- NumberFormat::Baht => number_currency::THB,
- NumberFormat::Forint => number_currency::HUF,
- NumberFormat::Koruna => number_currency::KORUNA,
- NumberFormat::Shekel => number_currency::SHEKEL,
- NumberFormat::ChileanPeso => number_currency::CLP,
- NumberFormat::PhilippinePeso => number_currency::PHP,
- NumberFormat::Dirham => number_currency::AED,
- NumberFormat::ColombianPeso => number_currency::COP,
- NumberFormat::Riyal => number_currency::SAR,
- NumberFormat::Ringgit => number_currency::MYR,
- NumberFormat::Leu => number_currency::RON,
- NumberFormat::ArgentinePeso => number_currency::ARS,
- NumberFormat::UruguayanPeso => number_currency::UYU,
- NumberFormat::Percent => number_currency::PERCENT,
- }
- }
-
- pub fn symbol(&self) -> String {
- self.currency().symbol.to_string()
- }
-}
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/mod.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/mod.rs
index 8136fb57c5..714b6baca8 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/mod.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/mod.rs
@@ -1,10 +1,8 @@
#![allow(clippy::module_inception)]
-mod format;
mod number_filter;
-mod number_tests;
mod number_type_option;
mod number_type_option_entities;
-pub use format::*;
+// pub use format::*;
pub use number_type_option::*;
pub use number_type_option_entities::*;
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_filter.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_filter.rs
index ba95dd8843..2c66a9fcfc 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_filter.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_filter.rs
@@ -1,12 +1,12 @@
use std::str::FromStr;
+use collab_database::fields::number_type_option::NumberCellFormat;
use collab_database::fields::Field;
use collab_database::rows::Cell;
use rust_decimal::Decimal;
use crate::entities::{NumberFilterConditionPB, NumberFilterPB};
use crate::services::cell::insert_text_cell;
-use crate::services::field::NumberCellFormat;
use crate::services::filter::PreFillCellsWithFilter;
impl NumberFilterPB {
@@ -108,7 +108,7 @@ impl NumberFilterStrategy {
#[cfg(test)]
mod tests {
use crate::entities::{NumberFilterConditionPB, NumberFilterPB};
- use crate::services::field::{NumberCellFormat, NumberFormat};
+ use collab_database::fields::number_type_option::{NumberCellFormat, NumberFormat};
#[test]
fn number_filter_equal_test() {
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_tests.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_tests.rs
deleted file mode 100644
index a998cdf87e..0000000000
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_tests.rs
+++ /dev/null
@@ -1,80 +0,0 @@
-#[cfg(test)]
-mod tests {
-
- use crate::services::cell::CellDataDecoder;
- use crate::services::field::NumberCellData;
- use crate::services::field::{NumberFormat, NumberTypeOption};
-
- /// Testing when the input is not a number.
- #[test]
- fn number_type_option_input_test() {
- let type_option = NumberTypeOption::default();
-
- // Input is empty String
- assert_number(&type_option, "", "");
- assert_number(&type_option, "abc", "");
- assert_number(&type_option, "-123", "-123");
- assert_number(&type_option, "abc-123", "-123");
- assert_number(&type_option, "+123", "123");
- assert_number(&type_option, "0.2", "0.2");
- assert_number(&type_option, "-0.2", "-0.2");
- assert_number(&type_option, "-$0.2", "0.2");
- assert_number(&type_option, ".2", "0.2");
- }
-
- #[test]
- fn dollar_type_option_test() {
- let mut type_option = NumberTypeOption::new();
- type_option.format = NumberFormat::USD;
-
- assert_number(&type_option, "", "");
- assert_number(&type_option, "abc", "");
- assert_number(&type_option, "-123", "-$123");
- assert_number(&type_option, "+123", "$123");
- assert_number(&type_option, "0.2", "$0.2");
- assert_number(&type_option, "-0.2", "-$0.2");
- assert_number(&type_option, "-$0.2", "-$0.2");
- assert_number(&type_option, "-€0.2", "-$0.2");
- assert_number(&type_option, ".2", "$0.2");
- }
-
- #[test]
- fn dollar_type_option_test2() {
- let mut type_option = NumberTypeOption::new();
- type_option.format = NumberFormat::USD;
-
- assert_number(&type_option, "99999999999", "$99,999,999,999");
- assert_number(&type_option, "$99,999,999,999", "$99,999,999,999");
- }
- #[test]
- fn other_symbol_to_dollar_type_option_test() {
- let mut type_option = NumberTypeOption::new();
- type_option.format = NumberFormat::USD;
-
- assert_number(&type_option, "€0.2", "$0.2");
- assert_number(&type_option, "-€0.2", "-$0.2");
- assert_number(&type_option, "-CN¥0.2", "-$0.2");
- assert_number(&type_option, "CN¥0.2", "$0.2");
- assert_number(&type_option, "0.2", "$0.2");
- }
-
- #[test]
- fn euro_type_option_test() {
- let mut type_option = NumberTypeOption::new();
- type_option.format = NumberFormat::EUR;
-
- assert_number(&type_option, "0.2", "€0,2");
- assert_number(&type_option, "1000", "€1.000");
- assert_number(&type_option, "1234.56", "€1.234,56");
- }
-
- fn assert_number(type_option: &NumberTypeOption, input_str: &str, expected_str: &str) {
- assert_eq!(
- type_option
- .decode_cell(&NumberCellData(input_str.to_owned()).into(),)
- .unwrap()
- .to_string(),
- expected_str.to_owned()
- );
- }
-}
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_type_option.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_type_option.rs
index a9fca50283..912f53d636 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_type_option.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_type_option.rs
@@ -1,51 +1,30 @@
use async_trait::async_trait;
-use collab::preclude::encoding::serde::from_any;
-use collab::preclude::Any;
+
use collab::util::AnyMapExt;
use collab_database::database::Database;
-use collab_database::fields::{Field, TypeOptionData, TypeOptionDataBuilder};
+use collab_database::fields::number_type_option::{
+ NumberCellFormat, NumberFormat, NumberTypeOption,
+};
+use collab_database::fields::{Field, TypeOptionData};
use collab_database::rows::{new_cell_builder, Cell};
use fancy_regex::Regex;
use flowy_error::FlowyResult;
use lazy_static::lazy_static;
-use rust_decimal::Decimal;
-use serde::{Deserialize, Deserializer, Serialize};
+
use std::cmp::Ordering;
use std::default::Default;
-use std::str::FromStr;
+
use tracing::info;
use crate::entities::{FieldType, NumberFilterPB};
use crate::services::cell::{CellDataChangeset, CellDataDecoder};
-use crate::services::field::type_options::number_type_option::format::*;
use crate::services::field::type_options::util::ProtobufStr;
use crate::services::field::{
- NumberCellFormat, TypeOption, TypeOptionCellData, TypeOptionCellDataCompare,
- TypeOptionCellDataFilter, TypeOptionCellDataSerde, TypeOptionTransform, CELL_DATA,
+ TypeOption, TypeOptionCellData, TypeOptionCellDataCompare, TypeOptionCellDataFilter,
+ TypeOptionCellDataSerde, TypeOptionTransform, CELL_DATA,
};
use crate::services::sort::SortCondition;
-// Number
-#[derive(Clone, Debug, Serialize, Deserialize)]
-pub struct NumberTypeOption {
- #[serde(default, deserialize_with = "number_format_from_i64")]
- pub format: NumberFormat,
- #[serde(default)]
- pub scale: u32,
- #[serde(default)]
- pub symbol: String,
- #[serde(default)]
- pub name: String,
-}
-
-fn number_format_from_i64<'de, D>(deserializer: D) -> Result<NumberFormat, D::Error>
-where
- D: Deserializer<'de>,
-{
- let value = i64::deserialize(deserializer)?;
- Ok(NumberFormat::from(value))
-}
-
#[derive(Clone, Debug, Default)]
pub struct NumberCellData(pub String);
@@ -94,23 +73,6 @@ impl TypeOption for NumberTypeOption {
type CellFilter = NumberFilterPB;
}
-impl From<TypeOptionData> for NumberTypeOption {
- fn from(data: TypeOptionData) -> Self {
- from_any(&Any::from(data)).unwrap()
- }
-}
-
-impl From<NumberTypeOption> for TypeOptionData {
- fn from(data: NumberTypeOption) -> Self {
- TypeOptionDataBuilder::from([
- ("format".into(), Any::BigInt(data.format.value())),
- ("scale".into(), Any::BigInt(data.scale as i64)),
- ("name".into(), data.name.into()),
- ("symbol".into(), data.symbol.into()),
- ])
- }
-}
-
impl TypeOptionCellDataSerde for NumberTypeOption {
fn protobuf_encode(
&self,
@@ -124,63 +86,6 @@ impl TypeOptionCellDataSerde for NumberTypeOption {
}
}
-impl NumberTypeOption {
- pub fn new() -> Self {
- Self::default()
- }
-
- fn format_cell_data<T: AsRef<str>>(&self, num_cell_data: T) -> FlowyResult<NumberCellFormat> {
- match self.format {
- NumberFormat::Num => {
- if SCIENTIFIC_NOTATION_REGEX
- .is_match(num_cell_data.as_ref())
- .unwrap()
- {
- match Decimal::from_scientific(&num_cell_data.as_ref().to_lowercase()) {
- Ok(value, ..) => Ok(NumberCellFormat::from_decimal(value)),
- Err(_) => Ok(NumberCellFormat::new()),
- }
- } else {
- // Test the input string is start with dot and only contains number.
- // If it is, add a 0 before the dot. For example, ".123" -> "0.123"
- let num_str = match START_WITH_DOT_NUM_REGEX.captures(num_cell_data.as_ref()) {
- Ok(Some(captures)) => match captures.get(0).map(|m| m.as_str().to_string()) {
- Some(s) => {
- format!("0{}", s)
- },
- None => "".to_string(),
- },
- // Extract the number from the string.
- // For example, "123abc" -> "123". check out the number_type_option_input_test test for
- // more examples.
- _ => match EXTRACT_NUM_REGEX.captures(num_cell_data.as_ref()) {
- Ok(Some(captures)) => captures
- .get(0)
- .map(|m| m.as_str().to_string())
- .unwrap_or_default(),
- _ => "".to_string(),
- },
- };
-
- match Decimal::from_str(&num_str) {
- Ok(decimal, ..) => Ok(NumberCellFormat::from_decimal(decimal)),
- Err(_) => Ok(NumberCellFormat::new()),
- }
- }
- },
- _ => {
- // If the format is not number, use the format string to format the number.
- NumberCellFormat::from_format_str(num_cell_data.as_ref(), &self.format)
- },
- }
- }
-
- pub fn set_format(&mut self, format: NumberFormat) {
- self.format = format;
- self.symbol = format.symbol();
- }
-}
-
#[async_trait]
impl TypeOptionTransform for NumberTypeOption {
async fn transform_type_option(
@@ -208,7 +113,7 @@ impl TypeOptionTransform for NumberTypeOption {
for (row_id, cell_data) in rows {
if let Ok(num_cell) = self
.parse_cell(&cell_data)
- .and_then(|num_cell_data| self.format_cell_data(num_cell_data))
+ .and_then(|num_cell_data| self.format_cell_data(num_cell_data).map_err(Into::into))
{
database
.update_row(row_id, |row| {
@@ -335,19 +240,6 @@ impl TypeOptionCellDataCompare for NumberTypeOption {
}
}
-impl std::default::Default for NumberTypeOption {
- fn default() -> Self {
- let format = NumberFormat::default();
- let symbol = format.symbol();
- NumberTypeOption {
- format,
- scale: 0,
- symbol,
- name: "Number".to_string(),
- }
- }
-}
-
lazy_static! {
static ref SCIENTIFIC_NOTATION_REGEX: Regex = Regex::new(r"([+-]?\d*\.?\d+)e([+-]?\d+)").unwrap();
pub(crate) static ref EXTRACT_NUM_REGEX: Regex = Regex::new(r"-?\d+(\.\d+)?").unwrap();
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_type_option_entities.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_type_option_entities.rs
index 5085bc3db3..6f9cb36c49 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_type_option_entities.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_type_option_entities.rs
@@ -1,119 +1,14 @@
use crate::services::cell::{CellBytesCustomParser, CellProtobufBlobParser};
-use crate::services::field::number_currency::Currency;
-use crate::services::field::{NumberFormat, EXTRACT_NUM_REGEX, START_WITH_DOT_NUM_REGEX};
use bytes::Bytes;
+use collab_database::fields::number_type_option::{NumberCellFormat, NumberFormat};
use flowy_error::FlowyResult;
-use rust_decimal::Decimal;
-use rusty_money::Money;
-use std::str::FromStr;
-
-#[derive(Debug, Default)]
-pub struct NumberCellFormat {
- decimal: Option<Decimal>,
- money: Option<String>,
-}
-
-impl NumberCellFormat {
- pub fn new() -> Self {
- Self {
- decimal: Default::default(),
- money: None,
- }
- }
-
- /// The num_str might contain currency symbol, e.g. $1,000.00
- pub fn from_format_str(num_str: &str, format: &NumberFormat) -> FlowyResult<Self> {
- if num_str.is_empty() {
- return Ok(Self::default());
- }
- // If the first char is not '-', then it is a sign.
- let sign_positive = match num_str.find('-') {
- None => true,
- Some(offset) => offset != 0,
- };
-
- let num_str = auto_fill_zero_at_start_if_need(num_str);
- let num_str = extract_number(&num_str);
- match Decimal::from_str(&num_str) {
- Ok(mut decimal) => {
- decimal.set_sign_positive(sign_positive);
- let money = Money::from_decimal(decimal, format.currency());
- Ok(Self::from_money(money))
- },
- Err(_) => match Money::from_str(&num_str, format.currency()) {
- Ok(money) => Ok(Self::from_money(money)),
- Err(_) => Ok(Self::default()),
- },
- }
- }
-
- pub fn from_decimal(decimal: Decimal) -> Self {
- Self {
- decimal: Some(decimal),
- money: None,
- }
- }
-
- pub fn from_money(money: Money<Currency>) -> Self {
- Self {
- decimal: Some(*money.amount()),
- money: Some(money.to_string()),
- }
- }
-
- pub fn decimal(&self) -> &Option<Decimal> {
- &self.decimal
- }
-
- pub fn is_empty(&self) -> bool {
- self.decimal.is_none()
- }
-
- pub fn to_unformatted_string(&self) -> String {
- match self.decimal {
- None => String::default(),
- Some(decimal) => decimal.to_string(),
- }
- }
-}
-
-fn auto_fill_zero_at_start_if_need(num_str: &str) -> String {
- match START_WITH_DOT_NUM_REGEX.captures(num_str) {
- Ok(Some(captures)) => match captures.get(0).map(|m| m.as_str().to_string()) {
- Some(s) => format!("0{}", s),
- None => num_str.to_string(),
- },
- _ => num_str.to_string(),
- }
-}
-
-fn extract_number(num_str: &str) -> String {
- let mut matches = EXTRACT_NUM_REGEX.find_iter(num_str);
- let mut values = vec![];
- while let Some(Ok(m)) = matches.next() {
- values.push(m.as_str().to_string());
- }
- values.join("")
-}
-
-impl ToString for NumberCellFormat {
- fn to_string(&self) -> String {
- match &self.money {
- None => match self.decimal {
- None => String::default(),
- Some(decimal) => decimal.to_string(),
- },
- Some(money) => money.to_string(),
- }
- }
-}
pub struct NumberCellDataParser();
impl CellProtobufBlobParser for NumberCellDataParser {
type Object = NumberCellFormat;
fn parser(bytes: &Bytes) -> FlowyResult<Self::Object> {
match String::from_utf8(bytes.to_vec()) {
- Ok(s) => NumberCellFormat::from_format_str(&s, &NumberFormat::Num),
+ Ok(s) => NumberCellFormat::from_format_str(&s, &NumberFormat::Num).map_err(Into::into),
Err(_) => Ok(NumberCellFormat::default()),
}
}
@@ -124,7 +19,7 @@ impl CellBytesCustomParser for NumberCellCustomDataParser {
type Object = NumberCellFormat;
fn parse(&self, bytes: &Bytes) -> FlowyResult<Self::Object> {
match String::from_utf8(bytes.to_vec()) {
- Ok(s) => NumberCellFormat::from_format_str(&s, &self.0),
+ Ok(s) => NumberCellFormat::from_format_str(&s, &self.0).map_err(Into::into),
Err(_) => Ok(NumberCellFormat::default()),
}
}
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/mod.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/mod.rs
index dbcac0b8c2..8a4d4e40c9 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/mod.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/mod.rs
@@ -1,13 +1,7 @@
mod multi_select_type_option;
mod select_filter;
-mod select_ids;
-mod select_option;
mod select_type_option;
mod single_select_type_option;
mod type_option_transform;
-pub use multi_select_type_option::*;
-pub use select_ids::*;
-pub use select_option::*;
pub use select_type_option::*;
-pub use single_select_type_option::*;
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/multi_select_type_option.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/multi_select_type_option.rs
index fc55ee4dcd..896c3cbae2 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/multi_select_type_option.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/multi_select_type_option.rs
@@ -1,26 +1,19 @@
-use collab::util::AnyMapExt;
-use collab_database::entity::SelectOption;
-use collab_database::fields::{TypeOptionData, TypeOptionDataBuilder};
-use collab_database::rows::Cell;
-use serde::{Deserialize, Serialize};
-use std::cmp::Ordering;
-
-use flowy_error::FlowyResult;
-
use crate::entities::{FieldType, SelectOptionCellDataPB, SelectOptionFilterPB};
use crate::services::cell::CellDataChangeset;
use crate::services::field::{
- default_order, SelectOptionCellChangeset, SelectOptionIds, SelectTypeOptionSharedAction,
- TypeOption, TypeOptionCellDataCompare, TypeOptionCellDataFilter, TypeOptionCellDataSerde,
+ default_order, SelectOptionCellChangeset, SelectTypeOptionSharedAction, TypeOption,
+ TypeOptionCellDataCompare, TypeOptionCellDataFilter, TypeOptionCellDataSerde,
};
use crate::services::sort::SortCondition;
-// Multiple select
-#[derive(Clone, Debug, Default, Serialize, Deserialize)]
-pub struct MultiSelectTypeOption {
- pub options: Vec<SelectOption>,
- pub disable_color: bool,
-}
+use collab_database::fields::select_type_option::{
+ MultiSelectTypeOption, SelectOption, SelectOptionIds,
+};
+use collab_database::fields::TypeOptionData;
+use collab_database::rows::Cell;
+use flowy_error::FlowyResult;
+
+use std::cmp::Ordering;
impl TypeOption for MultiSelectTypeOption {
type CellData = SelectOptionIds;
@@ -29,22 +22,6 @@ impl TypeOption for MultiSelectTypeOption {
type CellFilter = SelectOptionFilterPB;
}
-impl From<TypeOptionData> for MultiSelectTypeOption {
- fn from(data: TypeOptionData) -> Self {
- data
- .get_as::<String>("content")
- .map(|json| serde_json::from_str::<MultiSelectTypeOption>(&json).unwrap_or_default())
- .unwrap_or_default()
- }
-}
-
-impl From<MultiSelectTypeOption> for TypeOptionData {
- fn from(data: MultiSelectTypeOption) -> Self {
- let content = serde_json::to_string(&data).unwrap_or_default();
- TypeOptionDataBuilder::from([("content".into(), content.into())])
- }
-}
-
impl TypeOptionCellDataSerde for MultiSelectTypeOption {
fn protobuf_encode(
&self,
@@ -177,17 +154,18 @@ impl TypeOptionCellDataCompare for MultiSelectTypeOption {
mod tests {
use crate::services::cell::CellDataChangeset;
use crate::services::field::type_options::selection_type_option::*;
- use crate::services::field::MultiSelectTypeOption;
- use collab_database::entity::SelectOption;
+ use collab_database::fields::select_type_option::{
+ MultiSelectTypeOption, SelectOption, SelectOptionIds, SelectTypeOption,
+ };
#[test]
fn multi_select_insert_multi_option_test() {
let google = SelectOption::new("Google");
let facebook = SelectOption::new("Facebook");
- let multi_select = MultiSelectTypeOption {
+ let multi_select = MultiSelectTypeOption(SelectTypeOption {
options: vec![google.clone(), facebook.clone()],
disable_color: false,
- };
+ });
let option_ids = vec![google.id, facebook.id];
let changeset = SelectOptionCellChangeset::from_insert_options(option_ids.clone());
@@ -201,10 +179,10 @@ mod tests {
fn multi_select_unselect_multi_option_test() {
let google = SelectOption::new("Google");
let facebook = SelectOption::new("Facebook");
- let multi_select = MultiSelectTypeOption {
+ let multi_select = MultiSelectTypeOption(SelectTypeOption {
options: vec![google.clone(), facebook.clone()],
disable_color: false,
- };
+ });
let option_ids = vec![google.id, facebook.id];
// insert
@@ -221,10 +199,10 @@ mod tests {
#[test]
fn multi_select_insert_single_option_test() {
let google = SelectOption::new("Google");
- let multi_select = MultiSelectTypeOption {
+ let multi_select = MultiSelectTypeOption(SelectTypeOption {
options: vec![google.clone()],
disable_color: false,
- };
+ });
let changeset = SelectOptionCellChangeset::from_insert_option_id(&google.id);
let select_option_ids = multi_select.apply_changeset(changeset, None).unwrap().1;
@@ -234,10 +212,10 @@ mod tests {
#[test]
fn multi_select_insert_non_exist_option_test() {
let google = SelectOption::new("Google");
- let multi_select = MultiSelectTypeOption {
+ let multi_select = MultiSelectTypeOption(SelectTypeOption {
options: vec![],
disable_color: false,
- };
+ });
let changeset = SelectOptionCellChangeset::from_insert_option_id(&google.id);
let (_, select_option_ids) = multi_select.apply_changeset(changeset, None).unwrap();
@@ -247,10 +225,10 @@ mod tests {
#[test]
fn multi_select_insert_invalid_option_id_test() {
let google = SelectOption::new("Google");
- let multi_select = MultiSelectTypeOption {
+ let multi_select = MultiSelectTypeOption(SelectTypeOption {
options: vec![google],
disable_color: false,
- };
+ });
// empty option id string
let changeset = SelectOptionCellChangeset::from_insert_option_id("");
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/select_filter.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/select_filter.rs
index efd54332b9..63de18c28a 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/select_filter.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/select_filter.rs
@@ -1,4 +1,4 @@
-use collab_database::entity::SelectOption;
+use collab_database::fields::select_type_option::SelectOption;
use collab_database::fields::Field;
use collab_database::rows::Cell;
@@ -133,7 +133,7 @@ impl PreFillCellsWithFilter for SelectOptionFilterPB {
#[cfg(test)]
mod tests {
use crate::entities::{SelectOptionFilterConditionPB, SelectOptionFilterPB};
- use collab_database::entity::SelectOption;
+ use collab_database::fields::select_type_option::SelectOption;
#[test]
fn select_option_filter_is_empty_test() {
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/select_ids.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/select_ids.rs
deleted file mode 100644
index c75730dfac..0000000000
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/select_ids.rs
+++ /dev/null
@@ -1,102 +0,0 @@
-use collab::util::AnyMapExt;
-use std::str::FromStr;
-
-use collab_database::rows::{new_cell_builder, Cell};
-
-use flowy_error::FlowyError;
-
-use crate::entities::FieldType;
-use crate::services::field::{TypeOptionCellData, CELL_DATA};
-
-pub const SELECTION_IDS_SEPARATOR: &str = ",";
-
-/// List of select option ids
-///
-/// Calls [to_string] will return a string consists list of ids,
-/// placing a commas separator between each
-///
-#[derive(Default, Clone, Debug)]
-pub struct SelectOptionIds(Vec<String>);
-
-impl SelectOptionIds {
- pub fn new() -> Self {
- Self::default()
- }
- pub fn into_inner(self) -> Vec<String> {
- self.0
- }
- pub fn to_cell_data(&self, field_type: FieldType) -> Cell {
- let mut cell = new_cell_builder(field_type);
- cell.insert(CELL_DATA.into(), self.to_string().into());
- cell
- }
-}
-
-impl TypeOptionCellData for SelectOptionIds {
- fn is_cell_empty(&self) -> bool {
- self.is_empty()
- }
-}
-
-impl From<&Cell> for SelectOptionIds {
- fn from(cell: &Cell) -> Self {
- let value: String = cell.get_as(CELL_DATA).unwrap_or_default();
- Self::from_str(&value).unwrap_or_default()
- }
-}
-
-impl FromStr for SelectOptionIds {
- type Err = FlowyError;
-
- fn from_str(s: &str) -> Result<Self, Self::Err> {
- if s.is_empty() {
- return Ok(Self(vec![]));
- }
- let ids = s
- .split(SELECTION_IDS_SEPARATOR)
- .map(|id| id.to_string())
- .collect::<Vec<String>>();
- Ok(Self(ids))
- }
-}
-
-impl std::convert::From<Vec<String>> for SelectOptionIds {
- fn from(ids: Vec<String>) -> Self {
- let ids = ids
- .into_iter()
- .filter(|id| !id.is_empty())
- .collect::<Vec<String>>();
- Self(ids)
- }
-}
-
-impl ToString for SelectOptionIds {
- /// Returns a string that consists list of ids, placing a commas
- /// separator between each
- fn to_string(&self) -> String {
- self.0.join(SELECTION_IDS_SEPARATOR)
- }
-}
-
-impl std::convert::From<Option<String>> for SelectOptionIds {
- fn from(s: Option<String>) -> Self {
- match s {
- None => Self(vec![]),
- Some(s) => Self::from_str(&s).unwrap_or_default(),
- }
- }
-}
-
-impl std::ops::Deref for SelectOptionIds {
- type Target = Vec<String>;
-
- fn deref(&self) -> &Self::Target {
- &self.0
- }
-}
-
-impl std::ops::DerefMut for SelectOptionIds {
- fn deref_mut(&mut self) -> &mut Self::Target {
- &mut self.0
- }
-}
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/select_option.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/select_option.rs
deleted file mode 100644
index f57010c0a3..0000000000
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/select_option.rs
+++ /dev/null
@@ -1,32 +0,0 @@
-use crate::entities::SelectOptionCellDataPB;
-use crate::services::field::SelectOptionIds;
-use collab_database::entity::SelectOption;
-
-#[derive(Debug)]
-pub struct SelectOptionCellData {
- pub select_options: Vec<SelectOption>,
-}
-
-impl From<SelectOptionCellData> for SelectOptionCellDataPB {
- fn from(data: SelectOptionCellData) -> Self {
- SelectOptionCellDataPB {
- select_options: data
- .select_options
- .into_iter()
- .map(|option| option.into())
- .collect(),
- }
- }
-}
-
-pub fn make_selected_options(ids: SelectOptionIds, options: &[SelectOption]) -> Vec<SelectOption> {
- ids
- .iter()
- .flat_map(|option_id| {
- options
- .iter()
- .find(|option| &option.id == option_id)
- .cloned()
- })
- .collect()
-}
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/select_type_option.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/select_type_option.rs
index b464f9cd04..095830aa25 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/select_type_option.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/select_type_option.rs
@@ -1,20 +1,26 @@
+use crate::entities::{CheckboxCellDataPB, FieldType, SelectOptionCellDataPB};
+use crate::services::cell::{CellDataDecoder, CellProtobufBlobParser};
+use crate::services::field::selection_type_option::type_option_transform::SelectOptionTypeOptionTransformHelper;
+use crate::services::field::{
+ StringCellData, TypeOption, TypeOptionCellData, TypeOptionCellDataSerde, TypeOptionTransform,
+};
use async_trait::async_trait;
use bytes::Bytes;
use collab_database::database::Database;
-use collab_database::entity::{SelectOption, SelectOptionColor};
+use collab_database::fields::select_type_option::{
+ MultiSelectTypeOption, SelectOption, SelectOptionColor, SelectOptionIds, SingleSelectTypeOption,
+ SELECTION_IDS_SEPARATOR,
+};
use collab_database::fields::{Field, TypeOptionData};
use collab_database::rows::Cell;
use flowy_error::{internal_error, ErrorCode, FlowyResult};
use std::str::FromStr;
-use crate::entities::{CheckboxCellDataPB, FieldType, SelectOptionCellDataPB};
-use crate::services::cell::{CellDataDecoder, CellProtobufBlobParser};
-use crate::services::field::selection_type_option::type_option_transform::SelectOptionTypeOptionTransformHelper;
-use crate::services::field::{
- make_selected_options, MultiSelectTypeOption, SelectOptionCellData, SelectOptionIds,
- SingleSelectTypeOption, StringCellData, TypeOption, TypeOptionCellDataSerde, TypeOptionTransform,
- SELECTION_IDS_SEPARATOR,
-};
+impl TypeOptionCellData for SelectOptionIds {
+ fn is_cell_empty(&self) -> bool {
+ self.is_empty()
+ }
+}
/// Defines the shared actions used by SingleSelect or Multi-Select.
pub trait SelectTypeOptionSharedAction: Send + Sync {
@@ -206,7 +212,7 @@ impl CellProtobufBlobParser for SelectOptionIdsParser {
type Object = SelectOptionIds;
fn parser(bytes: &Bytes) -> FlowyResult<Self::Object> {
match String::from_utf8(bytes.to_vec()) {
- Ok(s) => SelectOptionIds::from_str(&s),
+ Ok(s) => SelectOptionIds::from_str(&s).map_err(Into::into),
Err(_) => Ok(SelectOptionIds::default()),
}
}
@@ -256,3 +262,32 @@ impl SelectOptionCellChangeset {
}
}
}
+
+#[derive(Debug)]
+pub struct SelectOptionCellData {
+ pub select_options: Vec<SelectOption>,
+}
+
+impl From<SelectOptionCellData> for SelectOptionCellDataPB {
+ fn from(data: SelectOptionCellData) -> Self {
+ SelectOptionCellDataPB {
+ select_options: data
+ .select_options
+ .into_iter()
+ .map(|option| option.into())
+ .collect(),
+ }
+ }
+}
+
+pub fn make_selected_options(ids: SelectOptionIds, options: &[SelectOption]) -> Vec<SelectOption> {
+ ids
+ .iter()
+ .flat_map(|option_id| {
+ options
+ .iter()
+ .find(|option| &option.id == option_id)
+ .cloned()
+ })
+ .collect()
+}
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/single_select_type_option.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/single_select_type_option.rs
index 8f805a077f..a97d0bf3f5 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/single_select_type_option.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/single_select_type_option.rs
@@ -4,24 +4,19 @@ use crate::services::field::{
default_order, TypeOption, TypeOptionCellDataCompare, TypeOptionCellDataFilter,
TypeOptionCellDataSerde,
};
-use crate::services::field::{
- SelectOptionCellChangeset, SelectOptionIds, SelectTypeOptionSharedAction,
-};
+use crate::services::field::{SelectOptionCellChangeset, SelectTypeOptionSharedAction};
use crate::services::sort::SortCondition;
-use collab::util::AnyMapExt;
-use collab_database::entity::SelectOption;
-use collab_database::fields::{TypeOptionData, TypeOptionDataBuilder};
+
+use collab_database::fields::select_type_option::{
+ SelectOption, SelectOptionIds, SingleSelectTypeOption,
+};
+use collab_database::fields::TypeOptionData;
use collab_database::rows::Cell;
use flowy_error::FlowyResult;
-use serde::{Deserialize, Serialize};
+
use std::cmp::Ordering;
// Single select
-#[derive(Clone, Debug, Default, Serialize, Deserialize)]
-pub struct SingleSelectTypeOption {
- pub options: Vec<SelectOption>,
- pub disable_color: bool,
-}
impl TypeOption for SingleSelectTypeOption {
type CellData = SelectOptionIds;
@@ -30,22 +25,6 @@ impl TypeOption for SingleSelectTypeOption {
type CellFilter = SelectOptionFilterPB;
}
-impl From<TypeOptionData> for SingleSelectTypeOption {
- fn from(data: TypeOptionData) -> Self {
- data
- .get_as::<String>("content")
- .map(|s| serde_json::from_str::<SingleSelectTypeOption>(&s).unwrap_or_default())
- .unwrap_or_default()
- }
-}
-
-impl From<SingleSelectTypeOption> for TypeOptionData {
- fn from(data: SingleSelectTypeOption) -> Self {
- let content = serde_json::to_string(&data).unwrap_or_default();
- TypeOptionDataBuilder::from([("content".into(), content.into())])
- }
-}
-
impl TypeOptionCellDataSerde for SingleSelectTypeOption {
fn protobuf_encode(
&self,
@@ -152,16 +131,18 @@ impl TypeOptionCellDataCompare for SingleSelectTypeOption {
mod tests {
use crate::services::cell::CellDataChangeset;
use crate::services::field::type_options::*;
- use collab_database::entity::SelectOption;
+ use collab_database::fields::select_type_option::{
+ SelectOption, SelectTypeOption, SingleSelectTypeOption,
+ };
#[test]
fn single_select_insert_multi_option_test() {
let google = SelectOption::new("Google");
let facebook = SelectOption::new("Facebook");
- let single_select = SingleSelectTypeOption {
+ let single_select = SingleSelectTypeOption(SelectTypeOption {
options: vec![google.clone(), facebook.clone()],
disable_color: false,
- };
+ });
let option_ids = vec![google.id.clone(), facebook.id];
let changeset = SelectOptionCellChangeset::from_insert_options(option_ids);
@@ -173,10 +154,10 @@ mod tests {
fn single_select_unselect_multi_option_test() {
let google = SelectOption::new("Google");
let facebook = SelectOption::new("Facebook");
- let single_select = SingleSelectTypeOption {
+ let single_select = SingleSelectTypeOption(SelectTypeOption {
options: vec![google.clone(), facebook.clone()],
disable_color: false,
- };
+ });
let option_ids = vec![google.id.clone(), facebook.id];
// insert
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/type_option_transform.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/type_option_transform.rs
index 048f5536ae..4b63f7e9c1 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/type_option_transform.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/selection_type_option/type_option_transform.rs
@@ -1,11 +1,11 @@
use crate::entities::FieldType;
use crate::services::cell::CellDataDecoder;
-use crate::services::field::{
- MultiSelectTypeOption, RichTextTypeOption, SelectOptionIds, SelectTypeOptionSharedAction,
- SingleSelectTypeOption, TypeOption, CHECK, UNCHECK,
-};
+use crate::services::field::{SelectTypeOptionSharedAction, TypeOption, CHECK, UNCHECK};
use collab_database::database::Database;
-use collab_database::entity::{SelectOption, SelectOptionColor};
+use collab_database::fields::select_type_option::{
+ 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;
@@ -89,7 +89,7 @@ impl SelectOptionTypeOptionTransformHelper {
}
},
FieldType::MultiSelect => {
- let options = MultiSelectTypeOption::from(old_type_option_data).options;
+ let options = SelectTypeOption::from(old_type_option_data).options;
options.iter().for_each(|new_option| {
if !shared
.options()
@@ -101,7 +101,7 @@ impl SelectOptionTypeOptionTransformHelper {
})
},
FieldType::SingleSelect => {
- let options = SingleSelectTypeOption::from(old_type_option_data).options;
+ let options = SelectTypeOption::from(old_type_option_data).options;
options.iter().for_each(|new_option| {
if !shared
.options()
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/text_type_option/text_tests.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/text_type_option/text_tests.rs
index 172a8a46a7..e5101a2775 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/text_type_option/text_tests.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/text_type_option/text_tests.rs
@@ -3,15 +3,16 @@ mod tests {
use crate::entities::FieldType;
use crate::services::cell::{insert_select_option_cell, stringify_cell};
use crate::services::field::FieldBuilder;
- use crate::services::field::*;
- use collab_database::entity::SelectOption;
+
+ use collab_database::fields::date_type_option::{DateCellData, DateTypeOption};
+ use collab_database::fields::select_type_option::{SelectOption, SelectTypeOption};
// Test parser the cell data which field's type is FieldType::Date to cell data
// which field's type is FieldType::Text
#[test]
fn date_type_to_text_type() {
let field_type = FieldType::DateTime;
- let field = FieldBuilder::new(field_type, DateTypeOption::test()).build();
+ let field = FieldBuilder::new(field_type, DateTypeOption::default_utc()).build();
let data = DateCellData {
timestamp: Some(1647251762),
@@ -68,7 +69,7 @@ mod tests {
let done_option = SelectOption::new("Done");
let option_id = done_option.id.clone();
- let single_select = SingleSelectTypeOption {
+ let single_select = SelectTypeOption {
options: vec![done_option.clone()],
disable_color: false,
};
@@ -85,7 +86,7 @@ mod tests {
let france = SelectOption::new("france");
let argentina = SelectOption::new("argentina");
- let multi_select = MultiSelectTypeOption {
+ let multi_select = SelectTypeOption {
options: vec![france.clone(), argentina.clone()],
disable_color: false,
};
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/text_type_option/text_type_option.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/text_type_option/text_type_option.rs
index 0566cdf641..254c60cb95 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/text_type_option/text_type_option.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/text_type_option/text_type_option.rs
@@ -1,9 +1,9 @@
use collab::util::AnyMapExt;
use std::cmp::Ordering;
-use collab_database::fields::{Field, TypeOptionData, TypeOptionDataBuilder};
+use collab_database::fields::text_type_option::RichTextTypeOption;
+use collab_database::fields::Field;
use collab_database::rows::{new_cell_builder, Cell};
-use serde::{Deserialize, Serialize};
use flowy_error::{FlowyError, FlowyResult};
@@ -16,14 +16,6 @@ use crate::services::field::{
};
use crate::services::sort::SortCondition;
-/// For the moment, the `RichTextTypeOptionPB` is empty. The `data` property is not
-/// used yet.
-#[derive(Debug, Clone, Default, Serialize, Deserialize)]
-pub struct RichTextTypeOption {
- #[serde(default)]
- pub inner: String,
-}
-
impl TypeOption for RichTextTypeOption {
type CellData = StringCellData;
type CellChangeset = String;
@@ -31,20 +23,6 @@ impl TypeOption for RichTextTypeOption {
type CellFilter = TextFilterPB;
}
-impl From<TypeOptionData> for RichTextTypeOption {
- fn from(data: TypeOptionData) -> Self {
- Self {
- inner: data.get_as(CELL_DATA).unwrap_or_default(),
- }
- }
-}
-
-impl From<RichTextTypeOption> for TypeOptionData {
- fn from(data: RichTextTypeOption) -> Self {
- TypeOptionDataBuilder::from([(CELL_DATA.into(), data.inner.into())])
- }
-}
-
impl TypeOptionTransform for RichTextTypeOption {}
impl TypeOptionCellDataSerde for RichTextTypeOption {
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/time_type_option/time.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/time_type_option/time.rs
index 2125eb8f88..0d877cef32 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/time_type_option/time.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/time_type_option/time.rs
@@ -5,14 +5,12 @@ use crate::services::field::{
TypeOptionCellDataSerde, TypeOptionTransform,
};
use crate::services::sort::SortCondition;
-use collab_database::fields::{TypeOptionData, TypeOptionDataBuilder};
+use collab_database::fields::date_type_option::TimeTypeOption;
+
use collab_database::rows::Cell;
use flowy_error::FlowyResult;
-use serde::{Deserialize, Serialize};
-use std::cmp::Ordering;
-#[derive(Clone, Debug, Serialize, Deserialize, Default)]
-pub struct TimeTypeOption;
+use std::cmp::Ordering;
impl TypeOption for TimeTypeOption {
type CellData = TimeCellData;
@@ -21,18 +19,6 @@ impl TypeOption for TimeTypeOption {
type CellFilter = TimeFilterPB;
}
-impl From<TypeOptionData> for TimeTypeOption {
- fn from(_data: TypeOptionData) -> Self {
- Self
- }
-}
-
-impl From<TimeTypeOption> for TypeOptionData {
- fn from(_data: TimeTypeOption) -> Self {
- TypeOptionDataBuilder::new()
- }
-}
-
impl TypeOptionCellDataSerde for TimeTypeOption {
fn protobuf_encode(
&self,
@@ -51,12 +37,6 @@ impl TypeOptionCellDataSerde for TimeTypeOption {
}
}
-impl TimeTypeOption {
- pub fn new() -> Self {
- Self
- }
-}
-
impl TypeOptionTransform for TimeTypeOption {}
impl CellDataDecoder for TimeTypeOption {
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/timestamp_type_option/mod.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/timestamp_type_option/mod.rs
index 3041a7947b..953bf8839e 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/timestamp_type_option/mod.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/timestamp_type_option/mod.rs
@@ -2,5 +2,4 @@
mod timestamp_type_option;
mod timestamp_type_option_entities;
-pub use timestamp_type_option::*;
pub use timestamp_type_option_entities::*;
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/timestamp_type_option/timestamp_type_option.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/timestamp_type_option/timestamp_type_option.rs
index 0e1416ab89..16f1800045 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/timestamp_type_option/timestamp_type_option.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/timestamp_type_option/timestamp_type_option.rs
@@ -1,39 +1,14 @@
-use std::cmp::Ordering;
-
-use chrono::{DateTime, Local, Offset};
-use collab::preclude::Any;
-use collab::util::AnyMapExt;
-use collab_database::fields::{TypeOptionData, TypeOptionDataBuilder};
-use collab_database::rows::Cell;
-use flowy_error::{ErrorCode, FlowyError, FlowyResult};
-use serde::{Deserialize, Serialize};
-
-use crate::entities::{DateFilterPB, FieldType, TimestampCellDataPB};
+use crate::entities::{DateFilterPB, TimestampCellDataPB};
use crate::services::cell::{CellDataChangeset, CellDataDecoder};
use crate::services::field::{
- default_order, DateFormat, TimeFormat, TimestampCellData, TypeOption, TypeOptionCellDataCompare,
+ default_order, TimestampCellData, TypeOption, TypeOptionCellDataCompare,
TypeOptionCellDataFilter, TypeOptionCellDataSerde, TypeOptionTransform,
};
use crate::services::sort::SortCondition;
-
-#[derive(Clone, Debug, Serialize, Deserialize)]
-pub struct TimestampTypeOption {
- pub date_format: DateFormat,
- pub time_format: TimeFormat,
- pub include_time: bool,
- pub field_type: FieldType,
-}
-
-impl Default for TimestampTypeOption {
- fn default() -> Self {
- Self {
- date_format: Default::default(),
- time_format: Default::default(),
- include_time: true,
- field_type: FieldType::LastEditedTime,
- }
- }
-}
+use collab_database::fields::timestamp_type_option::TimestampTypeOption;
+use collab_database::rows::Cell;
+use flowy_error::{ErrorCode, FlowyError, FlowyResult};
+use std::cmp::Ordering;
impl TypeOption for TimestampTypeOption {
type CellData = TimestampCellData;
@@ -42,47 +17,6 @@ impl TypeOption for TimestampTypeOption {
type CellFilter = DateFilterPB;
}
-impl From<TypeOptionData> for TimestampTypeOption {
- fn from(data: TypeOptionData) -> Self {
- let date_format = data
- .get_as::<i64>("date_format")
- .map(DateFormat::from)
- .unwrap_or_default();
- let time_format = data
- .get_as::<i64>("time_format")
- .map(TimeFormat::from)
- .unwrap_or_default();
- let include_time = data.get_as::<bool>("include_time").unwrap_or_default();
- let field_type = data
- .get_as::<i64>("field_type")
- .map(FieldType::from)
- .unwrap_or(FieldType::LastEditedTime);
- Self {
- date_format,
- time_format,
- include_time,
- field_type,
- }
- }
-}
-
-impl From<TimestampTypeOption> for TypeOptionData {
- fn from(option: TimestampTypeOption) -> Self {
- TypeOptionDataBuilder::from([
- (
- "date_format".into(),
- Any::BigInt(option.date_format.value()),
- ),
- (
- "time_format".into(),
- Any::BigInt(option.time_format.value()),
- ),
- ("include_time".into(), Any::Bool(option.include_time)),
- ("field_type".into(), Any::BigInt(option.field_type.value())),
- ])
- }
-}
-
impl TypeOptionCellDataSerde for TimestampTypeOption {
fn protobuf_encode(
&self,
@@ -102,32 +36,6 @@ impl TypeOptionCellDataSerde for TimestampTypeOption {
}
}
-impl TimestampTypeOption {
- pub fn new(field_type: FieldType) -> Self {
- Self {
- field_type,
- include_time: true,
- ..Default::default()
- }
- }
-
- fn formatted_date_time_from_timestamp(&self, timestamp: &Option<i64>) -> (String, String) {
- if let Some(timestamp) = timestamp {
- let naive = chrono::NaiveDateTime::from_timestamp_opt(*timestamp, 0).unwrap();
- let offset = Local::now().offset().fix();
- let date_time = DateTime::<Local>::from_naive_utc_and_offset(naive, offset);
-
- let fmt = self.date_format.format_str();
- let date = format!("{}", date_time.format(fmt));
- let fmt = self.time_format.format_str();
- let time = format!("{}", date_time.format(fmt));
- (date, time)
- } else {
- ("".to_owned(), "".to_owned())
- }
- }
-}
-
impl TypeOptionTransform for TimestampTypeOption {}
impl CellDataDecoder for TimestampTypeOption {
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/type_option.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/type_option.rs
index bfeae5cab4..1ec4821378 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/type_option.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/type_option.rs
@@ -1,14 +1,3 @@
-use async_trait::async_trait;
-use bytes::Bytes;
-use collab_database::database::Database;
-use collab_database::fields::TypeOptionData;
-use collab_database::rows::Cell;
-use protobuf::ProtobufError;
-use std::cmp::Ordering;
-use std::fmt::Debug;
-
-use flowy_error::FlowyResult;
-
use crate::entities::{
CheckboxTypeOptionPB, ChecklistTypeOptionPB, DateTypeOptionPB, FieldType, MediaTypeOptionPB,
MultiSelectTypeOptionPB, NumberTypeOptionPB, RelationTypeOptionPB, RichTextTypeOptionPB,
@@ -19,13 +8,26 @@ use crate::services::cell::CellDataDecoder;
use crate::services::field::checklist_type_option::ChecklistTypeOption;
use crate::services::field::summary_type_option::summary::SummarizationTypeOption;
use crate::services::field::translate_type_option::translate::TranslateTypeOption;
-use crate::services::field::{
- CheckboxTypeOption, DateTypeOption, MediaTypeOption, MultiSelectTypeOption, NumberTypeOption,
- RelationTypeOption, RichTextTypeOption, SingleSelectTypeOption, TimeTypeOption,
- TimestampTypeOption, URLTypeOption,
-};
+use crate::services::field::RelationTypeOption;
use crate::services::filter::{ParseFilterData, PreFillCellsWithFilter};
use crate::services::sort::SortCondition;
+use async_trait::async_trait;
+use bytes::Bytes;
+use collab_database::database::Database;
+use collab_database::fields::checkbox_type_option::CheckboxTypeOption;
+use collab_database::fields::date_type_option::{DateTypeOption, TimeTypeOption};
+use collab_database::fields::media_type_option::MediaTypeOption;
+use collab_database::fields::number_type_option::NumberTypeOption;
+use collab_database::fields::select_type_option::{MultiSelectTypeOption, SingleSelectTypeOption};
+use collab_database::fields::text_type_option::RichTextTypeOption;
+use collab_database::fields::timestamp_type_option::TimestampTypeOption;
+use collab_database::fields::url_type_option::URLTypeOption;
+use collab_database::fields::TypeOptionData;
+use collab_database::rows::Cell;
+use flowy_error::FlowyResult;
+use protobuf::ProtobufError;
+use std::cmp::Ordering;
+use std::fmt::Debug;
pub trait TypeOption: From<TypeOptionData> + Into<TypeOptionData> {
/// `CellData` represents the decoded model for the current type option. Each of them must
@@ -230,13 +232,13 @@ pub fn type_option_to_pb(type_option: TypeOptionData, field_type: &FieldType) ->
},
FieldType::SingleSelect => {
let single_select_type_option: SingleSelectTypeOption = type_option.into();
- SingleSelectTypeOptionPB::from(single_select_type_option)
+ SingleSelectTypeOptionPB::from(single_select_type_option.0)
.try_into()
.unwrap()
},
FieldType::MultiSelect => {
let multi_select_type_option: MultiSelectTypeOption = type_option.into();
- MultiSelectTypeOptionPB::from(multi_select_type_option)
+ MultiSelectTypeOptionPB::from(multi_select_type_option.0)
.try_into()
.unwrap()
},
@@ -289,17 +291,17 @@ pub fn type_option_to_pb(type_option: TypeOptionData, field_type: &FieldType) ->
pub fn default_type_option_data_from_type(field_type: FieldType) -> TypeOptionData {
match field_type {
- FieldType::RichText => RichTextTypeOption::default().into(),
+ FieldType::RichText => RichTextTypeOption.into(),
FieldType::Number => NumberTypeOption::default().into(),
FieldType::DateTime => DateTypeOption::default().into(),
FieldType::LastEditedTime | FieldType::CreatedTime => TimestampTypeOption {
- field_type,
+ field_type: field_type.into(),
..Default::default()
}
.into(),
FieldType::SingleSelect => SingleSelectTypeOption::default().into(),
FieldType::MultiSelect => MultiSelectTypeOption::default().into(),
- FieldType::Checkbox => CheckboxTypeOption::default().into(),
+ FieldType::Checkbox => CheckboxTypeOption.into(),
FieldType::URL => URLTypeOption::default().into(),
FieldType::Checklist => ChecklistTypeOption.into(),
FieldType::Relation => RelationTypeOption::default().into(),
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/type_option_cell.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/type_option_cell.rs
index 99a29813ad..4ece62b2cc 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/type_option_cell.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/type_option_cell.rs
@@ -1,25 +1,30 @@
-use collab::preclude::Any;
-use std::cmp::Ordering;
-use std::collections::hash_map::DefaultHasher;
-use std::collections::HashMap;
-use std::hash::{Hash, Hasher};
-
-use collab_database::fields::Field;
-use collab_database::rows::{get_field_type_from_cell, Cell, RowId};
-use flowy_error::FlowyResult;
-use lib_infra::box_any::BoxAny;
-
use crate::entities::FieldType;
use crate::services::cell::{CellCache, CellDataChangeset, CellDataDecoder, CellProtobufBlob};
use crate::services::field::summary_type_option::summary::SummarizationTypeOption;
use crate::services::field::translate_type_option::translate::TranslateTypeOption;
use crate::services::field::{
- CheckboxTypeOption, ChecklistTypeOption, DateTypeOption, MediaTypeOption, MultiSelectTypeOption,
- NumberTypeOption, RelationTypeOption, RichTextTypeOption, SingleSelectTypeOption, TimeTypeOption,
- TimestampTypeOption, TypeOption, TypeOptionCellData, TypeOptionCellDataCompare,
- TypeOptionCellDataFilter, TypeOptionCellDataSerde, TypeOptionTransform, URLTypeOption,
+ ChecklistTypeOption, RelationTypeOption, TypeOption, TypeOptionCellData,
+ TypeOptionCellDataCompare, TypeOptionCellDataFilter, TypeOptionCellDataSerde,
+ TypeOptionTransform,
};
use crate::services::sort::SortCondition;
+use collab::preclude::Any;
+use collab_database::fields::checkbox_type_option::CheckboxTypeOption;
+use collab_database::fields::date_type_option::{DateTypeOption, TimeTypeOption};
+use collab_database::fields::media_type_option::MediaTypeOption;
+use collab_database::fields::number_type_option::NumberTypeOption;
+use collab_database::fields::select_type_option::{MultiSelectTypeOption, SingleSelectTypeOption};
+use collab_database::fields::text_type_option::RichTextTypeOption;
+use collab_database::fields::timestamp_type_option::TimestampTypeOption;
+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 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::hash::{Hash, Hasher};
pub const CELL_DATA: &str = "data";
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/url_type_option/url_tests.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/url_type_option/url_tests.rs
index 7f32aa4c18..9c54ed2f0d 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/url_type_option/url_tests.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/url_type_option/url_tests.rs
@@ -5,7 +5,7 @@ mod tests {
use crate::entities::FieldType;
use crate::services::cell::CellDataChangeset;
use crate::services::field::FieldBuilder;
- use crate::services::field::URLTypeOption;
+ use collab_database::fields::url_type_option::URLTypeOption;
#[test]
fn url_test() {
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/url_type_option/url_type_option.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/url_type_option/url_type_option.rs
index 5184048f5d..0a7da1298b 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/url_type_option/url_type_option.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/url_type_option/url_type_option.rs
@@ -1,30 +1,20 @@
-use collab::preclude::encoding::serde::from_any;
-use collab::preclude::Any;
-
use crate::entities::{FieldType, TextFilterPB, URLCellDataPB};
use crate::services::cell::{CellDataChangeset, CellDataDecoder};
use crate::services::field::{
TypeOption, TypeOptionCellDataCompare, TypeOptionCellDataFilter, TypeOptionCellDataSerde,
- TypeOptionTransform, URLCellData,
+ TypeOptionTransform,
};
use crate::services::sort::SortCondition;
use async_trait::async_trait;
use collab_database::database::Database;
-use collab_database::fields::{Field, TypeOptionData, TypeOptionDataBuilder};
+use collab_database::fields::url_type_option::{URLCellData, URLTypeOption};
+use collab_database::fields::{Field, TypeOptionData};
use collab_database::rows::Cell;
use flowy_error::FlowyResult;
-use serde::{Deserialize, Serialize};
+
use std::cmp::Ordering;
use tracing::trace;
-#[derive(Debug, Clone, Serialize, Deserialize, Default)]
-pub struct URLTypeOption {
- #[serde(default)]
- pub url: String,
- #[serde(default)]
- pub content: String,
-}
-
impl TypeOption for URLTypeOption {
type CellData = URLCellData;
type CellChangeset = URLCellChangeset;
@@ -32,21 +22,6 @@ impl TypeOption for URLTypeOption {
type CellFilter = TextFilterPB;
}
-impl From<TypeOptionData> for URLTypeOption {
- fn from(data: TypeOptionData) -> Self {
- from_any(&Any::from(data)).unwrap()
- }
-}
-
-impl From<URLTypeOption> for TypeOptionData {
- fn from(data: URLTypeOption) -> Self {
- TypeOptionDataBuilder::from([
- ("url".into(), data.url.into()),
- ("content".into(), data.content.into()),
- ])
- }
-}
-
#[async_trait]
impl TypeOptionTransform for URLTypeOption {
async fn transform_type_option(
diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/url_type_option/url_type_option_entities.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/url_type_option/url_type_option_entities.rs
index dd351fcc2a..2a322c2a20 100644
--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/url_type_option/url_type_option_entities.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/url_type_option/url_type_option_entities.rs
@@ -1,30 +1,12 @@
use bytes::Bytes;
-use collab::util::AnyMapExt;
-use collab_database::rows::{new_cell_builder, Cell};
-use serde::{Deserialize, Serialize};
+
+use collab_database::fields::url_type_option::URLCellData;
use flowy_error::{internal_error, FlowyResult};
-use crate::entities::{FieldType, URLCellDataPB};
+use crate::entities::URLCellDataPB;
use crate::services::cell::CellProtobufBlobParser;
-use crate::services::field::{TypeOptionCellData, CELL_DATA};
-
-#[derive(Clone, Debug, Default, Serialize, Deserialize)]
-pub struct URLCellData {
- pub data: String,
-}
-
-impl URLCellData {
- pub fn new(s: &str) -> Self {
- Self {
- data: s.to_string(),
- }
- }
-
- pub fn to_json(&self) -> FlowyResult<String> {
- serde_json::to_string(self).map_err(internal_error)
- }
-}
+use crate::services::field::TypeOptionCellData;
impl TypeOptionCellData for URLCellData {
fn is_cell_empty(&self) -> bool {
@@ -32,22 +14,6 @@ impl TypeOptionCellData for URLCellData {
}
}
-impl From<&Cell> for URLCellData {
- fn from(cell: &Cell) -> Self {
- Self {
- data: cell.get_as(CELL_DATA).unwrap_or_default(),
- }
- }
-}
-
-impl From<URLCellData> for Cell {
- fn from(data: URLCellData) -> Self {
- let mut cell = new_cell_builder(FieldType::URL);
- cell.insert(CELL_DATA.into(), data.data.into());
- cell
- }
-}
-
impl From<URLCellData> for URLCellDataPB {
fn from(data: URLCellData) -> Self {
Self { content: data.data }
@@ -60,12 +26,6 @@ impl From<URLCellDataPB> for URLCellData {
}
}
-impl AsRef<str> for URLCellData {
- fn as_ref(&self) -> &str {
- &self.data
- }
-}
-
pub struct URLCellDataParser();
impl CellProtobufBlobParser for URLCellDataParser {
type Object = URLCellDataPB;
@@ -74,9 +34,3 @@ impl CellProtobufBlobParser for URLCellDataParser {
URLCellDataPB::try_from(bytes.as_ref()).map_err(internal_error)
}
}
-
-impl ToString for URLCellData {
- fn to_string(&self) -> String {
- self.to_json().unwrap()
- }
-}
diff --git a/frontend/rust-lib/flowy-database2/src/services/filter/entities.rs b/frontend/rust-lib/flowy-database2/src/services/filter/entities.rs
index 4d861ee9e6..8277eeca87 100644
--- a/frontend/rust-lib/flowy-database2/src/services/filter/entities.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/filter/entities.rs
@@ -6,6 +6,7 @@ use anyhow::bail;
use collab::preclude::Any;
use collab::util::AnyMapExt;
use collab_database::database::gen_database_filter_id;
+use collab_database::fields::select_type_option::SelectOptionIds;
use collab_database::rows::RowId;
use collab_database::views::{FilterMap, FilterMapBuilder};
use flowy_error::{FlowyError, FlowyResult};
@@ -17,7 +18,6 @@ use crate::entities::{
InsertedRowPB, MediaFilterPB, NumberFilterPB, RelationFilterPB, SelectOptionFilterPB,
TextFilterPB, TimeFilterPB,
};
-use crate::services::field::SelectOptionIds;
pub trait ParseFilterData {
fn parse(condition: u8, content: String) -> Self;
diff --git a/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/checkbox_controller.rs b/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/checkbox_controller.rs
index 9dbe66e4d6..b33d402dca 100644
--- a/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/checkbox_controller.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/checkbox_controller.rs
@@ -1,4 +1,5 @@
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 flowy_error::FlowyResult;
@@ -6,9 +7,7 @@ use serde::{Deserialize, Serialize};
use crate::entities::{FieldType, GroupPB, GroupRowsNotificationPB, InsertedRowPB, RowMetaPB};
use crate::services::cell::insert_checkbox_cell;
-use crate::services::field::{
- CheckboxCellDataParser, CheckboxTypeOption, TypeOption, CHECK, UNCHECK,
-};
+use crate::services::field::{CheckboxCellDataParser, TypeOption, CHECK, UNCHECK};
use crate::services::group::action::GroupCustomize;
use crate::services::group::configuration::GroupControllerContext;
use crate::services::group::controller::BaseGroupController;
diff --git a/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/date_controller.rs b/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/date_controller.rs
index 43e6b4ab3b..ba70618388 100644
--- a/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/date_controller.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/date_controller.rs
@@ -1,18 +1,18 @@
use async_trait::async_trait;
-use chrono::{DateTime, Datelike, Days, Duration, Local, NaiveDateTime};
+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 serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};
-use flowy_error::{internal_error, FlowyResult};
-
use crate::entities::{
FieldType, GroupPB, GroupRowsNotificationPB, InsertedGroupPB, InsertedRowPB, RowMetaPB,
};
use crate::services::cell::insert_date_cell;
-use crate::services::field::{DateCellData, DateCellDataParser, DateTypeOption, TypeOption};
+use crate::services::field::{DateCellDataParser, TypeOption};
use crate::services::group::action::GroupCustomize;
use crate::services::group::configuration::GroupControllerContext;
use crate::services::group::controller::BaseGroupController;
@@ -327,7 +327,9 @@ fn get_date_group_id(cell_data: &DateCellData, setting_content: &str) -> String
fn date_time_from_timestamp(timestamp: Option<i64>) -> DateTime<Local> {
match timestamp {
Some(timestamp) => {
- let naive = NaiveDateTime::from_timestamp_opt(timestamp, 0).unwrap();
+ let naive = DateTime::from_timestamp(timestamp, 0)
+ .unwrap_or_default()
+ .naive_utc();
let offset = *Local::now().offset();
DateTime::<Local>::from_naive_utc_and_offset(naive, offset)
@@ -338,13 +340,11 @@ fn date_time_from_timestamp(timestamp: Option<i64>) -> DateTime<Local> {
#[cfg(test)]
mod tests {
- use chrono::{offset, Days, Duration, NaiveDateTime};
-
- use crate::services::field::date_type_option::DateTypeOption;
- use crate::services::field::DateCellData;
use crate::services::group::controller_impls::date_controller::{
get_date_group_id, GROUP_ID_DATE_FORMAT,
};
+ use chrono::{offset, Days, Duration};
+ use collab_database::fields::date_type_option::{DateCellData, DateTypeOption};
#[test]
fn group_id_name_test() {
@@ -354,9 +354,11 @@ mod tests {
exp_group_id: String,
}
- let mar_14_2022 = NaiveDateTime::from_timestamp_opt(1647251762, 0).unwrap();
+ let mar_14_2022 = chrono::DateTime::from_timestamp(1647251762, 0)
+ .unwrap()
+ .naive_utc();
let mar_14_2022_cd = DateCellData {
- timestamp: Some(mar_14_2022.timestamp()),
+ timestamp: Some(mar_14_2022.and_utc().timestamp()),
include_time: false,
..Default::default()
};
@@ -407,6 +409,7 @@ mod tests {
mar_14_2022
.checked_add_signed(Duration::days(3))
.unwrap()
+ .and_utc()
.timestamp(),
),
include_time: false,
diff --git a/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/select_option_controller/multi_select_controller.rs b/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/select_option_controller/multi_select_controller.rs
index 0f8ba0b6cc..4adcdd1ef6 100644
--- a/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/select_option_controller/multi_select_controller.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/select_option_controller/multi_select_controller.rs
@@ -1,5 +1,5 @@
use async_trait::async_trait;
-use collab_database::entity::SelectOption;
+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 flowy_error::{FlowyError, FlowyResult};
@@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
use crate::entities::{FieldType, GroupPB, GroupRowsNotificationPB, InsertedGroupPB};
use crate::services::cell::insert_select_option_cell;
use crate::services::field::{
- MultiSelectTypeOption, SelectOptionCellDataParser, SelectTypeOptionSharedAction, TypeOption,
+ SelectOptionCellDataParser, SelectTypeOptionSharedAction, TypeOption,
};
use crate::services::group::action::GroupCustomize;
use crate::services::group::controller::BaseGroupController;
diff --git a/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/select_option_controller/single_select_controller.rs b/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/select_option_controller/single_select_controller.rs
index ae524d5076..abce9daef1 100644
--- a/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/select_option_controller/single_select_controller.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/select_option_controller/single_select_controller.rs
@@ -1,5 +1,5 @@
use async_trait::async_trait;
-use collab_database::entity::SelectOption;
+use collab_database::fields::select_type_option::{SelectOption, SingleSelectTypeOption};
use collab_database::fields::{Field, TypeOptionData};
use collab_database::rows::{new_cell_builder, Cell, Cells, Row};
use flowy_error::{FlowyError, FlowyResult};
@@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
use crate::entities::{FieldType, GroupPB, GroupRowsNotificationPB, InsertedGroupPB};
use crate::services::cell::insert_select_option_cell;
use crate::services::field::{
- SelectOptionCellDataParser, SelectTypeOptionSharedAction, SingleSelectTypeOption, TypeOption,
+ SelectOptionCellDataParser, SelectTypeOptionSharedAction, TypeOption,
};
use crate::services::group::action::GroupCustomize;
use crate::services::group::controller::BaseGroupController;
diff --git a/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/select_option_controller/util.rs b/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/select_option_controller/util.rs
index 1e6730cb46..827e4f0e53 100644
--- a/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/select_option_controller/util.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/select_option_controller/util.rs
@@ -4,10 +4,10 @@ use crate::entities::{
use crate::services::cell::{
insert_checkbox_cell, insert_date_cell, insert_select_option_cell, insert_url_cell,
};
-use crate::services::field::{SelectOptionIds, CHECK};
+use crate::services::field::CHECK;
use crate::services::group::{Group, GroupData, MoveGroupRowContext};
use chrono::NaiveDateTime;
-use collab_database::entity::SelectOption;
+use collab_database::fields::select_type_option::{SelectOption, SelectOptionIds};
use collab_database::fields::Field;
use collab_database::rows::{Cell, Row};
use tracing::debug;
@@ -157,7 +157,7 @@ pub fn make_inserted_cell(group_id: &str, field: &Field) -> Option<Cell> {
let date =
NaiveDateTime::parse_from_str(&format!("{} 00:00:00", group_id), "%Y/%m/%d %H:%M:%S")
.unwrap();
- let cell = insert_date_cell(date.timestamp(), None, Some(false), field);
+ let cell = insert_date_cell(date.and_utc().timestamp(), None, Some(false), field);
Some(cell)
},
_ => {
diff --git a/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/url_controller.rs b/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/url_controller.rs
index 691d690e33..aae0777b71 100644
--- a/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/url_controller.rs
+++ b/frontend/rust-lib/flowy-database2/src/services/group/controller_impls/url_controller.rs
@@ -1,4 +1,5 @@
use async_trait::async_trait;
+use collab_database::fields::url_type_option::{URLCellData, URLTypeOption};
use collab_database::fields::{Field, TypeOptionData};
use collab_database::rows::{new_cell_builder, Cell, Cells, Row};
use serde::{Deserialize, Serialize};
@@ -9,7 +10,7 @@ use crate::entities::{
FieldType, GroupPB, GroupRowsNotificationPB, InsertedGroupPB, InsertedRowPB, RowMetaPB,
};
use crate::services::cell::insert_url_cell;
-use crate::services::field::{TypeOption, URLCellData, URLCellDataParser, URLTypeOption};
+use crate::services::field::{TypeOption, URLCellDataParser};
use crate::services::group::action::GroupCustomize;
use crate::services::group::configuration::GroupControllerContext;
use crate::services::group::controller::BaseGroupController;
diff --git a/frontend/rust-lib/flowy-database2/src/template.rs b/frontend/rust-lib/flowy-database2/src/template.rs
index e4c4b25d71..2f93f4fd8e 100644
--- a/frontend/rust-lib/flowy-database2/src/template.rs
+++ b/frontend/rust-lib/flowy-database2/src/template.rs
@@ -1,13 +1,14 @@
use collab_database::database::{gen_database_id, gen_row_id, timestamp};
-use collab_database::entity::{
- CreateDatabaseParams, CreateViewParams, SelectOption, SelectOptionColor,
+use collab_database::entity::{CreateDatabaseParams, CreateViewParams};
+use collab_database::fields::select_type_option::{
+ SelectOption, SelectOptionColor, SingleSelectTypeOption,
};
use collab_database::rows::CreateRowParams;
use collab_database::views::{DatabaseLayout, LayoutSettings};
use crate::entities::FieldType;
use crate::services::cell::{insert_select_option_cell, insert_text_cell};
-use crate::services::field::{FieldBuilder, SingleSelectTypeOption};
+use crate::services::field::FieldBuilder;
use crate::services::field_settings::default_field_settings_for_fields;
use crate::services::setting::{BoardLayoutSetting, CalendarLayoutSetting};
diff --git a/frontend/rust-lib/flowy-database2/tests/database/block_test/row_test.rs b/frontend/rust-lib/flowy-database2/tests/database/block_test/row_test.rs
index 02e8b699c9..07e1287a86 100644
--- a/frontend/rust-lib/flowy-database2/tests/database/block_test/row_test.rs
+++ b/frontend/rust-lib/flowy-database2/tests/database/block_test/row_test.rs
@@ -1,8 +1,7 @@
-use std::time::Duration;
-
+use collab_database::fields::date_type_option::DateCellData;
use flowy_database2::entities::FieldType;
-use flowy_database2::services::field::DateCellData;
use lib_infra::util::timestamp;
+use std::time::Duration;
use crate::database::block_test::script::DatabaseRowTest;
use crate::database::block_test::script::RowScript::*;
diff --git a/frontend/rust-lib/flowy-database2/tests/database/cell_test/test.rs b/frontend/rust-lib/flowy-database2/tests/database/cell_test/test.rs
index 0d5b3057e2..64453e8eb0 100644
--- a/frontend/rust-lib/flowy-database2/tests/database/cell_test/test.rs
+++ b/frontend/rust-lib/flowy-database2/tests/database/cell_test/test.rs
@@ -1,15 +1,16 @@
-use std::time::Duration;
-
+use crate::database::cell_test::script::CellScript::UpdateCell;
+use crate::database::cell_test::script::DatabaseCellTest;
+use collab_database::fields::date_type_option::DateCellData;
+use collab_database::fields::media_type_option::{MediaFile, MediaFileType, MediaUploadType};
+use collab_database::fields::select_type_option::{MultiSelectTypeOption, SingleSelectTypeOption};
+use collab_database::fields::url_type_option::URLCellData;
use flowy_database2::entities::{FieldType, MediaCellChangeset};
use flowy_database2::services::field::{
- ChecklistCellChangeset, DateCellChangeset, DateCellData, MediaFile, MediaFileType,
- MediaUploadType, MultiSelectTypeOption, RelationCellChangeset, SelectOptionCellChangeset,
- SingleSelectTypeOption, StringCellData, TimeCellData, URLCellData,
+ ChecklistCellChangeset, DateCellChangeset, RelationCellChangeset, SelectOptionCellChangeset,
+ StringCellData, TimeCellData,
};
use lib_infra::box_any::BoxAny;
-
-use crate::database::cell_test::script::CellScript::UpdateCell;
-use crate::database::cell_test::script::DatabaseCellTest;
+use std::time::Duration;
#[tokio::test]
async fn grid_cell_update() {
@@ -63,7 +64,7 @@ async fn grid_cell_update() {
name: "link".to_string(),
url: "https://www.appflowy.io".to_string(),
file_type: MediaFileType::Link,
- upload_type: MediaUploadType::NetworkMedia,
+ upload_type: MediaUploadType::Network,
}],
removed_ids: vec![],
}),
diff --git a/frontend/rust-lib/flowy-database2/tests/database/database_editor.rs b/frontend/rust-lib/flowy-database2/tests/database/database_editor.rs
index 33c8a1e611..91d4a46cb5 100644
--- a/frontend/rust-lib/flowy-database2/tests/database/database_editor.rs
+++ b/frontend/rust-lib/flowy-database2/tests/database/database_editor.rs
@@ -2,7 +2,10 @@ use std::collections::HashMap;
use std::sync::Arc;
use collab_database::database::gen_database_view_id;
-use collab_database::entity::SelectOption;
+use collab_database::fields::checkbox_type_option::CheckboxTypeOption;
+use collab_database::fields::select_type_option::{
+ MultiSelectTypeOption, SelectOption, SingleSelectTypeOption,
+};
use collab_database::fields::Field;
use collab_database::rows::{Row, RowId};
use lib_infra::box_any::BoxAny;
@@ -16,9 +19,7 @@ use flowy_database2::services::database::DatabaseEditor;
use flowy_database2::services::field::checklist_type_option::{
ChecklistCellChangeset, ChecklistTypeOption,
};
-use flowy_database2::services::field::{
- CheckboxTypeOption, MultiSelectTypeOption, SelectOptionCellChangeset, SingleSelectTypeOption,
-};
+use flowy_database2::services::field::SelectOptionCellChangeset;
use flowy_database2::services::share::csv::{CSVFormat, ImportResult};
use flowy_error::FlowyResult;
@@ -159,7 +160,8 @@ impl DatabaseEditorTest {
let field = self.get_field(field_id, field_type).await;
let type_option = field
.get_type_option::<MultiSelectTypeOption>(field_type)
- .unwrap();
+ .unwrap()
+ .0;
type_option.options
}
@@ -168,7 +170,8 @@ impl DatabaseEditorTest {
let field = self.get_field(field_id, field_type).await;
let type_option = field
.get_type_option::<SingleSelectTypeOption>(field_type)
- .unwrap();
+ .unwrap()
+ .0;
type_option.options
}
diff --git a/frontend/rust-lib/flowy-database2/tests/database/field_test/test.rs b/frontend/rust-lib/flowy-database2/tests/database/field_test/test.rs
index 1e61742720..86f5290d24 100644
--- a/frontend/rust-lib/flowy-database2/tests/database/field_test/test.rs
+++ b/frontend/rust-lib/flowy-database2/tests/database/field_test/test.rs
@@ -1,11 +1,12 @@
use collab_database::database::gen_option_id;
-use collab_database::entity::SelectOption;
+use collab_database::fields::select_type_option::{SelectOption, SelectTypeOption};
use flowy_database2::entities::{FieldChangesetParams, FieldType};
-use flowy_database2::services::field::{SingleSelectTypeOption, CHECK, UNCHECK};
+use flowy_database2::services::field::{CHECK, UNCHECK};
use crate::database::field_test::script::DatabaseFieldTest;
use crate::database::field_test::script::FieldScript::*;
use crate::database::field_test::util::*;
+use collab_database::fields::select_type_option::SingleSelectTypeOption;
#[tokio::test]
async fn grid_create_field() {
@@ -143,10 +144,10 @@ async fn grid_switch_from_select_option_to_checkbox_test() {
let scripts = vec![
UpdateTypeOption {
field_id: field.id.clone(),
- type_option: SingleSelectTypeOption {
+ type_option: SingleSelectTypeOption(SelectTypeOption {
options,
disable_color: false,
- }
+ })
.into(),
},
SwitchToField {
diff --git a/frontend/rust-lib/flowy-database2/tests/database/field_test/util.rs b/frontend/rust-lib/flowy-database2/tests/database/field_test/util.rs
index b34407a5d4..54c5d06bdc 100644
--- a/frontend/rust-lib/flowy-database2/tests/database/field_test/util.rs
+++ b/frontend/rust-lib/flowy-database2/tests/database/field_test/util.rs
@@ -1,16 +1,18 @@
-use collab_database::entity::SelectOption;
+use collab_database::fields::date_type_option::{
+ DateFormat, DateTypeOption, TimeFormat, TimeTypeOption,
+};
+use collab_database::fields::select_type_option::{SelectOption, SingleSelectTypeOption};
+use collab_database::fields::text_type_option::RichTextTypeOption;
+use collab_database::fields::timestamp_type_option::TimestampTypeOption;
use collab_database::fields::Field;
use collab_database::views::OrderObjectPosition;
use flowy_database2::entities::{CreateFieldParams, FieldType};
-use flowy_database2::services::field::{
- type_option_to_pb, DateFormat, DateTypeOption, FieldBuilder, RichTextTypeOption,
- SingleSelectTypeOption, TimeFormat, TimeTypeOption, TimestampTypeOption,
-};
+use flowy_database2::services::field::{type_option_to_pb, FieldBuilder};
pub fn create_text_field(grid_id: &str) -> (CreateFieldParams, Field) {
let field_type = FieldType::RichText;
- let type_option = RichTextTypeOption::default();
+ let type_option = RichTextTypeOption;
let text_field = FieldBuilder::new(field_type, type_option.clone())
.name("Name")
.primary(true)
@@ -75,7 +77,7 @@ pub fn create_timestamp_field(grid_id: &str, field_type: FieldType) -> (CreateFi
date_format: DateFormat::US,
time_format: TimeFormat::TwentyFourHour,
include_time: true,
- field_type,
+ field_type: field_type.into(),
};
let field: Field = match field_type {
diff --git a/frontend/rust-lib/flowy-database2/tests/database/group_test/date_group_test.rs b/frontend/rust-lib/flowy-database2/tests/database/group_test/date_group_test.rs
index 4170d0259f..f7ccb3d609 100644
--- a/frontend/rust-lib/flowy-database2/tests/database/group_test/date_group_test.rs
+++ b/frontend/rust-lib/flowy-database2/tests/database/group_test/date_group_test.rs
@@ -3,9 +3,8 @@ use std::vec;
use chrono::NaiveDateTime;
use chrono::{offset, Duration};
-
+use collab_database::fields::date_type_option::DateCellData;
use flowy_database2::entities::{CreateRowPayloadPB, FieldType};
-use flowy_database2::services::field::DateCellData;
use crate::database::group_test::script::DatabaseGroupTest;
use crate::database::group_test::script::GroupScript::*;
@@ -195,5 +194,8 @@ async fn change_date_on_moving_row_to_another_group() {
let date_time =
NaiveDateTime::parse_from_str("2022/11/01 00:00:00", "%Y/%m/%d %H:%M:%S").unwrap();
- assert_eq!(date_time.timestamp(), date_cell.timestamp.unwrap());
+ assert_eq!(
+ date_time.and_utc().timestamp(),
+ date_cell.timestamp.unwrap()
+ );
}
diff --git a/frontend/rust-lib/flowy-database2/tests/database/group_test/script.rs b/frontend/rust-lib/flowy-database2/tests/database/group_test/script.rs
index 304add5d03..ce3fbe090e 100644
--- a/frontend/rust-lib/flowy-database2/tests/database/group_test/script.rs
+++ b/frontend/rust-lib/flowy-database2/tests/database/group_test/script.rs
@@ -1,15 +1,14 @@
-use collab_database::entity::SelectOption;
+use collab_database::fields::select_type_option::{SelectOption, SingleSelectTypeOption};
use collab_database::fields::Field;
use collab_database::rows::RowId;
-use std::time::Duration;
-
use flowy_database2::entities::{CreateRowPayloadPB, FieldType, GroupPB, RowMetaPB};
use flowy_database2::services::cell::{
delete_select_option_cell, insert_date_cell, insert_select_option_cell, insert_url_cell,
};
use flowy_database2::services::field::{
- edit_single_select_type_option, SelectTypeOptionSharedAction, SingleSelectTypeOption,
+ edit_single_select_type_option, SelectTypeOptionSharedAction,
};
+use std::time::Duration;
use crate::database::database_editor::DatabaseEditorTest;
diff --git a/frontend/rust-lib/flowy-database2/tests/database/group_test/test.rs b/frontend/rust-lib/flowy-database2/tests/database/group_test/test.rs
index 9f300c065e..a543f519d2 100644
--- a/frontend/rust-lib/flowy-database2/tests/database/group_test/test.rs
+++ b/frontend/rust-lib/flowy-database2/tests/database/group_test/test.rs
@@ -1,6 +1,6 @@
use crate::database::group_test::script::DatabaseGroupTest;
use crate::database::group_test::script::GroupScript::*;
-use collab_database::entity::SelectOption;
+use collab_database::fields::select_type_option::SelectOption;
#[tokio::test]
async fn group_init_test() {
diff --git a/frontend/rust-lib/flowy-database2/tests/database/mock_data/board_mock_data.rs b/frontend/rust-lib/flowy-database2/tests/database/mock_data/board_mock_data.rs
index ed50722070..1cf07529e8 100644
--- a/frontend/rust-lib/flowy-database2/tests/database/mock_data/board_mock_data.rs
+++ b/frontend/rust-lib/flowy-database2/tests/database/mock_data/board_mock_data.rs
@@ -1,5 +1,10 @@
use collab_database::database::{gen_database_id, gen_database_view_id, gen_row_id, DatabaseData};
-use collab_database::entity::{DatabaseView, SelectOption, SelectOptionColor};
+use collab_database::entity::DatabaseView;
+use collab_database::fields::date_type_option::{DateFormat, DateTypeOption, TimeFormat};
+use collab_database::fields::select_type_option::{
+ MultiSelectTypeOption, SelectOption, SelectOptionColor, SingleSelectTypeOption,
+};
+use collab_database::fields::timestamp_type_option::TimestampTypeOption;
use collab_database::views::{DatabaseLayout, LayoutSetting, LayoutSettings};
use strum::IntoEnumIterator;
@@ -8,10 +13,7 @@ use event_integration_test::database_event::TestRowBuilder;
use flowy_database2::entities::FieldType;
use flowy_database2::services::field::checklist_type_option::ChecklistTypeOption;
use flowy_database2::services::field::summary_type_option::summary::SummarizationTypeOption;
-use flowy_database2::services::field::{
- DateFormat, DateTypeOption, FieldBuilder, MultiSelectTypeOption, RelationTypeOption,
- SingleSelectTypeOption, TimeFormat, TimestampTypeOption,
-};
+use flowy_database2::services::field::{FieldBuilder, RelationTypeOption};
use flowy_database2::services::field_settings::default_field_settings_for_fields;
use flowy_database2::services::setting::BoardLayoutSetting;
@@ -56,7 +58,7 @@ pub fn make_test_board() -> DatabaseData {
date_format: DateFormat::US,
time_format: TimeFormat::TwentyFourHour,
include_time: true,
- field_type,
+ field_type: field_type.into(),
};
let name = match field_type {
FieldType::LastEditedTime => "Last Modified",
diff --git a/frontend/rust-lib/flowy-database2/tests/database/mock_data/calendar_mock_data.rs b/frontend/rust-lib/flowy-database2/tests/database/mock_data/calendar_mock_data.rs
index 476d8b7faf..a14de66ed4 100644
--- a/frontend/rust-lib/flowy-database2/tests/database/mock_data/calendar_mock_data.rs
+++ b/frontend/rust-lib/flowy-database2/tests/database/mock_data/calendar_mock_data.rs
@@ -1,12 +1,13 @@
use collab_database::database::{gen_database_id, gen_database_view_id, gen_row_id, DatabaseData};
use collab_database::entity::DatabaseView;
+use collab_database::fields::select_type_option::MultiSelectTypeOption;
use collab_database::views::{DatabaseLayout, LayoutSetting, LayoutSettings};
use flowy_database2::services::field_settings::default_field_settings_for_fields;
use strum::IntoEnumIterator;
use event_integration_test::database_event::TestRowBuilder;
use flowy_database2::entities::FieldType;
-use flowy_database2::services::field::{FieldBuilder, MultiSelectTypeOption};
+use flowy_database2::services::field::FieldBuilder;
use flowy_database2::services::setting::CalendarLayoutSetting;
// Calendar unit test mock data
diff --git a/frontend/rust-lib/flowy-database2/tests/database/mock_data/grid_mock_data.rs b/frontend/rust-lib/flowy-database2/tests/database/mock_data/grid_mock_data.rs
index 90769b689c..7e18dc9d91 100644
--- a/frontend/rust-lib/flowy-database2/tests/database/mock_data/grid_mock_data.rs
+++ b/frontend/rust-lib/flowy-database2/tests/database/mock_data/grid_mock_data.rs
@@ -1,5 +1,14 @@
use collab_database::database::{gen_database_id, gen_database_view_id, gen_row_id, DatabaseData};
-use collab_database::entity::{DatabaseView, SelectOption, SelectOptionColor};
+use collab_database::entity::DatabaseView;
+use collab_database::fields::date_type_option::{
+ DateFormat, DateTypeOption, TimeFormat, TimeTypeOption,
+};
+use collab_database::fields::media_type_option::MediaTypeOption;
+use collab_database::fields::number_type_option::{NumberFormat, NumberTypeOption};
+use collab_database::fields::select_type_option::{
+ MultiSelectTypeOption, SelectOption, SelectOptionColor, SingleSelectTypeOption,
+};
+use collab_database::fields::timestamp_type_option::TimestampTypeOption;
use collab_database::views::DatabaseLayout;
use strum::IntoEnumIterator;
@@ -8,11 +17,7 @@ use event_integration_test::database_event::TestRowBuilder;
use flowy_database2::entities::FieldType;
use flowy_database2::services::field::summary_type_option::summary::SummarizationTypeOption;
use flowy_database2::services::field::translate_type_option::translate::TranslateTypeOption;
-use flowy_database2::services::field::{
- ChecklistTypeOption, DateFormat, DateTypeOption, FieldBuilder, MediaTypeOption,
- MultiSelectTypeOption, NumberFormat, NumberTypeOption, RelationTypeOption,
- SingleSelectTypeOption, TimeFormat, TimeTypeOption, TimestampTypeOption,
-};
+use flowy_database2::services::field::{ChecklistTypeOption, FieldBuilder, RelationTypeOption};
use flowy_database2::services::field_settings::default_field_settings_for_fields;
pub fn make_test_grid() -> DatabaseData {
@@ -59,7 +64,7 @@ pub fn make_test_grid() -> DatabaseData {
date_format: DateFormat::US,
time_format: TimeFormat::TwentyFourHour,
include_time: true,
- field_type,
+ field_type: field_type.into(),
};
let name = match field_type {
FieldType::LastEditedTime => "Last Modified",
diff --git a/frontend/rust-lib/flowy-database2/tests/database/pre_fill_cell_test/pre_fill_row_according_to_filter_test.rs b/frontend/rust-lib/flowy-database2/tests/database/pre_fill_cell_test/pre_fill_row_according_to_filter_test.rs
index 69e139e560..bc8fe23e9e 100644
--- a/frontend/rust-lib/flowy-database2/tests/database/pre_fill_cell_test/pre_fill_row_according_to_filter_test.rs
+++ b/frontend/rust-lib/flowy-database2/tests/database/pre_fill_cell_test/pre_fill_row_according_to_filter_test.rs
@@ -1,13 +1,12 @@
+use crate::database::pre_fill_cell_test::script::{
+ DatabasePreFillRowCellTest, PreFillRowCellTestScript::*,
+};
+use collab_database::fields::select_type_option::SELECTION_IDS_SEPARATOR;
use flowy_database2::entities::{
CheckboxFilterConditionPB, CheckboxFilterPB, DateFilterConditionPB, DateFilterPB, FieldType,
FilterDataPB, SelectOptionFilterConditionPB, SelectOptionFilterPB, TextFilterConditionPB,
TextFilterPB,
};
-use flowy_database2::services::field::SELECTION_IDS_SEPARATOR;
-
-use crate::database::pre_fill_cell_test::script::{
- DatabasePreFillRowCellTest, PreFillRowCellTestScript::*,
-};
// This suite of tests cover creating an empty row into a database that has
// active filters. Where appropriate, the row's cell data will be pre-filled
diff --git a/frontend/rust-lib/flowy-database2/tests/database/pre_fill_cell_test/pre_fill_row_with_payload_test.rs b/frontend/rust-lib/flowy-database2/tests/database/pre_fill_cell_test/pre_fill_row_with_payload_test.rs
index aa25c76eb1..213eade839 100644
--- a/frontend/rust-lib/flowy-database2/tests/database/pre_fill_cell_test/pre_fill_row_with_payload_test.rs
+++ b/frontend/rust-lib/flowy-database2/tests/database/pre_fill_cell_test/pre_fill_row_with_payload_test.rs
@@ -1,11 +1,10 @@
-use std::collections::HashMap;
-
-use flowy_database2::entities::{CreateRowPayloadPB, FieldType};
-use flowy_database2::services::field::{DateCellData, SELECTION_IDS_SEPARATOR};
-
use crate::database::pre_fill_cell_test::script::{
DatabasePreFillRowCellTest, PreFillRowCellTestScript::*,
};
+use collab_database::fields::date_type_option::DateCellData;
+use collab_database::fields::select_type_option::SELECTION_IDS_SEPARATOR;
+use flowy_database2::entities::{CreateRowPayloadPB, FieldType};
+use std::collections::HashMap;
// This suite of tests cover creating a row using `CreateRowPayloadPB` that passes
// in some cell data in its `data` field of `HashMap<String, String>` which is a
diff --git a/frontend/rust-lib/flowy-database2/tests/database/pre_fill_cell_test/script.rs b/frontend/rust-lib/flowy-database2/tests/database/pre_fill_cell_test/script.rs
index e4541d1057..cc6000a62d 100644
--- a/frontend/rust-lib/flowy-database2/tests/database/pre_fill_cell_test/script.rs
+++ b/frontend/rust-lib/flowy-database2/tests/database/pre_fill_cell_test/script.rs
@@ -1,11 +1,9 @@
-use std::ops::{Deref, DerefMut};
-use std::time::Duration;
-
+use crate::database::database_editor::DatabaseEditorTest;
+use collab_database::fields::select_type_option::{SelectOptionIds, SELECTION_IDS_SEPARATOR};
use flowy_database2::entities::{CreateRowPayloadPB, FilterDataPB, InsertFilterPB};
use flowy_database2::services::cell::stringify_cell;
-use flowy_database2::services::field::{SelectOptionIds, SELECTION_IDS_SEPARATOR};
-
-use crate::database::database_editor::DatabaseEditorTest;
+use std::ops::{Deref, DerefMut};
+use std::time::Duration;
pub enum PreFillRowCellTestScript {
CreateEmptyRow,
diff --git a/frontend/rust-lib/lib-infra/Cargo.toml b/frontend/rust-lib/lib-infra/Cargo.toml
index f07a615621..62f872a553 100644
--- a/frontend/rust-lib/lib-infra/Cargo.toml
+++ b/frontend/rust-lib/lib-infra/Cargo.toml
@@ -31,7 +31,7 @@ rand = "0.8.5"
futures = "0.3.30"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
-zip = { version = "0.6.6", features = ["deflate"] }
+zip = { version = "2.2.0", features = ["deflate"] }
brotli = { version = "3.4.0", optional = true }
[features]
diff --git a/frontend/rust-lib/lib-infra/src/file_util.rs b/frontend/rust-lib/lib-infra/src/file_util.rs
index c8a464d5dd..6de14b2304 100644
--- a/frontend/rust-lib/lib-infra/src/file_util.rs
+++ b/frontend/rust-lib/lib-infra/src/file_util.rs
@@ -1,15 +1,14 @@
use anyhow::Context;
use std::cmp::Ordering;
use std::fs::File;
-use std::io::{Read, Write};
use std::path::{Path, PathBuf};
use std::time::SystemTime;
use std::{fs, io};
use tempfile::tempdir;
use walkdir::WalkDir;
use zip::write::FileOptions;
-use zip::ZipArchive;
use zip::ZipWriter;
+use zip::{CompressionMethod, ZipArchive};
pub fn copy_dir_recursive(src: &Path, dst: &Path) -> io::Result<()> {
for entry in WalkDir::new(src).into_iter().filter_map(|e| e.ok()) {
@@ -71,48 +70,62 @@ where
pub fn zip_folder(src_path: impl AsRef<Path>, dest_path: &Path) -> io::Result<()> {
let src_path = src_path.as_ref();
+ // Check if source path exists
if !src_path.exists() {
- return Err(io::ErrorKind::NotFound.into());
+ return Err(io::Error::new(
+ io::ErrorKind::NotFound,
+ "Source path not found",
+ ));
}
+ // Check if source and destination paths are the same
if src_path == dest_path {
- return Err(io::ErrorKind::InvalidInput.into());
+ return Err(io::Error::new(
+ io::ErrorKind::InvalidInput,
+ "Source and destination paths cannot be the same",
+ ));
}
+ // Create a file at the destination path to write the ZIP file
let file = File::create(dest_path)?;
let mut zip = ZipWriter::new(file);
- let options = FileOptions::default().compression_method(zip::CompressionMethod::Deflated);
- for entry in WalkDir::new(src_path) {
- let entry = entry?;
+ // Traverse through the source directory recursively
+ for entry in WalkDir::new(src_path).into_iter().filter_map(|e| e.ok()) {
let path = entry.path();
- let name = match path.strip_prefix(src_path) {
- Ok(n) => n,
- Err(_) => return Err(io::Error::new(io::ErrorKind::Other, "Invalid path")),
- };
+ let name = path
+ .strip_prefix(src_path)
+ .map_err(|_| io::Error::new(io::ErrorKind::Other, "Invalid path"))?;
+ // If the entry is a file, add it to the ZIP archive
if path.is_file() {
let file_name = name
.to_str()
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "Invalid file name"))?;
- zip.start_file(file_name, options)?;
+ zip.start_file::<_, ()>(
+ file_name,
+ FileOptions::default().compression_method(CompressionMethod::Deflated),
+ )?;
- let mut buffer = Vec::new();
- {
- let mut f = File::open(path)?;
- f.read_to_end(&mut buffer)?;
- drop(f);
- }
+ // Instead of loading the entire file into memory, use `copy` for efficient writing
+ let mut f = File::open(path)?;
+ io::copy(&mut f, &mut zip)?;
- zip.write_all(&buffer)?;
- } else if !name.as_os_str().is_empty() {
+ // If the entry is a directory, add it to the ZIP archive
+ } else if path.is_dir() {
let dir_name = name
.to_str()
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "Invalid directory name"))?;
- zip.add_directory(dir_name, options)?;
+ if !dir_name.is_empty() {
+ zip.add_directory::<_, ()>(
+ dir_name,
+ FileOptions::default().compression_method(CompressionMethod::Deflated),
+ )?;
+ }
}
}
+ // Finish the ZIP archive
zip.finish()?;
Ok(())
}
diff --git a/frontend/scripts/tool/update_collab_rev.sh b/frontend/scripts/tool/update_collab_rev.sh
index 469974cdb2..edff885cc0 100755
--- a/frontend/scripts/tool/update_collab_rev.sh
+++ b/frontend/scripts/tool/update_collab_rev.sh
@@ -28,7 +28,7 @@ for dir in "${directories[@]}"; do
# Update all the specified crates at once
echo "Updating crates: $crates_to_update"
- cargo update $crates_to_update
+ cargo update $crates_to_update 2> /dev/null
popd > /dev/null
done
diff --git a/frontend/scripts/tool/update_local_ai_rev.sh b/frontend/scripts/tool/update_local_ai_rev.sh
index 5f5e892a3f..f234ae2920 100755
--- a/frontend/scripts/tool/update_local_ai_rev.sh
+++ b/frontend/scripts/tool/update_local_ai_rev.sh
@@ -30,7 +30,7 @@ for dir in "${directories[@]}"; do
# Update all the specified crates at once
if [ -n "$crates_to_update" ]; then
echo "Updating crates: $crates_to_update"
- cargo update $crates_to_update
+ cargo update $crates_to_update 2> /dev/null
fi
popd > /dev/null