mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
Feat/http server adapt (#1754)
This commit is contained in:
parent
000569a836
commit
0d8adaa921
@ -35,21 +35,21 @@ class NetworkListener {
|
||||
final networkType = () {
|
||||
switch (result) {
|
||||
case ConnectivityResult.wifi:
|
||||
return NetworkType.Wifi;
|
||||
return NetworkTypePB.Wifi;
|
||||
case ConnectivityResult.ethernet:
|
||||
return NetworkType.Ethernet;
|
||||
return NetworkTypePB.Ethernet;
|
||||
case ConnectivityResult.mobile:
|
||||
return NetworkType.Cell;
|
||||
return NetworkTypePB.Cell;
|
||||
case ConnectivityResult.bluetooth:
|
||||
return NetworkType.Bluetooth;
|
||||
return NetworkTypePB.Bluetooth;
|
||||
case ConnectivityResult.vpn:
|
||||
return NetworkType.VPN;
|
||||
return NetworkTypePB.VPN;
|
||||
case ConnectivityResult.none:
|
||||
return NetworkType.UnknownNetworkType;
|
||||
return NetworkTypePB.Unknown;
|
||||
}
|
||||
}();
|
||||
Log.info("Network type: $networkType");
|
||||
final state = NetworkState.create()..ty = networkType;
|
||||
final state = NetworkStatePB.create()..ty = networkType;
|
||||
NetworkEventUpdateNetworkType(state).send().then((result) {
|
||||
result.fold(
|
||||
(l) {},
|
||||
|
@ -1,6 +1,5 @@
|
||||
import 'package:appflowy_backend/dispatch/dispatch.dart';
|
||||
import 'package:appflowy_backend/log.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-error/code.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
@ -76,7 +75,6 @@ class SplashScreen extends StatelessWidget {
|
||||
},
|
||||
(error) async {
|
||||
Log.error(error);
|
||||
assert(error.code == ErrorCode.RecordNotFound.value);
|
||||
getIt<SplashRoute>().pushWelcomeScreen(context, userProfile);
|
||||
},
|
||||
);
|
||||
|
335
frontend/appflowy_tauri/src-tauri/Cargo.lock
generated
335
frontend/appflowy_tauri/src-tauri/Cargo.lock
generated
@ -37,16 +37,6 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "allo-isolate"
|
||||
version = "0.1.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ed55848be9f41d44c79df6045b680a74a78bc579e0813f7f196cd7928e22fb1"
|
||||
dependencies = [
|
||||
"atomic",
|
||||
"pin-project",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "alloc-no-stdlib"
|
||||
version = "2.0.4"
|
||||
@ -169,32 +159,12 @@ dependencies = [
|
||||
"system-deps 6.0.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atomic"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b88d82667eca772c4aa12f0f1348b3ae643424c8876448f3f7bd5787032e234c"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atomic_refcell"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "857253367827bd9d0fd973f0ef15506a96e79e41b0ad7aa691203a4e3214f6c8"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi 0.1.19",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.1.0"
|
||||
@ -379,12 +349,6 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bytecount"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c"
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.12.3"
|
||||
@ -999,6 +963,15 @@ version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd5f0c7e4bd266b8ab2550e6238d2e74977c23c15536ac7be45e9c95e2e3fbbb"
|
||||
|
||||
[[package]]
|
||||
name = "document-model"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"revision-model",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dtoa"
|
||||
version = "0.4.8"
|
||||
@ -1053,19 +1026,6 @@ dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"humantime",
|
||||
"log",
|
||||
"regex",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "error-chain"
|
||||
version = "0.12.0"
|
||||
@ -1096,6 +1056,16 @@ dependencies = [
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fancy-regex"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2"
|
||||
dependencies = [
|
||||
"bit-set",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "1.8.0"
|
||||
@ -1146,13 +1116,63 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-client-network-config"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"config",
|
||||
"serde",
|
||||
"serde-aux",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-client-sync"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"chrono",
|
||||
"dissimilar",
|
||||
"document-model",
|
||||
"flowy-derive",
|
||||
"flowy-sync",
|
||||
"folder-model",
|
||||
"grid-model",
|
||||
"lib-infra",
|
||||
"lib-ot",
|
||||
"parking_lot",
|
||||
"revision-model",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-client-ws"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"futures-util",
|
||||
"lib-infra",
|
||||
"lib-ws",
|
||||
"parking_lot",
|
||||
"serde",
|
||||
"serde_repr",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-codegen"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cmd_lib",
|
||||
"console",
|
||||
"fancy-regex",
|
||||
"fancy-regex 0.10.0",
|
||||
"flowy-ast",
|
||||
"itertools",
|
||||
"lazy_static",
|
||||
@ -1175,24 +1195,27 @@ name = "flowy-core"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"flowy-client-ws",
|
||||
"flowy-database",
|
||||
"flowy-document",
|
||||
"flowy-error",
|
||||
"flowy-folder",
|
||||
"flowy-grid",
|
||||
"flowy-http-model",
|
||||
"flowy-net",
|
||||
"flowy-revision",
|
||||
"flowy-task",
|
||||
"flowy-user",
|
||||
"futures-core",
|
||||
"grid-rev-model",
|
||||
"grid-model",
|
||||
"lib-dispatch",
|
||||
"lib-infra",
|
||||
"lib-log",
|
||||
"lib-ws",
|
||||
"parking_lot",
|
||||
"revision-model",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"ws-model",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1235,32 +1258,32 @@ dependencies = [
|
||||
"dashmap",
|
||||
"diesel",
|
||||
"diesel_derives",
|
||||
"document-model",
|
||||
"flowy-client-sync",
|
||||
"flowy-codegen",
|
||||
"flowy-database",
|
||||
"flowy-derive",
|
||||
"flowy-error",
|
||||
"flowy-http-model",
|
||||
"flowy-notification",
|
||||
"flowy-revision",
|
||||
"flowy-revision-persistence",
|
||||
"flowy-sync",
|
||||
"futures",
|
||||
"futures-util",
|
||||
"lib-dispatch",
|
||||
"lib-infra",
|
||||
"lib-ot",
|
||||
"lib-ws",
|
||||
"log",
|
||||
"md5",
|
||||
"protobuf",
|
||||
"revision-model",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"unicode-segmentation",
|
||||
"url",
|
||||
"ws-model",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1269,15 +1292,17 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
"flowy-client-sync",
|
||||
"flowy-client-ws",
|
||||
"flowy-codegen",
|
||||
"flowy-database",
|
||||
"flowy-derive",
|
||||
"flowy-sync",
|
||||
"http-flowy",
|
||||
"http-error-code",
|
||||
"lib-dispatch",
|
||||
"lib-ot",
|
||||
"protobuf",
|
||||
"r2d2",
|
||||
"reqwest",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
]
|
||||
@ -1289,17 +1314,16 @@ dependencies = [
|
||||
"bytes",
|
||||
"diesel",
|
||||
"diesel_derives",
|
||||
"flowy-client-sync",
|
||||
"flowy-codegen",
|
||||
"flowy-database",
|
||||
"flowy-derive",
|
||||
"flowy-document",
|
||||
"flowy-error",
|
||||
"flowy-http-model",
|
||||
"flowy-notification",
|
||||
"flowy-revision",
|
||||
"flowy-revision-persistence",
|
||||
"flowy-sync",
|
||||
"folder-rev-model",
|
||||
"folder-model",
|
||||
"futures",
|
||||
"lazy_static",
|
||||
"lib-dispatch",
|
||||
@ -1309,6 +1333,7 @@ dependencies = [
|
||||
"parking_lot",
|
||||
"pin-project",
|
||||
"protobuf",
|
||||
"revision-model",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"strum",
|
||||
@ -1316,6 +1341,7 @@ dependencies = [
|
||||
"tokio",
|
||||
"tracing",
|
||||
"unicode-segmentation",
|
||||
"ws-model",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1330,19 +1356,18 @@ dependencies = [
|
||||
"crossbeam-utils",
|
||||
"dashmap",
|
||||
"diesel",
|
||||
"fancy-regex",
|
||||
"fancy-regex 0.10.0",
|
||||
"flowy-client-sync",
|
||||
"flowy-codegen",
|
||||
"flowy-database",
|
||||
"flowy-derive",
|
||||
"flowy-error",
|
||||
"flowy-http-model",
|
||||
"flowy-notification",
|
||||
"flowy-revision",
|
||||
"flowy-revision-persistence",
|
||||
"flowy-sync",
|
||||
"flowy-task",
|
||||
"futures",
|
||||
"grid-rev-model",
|
||||
"grid-model",
|
||||
"indexmap",
|
||||
"lazy_static",
|
||||
"lib-dispatch",
|
||||
@ -1353,6 +1378,7 @@ dependencies = [
|
||||
"protobuf",
|
||||
"rayon",
|
||||
"regex",
|
||||
"revision-model",
|
||||
"rust_decimal",
|
||||
"rusty-money",
|
||||
"serde",
|
||||
@ -1365,17 +1391,6 @@ dependencies = [
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-http-model"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"md5",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_repr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-net"
|
||||
version = "0.1.0"
|
||||
@ -1385,41 +1400,46 @@ dependencies = [
|
||||
"bytes",
|
||||
"config",
|
||||
"dashmap",
|
||||
"document-model",
|
||||
"flowy-client-network-config",
|
||||
"flowy-client-sync",
|
||||
"flowy-client-ws",
|
||||
"flowy-codegen",
|
||||
"flowy-derive",
|
||||
"flowy-document",
|
||||
"flowy-error",
|
||||
"flowy-folder",
|
||||
"flowy-http-model",
|
||||
"flowy-server-sync",
|
||||
"flowy-sync",
|
||||
"flowy-user",
|
||||
"folder-rev-model",
|
||||
"folder-model",
|
||||
"futures-util",
|
||||
"http-flowy",
|
||||
"hyper",
|
||||
"lazy_static",
|
||||
"lib-dispatch",
|
||||
"lib-infra",
|
||||
"lib-ws",
|
||||
"log",
|
||||
"nanoid",
|
||||
"parking_lot",
|
||||
"protobuf",
|
||||
"reqwest",
|
||||
"revision-model",
|
||||
"serde",
|
||||
"serde-aux",
|
||||
"serde_json",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"user-model",
|
||||
"ws-model",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-notification"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"allo-isolate",
|
||||
"bytes",
|
||||
"flowy-codegen",
|
||||
"flowy-derive",
|
||||
@ -1438,18 +1458,19 @@ dependencies = [
|
||||
"bytes",
|
||||
"dashmap",
|
||||
"flowy-error",
|
||||
"flowy-http-model",
|
||||
"flowy-revision-persistence",
|
||||
"futures",
|
||||
"futures-util",
|
||||
"lib-infra",
|
||||
"lib-ws",
|
||||
"revision-model",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"ws-model",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1457,35 +1478,46 @@ name = "flowy-revision-persistence"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"flowy-error",
|
||||
"flowy-http-model",
|
||||
"revision-model",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-server-sync"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-stream",
|
||||
"bytes",
|
||||
"dashmap",
|
||||
"document-model",
|
||||
"flowy-sync",
|
||||
"folder-model",
|
||||
"futures",
|
||||
"lib-infra",
|
||||
"lib-ot",
|
||||
"log",
|
||||
"revision-model",
|
||||
"serde",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"ws-model",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-sync"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-stream",
|
||||
"bytes",
|
||||
"chrono",
|
||||
"dashmap",
|
||||
"dissimilar",
|
||||
"flowy-derive",
|
||||
"flowy-http-model",
|
||||
"folder-rev-model",
|
||||
"futures",
|
||||
"grid-rev-model",
|
||||
"document-model",
|
||||
"folder-model",
|
||||
"lib-infra",
|
||||
"lib-ot",
|
||||
"log",
|
||||
"parking_lot",
|
||||
"protobuf",
|
||||
"revision-model",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"url",
|
||||
"ws-model",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1506,7 +1538,6 @@ dependencies = [
|
||||
"bytes",
|
||||
"diesel",
|
||||
"diesel_derives",
|
||||
"fancy-regex",
|
||||
"flowy-codegen",
|
||||
"flowy-database",
|
||||
"flowy-derive",
|
||||
@ -1525,8 +1556,7 @@ dependencies = [
|
||||
"strum_macros",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"unicode-segmentation",
|
||||
"validator",
|
||||
"user-model",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1536,17 +1566,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||
|
||||
[[package]]
|
||||
name = "folder-rev-model"
|
||||
name = "folder-model"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"chrono",
|
||||
"nanoid",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_repr",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1931,7 +1957,7 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "grid-rev-model"
|
||||
name = "grid-model"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
@ -2049,15 +2075,6 @@ version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.2.6"
|
||||
@ -2104,21 +2121,13 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http-flowy"
|
||||
name = "http-error-code"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Server#3012acce300024dda8819d8507c9105af84cd909"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Server?branch=refactor/appflowy_server#1ccd296de8530760d92652dbd9f38f27178059b6"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
"derive_more",
|
||||
"hyper",
|
||||
"protobuf",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_repr",
|
||||
"thiserror",
|
||||
"uuid 0.8.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2145,12 +2154,6 @@ version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "02296996cb8796d7c6e3bc2d9211b7802812d36999a51bb754123ead7d37d026"
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.14.23"
|
||||
@ -2441,24 +2444,19 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"bytes",
|
||||
"dashmap",
|
||||
"derivative",
|
||||
"dyn-clone",
|
||||
"env_logger",
|
||||
"futures",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"nanoid",
|
||||
"paste",
|
||||
"pin-project",
|
||||
"protobuf",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_repr",
|
||||
"serde_with",
|
||||
"thread-id",
|
||||
"tokio",
|
||||
"tracing",
|
||||
@ -2472,6 +2470,7 @@ dependencies = [
|
||||
"bytes",
|
||||
"chrono",
|
||||
"futures-core",
|
||||
"md5",
|
||||
"pin-project",
|
||||
"rand 0.8.5",
|
||||
"tokio",
|
||||
@ -2490,7 +2489,6 @@ dependencies = [
|
||||
"tracing-appender",
|
||||
"tracing-bunyan-formatter",
|
||||
"tracing-core",
|
||||
"tracing-futures",
|
||||
"tracing-log",
|
||||
"tracing-subscriber 0.2.25",
|
||||
]
|
||||
@ -2499,23 +2497,16 @@ dependencies = [
|
||||
name = "lib-ot"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytecount",
|
||||
"bytes",
|
||||
"dashmap",
|
||||
"derive_more",
|
||||
"indexmap",
|
||||
"indextree",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"md5",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_repr",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
@ -2532,13 +2523,11 @@ dependencies = [
|
||||
"lib-infra",
|
||||
"log",
|
||||
"parking_lot",
|
||||
"paste",
|
||||
"pin-project",
|
||||
"protobuf",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_repr",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"tokio",
|
||||
"tokio-tungstenite",
|
||||
@ -2876,7 +2865,7 @@ version = "1.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b"
|
||||
dependencies = [
|
||||
"hermit-abi 0.2.6",
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
]
|
||||
|
||||
@ -3758,6 +3747,16 @@ dependencies = [
|
||||
"winreg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "revision-model"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"md5",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rkyv"
|
||||
version = "0.7.39"
|
||||
@ -4865,16 +4864,6 @@ dependencies = [
|
||||
"valuable",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-futures"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
|
||||
dependencies = [
|
||||
"pin-project",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-log"
|
||||
version = "0.1.3"
|
||||
@ -5086,6 +5075,20 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "user-model"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"fancy-regex 0.11.0",
|
||||
"lazy_static",
|
||||
"serde",
|
||||
"serde_repr",
|
||||
"thiserror",
|
||||
"tracing",
|
||||
"unicode-segmentation",
|
||||
"validator",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "utf-8"
|
||||
version = "0.7.6"
|
||||
@ -5097,9 +5100,6 @@ name = "uuid"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
|
||||
dependencies = [
|
||||
"getrandom 0.2.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
@ -5112,9 +5112,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "validator"
|
||||
version = "0.15.0"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f07b0a1390e01c0fc35ebb26b28ced33c9a3808f7f9fbe94d3cc01e233bfeed5"
|
||||
checksum = "32ad5bf234c7d3ad1042e5252b7eddb2c4669ee23f32c7dd0e9b7705f07ef591"
|
||||
dependencies = [
|
||||
"idna 0.2.3",
|
||||
"lazy_static",
|
||||
@ -5586,6 +5586,17 @@ dependencies = [
|
||||
"windows-implement",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ws-model"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"revision-model",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_repr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "x11"
|
||||
version = "2.20.1"
|
||||
|
401
frontend/rust-lib/Cargo.lock
generated
401
frontend/rust-lib/Cargo.lock
generated
@ -310,12 +310,6 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bytecount"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.4.3"
|
||||
@ -386,15 +380,6 @@ dependencies = [
|
||||
"phf_codegen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "claim"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68ad37958d55b29a7088909368968d2fe876a24c203f8441195130f3b15194b9"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "claim"
|
||||
version = "0.5.0"
|
||||
@ -676,41 +661,6 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling"
|
||||
version = "0.13.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"darling_macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_core"
|
||||
version = "0.13.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610"
|
||||
dependencies = [
|
||||
"fnv",
|
||||
"ident_case",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_macro"
|
||||
version = "0.13.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dart-ffi"
|
||||
version = "0.1.0"
|
||||
@ -719,7 +669,6 @@ dependencies = [
|
||||
"byteorder",
|
||||
"bytes",
|
||||
"crossbeam-utils",
|
||||
"ffi-support",
|
||||
"flowy-codegen",
|
||||
"flowy-core",
|
||||
"flowy-derive",
|
||||
@ -832,6 +781,15 @@ version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd5f0c7e4bd266b8ab2550e6238d2e74977c23c15536ac7be45e9c95e2e3fbbb"
|
||||
|
||||
[[package]]
|
||||
name = "document-model"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"revision-model",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dyn-clone"
|
||||
version = "1.0.10"
|
||||
@ -865,11 +823,8 @@ version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"humantime",
|
||||
"log",
|
||||
"regex",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -921,6 +876,16 @@ dependencies = [
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fancy-regex"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2"
|
||||
dependencies = [
|
||||
"bit-set",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "1.8.0"
|
||||
@ -930,16 +895,6 @@ dependencies = [
|
||||
"instant",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ffi-support"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "27838c6815cfe9de2d3aeb145ffd19e565f577414b33f3bdbf42fe040e9e0ff6"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-ast"
|
||||
version = "0.1.0"
|
||||
@ -949,13 +904,63 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-client-network-config"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"config",
|
||||
"serde",
|
||||
"serde-aux",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-client-sync"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"chrono",
|
||||
"dissimilar",
|
||||
"document-model",
|
||||
"flowy-derive",
|
||||
"flowy-sync",
|
||||
"folder-model",
|
||||
"grid-model",
|
||||
"lib-infra",
|
||||
"lib-ot",
|
||||
"parking_lot 0.12.1",
|
||||
"revision-model",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-client-ws"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"futures-util",
|
||||
"lib-infra",
|
||||
"lib-ws",
|
||||
"parking_lot 0.12.1",
|
||||
"serde",
|
||||
"serde_repr",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-codegen"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cmd_lib",
|
||||
"console",
|
||||
"fancy-regex",
|
||||
"fancy-regex 0.10.0",
|
||||
"flowy-ast",
|
||||
"itertools",
|
||||
"lazy_static",
|
||||
@ -978,24 +983,27 @@ name = "flowy-core"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"flowy-client-ws",
|
||||
"flowy-database",
|
||||
"flowy-document",
|
||||
"flowy-error",
|
||||
"flowy-folder",
|
||||
"flowy-grid",
|
||||
"flowy-http-model",
|
||||
"flowy-net",
|
||||
"flowy-revision",
|
||||
"flowy-task",
|
||||
"flowy-user",
|
||||
"futures-core",
|
||||
"grid-rev-model",
|
||||
"grid-model",
|
||||
"lib-dispatch",
|
||||
"lib-infra",
|
||||
"lib-log",
|
||||
"lib-ws",
|
||||
"parking_lot 0.12.1",
|
||||
"revision-model",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"ws-model",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1046,16 +1054,16 @@ dependencies = [
|
||||
"derive_more",
|
||||
"diesel",
|
||||
"diesel_derives",
|
||||
"document-model",
|
||||
"flowy-client-sync",
|
||||
"flowy-codegen",
|
||||
"flowy-database",
|
||||
"flowy-derive",
|
||||
"flowy-document",
|
||||
"flowy-error",
|
||||
"flowy-http-model",
|
||||
"flowy-notification",
|
||||
"flowy-revision",
|
||||
"flowy-revision-persistence",
|
||||
"flowy-sync",
|
||||
"flowy-test",
|
||||
"futures",
|
||||
"futures-util",
|
||||
@ -1063,10 +1071,10 @@ dependencies = [
|
||||
"lib-infra",
|
||||
"lib-ot",
|
||||
"lib-ws",
|
||||
"log",
|
||||
"md5",
|
||||
"protobuf",
|
||||
"rand 0.8.5",
|
||||
"revision-model",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"strum",
|
||||
@ -1076,6 +1084,7 @@ dependencies = [
|
||||
"tracing-subscriber",
|
||||
"unicode-segmentation",
|
||||
"url",
|
||||
"ws-model",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1084,17 +1093,22 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
"flowy-client-sync",
|
||||
"flowy-client-ws",
|
||||
"flowy-codegen",
|
||||
"flowy-database",
|
||||
"flowy-derive",
|
||||
"flowy-sync",
|
||||
"http-flowy",
|
||||
"http-error-code",
|
||||
"lib-dispatch",
|
||||
"lib-ot",
|
||||
"protobuf",
|
||||
"r2d2",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_repr",
|
||||
"thiserror",
|
||||
"user-model",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1104,19 +1118,18 @@ dependencies = [
|
||||
"bytes",
|
||||
"diesel",
|
||||
"diesel_derives",
|
||||
"flowy-client-sync",
|
||||
"flowy-codegen",
|
||||
"flowy-database",
|
||||
"flowy-derive",
|
||||
"flowy-document",
|
||||
"flowy-error",
|
||||
"flowy-folder",
|
||||
"flowy-http-model",
|
||||
"flowy-notification",
|
||||
"flowy-revision",
|
||||
"flowy-revision-persistence",
|
||||
"flowy-sync",
|
||||
"flowy-test",
|
||||
"folder-rev-model",
|
||||
"folder-model",
|
||||
"futures",
|
||||
"lazy_static",
|
||||
"lib-dispatch",
|
||||
@ -1126,6 +1139,7 @@ dependencies = [
|
||||
"parking_lot 0.12.1",
|
||||
"pin-project",
|
||||
"protobuf",
|
||||
"revision-model",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"strum",
|
||||
@ -1133,6 +1147,7 @@ dependencies = [
|
||||
"tokio",
|
||||
"tracing",
|
||||
"unicode-segmentation",
|
||||
"ws-model",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1147,21 +1162,20 @@ dependencies = [
|
||||
"crossbeam-utils",
|
||||
"dashmap",
|
||||
"diesel",
|
||||
"fancy-regex",
|
||||
"fancy-regex 0.10.0",
|
||||
"flowy-client-sync",
|
||||
"flowy-codegen",
|
||||
"flowy-database",
|
||||
"flowy-derive",
|
||||
"flowy-error",
|
||||
"flowy-grid",
|
||||
"flowy-http-model",
|
||||
"flowy-notification",
|
||||
"flowy-revision",
|
||||
"flowy-revision-persistence",
|
||||
"flowy-sync",
|
||||
"flowy-task",
|
||||
"flowy-test",
|
||||
"futures",
|
||||
"grid-rev-model",
|
||||
"grid-model",
|
||||
"indexmap",
|
||||
"lazy_static",
|
||||
"lib-dispatch",
|
||||
@ -1172,6 +1186,7 @@ dependencies = [
|
||||
"protobuf",
|
||||
"rayon",
|
||||
"regex",
|
||||
"revision-model",
|
||||
"rust_decimal",
|
||||
"rusty-money",
|
||||
"serde",
|
||||
@ -1184,17 +1199,6 @@ dependencies = [
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-http-model"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"md5",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_repr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-net"
|
||||
version = "0.1.0"
|
||||
@ -1204,41 +1208,46 @@ dependencies = [
|
||||
"bytes",
|
||||
"config",
|
||||
"dashmap",
|
||||
"document-model",
|
||||
"flowy-client-network-config",
|
||||
"flowy-client-sync",
|
||||
"flowy-client-ws",
|
||||
"flowy-codegen",
|
||||
"flowy-derive",
|
||||
"flowy-document",
|
||||
"flowy-error",
|
||||
"flowy-folder",
|
||||
"flowy-http-model",
|
||||
"flowy-server-sync",
|
||||
"flowy-sync",
|
||||
"flowy-user",
|
||||
"folder-rev-model",
|
||||
"folder-model",
|
||||
"futures-util",
|
||||
"http-flowy",
|
||||
"hyper",
|
||||
"lazy_static",
|
||||
"lib-dispatch",
|
||||
"lib-infra",
|
||||
"lib-ws",
|
||||
"log",
|
||||
"nanoid",
|
||||
"parking_lot 0.12.1",
|
||||
"protobuf",
|
||||
"reqwest",
|
||||
"revision-model",
|
||||
"serde",
|
||||
"serde-aux",
|
||||
"serde_json",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"user-model",
|
||||
"ws-model",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-notification"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"allo-isolate",
|
||||
"bytes",
|
||||
"flowy-codegen",
|
||||
"flowy-derive",
|
||||
@ -1257,7 +1266,6 @@ dependencies = [
|
||||
"bytes",
|
||||
"dashmap",
|
||||
"flowy-error",
|
||||
"flowy-http-model",
|
||||
"flowy-revision",
|
||||
"flowy-revision-persistence",
|
||||
"futures",
|
||||
@ -1266,12 +1274,14 @@ dependencies = [
|
||||
"lib-ws",
|
||||
"nanoid",
|
||||
"parking_lot 0.12.1",
|
||||
"revision-model",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"ws-model",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1279,35 +1289,46 @@ name = "flowy-revision-persistence"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"flowy-error",
|
||||
"flowy-http-model",
|
||||
"revision-model",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-server-sync"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-stream",
|
||||
"bytes",
|
||||
"dashmap",
|
||||
"document-model",
|
||||
"flowy-sync",
|
||||
"folder-model",
|
||||
"futures",
|
||||
"lib-infra",
|
||||
"lib-ot",
|
||||
"log",
|
||||
"revision-model",
|
||||
"serde",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"ws-model",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flowy-sync"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-stream",
|
||||
"bytes",
|
||||
"chrono",
|
||||
"dashmap",
|
||||
"dissimilar",
|
||||
"flowy-derive",
|
||||
"flowy-http-model",
|
||||
"folder-rev-model",
|
||||
"futures",
|
||||
"grid-rev-model",
|
||||
"document-model",
|
||||
"folder-model",
|
||||
"lib-infra",
|
||||
"lib-ot",
|
||||
"log",
|
||||
"parking_lot 0.12.1",
|
||||
"protobuf",
|
||||
"revision-model",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"url",
|
||||
"ws-model",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1327,16 +1348,14 @@ dependencies = [
|
||||
name = "flowy-test"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"bytes",
|
||||
"claim 0.4.0",
|
||||
"claim 0.5.0",
|
||||
"claim",
|
||||
"fake",
|
||||
"flowy-client-sync",
|
||||
"flowy-core",
|
||||
"flowy-document",
|
||||
"flowy-folder",
|
||||
"flowy-net",
|
||||
"flowy-sync",
|
||||
"flowy-user",
|
||||
"futures",
|
||||
"futures-util",
|
||||
@ -1360,18 +1379,14 @@ name = "flowy-user"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"claim 0.4.0",
|
||||
"diesel",
|
||||
"diesel_derives",
|
||||
"fake",
|
||||
"fancy-regex",
|
||||
"flowy-codegen",
|
||||
"flowy-database",
|
||||
"flowy-derive",
|
||||
"flowy-error",
|
||||
"flowy-notification",
|
||||
"flowy-test",
|
||||
"futures",
|
||||
"lazy_static",
|
||||
"lib-dispatch",
|
||||
"lib-infra",
|
||||
@ -1380,19 +1395,13 @@ dependencies = [
|
||||
"once_cell",
|
||||
"parking_lot 0.12.1",
|
||||
"protobuf",
|
||||
"quickcheck",
|
||||
"quickcheck_macros",
|
||||
"rand 0.8.5",
|
||||
"rand_core 0.6.4",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serial_test",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"unicode-segmentation",
|
||||
"validator",
|
||||
"user-model",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1402,17 +1411,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||
|
||||
[[package]]
|
||||
name = "folder-rev-model"
|
||||
name = "folder-model"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"chrono",
|
||||
"nanoid",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_repr",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1607,7 +1612,7 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "grid-rev-model"
|
||||
name = "grid-model"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
@ -1711,21 +1716,13 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http-flowy"
|
||||
name = "http-error-code"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Server#3012acce300024dda8819d8507c9105af84cd909"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Server?branch=refactor/appflowy_server#1ccd296de8530760d92652dbd9f38f27178059b6"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
"derive_more",
|
||||
"hyper",
|
||||
"protobuf",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_repr",
|
||||
"thiserror",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1746,12 +1743,6 @@ version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "02296996cb8796d7c6e3bc2d9211b7802812d36999a51bb754123ead7d37d026"
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.14.23"
|
||||
@ -1813,12 +1804,6 @@ dependencies = [
|
||||
"cxx-build",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ident_case"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "0.2.3"
|
||||
@ -1950,24 +1935,19 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"bytes",
|
||||
"dashmap",
|
||||
"derivative",
|
||||
"dyn-clone",
|
||||
"env_logger",
|
||||
"futures",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"nanoid",
|
||||
"paste",
|
||||
"pin-project",
|
||||
"protobuf",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_repr",
|
||||
"serde_with",
|
||||
"thread-id",
|
||||
"tokio",
|
||||
"tracing",
|
||||
@ -1981,6 +1961,7 @@ dependencies = [
|
||||
"bytes",
|
||||
"chrono",
|
||||
"futures-core",
|
||||
"md5",
|
||||
"pin-project",
|
||||
"rand 0.8.5",
|
||||
"tokio",
|
||||
@ -1999,7 +1980,6 @@ dependencies = [
|
||||
"tracing-appender",
|
||||
"tracing-bunyan-formatter",
|
||||
"tracing-core",
|
||||
"tracing-futures",
|
||||
"tracing-log",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
@ -2008,23 +1988,16 @@ dependencies = [
|
||||
name = "lib-ot"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytecount",
|
||||
"bytes",
|
||||
"dashmap",
|
||||
"derive_more",
|
||||
"indexmap",
|
||||
"indextree",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"md5",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_repr",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
@ -2041,13 +2014,11 @@ dependencies = [
|
||||
"lib-infra",
|
||||
"log",
|
||||
"parking_lot 0.12.1",
|
||||
"paste",
|
||||
"pin-project",
|
||||
"protobuf",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_repr",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"tokio",
|
||||
"tokio-tungstenite",
|
||||
@ -2411,12 +2382,6 @@ dependencies = [
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba"
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "2.2.0"
|
||||
@ -3018,6 +2983,16 @@ dependencies = [
|
||||
"winreg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "revision-model"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"md5",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rkyv"
|
||||
version = "0.7.39"
|
||||
@ -3251,28 +3226,6 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_with"
|
||||
version = "1.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "678b5a069e50bf00ecd22d0cd8ddf7c236f68581b03db652061ed5eb13a312ff"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_with_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_with_macros"
|
||||
version = "1.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serial_test"
|
||||
version = "0.5.1"
|
||||
@ -3389,12 +3342,6 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "strum"
|
||||
version = "0.21.0"
|
||||
@ -3709,16 +3656,6 @@ dependencies = [
|
||||
"valuable",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-futures"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
|
||||
dependencies = [
|
||||
"pin-project",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-log"
|
||||
version = "0.1.3"
|
||||
@ -3917,26 +3854,31 @@ dependencies = [
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "user-model"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"fancy-regex 0.11.0",
|
||||
"lazy_static",
|
||||
"serde",
|
||||
"serde_repr",
|
||||
"thiserror",
|
||||
"tracing",
|
||||
"unicode-segmentation",
|
||||
"validator",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "utf-8"
|
||||
version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
|
||||
dependencies = [
|
||||
"getrandom 0.2.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "validator"
|
||||
version = "0.15.0"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f07b0a1390e01c0fc35ebb26b28ced33c9a3808f7f9fbe94d3cc01e233bfeed5"
|
||||
checksum = "32ad5bf234c7d3ad1042e5252b7eddb2c4669ee23f32c7dd0e9b7705f07ef591"
|
||||
dependencies = [
|
||||
"idna 0.2.3",
|
||||
"lazy_static",
|
||||
@ -4188,6 +4130,17 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ws-model"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"revision-model",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_repr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "yaml-rust"
|
||||
version = "0.4.5"
|
||||
|
@ -16,7 +16,7 @@ members = [
|
||||
"flowy-revision-persistence",
|
||||
"flowy-grid",
|
||||
"flowy-task",
|
||||
"flowy-sync",
|
||||
"flowy-client-sync",
|
||||
"flowy-derive",
|
||||
"flowy-ast",
|
||||
"flowy-codegen",
|
||||
|
@ -14,7 +14,6 @@ crate-type = ["staticlib"]
|
||||
[dependencies]
|
||||
allo-isolate = { version = "^0.1", features = ["catch-unwind"] }
|
||||
byteorder = { version = "1.3.4" }
|
||||
ffi-support = { version = "0.4.2" }
|
||||
protobuf = { version = "2.20.0" }
|
||||
tokio = { version = "1", features = ["rt", "rt-multi-thread"] }
|
||||
log = "0.4.14"
|
||||
|
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "flowy-sync"
|
||||
name = "flowy-client-sync"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
|
||||
@ -9,12 +9,12 @@ edition = "2018"
|
||||
lib-ot = { path = "../../../shared-lib/lib-ot" }
|
||||
lib-infra = { path = "../../../shared-lib/lib-infra" }
|
||||
flowy-derive = { path = "../flowy-derive" }
|
||||
folder-rev-model = { path = "../../../shared-lib/folder-rev-model" }
|
||||
grid-rev-model = { path = "../../../shared-lib/grid-rev-model" }
|
||||
flowy-http-model = { path = "../../../shared-lib/flowy-http-model" }
|
||||
protobuf = {version = "2.18.0"}
|
||||
folder-model = { path = "../../../shared-lib/folder-model" }
|
||||
grid-model = { path = "../../../shared-lib/grid-model" }
|
||||
revision-model = { path = "../../../shared-lib/revision-model" }
|
||||
document-model = { path = "../../../shared-lib/document-model" }
|
||||
flowy-sync = { path = "../../../shared-lib/flowy-sync" }
|
||||
bytes = "1.0"
|
||||
log = "0.4.14"
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
serde = { version = "1.0", features = ["derive", "rc"] }
|
||||
serde_json = {version = "1.0"}
|
||||
@ -25,6 +25,3 @@ strum = "0.21"
|
||||
strum_macros = "0.21"
|
||||
chrono = "0.4.19"
|
||||
parking_lot = "0.12.1"
|
||||
dashmap = "5"
|
||||
futures = "0.3.15"
|
||||
async-stream = "0.3.2"
|
@ -3,10 +3,10 @@ use crate::{
|
||||
history::{History, UndoResult},
|
||||
view::{ViewExtensions, RECORD_THRESHOLD},
|
||||
},
|
||||
errors::CollaborateError,
|
||||
errors::SyncError,
|
||||
};
|
||||
use bytes::Bytes;
|
||||
use flowy_http_model::util::md5;
|
||||
use lib_infra::util::md5;
|
||||
use lib_ot::text_delta::DeltaTextOperationBuilder;
|
||||
use lib_ot::{core::*, text_delta::DeltaTextOperations};
|
||||
use tokio::sync::mpsc;
|
||||
@ -57,7 +57,7 @@ impl ClientDocument {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_json(json: &str) -> Result<Self, CollaborateError> {
|
||||
pub fn from_json(json: &str) -> Result<Self, SyncError> {
|
||||
let operations = DeltaTextOperations::from_json(json)?;
|
||||
Ok(Self::from_operations(operations))
|
||||
}
|
||||
@ -99,7 +99,7 @@ impl ClientDocument {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn compose_operations(&mut self, operations: DeltaTextOperations) -> Result<(), CollaborateError> {
|
||||
pub fn compose_operations(&mut self, operations: DeltaTextOperations) -> Result<(), SyncError> {
|
||||
tracing::trace!("{} compose {}", &self.operations.json_str(), operations.json_str());
|
||||
let composed_operations = self.operations.compose(&operations)?;
|
||||
let mut undo_operations = operations.invert(&self.operations);
|
||||
@ -125,7 +125,7 @@ impl ClientDocument {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn insert<T: ToString>(&mut self, index: usize, data: T) -> Result<DeltaTextOperations, CollaborateError> {
|
||||
pub fn insert<T: ToString>(&mut self, index: usize, data: T) -> Result<DeltaTextOperations, SyncError> {
|
||||
let text = data.to_string();
|
||||
let interval = Interval::new(index, index);
|
||||
validate_interval(&self.operations, &interval)?;
|
||||
@ -134,7 +134,7 @@ impl ClientDocument {
|
||||
Ok(operations)
|
||||
}
|
||||
|
||||
pub fn delete(&mut self, interval: Interval) -> Result<DeltaTextOperations, CollaborateError> {
|
||||
pub fn delete(&mut self, interval: Interval) -> Result<DeltaTextOperations, SyncError> {
|
||||
validate_interval(&self.operations, &interval)?;
|
||||
debug_assert!(!interval.is_empty());
|
||||
let operations = self.view.delete(&self.operations, interval)?;
|
||||
@ -144,11 +144,7 @@ impl ClientDocument {
|
||||
Ok(operations)
|
||||
}
|
||||
|
||||
pub fn format(
|
||||
&mut self,
|
||||
interval: Interval,
|
||||
attribute: AttributeEntry,
|
||||
) -> Result<DeltaTextOperations, CollaborateError> {
|
||||
pub fn format(&mut self, interval: Interval, attribute: AttributeEntry) -> Result<DeltaTextOperations, SyncError> {
|
||||
validate_interval(&self.operations, &interval)?;
|
||||
tracing::trace!("format {} with {:?}", interval, attribute);
|
||||
let operations = self.view.format(&self.operations, attribute, interval).unwrap();
|
||||
@ -156,11 +152,7 @@ impl ClientDocument {
|
||||
Ok(operations)
|
||||
}
|
||||
|
||||
pub fn replace<T: ToString>(
|
||||
&mut self,
|
||||
interval: Interval,
|
||||
data: T,
|
||||
) -> Result<DeltaTextOperations, CollaborateError> {
|
||||
pub fn replace<T: ToString>(&mut self, interval: Interval, data: T) -> Result<DeltaTextOperations, SyncError> {
|
||||
validate_interval(&self.operations, &interval)?;
|
||||
let mut operations = DeltaTextOperations::default();
|
||||
let text = data.to_string();
|
||||
@ -185,9 +177,9 @@ impl ClientDocument {
|
||||
self.history.can_redo()
|
||||
}
|
||||
|
||||
pub fn undo(&mut self) -> Result<UndoResult, CollaborateError> {
|
||||
pub fn undo(&mut self) -> Result<UndoResult, SyncError> {
|
||||
match self.history.undo() {
|
||||
None => Err(CollaborateError::undo().context("Undo stack is empty")),
|
||||
None => Err(SyncError::undo().context("Undo stack is empty")),
|
||||
Some(undo_operations) => {
|
||||
let (new_operations, inverted_operations) = self.invert(&undo_operations)?;
|
||||
self.set_operations(new_operations);
|
||||
@ -199,9 +191,9 @@ impl ClientDocument {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn redo(&mut self) -> Result<UndoResult, CollaborateError> {
|
||||
pub fn redo(&mut self) -> Result<UndoResult, SyncError> {
|
||||
match self.history.redo() {
|
||||
None => Err(CollaborateError::redo()),
|
||||
None => Err(SyncError::redo()),
|
||||
Some(redo_operations) => {
|
||||
let (new_operations, inverted_operations) = self.invert(&redo_operations)?;
|
||||
self.set_operations(new_operations);
|
||||
@ -223,7 +215,7 @@ impl ClientDocument {
|
||||
fn invert(
|
||||
&self,
|
||||
operations: &DeltaTextOperations,
|
||||
) -> Result<(DeltaTextOperations, DeltaTextOperations), CollaborateError> {
|
||||
) -> Result<(DeltaTextOperations, DeltaTextOperations), SyncError> {
|
||||
// c = a.compose(b)
|
||||
// d = b.invert(a)
|
||||
// a = c.compose(d)
|
||||
@ -233,14 +225,14 @@ impl ClientDocument {
|
||||
}
|
||||
}
|
||||
|
||||
fn validate_interval(operations: &DeltaTextOperations, interval: &Interval) -> Result<(), CollaborateError> {
|
||||
fn validate_interval(operations: &DeltaTextOperations, interval: &Interval) -> Result<(), SyncError> {
|
||||
if operations.utf16_target_len < interval.end {
|
||||
log::error!(
|
||||
tracing::error!(
|
||||
"{:?} out of bounds. should 0..{}",
|
||||
interval,
|
||||
operations.utf16_target_len
|
||||
);
|
||||
return Err(CollaborateError::out_of_bound());
|
||||
return Err(SyncError::out_of_bound());
|
||||
}
|
||||
Ok(())
|
||||
}
|
@ -32,7 +32,7 @@ impl DeleteExt for PreserveLineFormatOnMerge {
|
||||
|
||||
while iter.has_next() {
|
||||
match iter.next() {
|
||||
None => log::error!("op must be not None when has_next() return true"),
|
||||
None => tracing::error!("op must be not None when has_next() return true"),
|
||||
Some(op) => {
|
||||
//
|
||||
match op.get_data().find(NEW_LINE) {
|
@ -23,7 +23,7 @@ pub(crate) fn line_break(
|
||||
new_delta.retain(1, attribute.clone().into());
|
||||
}
|
||||
_ => {
|
||||
log::error!("Unsupported parser line break for {:?}", scope);
|
||||
tracing::error!("Unsupported parser line break for {:?}", scope);
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ pub(crate) fn line_break(
|
||||
match scope {
|
||||
AttributeScope::Inline => new_delta.retain(end - start, attribute.clone().into()),
|
||||
AttributeScope::Block => new_delta.retain(end - start, empty_attributes()),
|
||||
_ => log::error!("Unsupported parser line break for {:?}", scope),
|
||||
_ => tracing::error!("Unsupported parser line break for {:?}", scope),
|
||||
}
|
||||
}
|
||||
new_delta
|
@ -1,12 +1,11 @@
|
||||
use crate::util::make_operations_from_revisions;
|
||||
use crate::client_folder::FolderOperations;
|
||||
use crate::{
|
||||
client_folder::{default_folder_operations, FolderPad},
|
||||
errors::CollaborateResult,
|
||||
errors::SyncResult,
|
||||
};
|
||||
|
||||
use crate::server_folder::FolderOperations;
|
||||
use flowy_http_model::revision::Revision;
|
||||
use folder_rev_model::{TrashRevision, WorkspaceRevision};
|
||||
use flowy_sync::util::make_operations_from_revisions;
|
||||
use folder_model::{TrashRevision, WorkspaceRevision};
|
||||
use revision_model::Revision;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
@ -35,7 +34,7 @@ impl FolderPadBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
pub(crate) fn build_with_revisions(self, revisions: Vec<Revision>) -> CollaborateResult<FolderPad> {
|
||||
pub(crate) fn build_with_revisions(self, revisions: Vec<Revision>) -> SyncResult<FolderPad> {
|
||||
let mut operations: FolderOperations = make_operations_from_revisions(revisions)?;
|
||||
if operations.is_empty() {
|
||||
operations = default_folder_operations();
|
||||
@ -44,7 +43,7 @@ impl FolderPadBuilder {
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn build(self) -> CollaborateResult<FolderPad> {
|
||||
pub(crate) fn build(self) -> SyncResult<FolderPad> {
|
||||
FolderPad::new(self.workspaces, self.trash)
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
use crate::client_folder::trash_node::TrashNode;
|
||||
use crate::client_folder::workspace_node::WorkspaceNode;
|
||||
use crate::errors::{CollaborateError, CollaborateResult};
|
||||
use crate::errors::{SyncError, SyncResult};
|
||||
use flowy_derive::Node;
|
||||
use lib_ot::core::NodeTree;
|
||||
use lib_ot::core::*;
|
||||
@ -78,11 +78,11 @@ impl FolderNodePad {
|
||||
self.workspaces.push(workspace);
|
||||
}
|
||||
|
||||
pub fn to_json(&self, pretty: bool) -> CollaborateResult<String> {
|
||||
pub fn to_json(&self, pretty: bool) -> SyncResult<String> {
|
||||
self.tree
|
||||
.read()
|
||||
.to_json(pretty)
|
||||
.map_err(|e| CollaborateError::serde().context(e))
|
||||
.map_err(|e| SyncError::serde().context(e))
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,20 @@
|
||||
use crate::errors::internal_error;
|
||||
use crate::server_folder::{FolderOperations, FolderOperationsBuilder};
|
||||
use crate::errors::internal_sync_error;
|
||||
use crate::util::cal_diff;
|
||||
use crate::{
|
||||
client_folder::builder::FolderPadBuilder,
|
||||
errors::{CollaborateError, CollaborateResult},
|
||||
errors::{SyncError, SyncResult},
|
||||
};
|
||||
use flowy_http_model::revision::Revision;
|
||||
use flowy_http_model::util::md5;
|
||||
use folder_rev_model::{AppRevision, FolderRevision, TrashRevision, ViewRevision, WorkspaceRevision};
|
||||
use folder_model::{AppRevision, FolderRevision, TrashRevision, ViewRevision, WorkspaceRevision};
|
||||
use lib_infra::util::md5;
|
||||
use lib_infra::util::move_vec_element;
|
||||
use lib_ot::core::*;
|
||||
use revision_model::Revision;
|
||||
use serde::Deserialize;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub type FolderOperations = DeltaOperations<EmptyAttributes>;
|
||||
pub type FolderOperationsBuilder = DeltaOperationBuilder<EmptyAttributes>;
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
pub struct FolderPad {
|
||||
folder_rev: FolderRevision,
|
||||
@ -20,7 +22,7 @@ pub struct FolderPad {
|
||||
}
|
||||
|
||||
impl FolderPad {
|
||||
pub fn new(workspaces: Vec<WorkspaceRevision>, trash: Vec<TrashRevision>) -> CollaborateResult<Self> {
|
||||
pub fn new(workspaces: Vec<WorkspaceRevision>, trash: Vec<TrashRevision>) -> SyncResult<Self> {
|
||||
let folder_rev = FolderRevision {
|
||||
workspaces: workspaces.into_iter().map(Arc::new).collect(),
|
||||
trash: trash.into_iter().map(Arc::new).collect(),
|
||||
@ -28,25 +30,25 @@ impl FolderPad {
|
||||
Self::from_folder_rev(folder_rev)
|
||||
}
|
||||
|
||||
pub fn from_folder_rev(folder_rev: FolderRevision) -> CollaborateResult<Self> {
|
||||
pub fn from_folder_rev(folder_rev: FolderRevision) -> SyncResult<Self> {
|
||||
let json = serde_json::to_string(&folder_rev)
|
||||
.map_err(|e| CollaborateError::internal().context(format!("Serialize to folder json str failed: {}", e)))?;
|
||||
.map_err(|e| SyncError::internal().context(format!("Serialize to folder json str failed: {}", e)))?;
|
||||
let operations = FolderOperationsBuilder::new().insert(&json).build();
|
||||
|
||||
Ok(Self { folder_rev, operations })
|
||||
}
|
||||
|
||||
pub fn from_revisions(revisions: Vec<Revision>) -> CollaborateResult<Self> {
|
||||
pub fn from_revisions(revisions: Vec<Revision>) -> SyncResult<Self> {
|
||||
FolderPadBuilder::new().build_with_revisions(revisions)
|
||||
}
|
||||
|
||||
pub fn from_operations(operations: FolderOperations) -> CollaborateResult<Self> {
|
||||
pub fn from_operations(operations: FolderOperations) -> SyncResult<Self> {
|
||||
let content = operations.content()?;
|
||||
let mut deserializer = serde_json::Deserializer::from_reader(content.as_bytes());
|
||||
|
||||
let folder_rev = FolderRevision::deserialize(&mut deserializer).map_err(|e| {
|
||||
tracing::error!("Deserialize folder from {} failed", content);
|
||||
CollaborateError::internal().context(format!("Deserialize operations to folder failed: {}", e))
|
||||
SyncError::internal().context(format!("Deserialize operations to folder failed: {}", e))
|
||||
})?;
|
||||
|
||||
Ok(Self { folder_rev, operations })
|
||||
@ -56,7 +58,7 @@ impl FolderPad {
|
||||
&self.operations
|
||||
}
|
||||
|
||||
pub fn reset_folder(&mut self, operations: FolderOperations) -> CollaborateResult<String> {
|
||||
pub fn reset_folder(&mut self, operations: FolderOperations) -> SyncResult<String> {
|
||||
let folder = FolderPad::from_operations(operations)?;
|
||||
self.folder_rev = folder.folder_rev;
|
||||
self.operations = folder.operations;
|
||||
@ -64,7 +66,7 @@ impl FolderPad {
|
||||
Ok(self.folder_md5())
|
||||
}
|
||||
|
||||
pub fn compose_remote_operations(&mut self, operations: FolderOperations) -> CollaborateResult<String> {
|
||||
pub fn compose_remote_operations(&mut self, operations: FolderOperations) -> SyncResult<String> {
|
||||
let composed_operations = self.operations.compose(&operations)?;
|
||||
self.reset_folder(composed_operations)
|
||||
}
|
||||
@ -74,7 +76,7 @@ impl FolderPad {
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip(self, workspace_rev), fields(workspace_name=%workspace_rev.name), err)]
|
||||
pub fn create_workspace(&mut self, workspace_rev: WorkspaceRevision) -> CollaborateResult<Option<FolderChangeset>> {
|
||||
pub fn create_workspace(&mut self, workspace_rev: WorkspaceRevision) -> SyncResult<Option<FolderChangeset>> {
|
||||
let workspace = Arc::new(workspace_rev);
|
||||
if self.folder_rev.workspaces.contains(&workspace) {
|
||||
tracing::warn!("[RootFolder]: Duplicate workspace");
|
||||
@ -92,7 +94,7 @@ impl FolderPad {
|
||||
workspace_id: &str,
|
||||
name: Option<String>,
|
||||
desc: Option<String>,
|
||||
) -> CollaborateResult<Option<FolderChangeset>> {
|
||||
) -> SyncResult<Option<FolderChangeset>> {
|
||||
self.with_workspace(workspace_id, |workspace| {
|
||||
if let Some(name) = name {
|
||||
workspace.name = name;
|
||||
@ -105,7 +107,7 @@ impl FolderPad {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn read_workspaces(&self, workspace_id: Option<String>) -> CollaborateResult<Vec<WorkspaceRevision>> {
|
||||
pub fn read_workspaces(&self, workspace_id: Option<String>) -> SyncResult<Vec<WorkspaceRevision>> {
|
||||
match workspace_id {
|
||||
None => {
|
||||
let workspaces = self
|
||||
@ -125,15 +127,14 @@ impl FolderPad {
|
||||
{
|
||||
Ok(vec![workspace.as_ref().clone()])
|
||||
} else {
|
||||
Err(CollaborateError::record_not_found()
|
||||
.context(format!("Can't find workspace with id {}", workspace_id)))
|
||||
Err(SyncError::record_not_found().context(format!("Can't find workspace with id {}", workspace_id)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip(self), err)]
|
||||
pub fn delete_workspace(&mut self, workspace_id: &str) -> CollaborateResult<Option<FolderChangeset>> {
|
||||
pub fn delete_workspace(&mut self, workspace_id: &str) -> SyncResult<Option<FolderChangeset>> {
|
||||
self.modify_workspaces(|workspaces| {
|
||||
workspaces.retain(|w| w.id != workspace_id);
|
||||
Ok(Some(()))
|
||||
@ -141,7 +142,7 @@ impl FolderPad {
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip(self), fields(app_name=%app_rev.name), err)]
|
||||
pub fn create_app(&mut self, app_rev: AppRevision) -> CollaborateResult<Option<FolderChangeset>> {
|
||||
pub fn create_app(&mut self, app_rev: AppRevision) -> SyncResult<Option<FolderChangeset>> {
|
||||
let workspace_id = app_rev.workspace_id.clone();
|
||||
self.with_workspace(&workspace_id, move |workspace| {
|
||||
if workspace.apps.contains(&app_rev) {
|
||||
@ -153,13 +154,13 @@ impl FolderPad {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn read_app(&self, app_id: &str) -> CollaborateResult<AppRevision> {
|
||||
pub fn read_app(&self, app_id: &str) -> SyncResult<AppRevision> {
|
||||
for workspace in &self.folder_rev.workspaces {
|
||||
if let Some(app) = workspace.apps.iter().find(|app| app.id == app_id) {
|
||||
return Ok(app.clone());
|
||||
}
|
||||
}
|
||||
Err(CollaborateError::record_not_found().context(format!("Can't find app with id {}", app_id)))
|
||||
Err(SyncError::record_not_found().context(format!("Can't find app with id {}", app_id)))
|
||||
}
|
||||
|
||||
pub fn update_app(
|
||||
@ -167,7 +168,7 @@ impl FolderPad {
|
||||
app_id: &str,
|
||||
name: Option<String>,
|
||||
desc: Option<String>,
|
||||
) -> CollaborateResult<Option<FolderChangeset>> {
|
||||
) -> SyncResult<Option<FolderChangeset>> {
|
||||
self.with_app(app_id, move |app| {
|
||||
if let Some(name) = name {
|
||||
app.name = name;
|
||||
@ -181,7 +182,7 @@ impl FolderPad {
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip(self), err)]
|
||||
pub fn delete_app(&mut self, app_id: &str) -> CollaborateResult<Option<FolderChangeset>> {
|
||||
pub fn delete_app(&mut self, app_id: &str) -> SyncResult<Option<FolderChangeset>> {
|
||||
let app = self.read_app(app_id)?;
|
||||
self.with_workspace(&app.workspace_id, |workspace| {
|
||||
workspace.apps.retain(|app| app.id != app_id);
|
||||
@ -190,10 +191,12 @@ impl FolderPad {
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip(self), err)]
|
||||
pub fn move_app(&mut self, app_id: &str, from: usize, to: usize) -> CollaborateResult<Option<FolderChangeset>> {
|
||||
pub fn move_app(&mut self, app_id: &str, from: usize, to: usize) -> SyncResult<Option<FolderChangeset>> {
|
||||
let app = self.read_app(app_id)?;
|
||||
self.with_workspace(&app.workspace_id, |workspace| {
|
||||
match move_vec_element(&mut workspace.apps, |app| app.id == app_id, from, to).map_err(internal_error)? {
|
||||
match move_vec_element(&mut workspace.apps, |app| app.id == app_id, from, to)
|
||||
.map_err(internal_sync_error)?
|
||||
{
|
||||
true => Ok(Some(())),
|
||||
false => Ok(None),
|
||||
}
|
||||
@ -201,7 +204,7 @@ impl FolderPad {
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip(self), fields(view_name=%view_rev.name), err)]
|
||||
pub fn create_view(&mut self, view_rev: ViewRevision) -> CollaborateResult<Option<FolderChangeset>> {
|
||||
pub fn create_view(&mut self, view_rev: ViewRevision) -> SyncResult<Option<FolderChangeset>> {
|
||||
let app_id = view_rev.app_id.clone();
|
||||
self.with_app(&app_id, move |app| {
|
||||
if app.belongings.contains(&view_rev) {
|
||||
@ -213,7 +216,7 @@ impl FolderPad {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn read_view(&self, view_id: &str) -> CollaborateResult<ViewRevision> {
|
||||
pub fn read_view(&self, view_id: &str) -> SyncResult<ViewRevision> {
|
||||
for workspace in &self.folder_rev.workspaces {
|
||||
for app in &(*workspace.apps) {
|
||||
if let Some(view) = app.belongings.iter().find(|b| b.id == view_id) {
|
||||
@ -221,10 +224,10 @@ impl FolderPad {
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(CollaborateError::record_not_found().context(format!("Can't find view with id {}", view_id)))
|
||||
Err(SyncError::record_not_found().context(format!("Can't find view with id {}", view_id)))
|
||||
}
|
||||
|
||||
pub fn read_views(&self, belong_to_id: &str) -> CollaborateResult<Vec<ViewRevision>> {
|
||||
pub fn read_views(&self, belong_to_id: &str) -> SyncResult<Vec<ViewRevision>> {
|
||||
for workspace in &self.folder_rev.workspaces {
|
||||
for app in &(*workspace.apps) {
|
||||
if app.id == belong_to_id {
|
||||
@ -241,7 +244,7 @@ impl FolderPad {
|
||||
name: Option<String>,
|
||||
desc: Option<String>,
|
||||
modified_time: i64,
|
||||
) -> CollaborateResult<Option<FolderChangeset>> {
|
||||
) -> SyncResult<Option<FolderChangeset>> {
|
||||
let view = self.read_view(view_id)?;
|
||||
self.with_view(&view.app_id, view_id, |view| {
|
||||
if let Some(name) = name {
|
||||
@ -258,7 +261,7 @@ impl FolderPad {
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip(self), err)]
|
||||
pub fn delete_view(&mut self, app_id: &str, view_id: &str) -> CollaborateResult<Option<FolderChangeset>> {
|
||||
pub fn delete_view(&mut self, app_id: &str, view_id: &str) -> SyncResult<Option<FolderChangeset>> {
|
||||
self.with_app(app_id, |app| {
|
||||
app.belongings.retain(|view| view.id != view_id);
|
||||
Ok(Some(()))
|
||||
@ -266,17 +269,19 @@ impl FolderPad {
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip(self), err)]
|
||||
pub fn move_view(&mut self, view_id: &str, from: usize, to: usize) -> CollaborateResult<Option<FolderChangeset>> {
|
||||
pub fn move_view(&mut self, view_id: &str, from: usize, to: usize) -> SyncResult<Option<FolderChangeset>> {
|
||||
let view = self.read_view(view_id)?;
|
||||
self.with_app(&view.app_id, |app| {
|
||||
match move_vec_element(&mut app.belongings, |view| view.id == view_id, from, to).map_err(internal_error)? {
|
||||
match move_vec_element(&mut app.belongings, |view| view.id == view_id, from, to)
|
||||
.map_err(internal_sync_error)?
|
||||
{
|
||||
true => Ok(Some(())),
|
||||
false => Ok(None),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn create_trash(&mut self, trash: Vec<TrashRevision>) -> CollaborateResult<Option<FolderChangeset>> {
|
||||
pub fn create_trash(&mut self, trash: Vec<TrashRevision>) -> SyncResult<Option<FolderChangeset>> {
|
||||
self.with_trash(|t| {
|
||||
let mut new_trash = trash.into_iter().map(Arc::new).collect::<Vec<Arc<TrashRevision>>>();
|
||||
t.append(&mut new_trash);
|
||||
@ -285,7 +290,7 @@ impl FolderPad {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn read_trash(&self, trash_id: Option<String>) -> CollaborateResult<Vec<TrashRevision>> {
|
||||
pub fn read_trash(&self, trash_id: Option<String>) -> SyncResult<Vec<TrashRevision>> {
|
||||
match trash_id {
|
||||
None => Ok(self
|
||||
.folder_rev
|
||||
@ -300,7 +305,7 @@ impl FolderPad {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn delete_trash(&mut self, trash_ids: Option<Vec<String>>) -> CollaborateResult<Option<FolderChangeset>> {
|
||||
pub fn delete_trash(&mut self, trash_ids: Option<Vec<String>>) -> SyncResult<Option<FolderChangeset>> {
|
||||
match trash_ids {
|
||||
None => self.with_trash(|trash| {
|
||||
trash.clear();
|
||||
@ -317,21 +322,21 @@ impl FolderPad {
|
||||
md5(&self.operations.json_bytes())
|
||||
}
|
||||
|
||||
pub fn to_json(&self) -> CollaborateResult<String> {
|
||||
pub fn to_json(&self) -> SyncResult<String> {
|
||||
make_folder_rev_json_str(&self.folder_rev)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn make_folder_rev_json_str(folder_rev: &FolderRevision) -> CollaborateResult<String> {
|
||||
pub fn make_folder_rev_json_str(folder_rev: &FolderRevision) -> SyncResult<String> {
|
||||
let json = serde_json::to_string(folder_rev)
|
||||
.map_err(|err| internal_error(format!("Serialize folder to json str failed. {:?}", err)))?;
|
||||
.map_err(|err| internal_sync_error(format!("Serialize folder to json str failed. {:?}", err)))?;
|
||||
Ok(json)
|
||||
}
|
||||
|
||||
impl FolderPad {
|
||||
fn modify_workspaces<F>(&mut self, f: F) -> CollaborateResult<Option<FolderChangeset>>
|
||||
fn modify_workspaces<F>(&mut self, f: F) -> SyncResult<Option<FolderChangeset>>
|
||||
where
|
||||
F: FnOnce(&mut Vec<Arc<WorkspaceRevision>>) -> CollaborateResult<Option<()>>,
|
||||
F: FnOnce(&mut Vec<Arc<WorkspaceRevision>>) -> SyncResult<Option<()>>,
|
||||
{
|
||||
let cloned_self = self.clone();
|
||||
match f(&mut self.folder_rev.workspaces)? {
|
||||
@ -353,9 +358,9 @@ impl FolderPad {
|
||||
}
|
||||
}
|
||||
|
||||
fn with_workspace<F>(&mut self, workspace_id: &str, f: F) -> CollaborateResult<Option<FolderChangeset>>
|
||||
fn with_workspace<F>(&mut self, workspace_id: &str, f: F) -> SyncResult<Option<FolderChangeset>>
|
||||
where
|
||||
F: FnOnce(&mut WorkspaceRevision) -> CollaborateResult<Option<()>>,
|
||||
F: FnOnce(&mut WorkspaceRevision) -> SyncResult<Option<()>>,
|
||||
{
|
||||
self.modify_workspaces(|workspaces| {
|
||||
if let Some(workspace) = workspaces.iter_mut().find(|workspace| workspace_id == workspace.id) {
|
||||
@ -367,9 +372,9 @@ impl FolderPad {
|
||||
})
|
||||
}
|
||||
|
||||
fn with_trash<F>(&mut self, f: F) -> CollaborateResult<Option<FolderChangeset>>
|
||||
fn with_trash<F>(&mut self, f: F) -> SyncResult<Option<FolderChangeset>>
|
||||
where
|
||||
F: FnOnce(&mut Vec<Arc<TrashRevision>>) -> CollaborateResult<Option<()>>,
|
||||
F: FnOnce(&mut Vec<Arc<TrashRevision>>) -> SyncResult<Option<()>>,
|
||||
{
|
||||
let cloned_self = self.clone();
|
||||
match f(&mut self.folder_rev.trash)? {
|
||||
@ -391,9 +396,9 @@ impl FolderPad {
|
||||
}
|
||||
}
|
||||
|
||||
fn with_app<F>(&mut self, app_id: &str, f: F) -> CollaborateResult<Option<FolderChangeset>>
|
||||
fn with_app<F>(&mut self, app_id: &str, f: F) -> SyncResult<Option<FolderChangeset>>
|
||||
where
|
||||
F: FnOnce(&mut AppRevision) -> CollaborateResult<Option<()>>,
|
||||
F: FnOnce(&mut AppRevision) -> SyncResult<Option<()>>,
|
||||
{
|
||||
let workspace_id = match self
|
||||
.folder_rev
|
||||
@ -414,9 +419,9 @@ impl FolderPad {
|
||||
})
|
||||
}
|
||||
|
||||
fn with_view<F>(&mut self, belong_to_id: &str, view_id: &str, f: F) -> CollaborateResult<Option<FolderChangeset>>
|
||||
fn with_view<F>(&mut self, belong_to_id: &str, view_id: &str, f: F) -> SyncResult<Option<FolderChangeset>>
|
||||
where
|
||||
F: FnOnce(&mut ViewRevision) -> CollaborateResult<Option<()>>,
|
||||
F: FnOnce(&mut ViewRevision) -> SyncResult<Option<()>>,
|
||||
{
|
||||
self.with_app(belong_to_id, |app| {
|
||||
match app.belongings.iter_mut().find(|view| view_id == view.id) {
|
||||
@ -436,7 +441,7 @@ pub fn default_folder_operations() -> FolderOperations {
|
||||
.build()
|
||||
}
|
||||
|
||||
pub fn initial_folder_operations(folder_pad: &FolderPad) -> CollaborateResult<FolderOperations> {
|
||||
pub fn initial_folder_operations(folder_pad: &FolderPad) -> SyncResult<FolderOperations> {
|
||||
let json = folder_pad.to_json()?;
|
||||
let operations = FolderOperationsBuilder::new().insert(&json).build();
|
||||
Ok(operations)
|
||||
@ -452,9 +457,9 @@ pub struct FolderChangeset {
|
||||
mod tests {
|
||||
#![allow(clippy::all)]
|
||||
use crate::client_folder::folder_pad::FolderPad;
|
||||
use crate::server_folder::{FolderOperations, FolderOperationsBuilder};
|
||||
use crate::client_folder::{FolderOperations, FolderOperationsBuilder};
|
||||
use chrono::Utc;
|
||||
use folder_rev_model::{AppRevision, FolderRevision, TrashRevision, ViewRevision, WorkspaceRevision};
|
||||
use folder_model::{AppRevision, FolderRevision, TrashRevision, ViewRevision, WorkspaceRevision};
|
||||
use lib_ot::core::OperationTransform;
|
||||
use serde::Deserialize;
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::client_folder::AtomicNodeTree;
|
||||
use crate::errors::CollaborateResult;
|
||||
use crate::errors::SyncResult;
|
||||
use lib_ot::core::{AttributeHashMap, AttributeValue, Changeset, NodeId, NodeOperation};
|
||||
use std::sync::Arc;
|
||||
|
||||
@ -15,7 +15,7 @@ pub fn set_attributes_str_value(
|
||||
node_id: &NodeId,
|
||||
key: &str,
|
||||
value: String,
|
||||
) -> CollaborateResult<()> {
|
||||
) -> SyncResult<()> {
|
||||
let old_attributes = match get_attributes(tree.clone(), node_id) {
|
||||
None => AttributeHashMap::new(),
|
||||
Some(attributes) => attributes,
|
@ -1,9 +1,10 @@
|
||||
use crate::errors::{CollaborateError, CollaborateResult};
|
||||
use crate::util::{cal_diff, make_operations_from_revisions};
|
||||
use flowy_http_model::revision::Revision;
|
||||
use flowy_http_model::util::md5;
|
||||
use grid_rev_model::{gen_block_id, gen_row_id, CellRevision, GridBlockRevision, RowChangeset, RowRevision};
|
||||
use crate::errors::{SyncError, SyncResult};
|
||||
use crate::util::cal_diff;
|
||||
use flowy_sync::util::make_operations_from_revisions;
|
||||
use grid_model::{gen_block_id, gen_row_id, CellRevision, GridBlockRevision, RowChangeset, RowRevision};
|
||||
use lib_infra::util::md5;
|
||||
use lib_ot::core::{DeltaBuilder, DeltaOperations, EmptyAttributes, OperationTransform};
|
||||
use revision_model::Revision;
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
@ -44,12 +45,12 @@ impl GridBlockRevisionPad {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_operations(operations: GridBlockOperations) -> CollaborateResult<Self> {
|
||||
pub fn from_operations(operations: GridBlockOperations) -> SyncResult<Self> {
|
||||
let s = operations.content()?;
|
||||
let revision: GridBlockRevision = serde_json::from_str(&s).map_err(|e| {
|
||||
let msg = format!("Deserialize operations to GridBlockRevision failed: {}", e);
|
||||
tracing::error!("{}", s);
|
||||
CollaborateError::internal().context(msg)
|
||||
SyncError::internal().context(msg)
|
||||
})?;
|
||||
Ok(Self {
|
||||
block: revision,
|
||||
@ -57,7 +58,7 @@ impl GridBlockRevisionPad {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn from_revisions(_grid_id: &str, revisions: Vec<Revision>) -> CollaborateResult<Self> {
|
||||
pub fn from_revisions(_grid_id: &str, revisions: Vec<Revision>) -> SyncResult<Self> {
|
||||
let operations: GridBlockOperations = make_operations_from_revisions(revisions)?;
|
||||
Self::from_operations(operations)
|
||||
}
|
||||
@ -67,7 +68,7 @@ impl GridBlockRevisionPad {
|
||||
&mut self,
|
||||
row: RowRevision,
|
||||
start_row_id: Option<String>,
|
||||
) -> CollaborateResult<Option<GridBlockRevisionChangeset>> {
|
||||
) -> SyncResult<Option<GridBlockRevisionChangeset>> {
|
||||
self.modify(|rows| {
|
||||
if let Some(start_row_id) = start_row_id {
|
||||
if !start_row_id.is_empty() {
|
||||
@ -83,10 +84,7 @@ impl GridBlockRevisionPad {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn delete_rows(
|
||||
&mut self,
|
||||
row_ids: Vec<Cow<'_, String>>,
|
||||
) -> CollaborateResult<Option<GridBlockRevisionChangeset>> {
|
||||
pub fn delete_rows(&mut self, row_ids: Vec<Cow<'_, String>>) -> SyncResult<Option<GridBlockRevisionChangeset>> {
|
||||
self.modify(|rows| {
|
||||
rows.retain(|row| !row_ids.contains(&Cow::Borrowed(&row.id)));
|
||||
Ok(Some(()))
|
||||
@ -102,7 +100,7 @@ impl GridBlockRevisionPad {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn get_row_revs<T>(&self, row_ids: Option<Vec<Cow<'_, T>>>) -> CollaborateResult<Vec<Arc<RowRevision>>>
|
||||
pub fn get_row_revs<T>(&self, row_ids: Option<Vec<Cow<'_, T>>>) -> SyncResult<Vec<Arc<RowRevision>>>
|
||||
where
|
||||
T: AsRef<str> + ToOwned + ?Sized,
|
||||
{
|
||||
@ -137,7 +135,7 @@ impl GridBlockRevisionPad {
|
||||
&self,
|
||||
field_id: &str,
|
||||
row_ids: Option<Vec<Cow<'_, String>>>,
|
||||
) -> CollaborateResult<Vec<CellRevision>> {
|
||||
) -> SyncResult<Vec<CellRevision>> {
|
||||
let rows = self.get_row_revs(row_ids)?;
|
||||
let cell_revs = rows
|
||||
.iter()
|
||||
@ -157,7 +155,7 @@ impl GridBlockRevisionPad {
|
||||
self.block.rows.iter().position(|row| row.id == row_id)
|
||||
}
|
||||
|
||||
pub fn update_row(&mut self, changeset: RowChangeset) -> CollaborateResult<Option<GridBlockRevisionChangeset>> {
|
||||
pub fn update_row(&mut self, changeset: RowChangeset) -> SyncResult<Option<GridBlockRevisionChangeset>> {
|
||||
let row_id = changeset.row_id.clone();
|
||||
self.modify_row(&row_id, |row| {
|
||||
let mut is_changed = None;
|
||||
@ -182,18 +180,13 @@ impl GridBlockRevisionPad {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn move_row(
|
||||
&mut self,
|
||||
row_id: &str,
|
||||
from: usize,
|
||||
to: usize,
|
||||
) -> CollaborateResult<Option<GridBlockRevisionChangeset>> {
|
||||
pub fn move_row(&mut self, row_id: &str, from: usize, to: usize) -> SyncResult<Option<GridBlockRevisionChangeset>> {
|
||||
self.modify(|row_revs| {
|
||||
if let Some(position) = row_revs.iter().position(|row_rev| row_rev.id == row_id) {
|
||||
debug_assert_eq!(from, position);
|
||||
let row_rev = row_revs.remove(position);
|
||||
if to > row_revs.len() {
|
||||
Err(CollaborateError::out_of_bound())
|
||||
Err(SyncError::out_of_bound())
|
||||
} else {
|
||||
row_revs.insert(to, row_rev);
|
||||
Ok(Some(()))
|
||||
@ -204,9 +197,9 @@ impl GridBlockRevisionPad {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn modify<F>(&mut self, f: F) -> CollaborateResult<Option<GridBlockRevisionChangeset>>
|
||||
pub fn modify<F>(&mut self, f: F) -> SyncResult<Option<GridBlockRevisionChangeset>>
|
||||
where
|
||||
F: for<'a> FnOnce(&'a mut Vec<Arc<RowRevision>>) -> CollaborateResult<Option<()>>,
|
||||
F: for<'a> FnOnce(&'a mut Vec<Arc<RowRevision>>) -> SyncResult<Option<()>>,
|
||||
{
|
||||
let cloned_self = self.clone();
|
||||
match f(&mut self.block.rows)? {
|
||||
@ -229,9 +222,9 @@ impl GridBlockRevisionPad {
|
||||
}
|
||||
}
|
||||
|
||||
fn modify_row<F>(&mut self, row_id: &str, f: F) -> CollaborateResult<Option<GridBlockRevisionChangeset>>
|
||||
fn modify_row<F>(&mut self, row_id: &str, f: F) -> SyncResult<Option<GridBlockRevisionChangeset>>
|
||||
where
|
||||
F: FnOnce(&mut RowRevision) -> CollaborateResult<Option<()>>,
|
||||
F: FnOnce(&mut RowRevision) -> SyncResult<Option<()>>,
|
||||
{
|
||||
self.modify(|rows| {
|
||||
if let Some(row_rev) = rows.iter_mut().find(|row_rev| row_id == row_rev.id) {
|
||||
@ -243,9 +236,9 @@ impl GridBlockRevisionPad {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn revision_json(&self) -> CollaborateResult<String> {
|
||||
pub fn revision_json(&self) -> SyncResult<String> {
|
||||
serde_json::to_string(&self.block)
|
||||
.map_err(|e| CollaborateError::internal().context(format!("serial block to json failed: {}", e)))
|
||||
.map_err(|e| SyncError::internal().context(format!("serial block to json failed: {}", e)))
|
||||
}
|
||||
|
||||
pub fn operations_json_str(&self) -> String {
|
||||
@ -289,7 +282,7 @@ impl std::default::Default for GridBlockRevisionPad {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::client_grid::{GridBlockOperations, GridBlockRevisionPad};
|
||||
use grid_rev_model::{RowChangeset, RowRevision};
|
||||
use grid_model::{RowChangeset, RowRevision};
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::errors::{CollaborateError, CollaborateResult};
|
||||
use grid_rev_model::{BuildGridContext, FieldRevision, GridBlockMetaRevision, GridBlockRevision, RowRevision};
|
||||
use crate::errors::{SyncError, SyncResult};
|
||||
use grid_model::{BuildGridContext, FieldRevision, GridBlockMetaRevision, GridBlockRevision, RowRevision};
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct GridBuilder {
|
||||
@ -57,13 +57,13 @@ impl GridBuilder {
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn check_rows(fields: &[FieldRevision], rows: &[RowRevision]) -> CollaborateResult<()> {
|
||||
fn check_rows(fields: &[FieldRevision], rows: &[RowRevision]) -> SyncResult<()> {
|
||||
let field_ids = fields.iter().map(|field| &field.id).collect::<Vec<&String>>();
|
||||
for row in rows {
|
||||
let cell_field_ids = row.cells.keys().into_iter().collect::<Vec<&String>>();
|
||||
if cell_field_ids != field_ids {
|
||||
let msg = format!("{:?} contains invalid cells", row);
|
||||
return Err(CollaborateError::internal().context(msg));
|
||||
return Err(SyncError::internal().context(msg));
|
||||
}
|
||||
}
|
||||
Ok(())
|
@ -1,13 +1,14 @@
|
||||
use crate::errors::{internal_error, CollaborateError, CollaborateResult};
|
||||
use crate::util::{cal_diff, make_operations_from_revisions};
|
||||
use flowy_http_model::revision::Revision;
|
||||
use flowy_http_model::util::md5;
|
||||
use grid_rev_model::{
|
||||
use crate::errors::{internal_sync_error, SyncError, SyncResult};
|
||||
use crate::util::cal_diff;
|
||||
use flowy_sync::util::make_operations_from_revisions;
|
||||
use grid_model::{
|
||||
gen_block_id, gen_grid_id, FieldRevision, FieldTypeRevision, GridBlockMetaRevision, GridBlockMetaRevisionChangeset,
|
||||
GridRevision,
|
||||
};
|
||||
use lib_infra::util::md5;
|
||||
use lib_infra::util::move_vec_element;
|
||||
use lib_ot::core::{DeltaOperationBuilder, DeltaOperations, EmptyAttributes, OperationTransform};
|
||||
use revision_model::Revision;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
@ -21,7 +22,7 @@ pub struct GridRevisionPad {
|
||||
}
|
||||
|
||||
pub trait JsonDeserializer {
|
||||
fn deserialize(&self, type_option_data: Vec<u8>) -> CollaborateResult<String>;
|
||||
fn deserialize(&self, type_option_data: Vec<u8>) -> SyncResult<String>;
|
||||
}
|
||||
|
||||
impl GridRevisionPad {
|
||||
@ -50,12 +51,12 @@ impl GridRevisionPad {
|
||||
(fields, blocks)
|
||||
}
|
||||
|
||||
pub fn from_operations(operations: GridOperations) -> CollaborateResult<Self> {
|
||||
pub fn from_operations(operations: GridOperations) -> SyncResult<Self> {
|
||||
let content = operations.content()?;
|
||||
let grid: GridRevision = serde_json::from_str(&content).map_err(|e| {
|
||||
let msg = format!("Deserialize operations to grid failed: {}", e);
|
||||
tracing::error!("{}", msg);
|
||||
CollaborateError::internal().context(msg)
|
||||
SyncError::internal().context(msg)
|
||||
})?;
|
||||
|
||||
Ok(Self {
|
||||
@ -64,7 +65,7 @@ impl GridRevisionPad {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn from_revisions(revisions: Vec<Revision>) -> CollaborateResult<Self> {
|
||||
pub fn from_revisions(revisions: Vec<Revision>) -> SyncResult<Self> {
|
||||
let operations: GridOperations = make_operations_from_revisions(revisions)?;
|
||||
Self::from_operations(operations)
|
||||
}
|
||||
@ -74,7 +75,7 @@ impl GridRevisionPad {
|
||||
&mut self,
|
||||
new_field_rev: FieldRevision,
|
||||
start_field_id: Option<String>,
|
||||
) -> CollaborateResult<Option<GridRevisionChangeset>> {
|
||||
) -> SyncResult<Option<GridRevisionChangeset>> {
|
||||
self.modify_grid(|grid_meta| {
|
||||
// Check if the field exists or not
|
||||
if grid_meta
|
||||
@ -99,13 +100,13 @@ impl GridRevisionPad {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn delete_field_rev(&mut self, field_id: &str) -> CollaborateResult<Option<GridRevisionChangeset>> {
|
||||
pub fn delete_field_rev(&mut self, field_id: &str) -> SyncResult<Option<GridRevisionChangeset>> {
|
||||
self.modify_grid(
|
||||
|grid_meta| match grid_meta.fields.iter().position(|field| field.id == field_id) {
|
||||
None => Ok(None),
|
||||
Some(index) => {
|
||||
if grid_meta.fields[index].is_primary {
|
||||
Err(CollaborateError::can_not_delete_primary_field())
|
||||
Err(SyncError::can_not_delete_primary_field())
|
||||
} else {
|
||||
grid_meta.fields.remove(index);
|
||||
Ok(Some(()))
|
||||
@ -119,7 +120,7 @@ impl GridRevisionPad {
|
||||
&mut self,
|
||||
field_id: &str,
|
||||
duplicated_field_id: &str,
|
||||
) -> CollaborateResult<Option<GridRevisionChangeset>> {
|
||||
) -> SyncResult<Option<GridRevisionChangeset>> {
|
||||
self.modify_grid(
|
||||
|grid_meta| match grid_meta.fields.iter().position(|field| field.id == field_id) {
|
||||
None => Ok(None),
|
||||
@ -150,7 +151,7 @@ impl GridRevisionPad {
|
||||
new_field_type: T,
|
||||
make_default_type_option: DT,
|
||||
type_option_transform: TT,
|
||||
) -> CollaborateResult<Option<GridRevisionChangeset>>
|
||||
) -> SyncResult<Option<GridRevisionChangeset>>
|
||||
where
|
||||
DT: FnOnce() -> String,
|
||||
TT: FnOnce(FieldTypeRevision, Option<String>, String) -> String,
|
||||
@ -194,10 +195,7 @@ impl GridRevisionPad {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn replace_field_rev(
|
||||
&mut self,
|
||||
field_rev: Arc<FieldRevision>,
|
||||
) -> CollaborateResult<Option<GridRevisionChangeset>> {
|
||||
pub fn replace_field_rev(&mut self, field_rev: Arc<FieldRevision>) -> SyncResult<Option<GridRevisionChangeset>> {
|
||||
self.modify_grid(
|
||||
|grid_meta| match grid_meta.fields.iter().position(|field| field.id == field_rev.id) {
|
||||
None => Ok(None),
|
||||
@ -215,7 +213,7 @@ impl GridRevisionPad {
|
||||
field_id: &str,
|
||||
from_index: usize,
|
||||
to_index: usize,
|
||||
) -> CollaborateResult<Option<GridRevisionChangeset>> {
|
||||
) -> SyncResult<Option<GridRevisionChangeset>> {
|
||||
self.modify_grid(|grid_meta| {
|
||||
match move_vec_element(
|
||||
&mut grid_meta.fields,
|
||||
@ -223,7 +221,7 @@ impl GridRevisionPad {
|
||||
from_index,
|
||||
to_index,
|
||||
)
|
||||
.map_err(internal_error)?
|
||||
.map_err(internal_sync_error)?
|
||||
{
|
||||
true => Ok(Some(())),
|
||||
false => Ok(None),
|
||||
@ -243,7 +241,7 @@ impl GridRevisionPad {
|
||||
.find(|(_, field)| field.id == field_id)
|
||||
}
|
||||
|
||||
pub fn get_field_revs(&self, field_ids: Option<Vec<String>>) -> CollaborateResult<Vec<Arc<FieldRevision>>> {
|
||||
pub fn get_field_revs(&self, field_ids: Option<Vec<String>>) -> SyncResult<Vec<Arc<FieldRevision>>> {
|
||||
match field_ids {
|
||||
None => Ok(self.grid_rev.fields.clone()),
|
||||
Some(field_ids) => {
|
||||
@ -269,10 +267,7 @@ impl GridRevisionPad {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_block_meta_rev(
|
||||
&mut self,
|
||||
block: GridBlockMetaRevision,
|
||||
) -> CollaborateResult<Option<GridRevisionChangeset>> {
|
||||
pub fn create_block_meta_rev(&mut self, block: GridBlockMetaRevision) -> SyncResult<Option<GridRevisionChangeset>> {
|
||||
self.modify_grid(|grid_meta| {
|
||||
if grid_meta.blocks.iter().any(|b| b.block_id == block.block_id) {
|
||||
tracing::warn!("Duplicate grid block");
|
||||
@ -285,7 +280,7 @@ impl GridRevisionPad {
|
||||
&& last_block.len() > block.start_row_index
|
||||
{
|
||||
let msg = "GridBlock's start_row_index should be greater than the last_block's start_row_index and its len".to_string();
|
||||
return Err(CollaborateError::internal().context(msg))
|
||||
return Err(SyncError::internal().context(msg))
|
||||
}
|
||||
grid_meta.blocks.push(Arc::new(block));
|
||||
}
|
||||
@ -302,7 +297,7 @@ impl GridRevisionPad {
|
||||
pub fn update_block_rev(
|
||||
&mut self,
|
||||
changeset: GridBlockMetaRevisionChangeset,
|
||||
) -> CollaborateResult<Option<GridRevisionChangeset>> {
|
||||
) -> SyncResult<Option<GridRevisionChangeset>> {
|
||||
let block_id = changeset.block_id.clone();
|
||||
self.modify_block(&block_id, |block| {
|
||||
let mut is_changed = None;
|
||||
@ -333,9 +328,9 @@ impl GridRevisionPad {
|
||||
&self.grid_rev.fields
|
||||
}
|
||||
|
||||
fn modify_grid<F>(&mut self, f: F) -> CollaborateResult<Option<GridRevisionChangeset>>
|
||||
fn modify_grid<F>(&mut self, f: F) -> SyncResult<Option<GridRevisionChangeset>>
|
||||
where
|
||||
F: FnOnce(&mut GridRevision) -> CollaborateResult<Option<()>>,
|
||||
F: FnOnce(&mut GridRevision) -> SyncResult<Option<()>>,
|
||||
{
|
||||
let cloned_grid = self.grid_rev.clone();
|
||||
match f(Arc::make_mut(&mut self.grid_rev))? {
|
||||
@ -357,9 +352,9 @@ impl GridRevisionPad {
|
||||
}
|
||||
}
|
||||
|
||||
fn modify_block<F>(&mut self, block_id: &str, f: F) -> CollaborateResult<Option<GridRevisionChangeset>>
|
||||
fn modify_block<F>(&mut self, block_id: &str, f: F) -> SyncResult<Option<GridRevisionChangeset>>
|
||||
where
|
||||
F: FnOnce(&mut GridBlockMetaRevision) -> CollaborateResult<Option<()>>,
|
||||
F: FnOnce(&mut GridBlockMetaRevision) -> SyncResult<Option<()>>,
|
||||
{
|
||||
self.modify_grid(
|
||||
|grid_rev| match grid_rev.blocks.iter().position(|block| block.block_id == block_id) {
|
||||
@ -375,9 +370,9 @@ impl GridRevisionPad {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn modify_field<F>(&mut self, field_id: &str, f: F) -> CollaborateResult<Option<GridRevisionChangeset>>
|
||||
pub fn modify_field<F>(&mut self, field_id: &str, f: F) -> SyncResult<Option<GridRevisionChangeset>>
|
||||
where
|
||||
F: FnOnce(&mut FieldRevision) -> CollaborateResult<Option<()>>,
|
||||
F: FnOnce(&mut FieldRevision) -> SyncResult<Option<()>>,
|
||||
{
|
||||
self.modify_grid(
|
||||
|grid_rev| match grid_rev.fields.iter().position(|field| field.id == field_id) {
|
||||
@ -393,14 +388,14 @@ impl GridRevisionPad {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn json_str(&self) -> CollaborateResult<String> {
|
||||
pub fn json_str(&self) -> SyncResult<String> {
|
||||
make_grid_rev_json_str(&self.grid_rev)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn make_grid_rev_json_str(grid_revision: &GridRevision) -> CollaborateResult<String> {
|
||||
pub fn make_grid_rev_json_str(grid_revision: &GridRevision) -> SyncResult<String> {
|
||||
let json = serde_json::to_string(grid_revision)
|
||||
.map_err(|err| internal_error(format!("Serialize grid to json str failed. {:?}", err)))?;
|
||||
.map_err(|err| internal_sync_error(format!("Serialize grid to json str failed. {:?}", err)))?;
|
||||
Ok(json)
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
use crate::errors::{internal_error, CollaborateError, CollaborateResult};
|
||||
use crate::util::{cal_diff, make_operations_from_revisions};
|
||||
use flowy_http_model::revision::Revision;
|
||||
use flowy_http_model::util::md5;
|
||||
use grid_rev_model::{
|
||||
use crate::errors::{internal_sync_error, SyncError, SyncResult};
|
||||
use crate::util::cal_diff;
|
||||
use flowy_sync::util::make_operations_from_revisions;
|
||||
use grid_model::{
|
||||
FieldRevision, FieldTypeRevision, FilterRevision, GridViewRevision, GroupConfigurationRevision, LayoutRevision,
|
||||
SortRevision,
|
||||
};
|
||||
use lib_infra::util::md5;
|
||||
use lib_ot::core::{DeltaBuilder, DeltaOperations, EmptyAttributes, OperationTransform};
|
||||
use revision_model::Revision;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub type GridViewOperations = DeltaOperations<EmptyAttributes>;
|
||||
@ -36,7 +37,7 @@ impl GridViewRevisionPad {
|
||||
Self { view, operations }
|
||||
}
|
||||
|
||||
pub fn from_operations(view_id: &str, operations: GridViewOperations) -> CollaborateResult<Self> {
|
||||
pub fn from_operations(view_id: &str, operations: GridViewOperations) -> SyncResult<Self> {
|
||||
if operations.is_empty() {
|
||||
return Ok(GridViewRevisionPad::new(
|
||||
view_id.to_owned(),
|
||||
@ -48,7 +49,7 @@ impl GridViewRevisionPad {
|
||||
let view: GridViewRevision = serde_json::from_str(&s).map_err(|e| {
|
||||
let msg = format!("Deserialize operations to GridViewRevision failed: {}", e);
|
||||
tracing::error!("parsing json: {}", s);
|
||||
CollaborateError::internal().context(msg)
|
||||
SyncError::internal().context(msg)
|
||||
})?;
|
||||
Ok(Self {
|
||||
view: Arc::new(view),
|
||||
@ -56,7 +57,7 @@ impl GridViewRevisionPad {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn from_revisions(view_id: &str, revisions: Vec<Revision>) -> CollaborateResult<Self> {
|
||||
pub fn from_revisions(view_id: &str, revisions: Vec<Revision>) -> SyncResult<Self> {
|
||||
let operations: GridViewOperations = make_operations_from_revisions(revisions)?;
|
||||
Self::from_operations(view_id, operations)
|
||||
}
|
||||
@ -75,7 +76,7 @@ impl GridViewRevisionPad {
|
||||
field_id: &str,
|
||||
field_type: &FieldTypeRevision,
|
||||
group_configuration_rev: GroupConfigurationRevision,
|
||||
) -> CollaborateResult<Option<GridViewRevisionChangeset>> {
|
||||
) -> SyncResult<Option<GridViewRevisionChangeset>> {
|
||||
self.modify(|view| {
|
||||
// Only save one group
|
||||
view.groups.clear();
|
||||
@ -96,7 +97,7 @@ impl GridViewRevisionPad {
|
||||
field_type: &FieldTypeRevision,
|
||||
configuration_id: &str,
|
||||
mut_configuration_fn: F,
|
||||
) -> CollaborateResult<Option<GridViewRevisionChangeset>> {
|
||||
) -> SyncResult<Option<GridViewRevisionChangeset>> {
|
||||
self.modify(|view| match view.groups.get_mut_objects(field_id, field_type) {
|
||||
None => Ok(None),
|
||||
Some(configurations_revs) => {
|
||||
@ -116,7 +117,7 @@ impl GridViewRevisionPad {
|
||||
group_id: &str,
|
||||
field_id: &str,
|
||||
field_type: &FieldTypeRevision,
|
||||
) -> CollaborateResult<Option<GridViewRevisionChangeset>> {
|
||||
) -> SyncResult<Option<GridViewRevisionChangeset>> {
|
||||
self.modify(|view| {
|
||||
if let Some(groups) = view.groups.get_mut_objects(field_id, field_type) {
|
||||
groups.retain(|group| group.id != group_id);
|
||||
@ -150,7 +151,7 @@ impl GridViewRevisionPad {
|
||||
&mut self,
|
||||
field_id: &str,
|
||||
sort_rev: SortRevision,
|
||||
) -> CollaborateResult<Option<GridViewRevisionChangeset>> {
|
||||
) -> SyncResult<Option<GridViewRevisionChangeset>> {
|
||||
self.modify(|view| {
|
||||
let field_type = sort_rev.field_type;
|
||||
view.sorts.add_object(field_id, &field_type, sort_rev);
|
||||
@ -162,7 +163,7 @@ impl GridViewRevisionPad {
|
||||
&mut self,
|
||||
field_id: &str,
|
||||
sort_rev: SortRevision,
|
||||
) -> CollaborateResult<Option<GridViewRevisionChangeset>> {
|
||||
) -> SyncResult<Option<GridViewRevisionChangeset>> {
|
||||
self.modify(|view| {
|
||||
if let Some(sort) = view
|
||||
.sorts
|
||||
@ -182,7 +183,7 @@ impl GridViewRevisionPad {
|
||||
sort_id: &str,
|
||||
field_id: &str,
|
||||
field_type: T,
|
||||
) -> CollaborateResult<Option<GridViewRevisionChangeset>> {
|
||||
) -> SyncResult<Option<GridViewRevisionChangeset>> {
|
||||
let field_type = field_type.into();
|
||||
self.modify(|view| {
|
||||
if let Some(sorts) = view.sorts.get_mut_objects(field_id, &field_type) {
|
||||
@ -194,7 +195,7 @@ impl GridViewRevisionPad {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn delete_all_sorts(&mut self) -> CollaborateResult<Option<GridViewRevisionChangeset>> {
|
||||
pub fn delete_all_sorts(&mut self) -> SyncResult<Option<GridViewRevisionChangeset>> {
|
||||
self.modify(|view| {
|
||||
view.sorts.clear();
|
||||
Ok(Some(()))
|
||||
@ -224,7 +225,7 @@ impl GridViewRevisionPad {
|
||||
&mut self,
|
||||
field_id: &str,
|
||||
filter_rev: FilterRevision,
|
||||
) -> CollaborateResult<Option<GridViewRevisionChangeset>> {
|
||||
) -> SyncResult<Option<GridViewRevisionChangeset>> {
|
||||
self.modify(|view| {
|
||||
let field_type = filter_rev.field_type;
|
||||
view.filters.add_object(field_id, &field_type, filter_rev);
|
||||
@ -236,7 +237,7 @@ impl GridViewRevisionPad {
|
||||
&mut self,
|
||||
field_id: &str,
|
||||
filter_rev: FilterRevision,
|
||||
) -> CollaborateResult<Option<GridViewRevisionChangeset>> {
|
||||
) -> SyncResult<Option<GridViewRevisionChangeset>> {
|
||||
self.modify(|view| {
|
||||
if let Some(filter) = view
|
||||
.filters
|
||||
@ -257,7 +258,7 @@ impl GridViewRevisionPad {
|
||||
filter_id: &str,
|
||||
field_id: &str,
|
||||
field_type: T,
|
||||
) -> CollaborateResult<Option<GridViewRevisionChangeset>> {
|
||||
) -> SyncResult<Option<GridViewRevisionChangeset>> {
|
||||
let field_type = field_type.into();
|
||||
self.modify(|view| {
|
||||
if let Some(filters) = view.filters.get_mut_objects(field_id, &field_type) {
|
||||
@ -269,7 +270,7 @@ impl GridViewRevisionPad {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn json_str(&self) -> CollaborateResult<String> {
|
||||
pub fn json_str(&self) -> SyncResult<String> {
|
||||
make_grid_view_rev_json_str(&self.view)
|
||||
}
|
||||
|
||||
@ -277,9 +278,9 @@ impl GridViewRevisionPad {
|
||||
self.layout.clone()
|
||||
}
|
||||
|
||||
fn modify<F>(&mut self, f: F) -> CollaborateResult<Option<GridViewRevisionChangeset>>
|
||||
fn modify<F>(&mut self, f: F) -> SyncResult<Option<GridViewRevisionChangeset>>
|
||||
where
|
||||
F: FnOnce(&mut GridViewRevision) -> CollaborateResult<Option<()>>,
|
||||
F: FnOnce(&mut GridViewRevision) -> SyncResult<Option<()>>,
|
||||
{
|
||||
let cloned_view = self.view.clone();
|
||||
match f(Arc::make_mut(&mut self.view))? {
|
||||
@ -306,9 +307,9 @@ pub struct GridViewRevisionChangeset {
|
||||
pub md5: String,
|
||||
}
|
||||
|
||||
pub fn make_grid_view_rev_json_str(grid_revision: &GridViewRevision) -> CollaborateResult<String> {
|
||||
pub fn make_grid_view_rev_json_str(grid_revision: &GridViewRevision) -> SyncResult<String> {
|
||||
let json = serde_json::to_string(grid_revision)
|
||||
.map_err(|err| internal_error(format!("Serialize grid view to json str failed. {:?}", err)))?;
|
||||
.map_err(|err| internal_sync_error(format!("Serialize grid view to json str failed. {:?}", err)))?;
|
||||
Ok(json)
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
pub mod client_document;
|
||||
pub mod client_folder;
|
||||
pub mod client_grid;
|
||||
pub mod errors;
|
||||
pub mod server_document;
|
||||
pub mod server_folder;
|
||||
pub mod synchronizer;
|
||||
pub mod errors {
|
||||
pub use flowy_sync::errors::*;
|
||||
}
|
||||
pub mod util;
|
||||
|
||||
pub use flowy_sync::util::*;
|
||||
pub use lib_ot::text_delta::DeltaTextOperations;
|
@ -1,14 +1,12 @@
|
||||
use crate::errors::{CollaborateError, CollaborateResult};
|
||||
use crate::server_folder::FolderOperations;
|
||||
use crate::errors::SyncError;
|
||||
use dissimilar::Chunk;
|
||||
use flowy_http_model::document::DocumentPayload;
|
||||
use flowy_http_model::folder::FolderInfo;
|
||||
use flowy_http_model::revision::Revision;
|
||||
use document_model::document::DocumentInfo;
|
||||
use lib_ot::core::{DeltaOperationBuilder, OTString, OperationAttributes};
|
||||
use lib_ot::{
|
||||
core::{DeltaOperations, OperationTransform, NEW_LINE, WHITESPACE},
|
||||
text_delta::DeltaTextOperations,
|
||||
};
|
||||
use revision_model::Revision;
|
||||
use serde::de::DeserializeOwned;
|
||||
|
||||
#[inline]
|
||||
@ -31,26 +29,6 @@ pub fn contain_newline(s: &str) -> bool {
|
||||
s.contains(NEW_LINE)
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip(revisions), err)]
|
||||
pub fn make_operations_from_revisions<T>(revisions: Vec<Revision>) -> CollaborateResult<DeltaOperations<T>>
|
||||
where
|
||||
T: OperationAttributes + DeserializeOwned + OperationAttributes + serde::Serialize,
|
||||
{
|
||||
let mut new_operations = DeltaOperations::<T>::new();
|
||||
for revision in revisions {
|
||||
if revision.bytes.is_empty() {
|
||||
return Err(CollaborateError::unexpected_empty_revision().context("Unexpected Empty revision"));
|
||||
}
|
||||
let operations = DeltaOperations::<T>::from_bytes(revision.bytes).map_err(|e| {
|
||||
let err_msg = format!("Deserialize revision failed: {:?}", e);
|
||||
CollaborateError::internal().context(err_msg)
|
||||
})?;
|
||||
|
||||
new_operations = new_operations.compose(&operations)?;
|
||||
}
|
||||
Ok(new_operations)
|
||||
}
|
||||
|
||||
pub fn recover_operation_from_revisions<T>(
|
||||
revisions: Vec<Revision>,
|
||||
validator: impl Fn(&DeltaOperations<T>) -> bool,
|
||||
@ -82,57 +60,11 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pair_rev_id_from_revision_pbs(revisions: &[Revision]) -> (i64, i64) {
|
||||
let mut rev_id = 0;
|
||||
revisions.iter().for_each(|revision| {
|
||||
if rev_id < revision.rev_id {
|
||||
rev_id = revision.rev_id;
|
||||
}
|
||||
});
|
||||
|
||||
if rev_id > 0 {
|
||||
(rev_id - 1, rev_id)
|
||||
} else {
|
||||
(0, rev_id)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn make_folder_from_revisions_pb(
|
||||
folder_id: &str,
|
||||
revisions: Vec<Revision>,
|
||||
) -> Result<Option<FolderInfo>, CollaborateError> {
|
||||
if revisions.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let mut folder_delta = FolderOperations::new();
|
||||
let mut base_rev_id = 0;
|
||||
let mut rev_id = 0;
|
||||
for revision in revisions {
|
||||
base_rev_id = revision.base_rev_id;
|
||||
rev_id = revision.rev_id;
|
||||
if revision.bytes.is_empty() {
|
||||
tracing::warn!("revision delta_data is empty");
|
||||
}
|
||||
let delta = FolderOperations::from_bytes(revision.bytes)?;
|
||||
folder_delta = folder_delta.compose(&delta)?;
|
||||
}
|
||||
|
||||
let text = folder_delta.json_str();
|
||||
Ok(Some(FolderInfo {
|
||||
folder_id: folder_id.to_string(),
|
||||
text,
|
||||
rev_id,
|
||||
base_rev_id,
|
||||
}))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn make_document_from_revision_pbs(
|
||||
pub fn make_document_info_from_revisions(
|
||||
doc_id: &str,
|
||||
revisions: Vec<Revision>,
|
||||
) -> Result<Option<DocumentPayload>, CollaborateError> {
|
||||
) -> Result<Option<DocumentInfo>, SyncError> {
|
||||
if revisions.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
@ -152,7 +84,7 @@ pub fn make_document_from_revision_pbs(
|
||||
delta = delta.compose(&new_delta)?;
|
||||
}
|
||||
|
||||
Ok(Some(DocumentPayload {
|
||||
Ok(Some(DocumentInfo {
|
||||
doc_id: doc_id.to_owned(),
|
||||
data: delta.json_bytes().to_vec(),
|
||||
rev_id,
|
||||
@ -161,11 +93,11 @@ pub fn make_document_from_revision_pbs(
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn rev_id_from_str(s: &str) -> Result<i64, CollaborateError> {
|
||||
pub fn rev_id_from_str(s: &str) -> Result<i64, SyncError> {
|
||||
let rev_id = s
|
||||
.to_owned()
|
||||
.parse::<i64>()
|
||||
.map_err(|e| CollaborateError::internal().context(format!("Parse rev_id from {} failed. {}", s, e)))?;
|
||||
.map_err(|e| SyncError::internal().context(format!("Parse rev_id from {} failed. {}", s, e)))?;
|
||||
Ok(rev_id)
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use flowy_sync::client_folder::{FolderNodePad, WorkspaceNode};
|
||||
use flowy_client_sync::client_folder::{FolderNodePad, WorkspaceNode};
|
||||
|
||||
#[test]
|
||||
fn client_folder_create_default_folder_test() {
|
@ -1,5 +1,5 @@
|
||||
use flowy_sync::client_folder::{AppNode, FolderNodePad, WorkspaceNode};
|
||||
use folder_rev_model::AppRevision;
|
||||
use flowy_client_sync::client_folder::{AppNode, FolderNodePad, WorkspaceNode};
|
||||
use folder_model::AppRevision;
|
||||
use lib_ot::core::Path;
|
||||
|
||||
pub enum FolderNodePadScript {
|
@ -12,10 +12,12 @@ flowy-user = { path = "../flowy-user" }
|
||||
flowy-net = { path = "../flowy-net" }
|
||||
flowy-folder = { path = "../flowy-folder", default-features = false }
|
||||
flowy-grid = { path = "../flowy-grid", default-features = false }
|
||||
grid-rev-model = { path = "../../../shared-lib/grid-rev-model" }
|
||||
grid-model = { path = "../../../shared-lib/grid-model" }
|
||||
flowy-client-ws = { path = "../../../shared-lib/flowy-client-ws" }
|
||||
flowy-database = { path = "../flowy-database", optional = true }
|
||||
flowy-document = { path = "../flowy-document", default-features = false }
|
||||
flowy-revision = { path = "../flowy-revision" }
|
||||
flowy-error = { path = "../flowy-error", features = ["adaptor_ws"] }
|
||||
flowy-task = { path = "../flowy-task" }
|
||||
|
||||
tracing = { version = "0.1", features = ["log"] }
|
||||
@ -24,7 +26,8 @@ bytes = "1.0"
|
||||
tokio = { version = "1", features = ["rt"] }
|
||||
parking_lot = "0.12.1"
|
||||
|
||||
flowy-http-model = { path = "../../../shared-lib/flowy-http-model" }
|
||||
revision-model = { path = "../../../shared-lib/revision-model" }
|
||||
ws-model = { path = "../../../shared-lib/ws-model" }
|
||||
lib-ws = { path = "../../../shared-lib/lib-ws" }
|
||||
lib-infra = { path = "../../../shared-lib/lib-infra" }
|
||||
|
||||
|
@ -1,20 +1,19 @@
|
||||
use bytes::Bytes;
|
||||
use flowy_client_ws::FlowyWebSocketConnect;
|
||||
use flowy_database::ConnectionPool;
|
||||
use flowy_document::{
|
||||
errors::{internal_error, FlowyError},
|
||||
DocumentCloudService, DocumentConfig, DocumentDatabase, DocumentManager, DocumentUser,
|
||||
};
|
||||
use flowy_http_model::ws_data::ClientRevisionWSData;
|
||||
use flowy_net::ClientServerConfiguration;
|
||||
use flowy_net::{
|
||||
http_server::document::DocumentCloudServiceImpl, local_server::LocalServer, ws::connection::FlowyWebSocketConnect,
|
||||
};
|
||||
use flowy_net::{http_server::document::DocumentCloudServiceImpl, local_server::LocalServer};
|
||||
use flowy_revision::{RevisionWebSocket, WSStateReceiver};
|
||||
use flowy_user::services::UserSession;
|
||||
use futures_core::future::BoxFuture;
|
||||
use lib_infra::future::BoxResultFuture;
|
||||
use lib_ws::{WSChannel, WSMessageReceiver, WebSocketRawMessage};
|
||||
use std::{convert::TryInto, path::Path, sync::Arc};
|
||||
use ws_model::ws_revision::ClientRevisionWSData;
|
||||
|
||||
pub struct DocumentDepsResolver();
|
||||
impl DocumentDepsResolver {
|
||||
|
@ -1,6 +1,7 @@
|
||||
use bytes::Bytes;
|
||||
use flowy_database::ConnectionPool;
|
||||
|
||||
use flowy_client_ws::FlowyWebSocketConnect;
|
||||
use flowy_document::DocumentManager;
|
||||
use flowy_folder::entities::{ViewDataFormatPB, ViewLayoutTypePB, ViewPB};
|
||||
use flowy_folder::manager::{ViewDataProcessor, ViewDataProcessorMap};
|
||||
@ -12,21 +13,19 @@ use flowy_folder::{
|
||||
use flowy_grid::entities::GridLayout;
|
||||
use flowy_grid::manager::{make_grid_view_data, GridManager};
|
||||
use flowy_grid::util::{make_default_board, make_default_calendar, make_default_grid};
|
||||
use flowy_http_model::revision::Revision;
|
||||
use flowy_http_model::ws_data::ClientRevisionWSData;
|
||||
use flowy_net::ClientServerConfiguration;
|
||||
use flowy_net::{
|
||||
http_server::folder::FolderHttpCloudService, local_server::LocalServer, ws::connection::FlowyWebSocketConnect,
|
||||
};
|
||||
use flowy_net::{http_server::folder::FolderHttpCloudService, local_server::LocalServer};
|
||||
use flowy_revision::{RevisionWebSocket, WSStateReceiver};
|
||||
use flowy_user::services::UserSession;
|
||||
use futures_core::future::BoxFuture;
|
||||
use grid_rev_model::BuildGridContext;
|
||||
use grid_model::BuildGridContext;
|
||||
use lib_infra::future::{BoxResultFuture, FutureResult};
|
||||
use lib_ws::{WSChannel, WSMessageReceiver, WebSocketRawMessage};
|
||||
use revision_model::Revision;
|
||||
use std::collections::HashMap;
|
||||
use std::convert::TryFrom;
|
||||
use std::{convert::TryInto, sync::Arc};
|
||||
use ws_model::ws_revision::ClientRevisionWSData;
|
||||
|
||||
pub struct FolderDepsResolver();
|
||||
impl FolderDepsResolver {
|
||||
|
@ -1,10 +1,9 @@
|
||||
use crate::FlowyError;
|
||||
use bytes::Bytes;
|
||||
use flowy_client_ws::FlowyWebSocketConnect;
|
||||
use flowy_database::ConnectionPool;
|
||||
use flowy_grid::manager::{GridManager, GridUser};
|
||||
use flowy_grid::services::persistence::GridDatabase;
|
||||
use flowy_http_model::ws_data::ClientRevisionWSData;
|
||||
use flowy_net::ws::connection::FlowyWebSocketConnect;
|
||||
use flowy_revision::{RevisionWebSocket, WSStateReceiver};
|
||||
use flowy_task::TaskDispatcher;
|
||||
use flowy_user::services::UserSession;
|
||||
@ -14,6 +13,7 @@ use lib_ws::{WSChannel, WebSocketRawMessage};
|
||||
use std::convert::TryInto;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
use ws_model::ws_revision::ClientRevisionWSData;
|
||||
|
||||
pub struct GridDepsResolver();
|
||||
|
||||
|
@ -4,17 +4,14 @@ pub use flowy_net::get_client_server_configuration;
|
||||
|
||||
use crate::deps_resolve::*;
|
||||
|
||||
use flowy_client_ws::{listen_on_websocket, FlowyWebSocketConnect, NetworkType};
|
||||
use flowy_document::entities::DocumentVersionPB;
|
||||
use flowy_document::{DocumentConfig, DocumentManager};
|
||||
use flowy_folder::entities::ViewDataFormatPB;
|
||||
use flowy_folder::{errors::FlowyError, manager::FolderManager};
|
||||
use flowy_grid::manager::GridManager;
|
||||
use flowy_net::local_server::LocalServer;
|
||||
use flowy_net::ClientServerConfiguration;
|
||||
use flowy_net::{
|
||||
entities::NetworkType,
|
||||
local_server::LocalServer,
|
||||
ws::connection::{listen_on_websocket, FlowyWebSocketConnect},
|
||||
};
|
||||
use flowy_task::{TaskDispatcher, TaskRunner};
|
||||
use flowy_user::services::{notifier::UserStatus, UserSession, UserSessionConfig};
|
||||
use lib_dispatch::prelude::*;
|
||||
|
@ -1,7 +1,7 @@
|
||||
use flowy_client_ws::FlowyWebSocketConnect;
|
||||
use flowy_document::DocumentManager;
|
||||
use flowy_folder::manager::FolderManager;
|
||||
use flowy_grid::manager::GridManager;
|
||||
use flowy_net::ws::connection::FlowyWebSocketConnect;
|
||||
use flowy_user::services::UserSession;
|
||||
use lib_dispatch::prelude::AFPlugin;
|
||||
use std::sync::Arc;
|
||||
|
@ -7,8 +7,10 @@ edition = "2018"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
flowy-sync = { path = "../flowy-sync"}
|
||||
flowy-http-model = { path = "../../../shared-lib/flowy-http-model"}
|
||||
flowy-client-sync = { path = "../flowy-client-sync"}
|
||||
revision-model = { path = "../../../shared-lib/revision-model"}
|
||||
document-model = { path = "../../../shared-lib/document-model"}
|
||||
ws-model = { path = "../../../shared-lib/ws-model"}
|
||||
flowy-derive = { path = "../flowy-derive" }
|
||||
lib-ot = { path = "../../../shared-lib/lib-ot" }
|
||||
lib-ws = { path = "../../../shared-lib/lib-ws" }
|
||||
@ -18,14 +20,12 @@ lib-dispatch = { path = "../lib-dispatch" }
|
||||
flowy-database = { path = "../flowy-database", optional = true }
|
||||
flowy-revision = { path = "../flowy-revision" }
|
||||
flowy-revision-persistence = { path = "../flowy-revision-persistence" }
|
||||
flowy-error = { path = "../flowy-error", features = ["collaboration", "ot", "http_server", "serde", "db"] }
|
||||
flowy-error = { path = "../flowy-error", features = ["adaptor_sync", "adaptor_ot", "adaptor_serde", "adaptor_database", "adaptor_dispatch"] }
|
||||
flowy-notification = { path = "../flowy-notification" }
|
||||
|
||||
diesel = {version = "1.4.8", features = ["sqlite"]}
|
||||
diesel_derives = {version = "1.4.1", features = ["sqlite"]}
|
||||
protobuf = {version = "2.18.0"}
|
||||
unicode-segmentation = "1.8"
|
||||
log = "0.4.14"
|
||||
tokio = {version = "1", features = ["sync"]}
|
||||
tracing = { version = "0.1", features = ["log"] }
|
||||
|
||||
@ -47,6 +47,7 @@ flowy-test = { path = "../flowy-test" }
|
||||
flowy-document = { path = "../flowy-document", features = ["flowy_unit_test"]}
|
||||
derive_more = {version = "0.99", features = ["display"]}
|
||||
tracing-subscriber = "0.2.0"
|
||||
unicode-segmentation = "1.8"
|
||||
|
||||
color-eyre = { version = "0.5", default-features = false }
|
||||
criterion = "0.3"
|
||||
|
@ -1,9 +1,9 @@
|
||||
use bytes::Bytes;
|
||||
use flowy_error::{FlowyError, FlowyResult};
|
||||
use flowy_http_model::revision::Revision;
|
||||
use flowy_revision::{RevisionMergeable, RevisionObjectDeserializer, RevisionObjectSerializer};
|
||||
use lib_ot::core::{Extension, NodeDataBuilder, NodeOperation, NodeTree, NodeTreeContext, Selection, Transaction};
|
||||
use lib_ot::text_delta::DeltaTextOperationBuilder;
|
||||
use revision_model::Revision;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Document {
|
||||
|
@ -6,7 +6,6 @@ use crate::{DocumentEditor, DocumentUser};
|
||||
use bytes::Bytes;
|
||||
use flowy_database::ConnectionPool;
|
||||
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
||||
use flowy_http_model::ws_data::ServerRevisionWSData;
|
||||
use flowy_revision::{RevisionCloudService, RevisionManager};
|
||||
use lib_infra::async_trait::async_trait;
|
||||
use lib_infra::future::FutureResult;
|
||||
@ -15,6 +14,7 @@ use lib_ws::WSConnectState;
|
||||
use std::any::Any;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::{mpsc, oneshot};
|
||||
use ws_model::ws_revision::ServerRevisionWSData;
|
||||
|
||||
pub struct AppFlowyDocumentEditor {
|
||||
#[allow(dead_code)]
|
||||
|
@ -22,7 +22,7 @@ impl From<i32> for ExportType {
|
||||
1 => ExportType::Markdown,
|
||||
2 => ExportType::Link,
|
||||
_ => {
|
||||
log::error!("Invalid export type: {}", val);
|
||||
tracing::error!("Invalid export type: {}", val);
|
||||
ExportType::Text
|
||||
}
|
||||
}
|
||||
|
@ -16,13 +16,13 @@ pub mod errors {
|
||||
pub const TEXT_BLOCK_SYNC_INTERVAL_IN_MILLIS: u64 = 1000;
|
||||
|
||||
use crate::errors::FlowyError;
|
||||
use flowy_http_model::document::{CreateDocumentParams, DocumentId, DocumentPayload, ResetDocumentParams};
|
||||
use document_model::document::{CreateDocumentParams, DocumentId, DocumentInfo, ResetDocumentParams};
|
||||
use lib_infra::future::FutureResult;
|
||||
|
||||
pub trait DocumentCloudService: Send + Sync {
|
||||
fn create_document(&self, token: &str, params: CreateDocumentParams) -> FutureResult<(), FlowyError>;
|
||||
|
||||
fn fetch_document(&self, token: &str, params: DocumentId) -> FutureResult<Option<DocumentPayload>, FlowyError>;
|
||||
fn fetch_document(&self, token: &str, params: DocumentId) -> FutureResult<Option<DocumentInfo>, FlowyError>;
|
||||
|
||||
fn update_document_content(&self, token: &str, params: ResetDocumentParams) -> FutureResult<(), FlowyError>;
|
||||
}
|
||||
|
@ -8,24 +8,25 @@ use crate::services::rev_sqlite::{
|
||||
use crate::services::DocumentPersistence;
|
||||
use crate::{errors::FlowyError, DocumentCloudService};
|
||||
use bytes::Bytes;
|
||||
use document_model::document::DocumentId;
|
||||
use flowy_client_sync::client_document::initial_delta_document_content;
|
||||
use flowy_database::ConnectionPool;
|
||||
use flowy_error::FlowyResult;
|
||||
use flowy_http_model::util::md5;
|
||||
use flowy_http_model::ws_data::ServerRevisionWSData;
|
||||
use flowy_http_model::{document::DocumentId, revision::Revision};
|
||||
use flowy_revision::{
|
||||
PhantomSnapshotPersistence, RevisionCloudService, RevisionManager, RevisionPersistence,
|
||||
RevisionPersistenceConfiguration, RevisionWebSocket,
|
||||
};
|
||||
use flowy_sync::client_document::initial_delta_document_content;
|
||||
use lib_infra::async_trait::async_trait;
|
||||
use lib_infra::future::FutureResult;
|
||||
use lib_infra::ref_map::{RefCountHashMap, RefCountValue};
|
||||
use lib_infra::util::md5;
|
||||
use lib_ws::WSConnectState;
|
||||
use revision_model::Revision;
|
||||
use std::any::Any;
|
||||
use std::convert::TryFrom;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
use ws_model::ws_revision::ServerRevisionWSData;
|
||||
|
||||
pub trait DocumentUser: Send + Sync {
|
||||
fn user_dir(&self) -> Result<String, FlowyError>;
|
||||
|
@ -4,16 +4,15 @@
|
||||
use crate::old_editor::queue::{EditDocumentQueue, EditorCommand, EditorCommandSender};
|
||||
use crate::{errors::FlowyError, DocumentEditor, DocumentUser};
|
||||
use bytes::Bytes;
|
||||
use document_model::document::DocumentInfo;
|
||||
use flowy_client_sync::errors::SyncResult;
|
||||
use flowy_client_sync::make_operations_from_revisions;
|
||||
use flowy_database::ConnectionPool;
|
||||
use flowy_error::{internal_error, FlowyResult};
|
||||
use flowy_http_model::document::DocumentPayload;
|
||||
use flowy_http_model::revision::Revision;
|
||||
use flowy_http_model::ws_data::ServerRevisionWSData;
|
||||
use flowy_revision::{
|
||||
RevisionCloudService, RevisionManager, RevisionMergeable, RevisionObjectDeserializer, RevisionObjectSerializer,
|
||||
RevisionWebSocket,
|
||||
};
|
||||
use flowy_sync::{errors::CollaborateResult, util::make_operations_from_revisions};
|
||||
use lib_infra::async_trait::async_trait;
|
||||
use lib_infra::future::FutureResult;
|
||||
use lib_ot::core::{AttributeEntry, AttributeHashMap};
|
||||
@ -22,9 +21,11 @@ use lib_ot::{
|
||||
text_delta::DeltaTextOperations,
|
||||
};
|
||||
use lib_ws::WSConnectState;
|
||||
use revision_model::Revision;
|
||||
use std::any::Any;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::{mpsc, oneshot};
|
||||
use ws_model::ws_revision::ServerRevisionWSData;
|
||||
|
||||
pub struct DeltaDocumentEditor {
|
||||
pub doc_id: String,
|
||||
@ -73,7 +74,7 @@ impl DeltaDocumentEditor {
|
||||
}
|
||||
|
||||
pub async fn insert<T: ToString>(&self, index: usize, data: T) -> Result<(), FlowyError> {
|
||||
let (ret, rx) = oneshot::channel::<CollaborateResult<()>>();
|
||||
let (ret, rx) = oneshot::channel::<SyncResult<()>>();
|
||||
let msg = EditorCommand::Insert {
|
||||
index,
|
||||
data: data.to_string(),
|
||||
@ -85,7 +86,7 @@ impl DeltaDocumentEditor {
|
||||
}
|
||||
|
||||
pub async fn delete(&self, interval: Interval) -> Result<(), FlowyError> {
|
||||
let (ret, rx) = oneshot::channel::<CollaborateResult<()>>();
|
||||
let (ret, rx) = oneshot::channel::<SyncResult<()>>();
|
||||
let msg = EditorCommand::Delete { interval, ret };
|
||||
let _ = self.edit_cmd_tx.send(msg).await;
|
||||
rx.await.map_err(internal_error)??;
|
||||
@ -93,7 +94,7 @@ impl DeltaDocumentEditor {
|
||||
}
|
||||
|
||||
pub async fn format(&self, interval: Interval, attribute: AttributeEntry) -> Result<(), FlowyError> {
|
||||
let (ret, rx) = oneshot::channel::<CollaborateResult<()>>();
|
||||
let (ret, rx) = oneshot::channel::<SyncResult<()>>();
|
||||
let msg = EditorCommand::Format {
|
||||
interval,
|
||||
attribute,
|
||||
@ -105,7 +106,7 @@ impl DeltaDocumentEditor {
|
||||
}
|
||||
|
||||
pub async fn replace<T: ToString>(&self, interval: Interval, data: T) -> Result<(), FlowyError> {
|
||||
let (ret, rx) = oneshot::channel::<CollaborateResult<()>>();
|
||||
let (ret, rx) = oneshot::channel::<SyncResult<()>>();
|
||||
let msg = EditorCommand::Replace {
|
||||
interval,
|
||||
data: data.to_string(),
|
||||
@ -155,7 +156,7 @@ impl DocumentEditor for Arc<DeltaDocumentEditor> {
|
||||
}
|
||||
|
||||
fn export(&self) -> FutureResult<String, FlowyError> {
|
||||
let (ret, rx) = oneshot::channel::<CollaborateResult<String>>();
|
||||
let (ret, rx) = oneshot::channel::<SyncResult<String>>();
|
||||
let msg = EditorCommand::GetOperationsString { ret };
|
||||
let edit_cmd_tx = self.edit_cmd_tx.clone();
|
||||
FutureResult::new(async move {
|
||||
@ -190,7 +191,7 @@ impl DocumentEditor for Arc<DeltaDocumentEditor> {
|
||||
let edit_cmd_tx = self.edit_cmd_tx.clone();
|
||||
FutureResult::new(async move {
|
||||
let operations = DeltaTextOperations::from_bytes(&data)?;
|
||||
let (ret, rx) = oneshot::channel::<CollaborateResult<()>>();
|
||||
let (ret, rx) = oneshot::channel::<SyncResult<()>>();
|
||||
let msg = EditorCommand::ComposeLocalOperations { operations, ret };
|
||||
|
||||
let _ = edit_cmd_tx.send(msg).await;
|
||||
@ -233,7 +234,7 @@ fn spawn_edit_queue(
|
||||
#[cfg(feature = "flowy_unit_test")]
|
||||
impl DeltaDocumentEditor {
|
||||
pub async fn document_operations(&self) -> FlowyResult<DeltaTextOperations> {
|
||||
let (ret, rx) = oneshot::channel::<CollaborateResult<DeltaTextOperations>>();
|
||||
let (ret, rx) = oneshot::channel::<SyncResult<DeltaTextOperations>>();
|
||||
let msg = EditorCommand::GetOperations { ret };
|
||||
let _ = self.edit_cmd_tx.send(msg).await;
|
||||
let delta = rx.await.map_err(internal_error)??;
|
||||
@ -247,14 +248,14 @@ impl DeltaDocumentEditor {
|
||||
|
||||
pub struct DeltaDocumentRevisionSerde();
|
||||
impl RevisionObjectDeserializer for DeltaDocumentRevisionSerde {
|
||||
type Output = DocumentPayload;
|
||||
type Output = DocumentInfo;
|
||||
|
||||
fn deserialize_revisions(object_id: &str, revisions: Vec<Revision>) -> FlowyResult<Self::Output> {
|
||||
let (base_rev_id, rev_id) = revisions.last().unwrap().pair_rev_id();
|
||||
let mut delta = make_operations_from_revisions(revisions)?;
|
||||
correct_delta(&mut delta);
|
||||
|
||||
Result::<DocumentPayload, FlowyError>::Ok(DocumentPayload {
|
||||
Result::<DocumentInfo, FlowyError>::Ok(DocumentInfo {
|
||||
doc_id: object_id.to_owned(),
|
||||
data: delta.json_bytes().to_vec(),
|
||||
rev_id,
|
||||
|
@ -1,13 +1,13 @@
|
||||
use crate::old_editor::web_socket::DeltaDocumentResolveOperations;
|
||||
use crate::DocumentUser;
|
||||
use async_stream::stream;
|
||||
use flowy_client_sync::{
|
||||
client_document::{history::UndoResult, ClientDocument},
|
||||
errors::SyncError,
|
||||
};
|
||||
use flowy_database::ConnectionPool;
|
||||
use flowy_error::FlowyError;
|
||||
use flowy_revision::{RevisionMD5, RevisionManager, TransformOperations};
|
||||
use flowy_sync::{
|
||||
client_document::{history::UndoResult, ClientDocument},
|
||||
errors::CollaborateError,
|
||||
};
|
||||
use futures::stream::StreamExt;
|
||||
use lib_ot::core::AttributeEntry;
|
||||
use lib_ot::{
|
||||
@ -104,7 +104,7 @@ impl EditDocumentQueue {
|
||||
server_operations = Some(DeltaDocumentResolveOperations(s_prime));
|
||||
}
|
||||
drop(read_guard);
|
||||
Ok::<TextTransformOperations, CollaborateError>(TransformOperations {
|
||||
Ok::<TextTransformOperations, SyncError>(TransformOperations {
|
||||
client_operations: DeltaDocumentResolveOperations(client_operations),
|
||||
server_operations,
|
||||
})
|
||||
@ -185,7 +185,7 @@ impl EditDocumentQueue {
|
||||
pub type TextTransformOperations = TransformOperations<DeltaDocumentResolveOperations>;
|
||||
pub(crate) type EditorCommandSender = Sender<EditorCommand>;
|
||||
pub(crate) type EditorCommandReceiver = Receiver<EditorCommand>;
|
||||
pub(crate) type Ret<T> = oneshot::Sender<Result<T, CollaborateError>>;
|
||||
pub(crate) type Ret<T> = oneshot::Sender<Result<T, SyncError>>;
|
||||
|
||||
pub(crate) enum EditorCommand {
|
||||
ComposeLocalOperations {
|
||||
|
@ -1,18 +1,18 @@
|
||||
use crate::old_editor::queue::{EditorCommand, EditorCommandSender, TextTransformOperations};
|
||||
use crate::TEXT_BLOCK_SYNC_INTERVAL_IN_MILLIS;
|
||||
use bytes::Bytes;
|
||||
use flowy_client_sync::errors::SyncResult;
|
||||
use flowy_client_sync::make_operations_from_revisions;
|
||||
use flowy_database::ConnectionPool;
|
||||
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
||||
use flowy_http_model::revision::{Revision, RevisionRange};
|
||||
use flowy_http_model::ws_data::{ClientRevisionWSData, NewDocumentUser};
|
||||
use flowy_revision::*;
|
||||
use flowy_sync::errors::CollaborateResult;
|
||||
use flowy_sync::util::make_operations_from_revisions;
|
||||
use lib_infra::future::{BoxResultFuture, FutureResult};
|
||||
use lib_ot::text_delta::DeltaTextOperations;
|
||||
use lib_ws::WSConnectState;
|
||||
use revision_model::{Revision, RevisionRange};
|
||||
use std::{sync::Arc, time::Duration};
|
||||
use tokio::sync::{broadcast, oneshot};
|
||||
use ws_model::ws_revision::{ClientRevisionWSData, NewDocumentUser};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct DeltaDocumentResolveOperations(pub DeltaTextOperations);
|
||||
@ -156,7 +156,7 @@ impl ConflictResolver<DeltaDocumentResolveOperations> for DocumentConflictResolv
|
||||
let tx = self.edit_cmd_tx.clone();
|
||||
let operations = operations.into_inner();
|
||||
Box::pin(async move {
|
||||
let (ret, rx) = oneshot::channel::<CollaborateResult<TextTransformOperations>>();
|
||||
let (ret, rx) = oneshot::channel::<SyncResult<TextTransformOperations>>();
|
||||
tx.send(EditorCommand::TransformOperations { operations, ret })
|
||||
.await
|
||||
.map_err(internal_error)?;
|
||||
|
@ -2,12 +2,12 @@ use crate::services::delta_migration::DeltaRevisionMigration;
|
||||
use crate::services::rev_sqlite::{DeltaRevisionSql, SQLiteDocumentRevisionPersistence};
|
||||
use crate::DocumentDatabase;
|
||||
use bytes::Bytes;
|
||||
use flowy_client_sync::make_operations_from_revisions;
|
||||
use flowy_database::kv::KV;
|
||||
use flowy_error::FlowyResult;
|
||||
use flowy_http_model::revision::Revision;
|
||||
use flowy_http_model::util::md5;
|
||||
use flowy_revision_persistence::{RevisionDiskCache, SyncRecord};
|
||||
use flowy_sync::util::make_operations_from_revisions;
|
||||
use lib_infra::util::md5;
|
||||
use revision_model::Revision;
|
||||
use std::sync::Arc;
|
||||
|
||||
const V1_MIGRATION: &str = "DOCUMENT_V1_MIGRATION";
|
||||
|
@ -7,11 +7,9 @@ use flowy_database::{
|
||||
ConnectionPool,
|
||||
};
|
||||
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
||||
use flowy_http_model::{
|
||||
revision::{Revision, RevisionRange},
|
||||
util::md5,
|
||||
};
|
||||
use flowy_revision_persistence::{RevisionChangeset, RevisionDiskCache, RevisionState, SyncRecord};
|
||||
use lib_infra::util::md5;
|
||||
use revision_model::{Revision, RevisionRange};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
@ -7,11 +7,9 @@ use flowy_database::{
|
||||
ConnectionPool,
|
||||
};
|
||||
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
||||
use flowy_http_model::{
|
||||
revision::{Revision, RevisionRange},
|
||||
util::md5,
|
||||
};
|
||||
use flowy_revision_persistence::{RevisionChangeset, RevisionDiskCache, RevisionState, SyncRecord};
|
||||
use lib_infra::util::md5;
|
||||
use revision_model::{Revision, RevisionRange};
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct SQLiteDocumentRevisionPersistence {
|
||||
|
@ -1,6 +1,6 @@
|
||||
#![cfg_attr(rustfmt, rustfmt::skip)]
|
||||
use crate::editor::{TestBuilder, TestOp::*};
|
||||
use flowy_sync::client_document::{NewlineDocument, EmptyDocument};
|
||||
use flowy_client_sync::client_document::{NewlineDocument, EmptyDocument};
|
||||
use lib_ot::core::{Interval, OperationTransform, NEW_LINE, WHITESPACE, OTString};
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
use lib_ot::text_delta::DeltaTextOperations;
|
||||
|
@ -5,7 +5,7 @@ mod serde_test;
|
||||
mod undo_redo_test;
|
||||
|
||||
use derive_more::Display;
|
||||
use flowy_sync::client_document::{ClientDocument, InitialDocument};
|
||||
use flowy_client_sync::client_document::{ClientDocument, InitialDocument};
|
||||
use lib_ot::{
|
||||
core::*,
|
||||
text_delta::{BuildInTextAttribute, DeltaTextOperations},
|
||||
@ -242,8 +242,8 @@ impl TestBuilder {
|
||||
let target_prime: DeltaTextOperations = serde_json::from_str(&prime_json).unwrap();
|
||||
|
||||
if expected_prime != target_prime {
|
||||
log::error!("✅ expect prime: {}", expected,);
|
||||
log::error!("❌ receive prime: {}", prime_json);
|
||||
tracing::error!("✅ expect prime: {}", expected,);
|
||||
tracing::error!("❌ receive prime: {}", prime_json);
|
||||
}
|
||||
assert_eq!(target_prime, expected_prime);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#![allow(clippy::all)]
|
||||
use crate::editor::{Rng, TestBuilder, TestOp::*};
|
||||
use flowy_sync::client_document::{EmptyDocument, NewlineDocument};
|
||||
use flowy_client_sync::client_document::{EmptyDocument, NewlineDocument};
|
||||
use lib_ot::text_delta::DeltaTextOperationBuilder;
|
||||
use lib_ot::{core::Interval, core::*, text_delta::DeltaTextOperations};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use flowy_sync::client_document::{ClientDocument, EmptyDocument};
|
||||
use flowy_client_sync::client_document::{ClientDocument, EmptyDocument};
|
||||
use lib_ot::text_delta::DeltaTextOperation;
|
||||
use lib_ot::{
|
||||
core::*,
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::editor::{TestBuilder, TestOp::*};
|
||||
use flowy_sync::client_document::{EmptyDocument, NewlineDocument, RECORD_THRESHOLD};
|
||||
use flowy_client_sync::client_document::{EmptyDocument, NewlineDocument, RECORD_THRESHOLD};
|
||||
use lib_ot::core::{Interval, NEW_LINE, WHITESPACE};
|
||||
|
||||
#[test]
|
||||
|
@ -7,26 +7,34 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
flowy-derive = { path = "../flowy-derive" }
|
||||
lib-dispatch = { path = "../lib-dispatch" }
|
||||
protobuf = {version = "2.20.0"}
|
||||
bytes = "1.0"
|
||||
anyhow = "1.0"
|
||||
thiserror = "1.0"
|
||||
|
||||
|
||||
flowy-sync = { path = "../flowy-sync", optional = true}
|
||||
flowy-client-sync = { path = "../flowy-client-sync", optional = true}
|
||||
lib-dispatch = { path = "../lib-dispatch", optional = true }
|
||||
lib-ot = { path = "../../../shared-lib/lib-ot", optional = true}
|
||||
user-model = { path = "../../../shared-lib/user-model", optional = true}
|
||||
flowy-client-ws = { path = "../../../shared-lib/flowy-client-ws", optional = true }
|
||||
serde_json = {version = "1.0", optional = true}
|
||||
http-flowy = { git = "https://github.com/AppFlowy-IO/AppFlowy-Server", optional = true}
|
||||
serde_repr = { version = "0.1" }
|
||||
serde = "1.0"
|
||||
reqwest = { version = "0.11", optional = true }
|
||||
http-error-code = { git = "https://github.com/AppFlowy-IO/AppFlowy-Server", branch = "refactor/appflowy_server", optional = true }
|
||||
flowy-database = { path = "../flowy-database", optional = true}
|
||||
r2d2 = { version = "0.8", optional = true}
|
||||
|
||||
[features]
|
||||
collaboration = ["flowy-sync"]
|
||||
ot = ["lib-ot"]
|
||||
serde = ["serde_json"]
|
||||
http_server = ["http-flowy"]
|
||||
db = ["flowy-database", "r2d2"]
|
||||
adaptor_sync = ["flowy-client-sync"]
|
||||
adaptor_ot = ["lib-ot"]
|
||||
adaptor_dispatch = ["lib-dispatch"]
|
||||
adaptor_serde = ["serde_json"]
|
||||
adaptor_reqwest = ["reqwest"]
|
||||
adaptor_database = ["flowy-database", "r2d2"]
|
||||
adaptor_ws= ["flowy-client-ws"]
|
||||
adaptor_user= ["user-model"]
|
||||
adaptor_server_error = ["http-error-code"]
|
||||
dart = ["flowy-codegen/dart"]
|
||||
ts = ["flowy-codegen/ts"]
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
use flowy_derive::ProtoBuf_Enum;
|
||||
use serde_repr::*;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Error, ProtoBuf_Enum)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Error, Serialize_repr, Deserialize_repr, ProtoBuf_Enum)]
|
||||
#[repr(u8)]
|
||||
pub enum ErrorCode {
|
||||
#[error("Internal error")]
|
||||
Internal = 0,
|
||||
@ -92,6 +94,7 @@ pub enum ErrorCode {
|
||||
|
||||
#[error("user id is empty or whitespace")]
|
||||
UserIdInvalid = 30,
|
||||
|
||||
#[error("User not exist")]
|
||||
UserNotExist = 31,
|
||||
|
||||
@ -160,6 +163,27 @@ pub enum ErrorCode {
|
||||
|
||||
#[error("Sort id is empty")]
|
||||
SortIdIsEmpty = 53,
|
||||
|
||||
#[error("Connect refused")]
|
||||
ConnectRefused = 54,
|
||||
|
||||
#[error("Connection timeout")]
|
||||
ConnectTimeout = 55,
|
||||
|
||||
#[error("Connection closed")]
|
||||
ConnectClose = 56,
|
||||
|
||||
#[error("Connection canceled")]
|
||||
ConnectCancel = 57,
|
||||
|
||||
#[error("Sql error")]
|
||||
SqlError = 58,
|
||||
|
||||
#[error("Http request error")]
|
||||
HttpError = 59,
|
||||
|
||||
#[error("Payload should not be empty")]
|
||||
UnexpectedEmptyPayload = 60,
|
||||
}
|
||||
|
||||
impl ErrorCode {
|
||||
|
@ -1,9 +1,7 @@
|
||||
use crate::ErrorCode;
|
||||
use crate::code::ErrorCode;
|
||||
use anyhow::Result;
|
||||
use bytes::Bytes;
|
||||
use flowy_derive::ProtoBuf;
|
||||
use lib_dispatch::prelude::{AFPluginEventResponse, ResponseBuilder};
|
||||
use std::{convert::TryInto, fmt::Debug};
|
||||
use std::fmt::Debug;
|
||||
use thiserror::Error;
|
||||
|
||||
pub type FlowyResult<T> = anyhow::Result<T, FlowyError>;
|
||||
@ -39,6 +37,10 @@ impl FlowyError {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn is_record_not_found(&self) -> bool {
|
||||
self.code == ErrorCode::RecordNotFound.value()
|
||||
}
|
||||
|
||||
static_flowy_error!(internal, ErrorCode::Internal);
|
||||
static_flowy_error!(record_not_found, ErrorCode::RecordNotFound);
|
||||
static_flowy_error!(workspace_name, ErrorCode::WorkspaceNameInvalid);
|
||||
@ -72,6 +74,8 @@ impl FlowyError {
|
||||
static_flowy_error!(out_of_bounds, ErrorCode::OutOfBounds);
|
||||
static_flowy_error!(serde, ErrorCode::Serde);
|
||||
static_flowy_error!(field_record_not_found, ErrorCode::FieldRecordNotFound);
|
||||
static_flowy_error!(payload_none, ErrorCode::UnexpectedEmptyPayload);
|
||||
static_flowy_error!(http, ErrorCode::HttpError);
|
||||
}
|
||||
|
||||
impl std::convert::From<ErrorCode> for FlowyError {
|
||||
@ -90,22 +94,6 @@ where
|
||||
FlowyError::internal().context(e)
|
||||
}
|
||||
|
||||
// Not needed because of thiserror derive macro
|
||||
/* impl fmt::Display for FlowyError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{:?}: {}", &self.code, &self.msg)
|
||||
}
|
||||
}
|
||||
*/
|
||||
impl lib_dispatch::Error for FlowyError {
|
||||
fn as_response(&self) -> AFPluginEventResponse {
|
||||
let bytes: Bytes = self.clone().try_into().unwrap();
|
||||
|
||||
println!("Serialize FlowyError: {:?} to event response", self);
|
||||
ResponseBuilder::Err().data(bytes).build()
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::From<std::io::Error> for FlowyError {
|
||||
fn from(error: std::io::Error) -> Self {
|
||||
FlowyError::internal().context(error)
|
||||
@ -117,5 +105,3 @@ impl std::convert::From<protobuf::ProtobufError> for FlowyError {
|
||||
FlowyError::internal().context(e)
|
||||
}
|
||||
}
|
||||
|
||||
//impl std::error::Error for FlowyError {}
|
||||
|
12
frontend/rust-lib/flowy-error/src/ext/dispatch.rs
Normal file
12
frontend/rust-lib/flowy-error/src/ext/dispatch.rs
Normal file
@ -0,0 +1,12 @@
|
||||
use crate::FlowyError;
|
||||
use bytes::Bytes;
|
||||
use lib_dispatch::prelude::{AFPluginEventResponse, ResponseBuilder};
|
||||
use std::convert::TryInto;
|
||||
impl lib_dispatch::Error for FlowyError {
|
||||
fn as_response(&self) -> AFPluginEventResponse {
|
||||
let bytes: Bytes = self.clone().try_into().unwrap();
|
||||
|
||||
println!("Serialize FlowyError: {:?} to event response", self);
|
||||
ResponseBuilder::Err().data(bytes).build()
|
||||
}
|
||||
}
|
@ -1,21 +1,16 @@
|
||||
use crate::{ErrorCode, FlowyError};
|
||||
use http_flowy::errors::{ErrorCode as ServerErrorCode, ServerError};
|
||||
use crate::code::ErrorCode;
|
||||
use http_error_code::ErrorCode as ServerErrorCode;
|
||||
|
||||
impl std::convert::From<ServerError> for FlowyError {
|
||||
fn from(error: ServerError) -> Self {
|
||||
let code = server_error_to_flowy_error(error.code);
|
||||
FlowyError::new(code, &error.msg)
|
||||
}
|
||||
}
|
||||
|
||||
fn server_error_to_flowy_error(code: ServerErrorCode) -> ErrorCode {
|
||||
match code {
|
||||
ServerErrorCode::UserUnauthorized => ErrorCode::UserUnauthorized,
|
||||
ServerErrorCode::PasswordNotMatch => ErrorCode::PasswordNotMatch,
|
||||
ServerErrorCode::RecordNotFound => ErrorCode::RecordNotFound,
|
||||
ServerErrorCode::ConnectRefused | ServerErrorCode::ConnectTimeout | ServerErrorCode::ConnectClose => {
|
||||
ErrorCode::HttpServerConnectError
|
||||
impl std::convert::From<ServerErrorCode> for ErrorCode {
|
||||
fn from(code: ServerErrorCode) -> Self {
|
||||
match code {
|
||||
ServerErrorCode::UserUnauthorized => ErrorCode::UserUnauthorized,
|
||||
ServerErrorCode::PasswordNotMatch => ErrorCode::PasswordNotMatch,
|
||||
ServerErrorCode::RecordNotFound => ErrorCode::RecordNotFound,
|
||||
ServerErrorCode::ConnectRefused | ServerErrorCode::ConnectTimeout | ServerErrorCode::ConnectClose => {
|
||||
ErrorCode::HttpServerConnectError
|
||||
}
|
||||
_ => ErrorCode::Internal,
|
||||
}
|
||||
_ => ErrorCode::Internal,
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +1,26 @@
|
||||
#[cfg(feature = "collaboration")]
|
||||
mod collaborate;
|
||||
#[cfg(feature = "collaboration")]
|
||||
pub use collaborate::*;
|
||||
#[cfg(feature = "adaptor_sync")]
|
||||
pub mod sync;
|
||||
|
||||
//
|
||||
#[cfg(feature = "ot")]
|
||||
mod ot;
|
||||
#[cfg(feature = "ot")]
|
||||
pub use ot::*;
|
||||
#[cfg(feature = "adaptor_ot")]
|
||||
pub mod ot;
|
||||
|
||||
//
|
||||
#[cfg(feature = "serde")]
|
||||
mod serde;
|
||||
#[cfg(feature = "serde")]
|
||||
pub use serde::*;
|
||||
#[cfg(feature = "adaptor_serde")]
|
||||
pub mod serde;
|
||||
|
||||
//
|
||||
#[cfg(feature = "http_server")]
|
||||
mod http_server;
|
||||
#[cfg(feature = "http_server")]
|
||||
pub use http_server::*;
|
||||
#[cfg(feature = "adaptor_dispatch")]
|
||||
pub mod dispatch;
|
||||
|
||||
#[cfg(feature = "db")]
|
||||
mod database;
|
||||
#[cfg(feature = "db")]
|
||||
pub use database::*;
|
||||
#[cfg(feature = "adaptor_reqwest")]
|
||||
pub mod reqwest;
|
||||
|
||||
#[cfg(feature = "adaptor_database")]
|
||||
pub mod database;
|
||||
|
||||
#[cfg(feature = "adaptor_ws")]
|
||||
pub mod ws;
|
||||
|
||||
#[cfg(feature = "adaptor_user")]
|
||||
pub mod user;
|
||||
|
||||
#[cfg(feature = "adaptor_server_error")]
|
||||
pub mod http_server;
|
||||
|
8
frontend/rust-lib/flowy-error/src/ext/reqwest.rs
Normal file
8
frontend/rust-lib/flowy-error/src/ext/reqwest.rs
Normal file
@ -0,0 +1,8 @@
|
||||
use crate::FlowyError;
|
||||
use reqwest::Error;
|
||||
|
||||
impl std::convert::From<reqwest::Error> for FlowyError {
|
||||
fn from(error: Error) -> Self {
|
||||
FlowyError::connection().context(error)
|
||||
}
|
||||
}
|
@ -2,6 +2,6 @@ use crate::FlowyError;
|
||||
|
||||
impl std::convert::From<serde_json::Error> for FlowyError {
|
||||
fn from(error: serde_json::Error) -> Self {
|
||||
FlowyError::internal().context(error)
|
||||
FlowyError::serde().context(error)
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
use crate::FlowyError;
|
||||
|
||||
use flowy_sync::errors::ErrorCode;
|
||||
use flowy_client_sync::errors::ErrorCode;
|
||||
|
||||
impl std::convert::From<flowy_sync::errors::CollaborateError> for FlowyError {
|
||||
fn from(error: flowy_sync::errors::CollaborateError) -> Self {
|
||||
impl std::convert::From<flowy_client_sync::errors::SyncError> for FlowyError {
|
||||
fn from(error: flowy_client_sync::errors::SyncError) -> Self {
|
||||
match error.code {
|
||||
ErrorCode::RecordNotFound => FlowyError::record_not_found().context(error.msg),
|
||||
_ => FlowyError::internal().context(error.msg),
|
23
frontend/rust-lib/flowy-error/src/ext/user.rs
Normal file
23
frontend/rust-lib/flowy-error/src/ext/user.rs
Normal file
@ -0,0 +1,23 @@
|
||||
use crate::code::ErrorCode;
|
||||
use user_model::errors::UserErrorCode;
|
||||
|
||||
impl std::convert::From<UserErrorCode> for ErrorCode {
|
||||
fn from(code: UserErrorCode) -> Self {
|
||||
match code {
|
||||
UserErrorCode::Internal => ErrorCode::Internal,
|
||||
UserErrorCode::WorkspaceIdInvalid => ErrorCode::WorkspaceIdInvalid,
|
||||
UserErrorCode::EmailIsEmpty => ErrorCode::EmailIsEmpty,
|
||||
UserErrorCode::EmailFormatInvalid => ErrorCode::EmailFormatInvalid,
|
||||
UserErrorCode::UserIdInvalid => ErrorCode::UserIdInvalid,
|
||||
UserErrorCode::UserNameContainForbiddenCharacters => ErrorCode::UserNameContainForbiddenCharacters,
|
||||
UserErrorCode::UserNameIsEmpty => ErrorCode::UserNameIsEmpty,
|
||||
UserErrorCode::UserNotExist => ErrorCode::UserNotExist,
|
||||
UserErrorCode::PasswordIsEmpty => ErrorCode::PasswordIsEmpty,
|
||||
UserErrorCode::PasswordTooLong => ErrorCode::PasswordTooLong,
|
||||
UserErrorCode::PasswordContainsForbidCharacters => ErrorCode::PasswordContainsForbidCharacters,
|
||||
UserErrorCode::PasswordFormatInvalid => ErrorCode::PasswordFormatInvalid,
|
||||
UserErrorCode::PasswordNotMatch => ErrorCode::PasswordNotMatch,
|
||||
UserErrorCode::UserNameTooLong => ErrorCode::UserNameTooLong,
|
||||
}
|
||||
}
|
||||
}
|
10
frontend/rust-lib/flowy-error/src/ext/ws.rs
Normal file
10
frontend/rust-lib/flowy-error/src/ext/ws.rs
Normal file
@ -0,0 +1,10 @@
|
||||
use crate::FlowyError;
|
||||
use flowy_client_ws::WSErrorCode;
|
||||
|
||||
impl std::convert::From<WSErrorCode> for FlowyError {
|
||||
fn from(code: WSErrorCode) -> Self {
|
||||
match code {
|
||||
WSErrorCode::Internal => FlowyError::internal().context(code),
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
mod code;
|
||||
pub mod code;
|
||||
mod errors;
|
||||
mod ext;
|
||||
pub mod protobuf;
|
||||
|
@ -6,16 +6,17 @@ edition = "2018"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
folder-rev-model = { path = "../../../shared-lib/folder-rev-model" }
|
||||
flowy-sync = { path = "../flowy-sync"}
|
||||
flowy-http-model = { path = "../../../shared-lib/flowy-http-model" }
|
||||
folder-model = { path = "../../../shared-lib/folder-model" }
|
||||
flowy-client-sync = { path = "../flowy-client-sync"}
|
||||
revision-model = { path = "../../../shared-lib/revision-model" }
|
||||
ws-model = { path = "../../../shared-lib/ws-model" }
|
||||
flowy-derive = { path = "../flowy-derive" }
|
||||
lib-ot = { path = "../../../shared-lib/lib-ot" }
|
||||
lib-infra = { path = "../../../shared-lib/lib-infra" }
|
||||
|
||||
flowy-document = { path = "../flowy-document" }
|
||||
flowy-database = { path = "../flowy-database", optional = true }
|
||||
flowy-error = { path = "../flowy-error", features = ["db", "http_server"]}
|
||||
flowy-error = { path = "../flowy-error", features = ["adaptor_database", "adaptor_dispatch"]}
|
||||
flowy-notification = { path = "../flowy-notification" }
|
||||
lib-dispatch = { path = "../lib-dispatch" }
|
||||
flowy-revision = { path = "../flowy-revision" }
|
||||
|
@ -8,7 +8,7 @@ use crate::{
|
||||
impl_def_and_def_mut,
|
||||
};
|
||||
use flowy_derive::ProtoBuf;
|
||||
use folder_rev_model::AppRevision;
|
||||
use folder_model::AppRevision;
|
||||
use std::convert::TryInto;
|
||||
|
||||
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone)]
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::impl_def_and_def_mut;
|
||||
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
||||
use folder_rev_model::{TrashRevision, TrashTypeRevision};
|
||||
use folder_model::{TrashRevision, TrashTypeRevision};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Formatter;
|
||||
|
||||
|
@ -7,7 +7,7 @@ use crate::{
|
||||
impl_def_and_def_mut,
|
||||
};
|
||||
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
||||
use folder_rev_model::{gen_view_id, ViewDataFormatRevision, ViewLayoutTypeRevision, ViewRevision};
|
||||
use folder_model::{gen_view_id, ViewDataFormatRevision, ViewLayoutTypeRevision, ViewRevision};
|
||||
use std::convert::TryInto;
|
||||
|
||||
#[derive(Eq, PartialEq, ProtoBuf, Debug, Default, Clone)]
|
||||
|
@ -5,7 +5,7 @@ use crate::{
|
||||
impl_def_and_def_mut,
|
||||
};
|
||||
use flowy_derive::ProtoBuf;
|
||||
use folder_rev_model::WorkspaceRevision;
|
||||
use folder_model::WorkspaceRevision;
|
||||
use std::convert::TryInto;
|
||||
|
||||
#[derive(Eq, PartialEq, ProtoBuf, Default, Debug, Clone)]
|
||||
|
@ -11,7 +11,7 @@ use crate::{
|
||||
};
|
||||
use flowy_database::{ConnectionPool, DBConnection};
|
||||
use flowy_derive::{Flowy_Event, ProtoBuf_Enum};
|
||||
use folder_rev_model::{AppRevision, TrashRevision, ViewRevision, WorkspaceRevision};
|
||||
use folder_model::{AppRevision, TrashRevision, ViewRevision, WorkspaceRevision};
|
||||
use lib_dispatch::prelude::*;
|
||||
use lib_infra::future::FutureResult;
|
||||
use std::sync::Arc;
|
||||
|
@ -15,7 +15,7 @@ use bytes::Bytes;
|
||||
use flowy_document::editor::initial_read_me;
|
||||
use flowy_error::FlowyError;
|
||||
use flowy_revision::{RevisionManager, RevisionPersistence, RevisionPersistenceConfiguration, RevisionWebSocket};
|
||||
use folder_rev_model::user_default;
|
||||
use folder_model::user_default;
|
||||
use lazy_static::lazy_static;
|
||||
use lib_infra::future::FutureResult;
|
||||
|
||||
@ -23,11 +23,11 @@ use crate::services::clear_current_workspace;
|
||||
use crate::services::persistence::rev_sqlite::{
|
||||
SQLiteFolderRevisionPersistence, SQLiteFolderRevisionSnapshotPersistence,
|
||||
};
|
||||
use flowy_http_model::ws_data::ServerRevisionWSData;
|
||||
use flowy_sync::client_folder::FolderPad;
|
||||
use flowy_client_sync::client_folder::FolderPad;
|
||||
use std::convert::TryFrom;
|
||||
use std::{collections::HashMap, fmt::Formatter, sync::Arc};
|
||||
use tokio::sync::RwLock as TokioRwLock;
|
||||
use ws_model::ws_revision::ServerRevisionWSData;
|
||||
lazy_static! {
|
||||
static ref INIT_FOLDER_FLAG: TokioRwLock<HashMap<String, bool>> = TokioRwLock::new(HashMap::new());
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ use crate::{
|
||||
},
|
||||
};
|
||||
|
||||
use folder_rev_model::AppRevision;
|
||||
use folder_model::AppRevision;
|
||||
use futures::{FutureExt, StreamExt};
|
||||
use std::{collections::HashSet, sync::Arc};
|
||||
|
||||
|
@ -3,7 +3,7 @@ use crate::{
|
||||
errors::FlowyError,
|
||||
services::{AppController, TrashController, ViewController},
|
||||
};
|
||||
use folder_rev_model::TrashRevision;
|
||||
use folder_model::TrashRevision;
|
||||
use lib_dispatch::prelude::{data_result, AFPluginData, AFPluginState, DataResult};
|
||||
use std::{convert::TryInto, sync::Arc};
|
||||
|
||||
|
@ -1,20 +1,20 @@
|
||||
use crate::manager::FolderId;
|
||||
use bytes::Bytes;
|
||||
use flowy_client_sync::client_folder::{FolderChangeset, FolderOperations, FolderPad};
|
||||
use flowy_client_sync::make_operations_from_revisions;
|
||||
use flowy_client_sync::util::recover_operation_from_revisions;
|
||||
use flowy_database::ConnectionPool;
|
||||
use flowy_error::{FlowyError, FlowyResult};
|
||||
use flowy_http_model::revision::Revision;
|
||||
use flowy_http_model::ws_data::ServerRevisionWSData;
|
||||
use flowy_revision::{
|
||||
RevisionCloudService, RevisionManager, RevisionMergeable, RevisionObjectDeserializer, RevisionObjectSerializer,
|
||||
RevisionWebSocket,
|
||||
};
|
||||
use flowy_sync::client_folder::{FolderChangeset, FolderPad};
|
||||
use flowy_sync::server_folder::FolderOperations;
|
||||
use flowy_sync::util::{make_operations_from_revisions, recover_operation_from_revisions};
|
||||
use lib_infra::future::FutureResult;
|
||||
use lib_ot::core::EmptyAttributes;
|
||||
use parking_lot::RwLock;
|
||||
use revision_model::Revision;
|
||||
use std::sync::Arc;
|
||||
use ws_model::ws_revision::ServerRevisionWSData;
|
||||
|
||||
pub struct FolderEditor {
|
||||
#[allow(dead_code)]
|
||||
|
@ -4,17 +4,16 @@ use crate::{
|
||||
services::persistence::{AppTableSql, TrashTableSql, ViewTableSql, WorkspaceTableSql},
|
||||
};
|
||||
use bytes::Bytes;
|
||||
use flowy_client_sync::client_folder::FolderPad;
|
||||
use flowy_client_sync::client_folder::{make_folder_rev_json_str, FolderOperationsBuilder};
|
||||
use flowy_database::kv::KV;
|
||||
use flowy_error::{FlowyError, FlowyResult};
|
||||
use flowy_http_model::revision::Revision;
|
||||
use flowy_revision::reset::{RevisionResettable, RevisionStructReset};
|
||||
use flowy_sync::client_folder::make_folder_rev_json_str;
|
||||
use flowy_sync::client_folder::FolderPad;
|
||||
use flowy_sync::server_folder::FolderOperationsBuilder;
|
||||
use folder_rev_model::{AppRevision, FolderRevision, ViewRevision, WorkspaceRevision};
|
||||
use folder_model::{AppRevision, FolderRevision, ViewRevision, WorkspaceRevision};
|
||||
use revision_model::Revision;
|
||||
|
||||
use crate::services::persistence::rev_sqlite::SQLiteFolderRevisionPersistence;
|
||||
use flowy_http_model::util::md5;
|
||||
use lib_infra::util::md5;
|
||||
use std::sync::Arc;
|
||||
|
||||
const V1_MIGRATION: &str = "FOLDER_V1_MIGRATION";
|
||||
|
@ -9,13 +9,12 @@ use crate::{
|
||||
manager::FolderId,
|
||||
services::{folder_editor::FolderEditor, persistence::migration::FolderMigration},
|
||||
};
|
||||
use flowy_client_sync::client_folder::{FolderOperationsBuilder, FolderPad};
|
||||
use flowy_database::ConnectionPool;
|
||||
use flowy_error::{FlowyError, FlowyResult};
|
||||
use flowy_http_model::revision::Revision;
|
||||
use flowy_revision_persistence::{RevisionDiskCache, RevisionState, SyncRecord};
|
||||
use flowy_sync::client_folder::FolderPad;
|
||||
use flowy_sync::server_folder::FolderOperationsBuilder;
|
||||
use folder_rev_model::{AppRevision, TrashRevision, ViewRevision, WorkspaceRevision};
|
||||
use folder_model::{AppRevision, TrashRevision, ViewRevision, WorkspaceRevision};
|
||||
use revision_model::Revision;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
pub use version_1::{app_sql::*, trash_sql::*, v1_impl::V1Transaction, view_sql::*, workspace_sql::*};
|
||||
|
@ -7,9 +7,9 @@ use flowy_database::{
|
||||
ConnectionPool,
|
||||
};
|
||||
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
||||
use flowy_http_model::revision::{Revision, RevisionRange};
|
||||
use flowy_http_model::util::md5;
|
||||
use flowy_revision_persistence::{RevisionChangeset, RevisionDiskCache, RevisionState, SyncRecord};
|
||||
use lib_infra::util::md5;
|
||||
use revision_model::{Revision, RevisionRange};
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct SQLiteFolderRevisionPersistence {
|
||||
|
@ -8,7 +8,7 @@ use flowy_database::{
|
||||
schema::{app_table, app_table::dsl},
|
||||
SqliteConnection,
|
||||
};
|
||||
use folder_rev_model::AppRevision;
|
||||
use folder_model::AppRevision;
|
||||
|
||||
pub struct AppTableSql();
|
||||
impl AppTableSql {
|
||||
|
@ -5,7 +5,7 @@ use flowy_database::{
|
||||
schema::{trash_table, trash_table::dsl},
|
||||
SqliteConnection,
|
||||
};
|
||||
use folder_rev_model::{TrashRevision, TrashTypeRevision};
|
||||
use folder_model::{TrashRevision, TrashTypeRevision};
|
||||
|
||||
pub struct TrashTableSql();
|
||||
impl TrashTableSql {
|
||||
|
@ -8,7 +8,7 @@ use crate::services::persistence::{
|
||||
};
|
||||
use flowy_database::DBConnection;
|
||||
use flowy_error::FlowyResult;
|
||||
use folder_rev_model::{AppRevision, TrashRevision, ViewRevision, WorkspaceRevision};
|
||||
use folder_model::{AppRevision, TrashRevision, ViewRevision, WorkspaceRevision};
|
||||
|
||||
/// V1Transaction is deprecated since version 0.0.2 version
|
||||
pub struct V1Transaction<'a>(pub &'a DBConnection);
|
||||
|
@ -13,7 +13,7 @@ use flowy_database::{
|
||||
SqliteConnection,
|
||||
};
|
||||
|
||||
use folder_rev_model::{ViewDataFormatRevision, ViewLayoutTypeRevision, ViewRevision};
|
||||
use folder_model::{ViewDataFormatRevision, ViewLayoutTypeRevision, ViewRevision};
|
||||
use lib_infra::util::timestamp;
|
||||
|
||||
pub struct ViewTableSql();
|
||||
|
@ -4,7 +4,7 @@ use flowy_database::{
|
||||
prelude::*,
|
||||
schema::{workspace_table, workspace_table::dsl},
|
||||
};
|
||||
use folder_rev_model::WorkspaceRevision;
|
||||
use folder_model::WorkspaceRevision;
|
||||
|
||||
pub(crate) struct WorkspaceTableSql();
|
||||
impl WorkspaceTableSql {
|
||||
|
@ -3,7 +3,7 @@ use crate::services::{
|
||||
persistence::{AppChangeset, FolderPersistenceTransaction, ViewChangeset, WorkspaceChangeset},
|
||||
};
|
||||
use flowy_error::{FlowyError, FlowyResult};
|
||||
use folder_rev_model::{AppRevision, TrashRevision, ViewRevision, WorkspaceRevision};
|
||||
use folder_model::{AppRevision, TrashRevision, ViewRevision, WorkspaceRevision};
|
||||
use std::sync::Arc;
|
||||
|
||||
impl FolderPersistenceTransaction for FolderEditor {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user