refactor errors

This commit is contained in:
appflowy 2021-12-14 18:04:51 +08:00
parent 72a8f7a9e3
commit 013d8f753a
177 changed files with 1657 additions and 2740 deletions

23
backend/Cargo.lock generated
View File

@ -1151,6 +1151,15 @@ dependencies = [
"backtrace",
]
[[package]]
name = "error-code"
version = "0.1.0"
dependencies = [
"derive_more",
"flowy-derive",
"protobuf",
]
[[package]]
name = "eyre"
version = "0.6.5"
@ -1241,6 +1250,7 @@ dependencies = [
"flowy-database",
"flowy-derive",
"flowy-document",
"flowy-error",
"flowy-net",
"futures",
"futures-core",
@ -1267,6 +1277,7 @@ dependencies = [
"bytes",
"chrono",
"derive_more",
"error-code",
"flowy-collaboration",
"flowy-derive",
"log",
@ -1317,6 +1328,7 @@ dependencies = [
"flowy-collaboration",
"flowy-database",
"flowy-derive",
"flowy-error",
"futures",
"futures-core",
"futures-util",
@ -1343,11 +1355,18 @@ dependencies = [
name = "flowy-error"
version = "0.1.0"
dependencies = [
"backend-service",
"bytes",
"derive_more",
"error-code",
"flowy-collaboration",
"flowy-database",
"flowy-derive",
"lib-dispatch",
"lib-ot",
"lib-sqlite",
"protobuf",
"r2d2",
"serde_json",
]
[[package]]
@ -1431,6 +1450,7 @@ dependencies = [
"diesel_derives",
"flowy-database",
"flowy-derive",
"flowy-error",
"flowy-net",
"flowy-user-infra",
"futures-core",
@ -1460,6 +1480,7 @@ version = "0.1.0"
dependencies = [
"bytes",
"derive_more",
"error-code",
"fancy-regex",
"flowy-derive",
"lazy_static",

View File

@ -8,7 +8,7 @@ use crate::{
use actix_rt::task::spawn_blocking;
use actix_web::web::Data;
use async_stream::stream;
use backend_service::errors::{internal_error, Result as DocResult, ServerError};
use backend_service::errors::{internal_error, Result, ServerError};
use flowy_collaboration::{
core::sync::ServerDocManager,
protobuf::{WsDataType, WsDocumentData},
@ -23,7 +23,7 @@ pub enum DocWsMsg {
ClientData {
client_data: WsClientData,
pool: Data<PgPool>,
ret: oneshot::Sender<DocResult<()>>,
ret: oneshot::Sender<Result<()>>,
},
}
@ -66,11 +66,11 @@ impl DocWsActor {
}
}
async fn handle_client_data(&self, client_data: WsClientData, pool: Data<PgPool>) -> DocResult<()> {
async fn handle_client_data(&self, client_data: WsClientData, pool: Data<PgPool>) -> Result<()> {
let WsClientData { user, socket, data } = client_data;
let document_data = spawn_blocking(move || {
let document_data: WsDocumentData = parse_from_bytes(&data)?;
DocResult::Ok(document_data)
Result::Ok(document_data)
})
.await
.map_err(internal_error)??;
@ -91,11 +91,11 @@ impl DocWsActor {
socket: Socket,
data: Vec<u8>,
pg_pool: Data<PgPool>,
) -> DocResult<()> {
) -> Result<()> {
let mut revision_pb = spawn_blocking(move || {
let revision: Revision = parse_from_bytes(&data)?;
let _ = verify_md5(&revision)?;
DocResult::Ok(revision)
Result::Ok(revision)
})
.await
.map_err(internal_error)??;
@ -116,7 +116,7 @@ impl DocWsActor {
}
}
fn verify_md5(revision: &Revision) -> DocResult<()> {
fn verify_md5(revision: &Revision) -> Result<()> {
if md5(&revision.delta_data) != revision.md5 {
return Err(ServerError::internal().context("Revision md5 not match"));
}

View File

@ -1,7 +1,7 @@
import 'package:app_flowy/user/domain/i_auth.dart';
import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-user-infra/protobuf.dart' show UserProfile, ErrorCode;
import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@ -40,7 +40,7 @@ class SignInBloc extends Bloc<SignInEvent, SignInState> {
);
}
SignInState stateFromCode(UserError error) {
SignInState stateFromCode(FlowyError error) {
switch (ErrorCode.valueOf(error.code)!) {
case ErrorCode.EmailFormatInvalid:
return state.copyWith(isSubmitting: false, emailError: some(error.msg), passwordError: none());
@ -67,7 +67,7 @@ abstract class SignInState with _$SignInState {
required bool isSubmitting,
required Option<String> passwordError,
required Option<String> emailError,
required Option<Either<UserProfile, UserError>> successOrFail,
required Option<Either<UserProfile, FlowyError>> successOrFail,
}) = _SignInState;
factory SignInState.initial() => SignInState(

View File

@ -519,7 +519,7 @@ class _$SignInStateTearOff {
required bool isSubmitting,
required Option<String> passwordError,
required Option<String> emailError,
required Option<Either<UserProfile, UserError>> successOrFail}) {
required Option<Either<UserProfile, FlowyError>> successOrFail}) {
return _SignInState(
email: email,
password: password,
@ -541,7 +541,7 @@ mixin _$SignInState {
bool get isSubmitting => throw _privateConstructorUsedError;
Option<String> get passwordError => throw _privateConstructorUsedError;
Option<String> get emailError => throw _privateConstructorUsedError;
Option<Either<UserProfile, UserError>> get successOrFail =>
Option<Either<UserProfile, FlowyError>> get successOrFail =>
throw _privateConstructorUsedError;
@JsonKey(ignore: true)
@ -560,7 +560,7 @@ abstract class $SignInStateCopyWith<$Res> {
bool isSubmitting,
Option<String> passwordError,
Option<String> emailError,
Option<Either<UserProfile, UserError>> successOrFail});
Option<Either<UserProfile, FlowyError>> successOrFail});
}
/// @nodoc
@ -604,7 +604,7 @@ class _$SignInStateCopyWithImpl<$Res> implements $SignInStateCopyWith<$Res> {
successOrFail: successOrFail == freezed
? _value.successOrFail
: successOrFail // ignore: cast_nullable_to_non_nullable
as Option<Either<UserProfile, UserError>>,
as Option<Either<UserProfile, FlowyError>>,
));
}
}
@ -622,7 +622,7 @@ abstract class _$SignInStateCopyWith<$Res>
bool isSubmitting,
Option<String> passwordError,
Option<String> emailError,
Option<Either<UserProfile, UserError>> successOrFail});
Option<Either<UserProfile, FlowyError>> successOrFail});
}
/// @nodoc
@ -668,7 +668,7 @@ class __$SignInStateCopyWithImpl<$Res> extends _$SignInStateCopyWithImpl<$Res>
successOrFail: successOrFail == freezed
? _value.successOrFail
: successOrFail // ignore: cast_nullable_to_non_nullable
as Option<Either<UserProfile, UserError>>,
as Option<Either<UserProfile, FlowyError>>,
));
}
}
@ -695,7 +695,7 @@ class _$_SignInState implements _SignInState {
@override
final Option<String> emailError;
@override
final Option<Either<UserProfile, UserError>> successOrFail;
final Option<Either<UserProfile, FlowyError>> successOrFail;
@override
String toString() {
@ -748,7 +748,7 @@ abstract class _SignInState implements SignInState {
required bool isSubmitting,
required Option<String> passwordError,
required Option<String> emailError,
required Option<Either<UserProfile, UserError>> successOrFail}) =
required Option<Either<UserProfile, FlowyError>> successOrFail}) =
_$_SignInState;
@override
@ -762,7 +762,7 @@ abstract class _SignInState implements SignInState {
@override
Option<String> get emailError => throw _privateConstructorUsedError;
@override
Option<Either<UserProfile, UserError>> get successOrFail =>
Option<Either<UserProfile, FlowyError>> get successOrFail =>
throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)

View File

@ -2,7 +2,7 @@ import 'package:app_flowy/user/domain/i_auth.dart';
import 'package:dartz/dartz.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_sdk/protobuf/flowy-user-infra/protobuf.dart' show UserProfile, ErrorCode;
import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:app_flowy/generated/locale_keys.g.dart';
@ -78,7 +78,7 @@ class SignUpBloc extends Bloc<SignUpEvent, SignUpState> {
);
}
SignUpState stateFromCode(UserError error) {
SignUpState stateFromCode(FlowyError error) {
switch (ErrorCode.valueOf(error.code)!) {
case ErrorCode.EmailFormatInvalid:
return state.copyWith(
@ -118,7 +118,7 @@ class SignUpState with _$SignUpState {
required Option<String> passwordError,
required Option<String> repeatPasswordError,
required Option<String> emailError,
required Option<Either<UserProfile, UserError>> successOrFail,
required Option<Either<UserProfile, FlowyError>> successOrFail,
}) = _SignUpState;
factory SignUpState.initial() => SignUpState(

View File

@ -707,7 +707,7 @@ class _$SignUpStateTearOff {
required Option<String> passwordError,
required Option<String> repeatPasswordError,
required Option<String> emailError,
required Option<Either<UserProfile, UserError>> successOrFail}) {
required Option<Either<UserProfile, FlowyError>> successOrFail}) {
return _SignUpState(
email: email,
password: password,
@ -733,7 +733,7 @@ mixin _$SignUpState {
Option<String> get passwordError => throw _privateConstructorUsedError;
Option<String> get repeatPasswordError => throw _privateConstructorUsedError;
Option<String> get emailError => throw _privateConstructorUsedError;
Option<Either<UserProfile, UserError>> get successOrFail =>
Option<Either<UserProfile, FlowyError>> get successOrFail =>
throw _privateConstructorUsedError;
@JsonKey(ignore: true)
@ -754,7 +754,7 @@ abstract class $SignUpStateCopyWith<$Res> {
Option<String> passwordError,
Option<String> repeatPasswordError,
Option<String> emailError,
Option<Either<UserProfile, UserError>> successOrFail});
Option<Either<UserProfile, FlowyError>> successOrFail});
}
/// @nodoc
@ -808,7 +808,7 @@ class _$SignUpStateCopyWithImpl<$Res> implements $SignUpStateCopyWith<$Res> {
successOrFail: successOrFail == freezed
? _value.successOrFail
: successOrFail // ignore: cast_nullable_to_non_nullable
as Option<Either<UserProfile, UserError>>,
as Option<Either<UserProfile, FlowyError>>,
));
}
}
@ -828,7 +828,7 @@ abstract class _$SignUpStateCopyWith<$Res>
Option<String> passwordError,
Option<String> repeatPasswordError,
Option<String> emailError,
Option<Either<UserProfile, UserError>> successOrFail});
Option<Either<UserProfile, FlowyError>> successOrFail});
}
/// @nodoc
@ -884,7 +884,7 @@ class __$SignUpStateCopyWithImpl<$Res> extends _$SignUpStateCopyWithImpl<$Res>
successOrFail: successOrFail == freezed
? _value.successOrFail
: successOrFail // ignore: cast_nullable_to_non_nullable
as Option<Either<UserProfile, UserError>>,
as Option<Either<UserProfile, FlowyError>>,
));
}
}
@ -917,7 +917,7 @@ class _$_SignUpState implements _SignUpState {
@override
final Option<String> emailError;
@override
final Option<Either<UserProfile, UserError>> successOrFail;
final Option<Either<UserProfile, FlowyError>> successOrFail;
@override
String toString() {
@ -980,7 +980,7 @@ abstract class _SignUpState implements SignUpState {
required Option<String> passwordError,
required Option<String> repeatPasswordError,
required Option<String> emailError,
required Option<Either<UserProfile, UserError>> successOrFail}) =
required Option<Either<UserProfile, FlowyError>> successOrFail}) =
_$_SignUpState;
@override
@ -998,7 +998,7 @@ abstract class _SignUpState implements SignUpState {
@override
Option<String> get emailError => throw _privateConstructorUsedError;
@override
Option<Either<UserProfile, UserError>> get successOrFail =>
Option<Either<UserProfile, FlowyError>> get successOrFail =>
throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)

View File

@ -1,11 +1,11 @@
import 'package:flowy_sdk/protobuf/flowy-user-infra/protobuf.dart' show UserProfile;
import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'auth_state.freezed.dart';
@freezed
abstract class AuthState with _$AuthState {
const factory AuthState.authenticated(UserProfile userProfile) = Authenticated;
const factory AuthState.unauthenticated(UserError error) = Unauthenticated;
const factory AuthState.unauthenticated(FlowyError error) = Unauthenticated;
const factory AuthState.initial() = _Initial;
}

View File

@ -23,7 +23,7 @@ class _$AuthStateTearOff {
);
}
Unauthenticated unauthenticated(UserError error) {
Unauthenticated unauthenticated(FlowyError error) {
return Unauthenticated(
error,
);
@ -42,21 +42,21 @@ mixin _$AuthState {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(UserProfile userProfile) authenticated,
required TResult Function(UserError error) unauthenticated,
required TResult Function(FlowyError error) unauthenticated,
required TResult Function() initial,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult Function(UserProfile userProfile)? authenticated,
TResult Function(UserError error)? unauthenticated,
TResult Function(FlowyError error)? unauthenticated,
TResult Function()? initial,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(UserProfile userProfile)? authenticated,
TResult Function(UserError error)? unauthenticated,
TResult Function(FlowyError error)? unauthenticated,
TResult Function()? initial,
required TResult orElse(),
}) =>
@ -166,7 +166,7 @@ class _$Authenticated implements Authenticated {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(UserProfile userProfile) authenticated,
required TResult Function(UserError error) unauthenticated,
required TResult Function(FlowyError error) unauthenticated,
required TResult Function() initial,
}) {
return authenticated(userProfile);
@ -176,7 +176,7 @@ class _$Authenticated implements Authenticated {
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult Function(UserProfile userProfile)? authenticated,
TResult Function(UserError error)? unauthenticated,
TResult Function(FlowyError error)? unauthenticated,
TResult Function()? initial,
}) {
return authenticated?.call(userProfile);
@ -186,7 +186,7 @@ class _$Authenticated implements Authenticated {
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(UserProfile userProfile)? authenticated,
TResult Function(UserError error)? unauthenticated,
TResult Function(FlowyError error)? unauthenticated,
TResult Function()? initial,
required TResult orElse(),
}) {
@ -245,7 +245,7 @@ abstract class $UnauthenticatedCopyWith<$Res> {
factory $UnauthenticatedCopyWith(
Unauthenticated value, $Res Function(Unauthenticated) then) =
_$UnauthenticatedCopyWithImpl<$Res>;
$Res call({UserError error});
$Res call({FlowyError error});
}
/// @nodoc
@ -266,7 +266,7 @@ class _$UnauthenticatedCopyWithImpl<$Res> extends _$AuthStateCopyWithImpl<$Res>
error == freezed
? _value.error
: error // ignore: cast_nullable_to_non_nullable
as UserError,
as FlowyError,
));
}
}
@ -277,7 +277,7 @@ class _$Unauthenticated implements Unauthenticated {
const _$Unauthenticated(this.error);
@override
final UserError error;
final FlowyError error;
@override
String toString() {
@ -305,7 +305,7 @@ class _$Unauthenticated implements Unauthenticated {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(UserProfile userProfile) authenticated,
required TResult Function(UserError error) unauthenticated,
required TResult Function(FlowyError error) unauthenticated,
required TResult Function() initial,
}) {
return unauthenticated(error);
@ -315,7 +315,7 @@ class _$Unauthenticated implements Unauthenticated {
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult Function(UserProfile userProfile)? authenticated,
TResult Function(UserError error)? unauthenticated,
TResult Function(FlowyError error)? unauthenticated,
TResult Function()? initial,
}) {
return unauthenticated?.call(error);
@ -325,7 +325,7 @@ class _$Unauthenticated implements Unauthenticated {
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(UserProfile userProfile)? authenticated,
TResult Function(UserError error)? unauthenticated,
TResult Function(FlowyError error)? unauthenticated,
TResult Function()? initial,
required TResult orElse(),
}) {
@ -371,9 +371,9 @@ class _$Unauthenticated implements Unauthenticated {
}
abstract class Unauthenticated implements AuthState {
const factory Unauthenticated(UserError error) = _$Unauthenticated;
const factory Unauthenticated(FlowyError error) = _$Unauthenticated;
UserError get error => throw _privateConstructorUsedError;
FlowyError get error => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$UnauthenticatedCopyWith<Unauthenticated> get copyWith =>
throw _privateConstructorUsedError;
@ -417,7 +417,7 @@ class _$_Initial implements _Initial {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(UserProfile userProfile) authenticated,
required TResult Function(UserError error) unauthenticated,
required TResult Function(FlowyError error) unauthenticated,
required TResult Function() initial,
}) {
return initial();
@ -427,7 +427,7 @@ class _$_Initial implements _Initial {
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult Function(UserProfile userProfile)? authenticated,
TResult Function(UserError error)? unauthenticated,
TResult Function(FlowyError error)? unauthenticated,
TResult Function()? initial,
}) {
return initial?.call();
@ -437,7 +437,7 @@ class _$_Initial implements _Initial {
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(UserProfile userProfile)? authenticated,
TResult Function(UserError error)? unauthenticated,
TResult Function(FlowyError error)? unauthenticated,
TResult Function()? initial,
required TResult orElse(),
}) {

View File

@ -1,5 +1,5 @@
import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/protobuf.dart';
import 'package:flowy_sdk/protobuf/flowy-user-infra/protobuf.dart' show UserProfile;
import 'package:flutter/material.dart';
@ -14,9 +14,9 @@ class NewUser {
}
abstract class IAuth {
Future<Either<UserProfile, UserError>> signIn(String? email, String? password);
Future<Either<UserProfile, UserError>> signUp(String? name, String? password, String? email);
Future<Either<Unit, UserError>> signOut();
Future<Either<UserProfile, FlowyError>> signIn(String? email, String? password);
Future<Either<UserProfile, FlowyError>> signUp(String? name, String? password, String? email);
Future<Either<Unit, FlowyError>> signOut();
}
abstract class IAuthRouter {

View File

@ -8,7 +8,7 @@ import 'package:flowy_infra_ui/widget/route/animation.dart';
import 'package:flowy_sdk/protobuf/flowy-user-infra/protobuf.dart' show UserProfile;
import 'package:app_flowy/user/domain/i_auth.dart';
import 'package:app_flowy/user/infrastructure/repos/auth_repo.dart';
import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/protobuf.dart';
import 'package:flutter/material.dart';
@ -19,17 +19,17 @@ class AuthImpl extends IAuth {
});
@override
Future<Either<UserProfile, UserError>> signIn(String? email, String? password) {
Future<Either<UserProfile, FlowyError>> signIn(String? email, String? password) {
return repo.signIn(email: email, password: password);
}
@override
Future<Either<UserProfile, UserError>> signUp(String? name, String? password, String? email) {
Future<Either<UserProfile, FlowyError>> signUp(String? name, String? password, String? email) {
return repo.signUp(name: name, password: password, email: email);
}
@override
Future<Either<Unit, UserError>> signOut() {
Future<Either<Unit, FlowyError>> signOut() {
return repo.signOut();
}
}

View File

@ -24,8 +24,8 @@ class SplashUserImpl implements ISplashUser {
(userProfile) {
return AuthState.authenticated(userProfile);
},
(userError) {
return AuthState.unauthenticated(userError);
(FlowyError) {
return AuthState.unauthenticated(FlowyError);
},
);
});

View File

@ -1,10 +1,10 @@
import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/dispatch/dispatch.dart';
import 'package:flowy_sdk/protobuf/flowy-user-infra/protobuf.dart' show SignInRequest, SignUpRequest, UserProfile;
import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
class AuthRepository {
Future<Either<UserProfile, UserError>> signIn({required String? email, required String? password}) {
Future<Either<UserProfile, FlowyError>> signIn({required String? email, required String? password}) {
//
final request = SignInRequest.create()
..email = email ?? ''
@ -13,7 +13,7 @@ class AuthRepository {
return UserEventSignIn(request).send();
}
Future<Either<UserProfile, UserError>> signUp(
Future<Either<UserProfile, FlowyError>> signUp(
{required String? name, required String? password, required String? email}) {
final request = SignUpRequest.create()
..email = email ?? ''
@ -35,7 +35,7 @@ class AuthRepository {
// });
}
Future<Either<Unit, UserError>> signOut() {
Future<Either<Unit, FlowyError>> signOut() {
return UserEventSignOut().send();
}
}

View File

@ -9,7 +9,7 @@ import 'package:flowy_infra_ui/widget/rounded_button.dart';
import 'package:flowy_infra_ui/widget/rounded_input_field.dart';
import 'package:flowy_infra_ui/widget/spacing.dart';
import 'package:flowy_infra_ui/style_widget/snap_bar.dart';
import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-user-infra/protobuf.dart' show UserProfile;
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@ -39,7 +39,7 @@ class SignInScreen extends StatelessWidget {
);
}
void _handleSuccessOrFail(Either<UserProfile, UserError> result, BuildContext context) {
void _handleSuccessOrFail(Either<UserProfile, FlowyError> result, BuildContext context) {
result.fold(
(user) => router.pushWelcomeScreen(context, user),
(error) => showSnapBar(context, error.msg),

View File

@ -7,7 +7,7 @@ import 'package:flowy_infra/theme.dart';
import 'package:flowy_infra_ui/widget/rounded_button.dart';
import 'package:flowy_infra_ui/widget/rounded_input_field.dart';
import 'package:flowy_infra_ui/widget/spacing.dart';
import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-user-infra/protobuf.dart' show UserProfile;
import 'package:flowy_infra_ui/style_widget/snap_bar.dart';
import 'package:flutter/material.dart';
@ -36,7 +36,7 @@ class SignUpScreen extends StatelessWidget {
);
}
void _handleSuccessOrFail(BuildContext context, Either<UserProfile, UserError> result) {
void _handleSuccessOrFail(BuildContext context, Either<UserProfile, FlowyError> result) {
result.fold(
(user) => router.pushWelcomeScreen(context, user),
(error) => showSnapBar(context, error.msg),

View File

@ -10,7 +10,7 @@ import 'package:flowy_infra_ui/widget/spacing.dart';
import 'package:flowy_log/flowy_log.dart';
import 'package:flowy_sdk/dispatch/dispatch.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/protobuf.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:url_launcher/url_launcher.dart';
@ -113,7 +113,7 @@ class _SkipLogInScreenState extends State<SkipLogInScreen> {
void _openCurrentWorkspace(
BuildContext context,
UserProfile user,
dartz.Either<CurrentWorkspaceSetting, WorkspaceError> workspacesOrError,
dartz.Either<CurrentWorkspaceSetting, FlowyError> workspacesOrError,
) {
workspacesOrError.fold(
(workspaceSetting) {

View File

@ -2,7 +2,7 @@ import 'package:app_flowy/workspace/domain/i_app.dart';
import 'package:flowy_log/flowy_log.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/app_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/view_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:dartz/dartz.dart';
@ -61,7 +61,7 @@ class AppBloc extends Bloc<AppEvent, AppState> {
return super.close();
}
void _handleViewsChanged(Either<List<View>, WorkspaceError> result) {
void _handleViewsChanged(Either<List<View>, FlowyError> result) {
result.fold(
(views) => add(AppEvent.didReceiveViews(views)),
(error) {
@ -112,7 +112,7 @@ class AppState with _$AppState {
required bool isLoading,
required List<View>? views,
View? latestCreatedView,
required Either<Unit, WorkspaceError> successOrFailure,
required Either<Unit, FlowyError> successOrFailure,
}) = _AppState;
factory AppState.initial(App app) => AppState(

View File

@ -1051,7 +1051,7 @@ class _$AppStateTearOff {
required bool isLoading,
required List<View>? views,
View? latestCreatedView,
required Either<Unit, WorkspaceError> successOrFailure}) {
required Either<Unit, FlowyError> successOrFailure}) {
return _AppState(
app: app,
isLoading: isLoading,
@ -1071,7 +1071,7 @@ mixin _$AppState {
bool get isLoading => throw _privateConstructorUsedError;
List<View>? get views => throw _privateConstructorUsedError;
View? get latestCreatedView => throw _privateConstructorUsedError;
Either<Unit, WorkspaceError> get successOrFailure =>
Either<Unit, FlowyError> get successOrFailure =>
throw _privateConstructorUsedError;
@JsonKey(ignore: true)
@ -1088,7 +1088,7 @@ abstract class $AppStateCopyWith<$Res> {
bool isLoading,
List<View>? views,
View? latestCreatedView,
Either<Unit, WorkspaceError> successOrFailure});
Either<Unit, FlowyError> successOrFailure});
}
/// @nodoc
@ -1127,7 +1127,7 @@ class _$AppStateCopyWithImpl<$Res> implements $AppStateCopyWith<$Res> {
successOrFailure: successOrFailure == freezed
? _value.successOrFailure
: successOrFailure // ignore: cast_nullable_to_non_nullable
as Either<Unit, WorkspaceError>,
as Either<Unit, FlowyError>,
));
}
}
@ -1142,7 +1142,7 @@ abstract class _$AppStateCopyWith<$Res> implements $AppStateCopyWith<$Res> {
bool isLoading,
List<View>? views,
View? latestCreatedView,
Either<Unit, WorkspaceError> successOrFailure});
Either<Unit, FlowyError> successOrFailure});
}
/// @nodoc
@ -1182,7 +1182,7 @@ class __$AppStateCopyWithImpl<$Res> extends _$AppStateCopyWithImpl<$Res>
successOrFailure: successOrFailure == freezed
? _value.successOrFailure
: successOrFailure // ignore: cast_nullable_to_non_nullable
as Either<Unit, WorkspaceError>,
as Either<Unit, FlowyError>,
));
}
}
@ -1206,7 +1206,7 @@ class _$_AppState implements _AppState {
@override
final View? latestCreatedView;
@override
final Either<Unit, WorkspaceError> successOrFailure;
final Either<Unit, FlowyError> successOrFailure;
@override
String toString() {
@ -1253,7 +1253,7 @@ abstract class _AppState implements AppState {
required bool isLoading,
required List<View>? views,
View? latestCreatedView,
required Either<Unit, WorkspaceError> successOrFailure}) = _$_AppState;
required Either<Unit, FlowyError> successOrFailure}) = _$_AppState;
@override
App get app => throw _privateConstructorUsedError;
@ -1264,7 +1264,7 @@ abstract class _AppState implements AppState {
@override
View? get latestCreatedView => throw _privateConstructorUsedError;
@override
Either<Unit, WorkspaceError> get successOrFailure =>
Either<Unit, FlowyError> get successOrFailure =>
throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)

View File

@ -4,7 +4,7 @@ import 'package:app_flowy/workspace/domain/i_trash.dart';
import 'package:app_flowy/workspace/domain/i_view.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/trash_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/view_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flutter_quill/flutter_quill.dart';
import 'package:flowy_log/flowy_log.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@ -155,5 +155,5 @@ class DocState with _$DocState {
@freezed
class DocLoadState with _$DocLoadState {
const factory DocLoadState.loading() = _Loading;
const factory DocLoadState.finish(Either<Unit, WorkspaceError> successOrFail) = _Finish;
const factory DocLoadState.finish(Either<Unit, FlowyError> successOrFail) = _Finish;
}

View File

@ -909,7 +909,7 @@ class _$DocLoadStateTearOff {
return const _Loading();
}
_Finish finish(Either<Unit, WorkspaceError> successOrFail) {
_Finish finish(Either<Unit, FlowyError> successOrFail) {
return _Finish(
successOrFail,
);
@ -924,20 +924,20 @@ mixin _$DocLoadState {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() loading,
required TResult Function(Either<Unit, WorkspaceError> successOrFail)
required TResult Function(Either<Unit, FlowyError> successOrFail)
finish,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult Function()? loading,
TResult Function(Either<Unit, WorkspaceError> successOrFail)? finish,
TResult Function(Either<Unit, FlowyError> successOrFail)? finish,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? loading,
TResult Function(Either<Unit, WorkspaceError> successOrFail)? finish,
TResult Function(Either<Unit, FlowyError> successOrFail)? finish,
required TResult orElse(),
}) =>
throw _privateConstructorUsedError;
@ -1016,7 +1016,7 @@ class _$_Loading implements _Loading {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() loading,
required TResult Function(Either<Unit, WorkspaceError> successOrFail)
required TResult Function(Either<Unit, FlowyError> successOrFail)
finish,
}) {
return loading();
@ -1026,7 +1026,7 @@ class _$_Loading implements _Loading {
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult Function()? loading,
TResult Function(Either<Unit, WorkspaceError> successOrFail)? finish,
TResult Function(Either<Unit, FlowyError> successOrFail)? finish,
}) {
return loading?.call();
}
@ -1035,7 +1035,7 @@ class _$_Loading implements _Loading {
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? loading,
TResult Function(Either<Unit, WorkspaceError> successOrFail)? finish,
TResult Function(Either<Unit, FlowyError> successOrFail)? finish,
required TResult orElse(),
}) {
if (loading != null) {
@ -1084,7 +1084,7 @@ abstract class _Loading implements DocLoadState {
abstract class _$FinishCopyWith<$Res> {
factory _$FinishCopyWith(_Finish value, $Res Function(_Finish) then) =
__$FinishCopyWithImpl<$Res>;
$Res call({Either<Unit, WorkspaceError> successOrFail});
$Res call({Either<Unit, FlowyError> successOrFail});
}
/// @nodoc
@ -1104,7 +1104,7 @@ class __$FinishCopyWithImpl<$Res> extends _$DocLoadStateCopyWithImpl<$Res>
successOrFail == freezed
? _value.successOrFail
: successOrFail // ignore: cast_nullable_to_non_nullable
as Either<Unit, WorkspaceError>,
as Either<Unit, FlowyError>,
));
}
}
@ -1115,7 +1115,7 @@ class _$_Finish implements _Finish {
const _$_Finish(this.successOrFail);
@override
final Either<Unit, WorkspaceError> successOrFail;
final Either<Unit, FlowyError> successOrFail;
@override
String toString() {
@ -1144,7 +1144,7 @@ class _$_Finish implements _Finish {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() loading,
required TResult Function(Either<Unit, WorkspaceError> successOrFail)
required TResult Function(Either<Unit, FlowyError> successOrFail)
finish,
}) {
return finish(successOrFail);
@ -1154,7 +1154,7 @@ class _$_Finish implements _Finish {
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult Function()? loading,
TResult Function(Either<Unit, WorkspaceError> successOrFail)? finish,
TResult Function(Either<Unit, FlowyError> successOrFail)? finish,
}) {
return finish?.call(successOrFail);
}
@ -1163,7 +1163,7 @@ class _$_Finish implements _Finish {
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? loading,
TResult Function(Either<Unit, WorkspaceError> successOrFail)? finish,
TResult Function(Either<Unit, FlowyError> successOrFail)? finish,
required TResult orElse(),
}) {
if (finish != null) {
@ -1205,9 +1205,9 @@ class _$_Finish implements _Finish {
}
abstract class _Finish implements DocLoadState {
const factory _Finish(Either<Unit, WorkspaceError> successOrFail) = _$_Finish;
const factory _Finish(Either<Unit, FlowyError> successOrFail) = _$_Finish;
Either<Unit, WorkspaceError> get successOrFail =>
Either<Unit, FlowyError> get successOrFail =>
throw _privateConstructorUsedError;
@JsonKey(ignore: true)
_$FinishCopyWith<_Finish> get copyWith => throw _privateConstructorUsedError;

View File

@ -2,7 +2,7 @@ import 'package:app_flowy/workspace/domain/i_share.dart';
import 'package:app_flowy/workspace/infrastructure/markdown/delta_markdown.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/export.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/view_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:dartz/dartz.dart';
@ -48,5 +48,5 @@ class DocShareEvent with _$DocShareEvent {
class DocShareState with _$DocShareState {
const factory DocShareState.initial() = _Initial;
const factory DocShareState.loading() = _Loading;
const factory DocShareState.finish(Either<ExportData, WorkspaceError> successOrFail) = _Finish;
const factory DocShareState.finish(Either<ExportData, FlowyError> successOrFail) = _Finish;
}

View File

@ -434,7 +434,7 @@ class _$DocShareStateTearOff {
return const _Loading();
}
_Finish finish(Either<ExportData, WorkspaceError> successOrFail) {
_Finish finish(Either<ExportData, FlowyError> successOrFail) {
return _Finish(
successOrFail,
);
@ -450,7 +450,7 @@ mixin _$DocShareState {
TResult when<TResult extends Object?>({
required TResult Function() initial,
required TResult Function() loading,
required TResult Function(Either<ExportData, WorkspaceError> successOrFail)
required TResult Function(Either<ExportData, FlowyError> successOrFail)
finish,
}) =>
throw _privateConstructorUsedError;
@ -458,14 +458,14 @@ mixin _$DocShareState {
TResult? whenOrNull<TResult extends Object?>({
TResult Function()? initial,
TResult Function()? loading,
TResult Function(Either<ExportData, WorkspaceError> successOrFail)? finish,
TResult Function(Either<ExportData, FlowyError> successOrFail)? finish,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? initial,
TResult Function()? loading,
TResult Function(Either<ExportData, WorkspaceError> successOrFail)? finish,
TResult Function(Either<ExportData, FlowyError> successOrFail)? finish,
required TResult orElse(),
}) =>
throw _privateConstructorUsedError;
@ -549,7 +549,7 @@ class _$_Initial implements _Initial {
TResult when<TResult extends Object?>({
required TResult Function() initial,
required TResult Function() loading,
required TResult Function(Either<ExportData, WorkspaceError> successOrFail)
required TResult Function(Either<ExportData, FlowyError> successOrFail)
finish,
}) {
return initial();
@ -560,7 +560,7 @@ class _$_Initial implements _Initial {
TResult? whenOrNull<TResult extends Object?>({
TResult Function()? initial,
TResult Function()? loading,
TResult Function(Either<ExportData, WorkspaceError> successOrFail)? finish,
TResult Function(Either<ExportData, FlowyError> successOrFail)? finish,
}) {
return initial?.call();
}
@ -570,7 +570,7 @@ class _$_Initial implements _Initial {
TResult maybeWhen<TResult extends Object?>({
TResult Function()? initial,
TResult Function()? loading,
TResult Function(Either<ExportData, WorkspaceError> successOrFail)? finish,
TResult Function(Either<ExportData, FlowyError> successOrFail)? finish,
required TResult orElse(),
}) {
if (initial != null) {
@ -657,7 +657,7 @@ class _$_Loading implements _Loading {
TResult when<TResult extends Object?>({
required TResult Function() initial,
required TResult Function() loading,
required TResult Function(Either<ExportData, WorkspaceError> successOrFail)
required TResult Function(Either<ExportData, FlowyError> successOrFail)
finish,
}) {
return loading();
@ -668,7 +668,7 @@ class _$_Loading implements _Loading {
TResult? whenOrNull<TResult extends Object?>({
TResult Function()? initial,
TResult Function()? loading,
TResult Function(Either<ExportData, WorkspaceError> successOrFail)? finish,
TResult Function(Either<ExportData, FlowyError> successOrFail)? finish,
}) {
return loading?.call();
}
@ -678,7 +678,7 @@ class _$_Loading implements _Loading {
TResult maybeWhen<TResult extends Object?>({
TResult Function()? initial,
TResult Function()? loading,
TResult Function(Either<ExportData, WorkspaceError> successOrFail)? finish,
TResult Function(Either<ExportData, FlowyError> successOrFail)? finish,
required TResult orElse(),
}) {
if (loading != null) {
@ -730,7 +730,7 @@ abstract class _Loading implements DocShareState {
abstract class _$FinishCopyWith<$Res> {
factory _$FinishCopyWith(_Finish value, $Res Function(_Finish) then) =
__$FinishCopyWithImpl<$Res>;
$Res call({Either<ExportData, WorkspaceError> successOrFail});
$Res call({Either<ExportData, FlowyError> successOrFail});
}
/// @nodoc
@ -750,7 +750,7 @@ class __$FinishCopyWithImpl<$Res> extends _$DocShareStateCopyWithImpl<$Res>
successOrFail == freezed
? _value.successOrFail
: successOrFail // ignore: cast_nullable_to_non_nullable
as Either<ExportData, WorkspaceError>,
as Either<ExportData, FlowyError>,
));
}
}
@ -761,7 +761,7 @@ class _$_Finish implements _Finish {
const _$_Finish(this.successOrFail);
@override
final Either<ExportData, WorkspaceError> successOrFail;
final Either<ExportData, FlowyError> successOrFail;
@override
String toString() {
@ -791,7 +791,7 @@ class _$_Finish implements _Finish {
TResult when<TResult extends Object?>({
required TResult Function() initial,
required TResult Function() loading,
required TResult Function(Either<ExportData, WorkspaceError> successOrFail)
required TResult Function(Either<ExportData, FlowyError> successOrFail)
finish,
}) {
return finish(successOrFail);
@ -802,7 +802,7 @@ class _$_Finish implements _Finish {
TResult? whenOrNull<TResult extends Object?>({
TResult Function()? initial,
TResult Function()? loading,
TResult Function(Either<ExportData, WorkspaceError> successOrFail)? finish,
TResult Function(Either<ExportData, FlowyError> successOrFail)? finish,
}) {
return finish?.call(successOrFail);
}
@ -812,7 +812,7 @@ class _$_Finish implements _Finish {
TResult maybeWhen<TResult extends Object?>({
TResult Function()? initial,
TResult Function()? loading,
TResult Function(Either<ExportData, WorkspaceError> successOrFail)? finish,
TResult Function(Either<ExportData, FlowyError> successOrFail)? finish,
required TResult orElse(),
}) {
if (finish != null) {
@ -857,10 +857,10 @@ class _$_Finish implements _Finish {
}
abstract class _Finish implements DocShareState {
const factory _Finish(Either<ExportData, WorkspaceError> successOrFail) =
const factory _Finish(Either<ExportData, FlowyError> successOrFail) =
_$_Finish;
Either<ExportData, WorkspaceError> get successOrFail =>
Either<ExportData, FlowyError> get successOrFail =>
throw _privateConstructorUsedError;
@JsonKey(ignore: true)
_$FinishCopyWith<_Finish> get copyWith => throw _privateConstructorUsedError;

View File

@ -1,5 +1,6 @@
import 'package:app_flowy/workspace/domain/i_user.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:dartz/dartz.dart';
@ -31,7 +32,7 @@ class HomeListenBloc extends Bloc<HomeListenEvent, HomeListenState> {
super.close();
}
void _authDidChanged(Either<Unit, UserError> errorOrNothing) {
void _authDidChanged(Either<Unit, FlowyError> errorOrNothing) {
errorOrNothing.fold((_) {}, (error) {
if (error.code == ErrorCode.UserUnauthorized.value) {
add(HomeListenEvent.unauthorized(error.msg));

View File

@ -5,7 +5,7 @@ import 'package:app_flowy/workspace/presentation/stack_page/blank/blank_page.dar
import 'package:dartz/dartz.dart';
import 'package:flowy_log/flowy_log.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/app_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@ -77,7 +77,7 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> {
);
}
void _handleAppsOrFail(Either<List<App>, WorkspaceError> appsOrFail) {
void _handleAppsOrFail(Either<List<App>, FlowyError> appsOrFail) {
appsOrFail.fold(
(apps) => add(MenuEvent.didReceiveApps(left(apps))),
(error) => add(MenuEvent.didReceiveApps(right(error))),
@ -91,7 +91,7 @@ class MenuEvent with _$MenuEvent {
const factory MenuEvent.collapse() = Collapse;
const factory MenuEvent.openPage(HomeStackContext context) = OpenPage;
const factory MenuEvent.createApp(String name, {String? desc}) = CreateApp;
const factory MenuEvent.didReceiveApps(Either<List<App>, WorkspaceError> appsOrFail) = ReceiveApps;
const factory MenuEvent.didReceiveApps(Either<List<App>, FlowyError> appsOrFail) = ReceiveApps;
}
@freezed
@ -99,7 +99,7 @@ class MenuState with _$MenuState {
const factory MenuState({
required bool isCollapse,
required Option<List<App>> apps,
required Either<Unit, WorkspaceError> successOrFailure,
required Either<Unit, FlowyError> successOrFailure,
required HomeStackContext stackContext,
}) = _MenuState;

View File

@ -38,7 +38,7 @@ class _$MenuEventTearOff {
);
}
ReceiveApps didReceiveApps(Either<List<App>, WorkspaceError> appsOrFail) {
ReceiveApps didReceiveApps(Either<List<App>, FlowyError> appsOrFail) {
return ReceiveApps(
appsOrFail,
);
@ -57,7 +57,7 @@ mixin _$MenuEvent {
required TResult Function(HomeStackContext<dynamic, dynamic> context)
openPage,
required TResult Function(String name, String? desc) createApp,
required TResult Function(Either<List<App>, WorkspaceError> appsOrFail)
required TResult Function(Either<List<App>, FlowyError> appsOrFail)
didReceiveApps,
}) =>
throw _privateConstructorUsedError;
@ -67,7 +67,7 @@ mixin _$MenuEvent {
TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, WorkspaceError> appsOrFail)?
TResult Function(Either<List<App>, FlowyError> appsOrFail)?
didReceiveApps,
}) =>
throw _privateConstructorUsedError;
@ -77,7 +77,7 @@ mixin _$MenuEvent {
TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, WorkspaceError> appsOrFail)?
TResult Function(Either<List<App>, FlowyError> appsOrFail)?
didReceiveApps,
required TResult orElse(),
}) =>
@ -169,7 +169,7 @@ class _$_Initial implements _Initial {
required TResult Function(HomeStackContext<dynamic, dynamic> context)
openPage,
required TResult Function(String name, String? desc) createApp,
required TResult Function(Either<List<App>, WorkspaceError> appsOrFail)
required TResult Function(Either<List<App>, FlowyError> appsOrFail)
didReceiveApps,
}) {
return initial();
@ -182,7 +182,7 @@ class _$_Initial implements _Initial {
TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, WorkspaceError> appsOrFail)?
TResult Function(Either<List<App>, FlowyError> appsOrFail)?
didReceiveApps,
}) {
return initial?.call();
@ -195,7 +195,7 @@ class _$_Initial implements _Initial {
TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, WorkspaceError> appsOrFail)?
TResult Function(Either<List<App>, FlowyError> appsOrFail)?
didReceiveApps,
required TResult orElse(),
}) {
@ -292,7 +292,7 @@ class _$Collapse implements Collapse {
required TResult Function(HomeStackContext<dynamic, dynamic> context)
openPage,
required TResult Function(String name, String? desc) createApp,
required TResult Function(Either<List<App>, WorkspaceError> appsOrFail)
required TResult Function(Either<List<App>, FlowyError> appsOrFail)
didReceiveApps,
}) {
return collapse();
@ -305,7 +305,7 @@ class _$Collapse implements Collapse {
TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, WorkspaceError> appsOrFail)?
TResult Function(Either<List<App>, FlowyError> appsOrFail)?
didReceiveApps,
}) {
return collapse?.call();
@ -318,7 +318,7 @@ class _$Collapse implements Collapse {
TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, WorkspaceError> appsOrFail)?
TResult Function(Either<List<App>, FlowyError> appsOrFail)?
didReceiveApps,
required TResult orElse(),
}) {
@ -440,7 +440,7 @@ class _$OpenPage implements OpenPage {
required TResult Function(HomeStackContext<dynamic, dynamic> context)
openPage,
required TResult Function(String name, String? desc) createApp,
required TResult Function(Either<List<App>, WorkspaceError> appsOrFail)
required TResult Function(Either<List<App>, FlowyError> appsOrFail)
didReceiveApps,
}) {
return openPage(context);
@ -453,7 +453,7 @@ class _$OpenPage implements OpenPage {
TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, WorkspaceError> appsOrFail)?
TResult Function(Either<List<App>, FlowyError> appsOrFail)?
didReceiveApps,
}) {
return openPage?.call(context);
@ -466,7 +466,7 @@ class _$OpenPage implements OpenPage {
TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, WorkspaceError> appsOrFail)?
TResult Function(Either<List<App>, FlowyError> appsOrFail)?
didReceiveApps,
required TResult orElse(),
}) {
@ -606,7 +606,7 @@ class _$CreateApp implements CreateApp {
required TResult Function(HomeStackContext<dynamic, dynamic> context)
openPage,
required TResult Function(String name, String? desc) createApp,
required TResult Function(Either<List<App>, WorkspaceError> appsOrFail)
required TResult Function(Either<List<App>, FlowyError> appsOrFail)
didReceiveApps,
}) {
return createApp(name, desc);
@ -619,7 +619,7 @@ class _$CreateApp implements CreateApp {
TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, WorkspaceError> appsOrFail)?
TResult Function(Either<List<App>, FlowyError> appsOrFail)?
didReceiveApps,
}) {
return createApp?.call(name, desc);
@ -632,7 +632,7 @@ class _$CreateApp implements CreateApp {
TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, WorkspaceError> appsOrFail)?
TResult Function(Either<List<App>, FlowyError> appsOrFail)?
didReceiveApps,
required TResult orElse(),
}) {
@ -698,7 +698,7 @@ abstract class $ReceiveAppsCopyWith<$Res> {
factory $ReceiveAppsCopyWith(
ReceiveApps value, $Res Function(ReceiveApps) then) =
_$ReceiveAppsCopyWithImpl<$Res>;
$Res call({Either<List<App>, WorkspaceError> appsOrFail});
$Res call({Either<List<App>, FlowyError> appsOrFail});
}
/// @nodoc
@ -719,7 +719,7 @@ class _$ReceiveAppsCopyWithImpl<$Res> extends _$MenuEventCopyWithImpl<$Res>
appsOrFail == freezed
? _value.appsOrFail
: appsOrFail // ignore: cast_nullable_to_non_nullable
as Either<List<App>, WorkspaceError>,
as Either<List<App>, FlowyError>,
));
}
}
@ -730,7 +730,7 @@ class _$ReceiveApps implements ReceiveApps {
const _$ReceiveApps(this.appsOrFail);
@override
final Either<List<App>, WorkspaceError> appsOrFail;
final Either<List<App>, FlowyError> appsOrFail;
@override
String toString() {
@ -763,7 +763,7 @@ class _$ReceiveApps implements ReceiveApps {
required TResult Function(HomeStackContext<dynamic, dynamic> context)
openPage,
required TResult Function(String name, String? desc) createApp,
required TResult Function(Either<List<App>, WorkspaceError> appsOrFail)
required TResult Function(Either<List<App>, FlowyError> appsOrFail)
didReceiveApps,
}) {
return didReceiveApps(appsOrFail);
@ -776,7 +776,7 @@ class _$ReceiveApps implements ReceiveApps {
TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, WorkspaceError> appsOrFail)?
TResult Function(Either<List<App>, FlowyError> appsOrFail)?
didReceiveApps,
}) {
return didReceiveApps?.call(appsOrFail);
@ -789,7 +789,7 @@ class _$ReceiveApps implements ReceiveApps {
TResult Function()? collapse,
TResult Function(HomeStackContext<dynamic, dynamic> context)? openPage,
TResult Function(String name, String? desc)? createApp,
TResult Function(Either<List<App>, WorkspaceError> appsOrFail)?
TResult Function(Either<List<App>, FlowyError> appsOrFail)?
didReceiveApps,
required TResult orElse(),
}) {
@ -841,10 +841,10 @@ class _$ReceiveApps implements ReceiveApps {
}
abstract class ReceiveApps implements MenuEvent {
const factory ReceiveApps(Either<List<App>, WorkspaceError> appsOrFail) =
const factory ReceiveApps(Either<List<App>, FlowyError> appsOrFail) =
_$ReceiveApps;
Either<List<App>, WorkspaceError> get appsOrFail =>
Either<List<App>, FlowyError> get appsOrFail =>
throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ReceiveAppsCopyWith<ReceiveApps> get copyWith =>
@ -858,7 +858,7 @@ class _$MenuStateTearOff {
_MenuState call(
{required bool isCollapse,
required Option<List<App>> apps,
required Either<Unit, WorkspaceError> successOrFailure,
required Either<Unit, FlowyError> successOrFailure,
required HomeStackContext<dynamic, dynamic> stackContext}) {
return _MenuState(
isCollapse: isCollapse,
@ -876,7 +876,7 @@ const $MenuState = _$MenuStateTearOff();
mixin _$MenuState {
bool get isCollapse => throw _privateConstructorUsedError;
Option<List<App>> get apps => throw _privateConstructorUsedError;
Either<Unit, WorkspaceError> get successOrFailure =>
Either<Unit, FlowyError> get successOrFailure =>
throw _privateConstructorUsedError;
HomeStackContext<dynamic, dynamic> get stackContext =>
throw _privateConstructorUsedError;
@ -893,7 +893,7 @@ abstract class $MenuStateCopyWith<$Res> {
$Res call(
{bool isCollapse,
Option<List<App>> apps,
Either<Unit, WorkspaceError> successOrFailure,
Either<Unit, FlowyError> successOrFailure,
HomeStackContext<dynamic, dynamic> stackContext});
}
@ -924,7 +924,7 @@ class _$MenuStateCopyWithImpl<$Res> implements $MenuStateCopyWith<$Res> {
successOrFailure: successOrFailure == freezed
? _value.successOrFailure
: successOrFailure // ignore: cast_nullable_to_non_nullable
as Either<Unit, WorkspaceError>,
as Either<Unit, FlowyError>,
stackContext: stackContext == freezed
? _value.stackContext
: stackContext // ignore: cast_nullable_to_non_nullable
@ -942,7 +942,7 @@ abstract class _$MenuStateCopyWith<$Res> implements $MenuStateCopyWith<$Res> {
$Res call(
{bool isCollapse,
Option<List<App>> apps,
Either<Unit, WorkspaceError> successOrFailure,
Either<Unit, FlowyError> successOrFailure,
HomeStackContext<dynamic, dynamic> stackContext});
}
@ -974,7 +974,7 @@ class __$MenuStateCopyWithImpl<$Res> extends _$MenuStateCopyWithImpl<$Res>
successOrFailure: successOrFailure == freezed
? _value.successOrFailure
: successOrFailure // ignore: cast_nullable_to_non_nullable
as Either<Unit, WorkspaceError>,
as Either<Unit, FlowyError>,
stackContext: stackContext == freezed
? _value.stackContext
: stackContext // ignore: cast_nullable_to_non_nullable
@ -997,7 +997,7 @@ class _$_MenuState implements _MenuState {
@override
final Option<List<App>> apps;
@override
final Either<Unit, WorkspaceError> successOrFailure;
final Either<Unit, FlowyError> successOrFailure;
@override
final HomeStackContext<dynamic, dynamic> stackContext;
@ -1041,7 +1041,7 @@ abstract class _MenuState implements MenuState {
const factory _MenuState(
{required bool isCollapse,
required Option<List<App>> apps,
required Either<Unit, WorkspaceError> successOrFailure,
required Either<Unit, FlowyError> successOrFailure,
required HomeStackContext<dynamic, dynamic> stackContext}) = _$_MenuState;
@override
@ -1049,7 +1049,7 @@ abstract class _MenuState implements MenuState {
@override
Option<List<App>> get apps => throw _privateConstructorUsedError;
@override
Either<Unit, WorkspaceError> get successOrFailure =>
Either<Unit, FlowyError> get successOrFailure =>
throw _privateConstructorUsedError;
@override
HomeStackContext<dynamic, dynamic> get stackContext =>

View File

@ -1,7 +1,7 @@
import 'package:app_flowy/workspace/domain/i_user.dart';
import 'package:flowy_log/flowy_log.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/workspace_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:dartz/dartz.dart';
@ -39,8 +39,8 @@ class MenuUserBloc extends Bloc<MenuUserEvent, MenuUserState> {
result.fold((l) => null, (error) => Log.error(error));
}
void _profileUpdated(Either<UserProfile, UserError> userOrFailed) {}
void _workspacesUpdated(Either<List<Workspace>, WorkspaceError> workspacesOrFailed) {
void _profileUpdated(Either<UserProfile, FlowyError> userOrFailed) {}
void _workspacesUpdated(Either<List<Workspace>, FlowyError> workspacesOrFailed) {
// fetch workspaces
// iUserImpl.fetchWorkspaces().then((result) {
// result.fold(

View File

@ -2,7 +2,7 @@ import 'package:app_flowy/workspace/domain/i_trash.dart';
import 'package:dartz/dartz.dart';
import 'package:flowy_log/flowy_log.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/trash_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'trash_bloc.freezed.dart';
@ -45,14 +45,14 @@ class TrashBloc extends Bloc<TrashEvent, TrashState> {
);
}
Stream<TrashState> _handleResult(Either<dynamic, WorkspaceError> result) async* {
Stream<TrashState> _handleResult(Either<dynamic, FlowyError> result) async* {
yield result.fold(
(l) => state.copyWith(successOrFailure: left(unit)),
(error) => state.copyWith(successOrFailure: right(error)),
);
}
void _listenTrashUpdated(Either<List<Trash>, WorkspaceError> trashOrFailed) {
void _listenTrashUpdated(Either<List<Trash>, FlowyError> trashOrFailed) {
trashOrFailed.fold(
(trash) {
add(TrashEvent.didReceiveTrash(trash));
@ -84,7 +84,7 @@ class TrashEvent with _$TrashEvent {
class TrashState with _$TrashState {
const factory TrashState({
required List<Trash> objects,
required Either<Unit, WorkspaceError> successOrFailure,
required Either<Unit, FlowyError> successOrFailure,
}) = _TrashState;
factory TrashState.init() => TrashState(

View File

@ -980,7 +980,7 @@ class _$TrashStateTearOff {
_TrashState call(
{required List<Trash> objects,
required Either<Unit, WorkspaceError> successOrFailure}) {
required Either<Unit, FlowyError> successOrFailure}) {
return _TrashState(
objects: objects,
successOrFailure: successOrFailure,
@ -994,7 +994,7 @@ const $TrashState = _$TrashStateTearOff();
/// @nodoc
mixin _$TrashState {
List<Trash> get objects => throw _privateConstructorUsedError;
Either<Unit, WorkspaceError> get successOrFailure =>
Either<Unit, FlowyError> get successOrFailure =>
throw _privateConstructorUsedError;
@JsonKey(ignore: true)
@ -1008,7 +1008,7 @@ abstract class $TrashStateCopyWith<$Res> {
TrashState value, $Res Function(TrashState) then) =
_$TrashStateCopyWithImpl<$Res>;
$Res call(
{List<Trash> objects, Either<Unit, WorkspaceError> successOrFailure});
{List<Trash> objects, Either<Unit, FlowyError> successOrFailure});
}
/// @nodoc
@ -1032,7 +1032,7 @@ class _$TrashStateCopyWithImpl<$Res> implements $TrashStateCopyWith<$Res> {
successOrFailure: successOrFailure == freezed
? _value.successOrFailure
: successOrFailure // ignore: cast_nullable_to_non_nullable
as Either<Unit, WorkspaceError>,
as Either<Unit, FlowyError>,
));
}
}
@ -1044,7 +1044,7 @@ abstract class _$TrashStateCopyWith<$Res> implements $TrashStateCopyWith<$Res> {
__$TrashStateCopyWithImpl<$Res>;
@override
$Res call(
{List<Trash> objects, Either<Unit, WorkspaceError> successOrFailure});
{List<Trash> objects, Either<Unit, FlowyError> successOrFailure});
}
/// @nodoc
@ -1070,7 +1070,7 @@ class __$TrashStateCopyWithImpl<$Res> extends _$TrashStateCopyWithImpl<$Res>
successOrFailure: successOrFailure == freezed
? _value.successOrFailure
: successOrFailure // ignore: cast_nullable_to_non_nullable
as Either<Unit, WorkspaceError>,
as Either<Unit, FlowyError>,
));
}
}
@ -1083,7 +1083,7 @@ class _$_TrashState implements _TrashState {
@override
final List<Trash> objects;
@override
final Either<Unit, WorkspaceError> successOrFailure;
final Either<Unit, FlowyError> successOrFailure;
@override
String toString() {
@ -1117,12 +1117,12 @@ class _$_TrashState implements _TrashState {
abstract class _TrashState implements TrashState {
const factory _TrashState(
{required List<Trash> objects,
required Either<Unit, WorkspaceError> successOrFailure}) = _$_TrashState;
required Either<Unit, FlowyError> successOrFailure}) = _$_TrashState;
@override
List<Trash> get objects => throw _privateConstructorUsedError;
@override
Either<Unit, WorkspaceError> get successOrFailure =>
Either<Unit, FlowyError> get successOrFailure =>
throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)

View File

@ -1,6 +1,6 @@
import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/view_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:app_flowy/workspace/domain/i_view.dart';
@ -56,7 +56,7 @@ class ViewBloc extends Bloc<ViewEvent, ViewState> {
);
}
Stream<ViewState> _handleViewDidUpdate(Either<View, WorkspaceError> result) async* {
Stream<ViewState> _handleViewDidUpdate(Either<View, FlowyError> result) async* {
yield result.fold(
(view) => state.copyWith(view: view, successOrFailure: left(unit)),
(error) => state.copyWith(successOrFailure: right(error)),
@ -77,7 +77,7 @@ class ViewEvent with _$ViewEvent {
const factory ViewEvent.rename(String newName) = Rename;
const factory ViewEvent.delete() = Delete;
const factory ViewEvent.duplicate() = Duplicate;
const factory ViewEvent.viewDidUpdate(Either<View, WorkspaceError> result) = ViewDidUpdate;
const factory ViewEvent.viewDidUpdate(Either<View, FlowyError> result) = ViewDidUpdate;
}
@freezed
@ -85,7 +85,7 @@ class ViewState with _$ViewState {
const factory ViewState({
required View view,
required bool isEditing,
required Either<Unit, WorkspaceError> successOrFailure,
required Either<Unit, FlowyError> successOrFailure,
}) = _ViewState;
factory ViewState.init(View view) => ViewState(

View File

@ -41,7 +41,7 @@ class _$ViewEventTearOff {
return const Duplicate();
}
ViewDidUpdate viewDidUpdate(Either<View, WorkspaceError> result) {
ViewDidUpdate viewDidUpdate(Either<View, FlowyError> result) {
return ViewDidUpdate(
result,
);
@ -60,7 +60,7 @@ mixin _$ViewEvent {
required TResult Function(String newName) rename,
required TResult Function() delete,
required TResult Function() duplicate,
required TResult Function(Either<View, WorkspaceError> result)
required TResult Function(Either<View, FlowyError> result)
viewDidUpdate,
}) =>
throw _privateConstructorUsedError;
@ -71,7 +71,7 @@ mixin _$ViewEvent {
TResult Function(String newName)? rename,
TResult Function()? delete,
TResult Function()? duplicate,
TResult Function(Either<View, WorkspaceError> result)? viewDidUpdate,
TResult Function(Either<View, FlowyError> result)? viewDidUpdate,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
@ -81,7 +81,7 @@ mixin _$ViewEvent {
TResult Function(String newName)? rename,
TResult Function()? delete,
TResult Function()? duplicate,
TResult Function(Either<View, WorkspaceError> result)? viewDidUpdate,
TResult Function(Either<View, FlowyError> result)? viewDidUpdate,
required TResult orElse(),
}) =>
throw _privateConstructorUsedError;
@ -175,7 +175,7 @@ class _$Initial implements Initial {
required TResult Function(String newName) rename,
required TResult Function() delete,
required TResult Function() duplicate,
required TResult Function(Either<View, WorkspaceError> result)
required TResult Function(Either<View, FlowyError> result)
viewDidUpdate,
}) {
return initial();
@ -189,7 +189,7 @@ class _$Initial implements Initial {
TResult Function(String newName)? rename,
TResult Function()? delete,
TResult Function()? duplicate,
TResult Function(Either<View, WorkspaceError> result)? viewDidUpdate,
TResult Function(Either<View, FlowyError> result)? viewDidUpdate,
}) {
return initial?.call();
}
@ -202,7 +202,7 @@ class _$Initial implements Initial {
TResult Function(String newName)? rename,
TResult Function()? delete,
TResult Function()? duplicate,
TResult Function(Either<View, WorkspaceError> result)? viewDidUpdate,
TResult Function(Either<View, FlowyError> result)? viewDidUpdate,
required TResult orElse(),
}) {
if (initial != null) {
@ -328,7 +328,7 @@ class _$SetEditing implements SetEditing {
required TResult Function(String newName) rename,
required TResult Function() delete,
required TResult Function() duplicate,
required TResult Function(Either<View, WorkspaceError> result)
required TResult Function(Either<View, FlowyError> result)
viewDidUpdate,
}) {
return setIsEditing(isEditing);
@ -342,7 +342,7 @@ class _$SetEditing implements SetEditing {
TResult Function(String newName)? rename,
TResult Function()? delete,
TResult Function()? duplicate,
TResult Function(Either<View, WorkspaceError> result)? viewDidUpdate,
TResult Function(Either<View, FlowyError> result)? viewDidUpdate,
}) {
return setIsEditing?.call(isEditing);
}
@ -355,7 +355,7 @@ class _$SetEditing implements SetEditing {
TResult Function(String newName)? rename,
TResult Function()? delete,
TResult Function()? duplicate,
TResult Function(Either<View, WorkspaceError> result)? viewDidUpdate,
TResult Function(Either<View, FlowyError> result)? viewDidUpdate,
required TResult orElse(),
}) {
if (setIsEditing != null) {
@ -484,7 +484,7 @@ class _$Rename implements Rename {
required TResult Function(String newName) rename,
required TResult Function() delete,
required TResult Function() duplicate,
required TResult Function(Either<View, WorkspaceError> result)
required TResult Function(Either<View, FlowyError> result)
viewDidUpdate,
}) {
return rename(newName);
@ -498,7 +498,7 @@ class _$Rename implements Rename {
TResult Function(String newName)? rename,
TResult Function()? delete,
TResult Function()? duplicate,
TResult Function(Either<View, WorkspaceError> result)? viewDidUpdate,
TResult Function(Either<View, FlowyError> result)? viewDidUpdate,
}) {
return rename?.call(newName);
}
@ -511,7 +511,7 @@ class _$Rename implements Rename {
TResult Function(String newName)? rename,
TResult Function()? delete,
TResult Function()? duplicate,
TResult Function(Either<View, WorkspaceError> result)? viewDidUpdate,
TResult Function(Either<View, FlowyError> result)? viewDidUpdate,
required TResult orElse(),
}) {
if (rename != null) {
@ -614,7 +614,7 @@ class _$Delete implements Delete {
required TResult Function(String newName) rename,
required TResult Function() delete,
required TResult Function() duplicate,
required TResult Function(Either<View, WorkspaceError> result)
required TResult Function(Either<View, FlowyError> result)
viewDidUpdate,
}) {
return delete();
@ -628,7 +628,7 @@ class _$Delete implements Delete {
TResult Function(String newName)? rename,
TResult Function()? delete,
TResult Function()? duplicate,
TResult Function(Either<View, WorkspaceError> result)? viewDidUpdate,
TResult Function(Either<View, FlowyError> result)? viewDidUpdate,
}) {
return delete?.call();
}
@ -641,7 +641,7 @@ class _$Delete implements Delete {
TResult Function(String newName)? rename,
TResult Function()? delete,
TResult Function()? duplicate,
TResult Function(Either<View, WorkspaceError> result)? viewDidUpdate,
TResult Function(Either<View, FlowyError> result)? viewDidUpdate,
required TResult orElse(),
}) {
if (delete != null) {
@ -740,7 +740,7 @@ class _$Duplicate implements Duplicate {
required TResult Function(String newName) rename,
required TResult Function() delete,
required TResult Function() duplicate,
required TResult Function(Either<View, WorkspaceError> result)
required TResult Function(Either<View, FlowyError> result)
viewDidUpdate,
}) {
return duplicate();
@ -754,7 +754,7 @@ class _$Duplicate implements Duplicate {
TResult Function(String newName)? rename,
TResult Function()? delete,
TResult Function()? duplicate,
TResult Function(Either<View, WorkspaceError> result)? viewDidUpdate,
TResult Function(Either<View, FlowyError> result)? viewDidUpdate,
}) {
return duplicate?.call();
}
@ -767,7 +767,7 @@ class _$Duplicate implements Duplicate {
TResult Function(String newName)? rename,
TResult Function()? delete,
TResult Function()? duplicate,
TResult Function(Either<View, WorkspaceError> result)? viewDidUpdate,
TResult Function(Either<View, FlowyError> result)? viewDidUpdate,
required TResult orElse(),
}) {
if (duplicate != null) {
@ -829,7 +829,7 @@ abstract class $ViewDidUpdateCopyWith<$Res> {
factory $ViewDidUpdateCopyWith(
ViewDidUpdate value, $Res Function(ViewDidUpdate) then) =
_$ViewDidUpdateCopyWithImpl<$Res>;
$Res call({Either<View, WorkspaceError> result});
$Res call({Either<View, FlowyError> result});
}
/// @nodoc
@ -850,7 +850,7 @@ class _$ViewDidUpdateCopyWithImpl<$Res> extends _$ViewEventCopyWithImpl<$Res>
result == freezed
? _value.result
: result // ignore: cast_nullable_to_non_nullable
as Either<View, WorkspaceError>,
as Either<View, FlowyError>,
));
}
}
@ -861,7 +861,7 @@ class _$ViewDidUpdate implements ViewDidUpdate {
const _$ViewDidUpdate(this.result);
@override
final Either<View, WorkspaceError> result;
final Either<View, FlowyError> result;
@override
String toString() {
@ -893,7 +893,7 @@ class _$ViewDidUpdate implements ViewDidUpdate {
required TResult Function(String newName) rename,
required TResult Function() delete,
required TResult Function() duplicate,
required TResult Function(Either<View, WorkspaceError> result)
required TResult Function(Either<View, FlowyError> result)
viewDidUpdate,
}) {
return viewDidUpdate(result);
@ -907,7 +907,7 @@ class _$ViewDidUpdate implements ViewDidUpdate {
TResult Function(String newName)? rename,
TResult Function()? delete,
TResult Function()? duplicate,
TResult Function(Either<View, WorkspaceError> result)? viewDidUpdate,
TResult Function(Either<View, FlowyError> result)? viewDidUpdate,
}) {
return viewDidUpdate?.call(result);
}
@ -920,7 +920,7 @@ class _$ViewDidUpdate implements ViewDidUpdate {
TResult Function(String newName)? rename,
TResult Function()? delete,
TResult Function()? duplicate,
TResult Function(Either<View, WorkspaceError> result)? viewDidUpdate,
TResult Function(Either<View, FlowyError> result)? viewDidUpdate,
required TResult orElse(),
}) {
if (viewDidUpdate != null) {
@ -974,10 +974,10 @@ class _$ViewDidUpdate implements ViewDidUpdate {
}
abstract class ViewDidUpdate implements ViewEvent {
const factory ViewDidUpdate(Either<View, WorkspaceError> result) =
const factory ViewDidUpdate(Either<View, FlowyError> result) =
_$ViewDidUpdate;
Either<View, WorkspaceError> get result => throw _privateConstructorUsedError;
Either<View, FlowyError> get result => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ViewDidUpdateCopyWith<ViewDidUpdate> get copyWith =>
throw _privateConstructorUsedError;
@ -990,7 +990,7 @@ class _$ViewStateTearOff {
_ViewState call(
{required View view,
required bool isEditing,
required Either<Unit, WorkspaceError> successOrFailure}) {
required Either<Unit, FlowyError> successOrFailure}) {
return _ViewState(
view: view,
isEditing: isEditing,
@ -1006,7 +1006,7 @@ const $ViewState = _$ViewStateTearOff();
mixin _$ViewState {
View get view => throw _privateConstructorUsedError;
bool get isEditing => throw _privateConstructorUsedError;
Either<Unit, WorkspaceError> get successOrFailure =>
Either<Unit, FlowyError> get successOrFailure =>
throw _privateConstructorUsedError;
@JsonKey(ignore: true)
@ -1021,7 +1021,7 @@ abstract class $ViewStateCopyWith<$Res> {
$Res call(
{View view,
bool isEditing,
Either<Unit, WorkspaceError> successOrFailure});
Either<Unit, FlowyError> successOrFailure});
}
/// @nodoc
@ -1050,7 +1050,7 @@ class _$ViewStateCopyWithImpl<$Res> implements $ViewStateCopyWith<$Res> {
successOrFailure: successOrFailure == freezed
? _value.successOrFailure
: successOrFailure // ignore: cast_nullable_to_non_nullable
as Either<Unit, WorkspaceError>,
as Either<Unit, FlowyError>,
));
}
}
@ -1064,7 +1064,7 @@ abstract class _$ViewStateCopyWith<$Res> implements $ViewStateCopyWith<$Res> {
$Res call(
{View view,
bool isEditing,
Either<Unit, WorkspaceError> successOrFailure});
Either<Unit, FlowyError> successOrFailure});
}
/// @nodoc
@ -1094,7 +1094,7 @@ class __$ViewStateCopyWithImpl<$Res> extends _$ViewStateCopyWithImpl<$Res>
successOrFailure: successOrFailure == freezed
? _value.successOrFailure
: successOrFailure // ignore: cast_nullable_to_non_nullable
as Either<Unit, WorkspaceError>,
as Either<Unit, FlowyError>,
));
}
}
@ -1112,7 +1112,7 @@ class _$_ViewState implements _ViewState {
@override
final bool isEditing;
@override
final Either<Unit, WorkspaceError> successOrFailure;
final Either<Unit, FlowyError> successOrFailure;
@override
String toString() {
@ -1150,14 +1150,14 @@ abstract class _ViewState implements ViewState {
const factory _ViewState(
{required View view,
required bool isEditing,
required Either<Unit, WorkspaceError> successOrFailure}) = _$_ViewState;
required Either<Unit, FlowyError> successOrFailure}) = _$_ViewState;
@override
View get view => throw _privateConstructorUsedError;
@override
bool get isEditing => throw _privateConstructorUsedError;
@override
Either<Unit, WorkspaceError> get successOrFailure =>
Either<Unit, FlowyError> get successOrFailure =>
throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)

View File

@ -2,7 +2,7 @@ import 'package:app_flowy/workspace/domain/i_user.dart';
import 'package:app_flowy/workspace/infrastructure/repos/user_repo.dart';
import 'package:flowy_log/flowy_log.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/workspace_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:dartz/dartz.dart';
@ -76,7 +76,7 @@ class WelcomeBloc extends Bloc<WelcomeEvent, WelcomeState> {
);
}
void _workspacesUpdated(Either<List<Workspace>, WorkspaceError> workspacesOrFail) {
void _workspacesUpdated(Either<List<Workspace>, FlowyError> workspacesOrFail) {
add(WelcomeEvent.workspacesReveived(workspacesOrFail));
}
}
@ -87,7 +87,7 @@ class WelcomeEvent with _$WelcomeEvent {
// const factory WelcomeEvent.fetchWorkspaces() = FetchWorkspace;
const factory WelcomeEvent.createWorkspace(String name, String desc) = CreateWorkspace;
const factory WelcomeEvent.openWorkspace(Workspace workspace) = OpenWorkspace;
const factory WelcomeEvent.workspacesReveived(Either<List<Workspace>, WorkspaceError> workspacesOrFail) =
const factory WelcomeEvent.workspacesReveived(Either<List<Workspace>, FlowyError> workspacesOrFail) =
WorkspacesReceived;
}
@ -96,7 +96,7 @@ class WelcomeState with _$WelcomeState {
const factory WelcomeState({
required bool isLoading,
required List<Workspace> workspaces,
required Either<Unit, WorkspaceError> successOrFailure,
required Either<Unit, FlowyError> successOrFailure,
}) = _WelcomeState;
factory WelcomeState.initial() => WelcomeState(

View File

@ -35,7 +35,7 @@ class _$WelcomeEventTearOff {
}
WorkspacesReceived workspacesReveived(
Either<List<Workspace>, WorkspaceError> workspacesOrFail) {
Either<List<Workspace>, FlowyError> workspacesOrFail) {
return WorkspacesReceived(
workspacesOrFail,
);
@ -53,7 +53,7 @@ mixin _$WelcomeEvent {
required TResult Function(String name, String desc) createWorkspace,
required TResult Function(Workspace workspace) openWorkspace,
required TResult Function(
Either<List<Workspace>, WorkspaceError> workspacesOrFail)
Either<List<Workspace>, FlowyError> workspacesOrFail)
workspacesReveived,
}) =>
throw _privateConstructorUsedError;
@ -62,7 +62,7 @@ mixin _$WelcomeEvent {
TResult Function()? initial,
TResult Function(String name, String desc)? createWorkspace,
TResult Function(Workspace workspace)? openWorkspace,
TResult Function(Either<List<Workspace>, WorkspaceError> workspacesOrFail)?
TResult Function(Either<List<Workspace>, FlowyError> workspacesOrFail)?
workspacesReveived,
}) =>
throw _privateConstructorUsedError;
@ -71,7 +71,7 @@ mixin _$WelcomeEvent {
TResult Function()? initial,
TResult Function(String name, String desc)? createWorkspace,
TResult Function(Workspace workspace)? openWorkspace,
TResult Function(Either<List<Workspace>, WorkspaceError> workspacesOrFail)?
TResult Function(Either<List<Workspace>, FlowyError> workspacesOrFail)?
workspacesReveived,
required TResult orElse(),
}) =>
@ -160,7 +160,7 @@ class _$Initial implements Initial {
required TResult Function(String name, String desc) createWorkspace,
required TResult Function(Workspace workspace) openWorkspace,
required TResult Function(
Either<List<Workspace>, WorkspaceError> workspacesOrFail)
Either<List<Workspace>, FlowyError> workspacesOrFail)
workspacesReveived,
}) {
return initial();
@ -172,7 +172,7 @@ class _$Initial implements Initial {
TResult Function()? initial,
TResult Function(String name, String desc)? createWorkspace,
TResult Function(Workspace workspace)? openWorkspace,
TResult Function(Either<List<Workspace>, WorkspaceError> workspacesOrFail)?
TResult Function(Either<List<Workspace>, FlowyError> workspacesOrFail)?
workspacesReveived,
}) {
return initial?.call();
@ -184,7 +184,7 @@ class _$Initial implements Initial {
TResult Function()? initial,
TResult Function(String name, String desc)? createWorkspace,
TResult Function(Workspace workspace)? openWorkspace,
TResult Function(Either<List<Workspace>, WorkspaceError> workspacesOrFail)?
TResult Function(Either<List<Workspace>, FlowyError> workspacesOrFail)?
workspacesReveived,
required TResult orElse(),
}) {
@ -316,7 +316,7 @@ class _$CreateWorkspace implements CreateWorkspace {
required TResult Function(String name, String desc) createWorkspace,
required TResult Function(Workspace workspace) openWorkspace,
required TResult Function(
Either<List<Workspace>, WorkspaceError> workspacesOrFail)
Either<List<Workspace>, FlowyError> workspacesOrFail)
workspacesReveived,
}) {
return createWorkspace(name, desc);
@ -328,7 +328,7 @@ class _$CreateWorkspace implements CreateWorkspace {
TResult Function()? initial,
TResult Function(String name, String desc)? createWorkspace,
TResult Function(Workspace workspace)? openWorkspace,
TResult Function(Either<List<Workspace>, WorkspaceError> workspacesOrFail)?
TResult Function(Either<List<Workspace>, FlowyError> workspacesOrFail)?
workspacesReveived,
}) {
return createWorkspace?.call(name, desc);
@ -340,7 +340,7 @@ class _$CreateWorkspace implements CreateWorkspace {
TResult Function()? initial,
TResult Function(String name, String desc)? createWorkspace,
TResult Function(Workspace workspace)? openWorkspace,
TResult Function(Either<List<Workspace>, WorkspaceError> workspacesOrFail)?
TResult Function(Either<List<Workspace>, FlowyError> workspacesOrFail)?
workspacesReveived,
required TResult orElse(),
}) {
@ -467,7 +467,7 @@ class _$OpenWorkspace implements OpenWorkspace {
required TResult Function(String name, String desc) createWorkspace,
required TResult Function(Workspace workspace) openWorkspace,
required TResult Function(
Either<List<Workspace>, WorkspaceError> workspacesOrFail)
Either<List<Workspace>, FlowyError> workspacesOrFail)
workspacesReveived,
}) {
return openWorkspace(workspace);
@ -479,7 +479,7 @@ class _$OpenWorkspace implements OpenWorkspace {
TResult Function()? initial,
TResult Function(String name, String desc)? createWorkspace,
TResult Function(Workspace workspace)? openWorkspace,
TResult Function(Either<List<Workspace>, WorkspaceError> workspacesOrFail)?
TResult Function(Either<List<Workspace>, FlowyError> workspacesOrFail)?
workspacesReveived,
}) {
return openWorkspace?.call(workspace);
@ -491,7 +491,7 @@ class _$OpenWorkspace implements OpenWorkspace {
TResult Function()? initial,
TResult Function(String name, String desc)? createWorkspace,
TResult Function(Workspace workspace)? openWorkspace,
TResult Function(Either<List<Workspace>, WorkspaceError> workspacesOrFail)?
TResult Function(Either<List<Workspace>, FlowyError> workspacesOrFail)?
workspacesReveived,
required TResult orElse(),
}) {
@ -553,7 +553,7 @@ abstract class $WorkspacesReceivedCopyWith<$Res> {
factory $WorkspacesReceivedCopyWith(
WorkspacesReceived value, $Res Function(WorkspacesReceived) then) =
_$WorkspacesReceivedCopyWithImpl<$Res>;
$Res call({Either<List<Workspace>, WorkspaceError> workspacesOrFail});
$Res call({Either<List<Workspace>, FlowyError> workspacesOrFail});
}
/// @nodoc
@ -575,7 +575,7 @@ class _$WorkspacesReceivedCopyWithImpl<$Res>
workspacesOrFail == freezed
? _value.workspacesOrFail
: workspacesOrFail // ignore: cast_nullable_to_non_nullable
as Either<List<Workspace>, WorkspaceError>,
as Either<List<Workspace>, FlowyError>,
));
}
}
@ -586,7 +586,7 @@ class _$WorkspacesReceived implements WorkspacesReceived {
const _$WorkspacesReceived(this.workspacesOrFail);
@override
final Either<List<Workspace>, WorkspaceError> workspacesOrFail;
final Either<List<Workspace>, FlowyError> workspacesOrFail;
@override
String toString() {
@ -619,7 +619,7 @@ class _$WorkspacesReceived implements WorkspacesReceived {
required TResult Function(String name, String desc) createWorkspace,
required TResult Function(Workspace workspace) openWorkspace,
required TResult Function(
Either<List<Workspace>, WorkspaceError> workspacesOrFail)
Either<List<Workspace>, FlowyError> workspacesOrFail)
workspacesReveived,
}) {
return workspacesReveived(workspacesOrFail);
@ -631,7 +631,7 @@ class _$WorkspacesReceived implements WorkspacesReceived {
TResult Function()? initial,
TResult Function(String name, String desc)? createWorkspace,
TResult Function(Workspace workspace)? openWorkspace,
TResult Function(Either<List<Workspace>, WorkspaceError> workspacesOrFail)?
TResult Function(Either<List<Workspace>, FlowyError> workspacesOrFail)?
workspacesReveived,
}) {
return workspacesReveived?.call(workspacesOrFail);
@ -643,7 +643,7 @@ class _$WorkspacesReceived implements WorkspacesReceived {
TResult Function()? initial,
TResult Function(String name, String desc)? createWorkspace,
TResult Function(Workspace workspace)? openWorkspace,
TResult Function(Either<List<Workspace>, WorkspaceError> workspacesOrFail)?
TResult Function(Either<List<Workspace>, FlowyError> workspacesOrFail)?
workspacesReveived,
required TResult orElse(),
}) {
@ -693,10 +693,10 @@ class _$WorkspacesReceived implements WorkspacesReceived {
abstract class WorkspacesReceived implements WelcomeEvent {
const factory WorkspacesReceived(
Either<List<Workspace>, WorkspaceError> workspacesOrFail) =
Either<List<Workspace>, FlowyError> workspacesOrFail) =
_$WorkspacesReceived;
Either<List<Workspace>, WorkspaceError> get workspacesOrFail =>
Either<List<Workspace>, FlowyError> get workspacesOrFail =>
throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$WorkspacesReceivedCopyWith<WorkspacesReceived> get copyWith =>
@ -710,7 +710,7 @@ class _$WelcomeStateTearOff {
_WelcomeState call(
{required bool isLoading,
required List<Workspace> workspaces,
required Either<Unit, WorkspaceError> successOrFailure}) {
required Either<Unit, FlowyError> successOrFailure}) {
return _WelcomeState(
isLoading: isLoading,
workspaces: workspaces,
@ -726,7 +726,7 @@ const $WelcomeState = _$WelcomeStateTearOff();
mixin _$WelcomeState {
bool get isLoading => throw _privateConstructorUsedError;
List<Workspace> get workspaces => throw _privateConstructorUsedError;
Either<Unit, WorkspaceError> get successOrFailure =>
Either<Unit, FlowyError> get successOrFailure =>
throw _privateConstructorUsedError;
@JsonKey(ignore: true)
@ -742,7 +742,7 @@ abstract class $WelcomeStateCopyWith<$Res> {
$Res call(
{bool isLoading,
List<Workspace> workspaces,
Either<Unit, WorkspaceError> successOrFailure});
Either<Unit, FlowyError> successOrFailure});
}
/// @nodoc
@ -771,7 +771,7 @@ class _$WelcomeStateCopyWithImpl<$Res> implements $WelcomeStateCopyWith<$Res> {
successOrFailure: successOrFailure == freezed
? _value.successOrFailure
: successOrFailure // ignore: cast_nullable_to_non_nullable
as Either<Unit, WorkspaceError>,
as Either<Unit, FlowyError>,
));
}
}
@ -786,7 +786,7 @@ abstract class _$WelcomeStateCopyWith<$Res>
$Res call(
{bool isLoading,
List<Workspace> workspaces,
Either<Unit, WorkspaceError> successOrFailure});
Either<Unit, FlowyError> successOrFailure});
}
/// @nodoc
@ -817,7 +817,7 @@ class __$WelcomeStateCopyWithImpl<$Res> extends _$WelcomeStateCopyWithImpl<$Res>
successOrFailure: successOrFailure == freezed
? _value.successOrFailure
: successOrFailure // ignore: cast_nullable_to_non_nullable
as Either<Unit, WorkspaceError>,
as Either<Unit, FlowyError>,
));
}
}
@ -835,7 +835,7 @@ class _$_WelcomeState implements _WelcomeState {
@override
final List<Workspace> workspaces;
@override
final Either<Unit, WorkspaceError> successOrFailure;
final Either<Unit, FlowyError> successOrFailure;
@override
String toString() {
@ -874,7 +874,7 @@ abstract class _WelcomeState implements WelcomeState {
const factory _WelcomeState(
{required bool isLoading,
required List<Workspace> workspaces,
required Either<Unit, WorkspaceError> successOrFailure}) =
required Either<Unit, FlowyError> successOrFailure}) =
_$_WelcomeState;
@override
@ -882,7 +882,7 @@ abstract class _WelcomeState implements WelcomeState {
@override
List<Workspace> get workspaces => throw _privateConstructorUsedError;
@override
Either<Unit, WorkspaceError> get successOrFailure =>
Either<Unit, FlowyError> get successOrFailure =>
throw _privateConstructorUsedError;
@override
@JsonKey(ignore: true)

View File

@ -1,18 +1,18 @@
import 'package:flowy_sdk/protobuf/flowy-core-infra/protobuf.dart';
import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
typedef AppUpdatedCallback = void Function(App app);
typedef AppViewsChangeCallback = void Function(Either<List<View>, WorkspaceError> viewsOrFailed);
typedef AppViewsChangeCallback = void Function(Either<List<View>, FlowyError> viewsOrFailed);
abstract class IApp {
Future<Either<List<View>, WorkspaceError>> getViews();
Future<Either<List<View>, FlowyError>> getViews();
Future<Either<View, WorkspaceError>> createView({required String name, String? desc, required ViewType viewType});
Future<Either<View, FlowyError>> createView({required String name, String? desc, required ViewType viewType});
Future<Either<Unit, WorkspaceError>> delete();
Future<Either<Unit, FlowyError>> delete();
Future<Either<Unit, WorkspaceError>> rename(String newName);
Future<Either<Unit, FlowyError>> rename(String newName);
}
abstract class IAppListenr {

View File

@ -1,10 +1,10 @@
import 'dart:async';
import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/protobuf/flowy-collaboration/doc.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
abstract class IDoc {
Future<Either<DocDelta, WorkspaceError>> readDoc();
Future<Either<DocDelta, WorkspaceError>> composeDelta({required String json});
Future<Either<Unit, WorkspaceError>> closeDoc();
Future<Either<DocDelta, FlowyError>> readDoc();
Future<Either<DocDelta, FlowyError>> composeDelta({required String json});
Future<Either<Unit, FlowyError>> closeDoc();
}

View File

@ -1,12 +1,12 @@
import 'dart:async';
import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/protobuf.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
abstract class IShare {
Future<Either<ExportData, WorkspaceError>> exportText(String docId);
Future<Either<ExportData, FlowyError>> exportText(String docId);
Future<Either<ExportData, WorkspaceError>> exportMarkdown(String docId);
Future<Either<ExportData, FlowyError>> exportMarkdown(String docId);
Future<Either<ExportData, WorkspaceError>> exportURL(String docId);
Future<Either<ExportData, FlowyError>> exportURL(String docId);
}

View File

@ -1,21 +1,21 @@
import 'dart:async';
import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/trash_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
abstract class ITrash {
Future<Either<List<Trash>, WorkspaceError>> readTrash();
Future<Either<List<Trash>, FlowyError>> readTrash();
Future<Either<Unit, WorkspaceError>> putback(String trashId);
Future<Either<Unit, FlowyError>> putback(String trashId);
Future<Either<Unit, WorkspaceError>> deleteViews(List<Tuple2<String, TrashType>> trashList);
Future<Either<Unit, FlowyError>> deleteViews(List<Tuple2<String, TrashType>> trashList);
Future<Either<Unit, WorkspaceError>> restoreAll();
Future<Either<Unit, FlowyError>> restoreAll();
Future<Either<Unit, WorkspaceError>> deleteAll();
Future<Either<Unit, FlowyError>> deleteAll();
}
typedef TrashUpdatedCallback = void Function(Either<List<Trash>, WorkspaceError> trashOrFailed);
typedef TrashUpdatedCallback = void Function(Either<List<Trash>, FlowyError> trashOrFailed);
abstract class ITrashListener {
void start(TrashUpdatedCallback updateCallback);

View File

@ -1,24 +1,22 @@
import 'package:dartz/dartz.dart';
import 'package:flowy_infra/notifier.dart';
import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-user-infra/protobuf.dart' show UserProfile;
import 'package:flowy_sdk/protobuf/flowy-core-infra/workspace_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
export 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
export 'package:flowy_sdk/protobuf/flowy-user-infra/protobuf.dart' show UserProfile;
abstract class IUser {
UserProfile get user;
Future<Either<UserProfile, UserError>> fetchUserProfile(String userId);
Future<Either<List<Workspace>, WorkspaceError>> fetchWorkspaces();
Future<Either<Unit, WorkspaceError>> deleteWorkspace(String workspaceId);
Future<Either<Unit, UserError>> signOut();
Future<Either<Unit, UserError>> initUser();
Future<Either<UserProfile, FlowyError>> fetchUserProfile(String userId);
Future<Either<List<Workspace>, FlowyError>> fetchWorkspaces();
Future<Either<Unit, FlowyError>> deleteWorkspace(String workspaceId);
Future<Either<Unit, FlowyError>> signOut();
Future<Either<Unit, FlowyError>> initUser();
}
typedef UserProfileUpdatedNotifierValue = Either<UserProfile, UserError>;
typedef AuthNotifierValue = Either<Unit, UserError>;
typedef WorkspaceUpdatedNotifierValue = Either<List<Workspace>, WorkspaceError>;
typedef UserProfileUpdatedNotifierValue = Either<UserProfile, FlowyError>;
typedef AuthNotifierValue = Either<Unit, FlowyError>;
typedef WorkspaceUpdatedNotifierValue = Either<List<Workspace>, FlowyError>;
abstract class IUserListener {
void start();

View File

@ -1,22 +1,22 @@
import 'package:flowy_sdk/protobuf/flowy-core-infra/view_create.pb.dart';
import 'package:dartz/dartz.dart';
import 'package:flowy_infra/notifier.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
typedef ViewUpdatedCallback = void Function(Either<View, WorkspaceError>);
typedef ViewUpdatedCallback = void Function(Either<View, FlowyError>);
typedef DeleteNotifierValue = Either<View, WorkspaceError>;
typedef UpdateNotifierValue = Either<View, WorkspaceError>;
typedef RestoreNotifierValue = Either<View, WorkspaceError>;
typedef DeleteNotifierValue = Either<View, FlowyError>;
typedef UpdateNotifierValue = Either<View, FlowyError>;
typedef RestoreNotifierValue = Either<View, FlowyError>;
abstract class IView {
View get view;
Future<Either<Unit, WorkspaceError>> delete();
Future<Either<Unit, FlowyError>> delete();
Future<Either<View, WorkspaceError>> rename(String newName);
Future<Either<View, FlowyError>> rename(String newName);
Future<Either<Unit, WorkspaceError>> duplicate();
Future<Either<Unit, FlowyError>> duplicate();
}
abstract class IViewListener {

View File

@ -1,15 +1,15 @@
import 'package:flowy_sdk/protobuf/flowy-core-infra/protobuf.dart';
import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
typedef WorkspaceAppsChangedCallback = void Function(Either<List<App>, WorkspaceError> appsOrFail);
typedef WorkspaceAppsChangedCallback = void Function(Either<List<App>, FlowyError> appsOrFail);
typedef WorkspaceUpdatedCallback = void Function(String name, String desc);
abstract class IWorkspace {
Future<Either<App, WorkspaceError>> createApp({required String name, String? desc});
Future<Either<App, FlowyError>> createApp({required String name, String? desc});
Future<Either<List<App>, WorkspaceError>> getApps();
Future<Either<List<App>, FlowyError>> getApps();
}
abstract class IWorkspaceListener {

View File

@ -2,7 +2,7 @@ import 'package:app_flowy/workspace/infrastructure/repos/app_repo.dart';
import 'package:dartz/dartz.dart';
import 'package:app_flowy/workspace/domain/i_app.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/view_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
export 'package:app_flowy/workspace/domain/i_app.dart';
class IAppImpl extends IApp {
@ -12,12 +12,12 @@ class IAppImpl extends IApp {
});
@override
Future<Either<List<View>, WorkspaceError>> getViews() {
Future<Either<List<View>, FlowyError>> getViews() {
return repo.getViews();
}
@override
Future<Either<View, WorkspaceError>> createView({required String name, String? desc, required ViewType viewType}) {
Future<Either<View, FlowyError>> createView({required String name, String? desc, required ViewType viewType}) {
return repo.createView(name, desc ?? "", viewType).then((result) {
return result.fold(
(view) => left(view),
@ -27,12 +27,12 @@ class IAppImpl extends IApp {
}
@override
Future<Either<Unit, WorkspaceError>> delete() {
Future<Either<Unit, FlowyError>> delete() {
return repo.delete();
}
@override
Future<Either<Unit, WorkspaceError>> rename(String newName) {
Future<Either<Unit, FlowyError>> rename(String newName) {
return repo.updateApp(name: newName);
}
}

View File

@ -5,7 +5,7 @@ import 'package:dartz/dartz.dart';
import 'package:app_flowy/workspace/domain/i_doc.dart';
import 'package:app_flowy/workspace/infrastructure/repos/doc_repo.dart';
import 'package:flowy_sdk/protobuf/flowy-collaboration/doc.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
class IDocImpl extends IDoc {
DocRepository repo;
@ -13,18 +13,18 @@ class IDocImpl extends IDoc {
IDocImpl({required this.repo});
@override
Future<Either<Unit, WorkspaceError>> closeDoc() {
Future<Either<Unit, FlowyError>> closeDoc() {
return repo.closeDoc();
}
@override
Future<Either<DocDelta, WorkspaceError>> readDoc() async {
Future<Either<DocDelta, FlowyError>> readDoc() async {
final docOrFail = await repo.readDoc();
return docOrFail;
}
@override
Future<Either<DocDelta, WorkspaceError>> composeDelta({required String json}) {
Future<Either<DocDelta, FlowyError>> composeDelta({required String json}) {
return repo.composeDelta(data: json);
}
}

View File

@ -1,6 +1,6 @@
import 'package:app_flowy/workspace/domain/i_share.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/protobuf.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:dartz/dartz.dart';
import 'repos/share_repo.dart';
@ -11,17 +11,17 @@ class IShareImpl extends IShare {
IShareImpl({required this.repo});
@override
Future<Either<ExportData, WorkspaceError>> exportText(String docId) {
Future<Either<ExportData, FlowyError>> exportText(String docId) {
return repo.export(docId, ExportType.Text);
}
@override
Future<Either<ExportData, WorkspaceError>> exportMarkdown(String docId) {
Future<Either<ExportData, FlowyError>> exportMarkdown(String docId) {
return repo.export(docId, ExportType.Markdown);
}
@override
Future<Either<ExportData, WorkspaceError>> exportURL(String docId) {
Future<Either<ExportData, FlowyError>> exportURL(String docId) {
return repo.export(docId, ExportType.Link);
}
}

View File

@ -2,7 +2,7 @@ import 'package:app_flowy/workspace/domain/i_trash.dart';
import 'package:app_flowy/workspace/infrastructure/repos/trash_repo.dart';
import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/trash_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
class ITrashImpl implements ITrash {
TrashRepo repo;
@ -10,7 +10,7 @@ class ITrashImpl implements ITrash {
ITrashImpl({required this.repo});
@override
Future<Either<List<Trash>, WorkspaceError>> readTrash() {
Future<Either<List<Trash>, FlowyError>> readTrash() {
return repo.readTrash().then((result) {
return result.fold(
(repeatedTrash) => left(repeatedTrash.items),
@ -20,22 +20,22 @@ class ITrashImpl implements ITrash {
}
@override
Future<Either<Unit, WorkspaceError>> putback(String trashId) {
Future<Either<Unit, FlowyError>> putback(String trashId) {
return repo.putback(trashId);
}
@override
Future<Either<Unit, WorkspaceError>> deleteAll() {
Future<Either<Unit, FlowyError>> deleteAll() {
return repo.deleteAll();
}
@override
Future<Either<Unit, WorkspaceError>> restoreAll() {
Future<Either<Unit, FlowyError>> restoreAll() {
return repo.restoreAll();
}
@override
Future<Either<Unit, WorkspaceError>> deleteViews(List<Tuple2<String, TrashType>> trashList) {
Future<Either<Unit, FlowyError>> deleteViews(List<Tuple2<String, TrashType>> trashList) {
return repo.deleteViews(trashList);
}
}

View File

@ -10,7 +10,7 @@ import 'package:flowy_sdk/protobuf/flowy-user-infra/errors.pb.dart';
// import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart' as user_error;
import 'package:flowy_sdk/protobuf/flowy-user/observable.pb.dart' as user;
import 'package:flowy_sdk/protobuf/flowy-core-infra/workspace_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/observable.pb.dart';
export 'package:app_flowy/workspace/domain/i_user.dart';
export 'package:app_flowy/workspace/infrastructure/repos/user_repo.dart';
@ -24,17 +24,17 @@ class IUserImpl extends IUser {
});
@override
Future<Either<Unit, WorkspaceError>> deleteWorkspace(String workspaceId) {
Future<Either<Unit, FlowyError>> deleteWorkspace(String workspaceId) {
return repo.deleteWorkspace(workspaceId: workspaceId);
}
@override
Future<Either<UserProfile, UserError>> fetchUserProfile(String userId) {
Future<Either<UserProfile, FlowyError>> fetchUserProfile(String userId) {
return repo.fetchUserProfile(userId: userId);
}
@override
Future<Either<Unit, UserError>> signOut() {
Future<Either<Unit, FlowyError>> signOut() {
return repo.signOut();
}
@ -42,12 +42,12 @@ class IUserImpl extends IUser {
UserProfile get user => repo.user;
@override
Future<Either<List<Workspace>, WorkspaceError>> fetchWorkspaces() {
Future<Either<List<Workspace>, FlowyError>> fetchWorkspaces() {
return repo.getWorkspaces();
}
@override
Future<Either<Unit, UserError>> initUser() {
Future<Either<Unit, FlowyError>> initUser() {
return repo.initUser();
}
}
@ -88,7 +88,7 @@ class IUserListenerImpl extends IUserListener {
await _subscription?.cancel();
}
void _notificationCallback(WorkspaceNotification ty, Either<Uint8List, WorkspaceError> result) {
void _notificationCallback(WorkspaceNotification ty, Either<Uint8List, FlowyError> result) {
switch (ty) {
case WorkspaceNotification.UserCreateWorkspace:
case WorkspaceNotification.UserDeleteWorkspace:
@ -101,7 +101,7 @@ class IUserListenerImpl extends IUserListener {
case WorkspaceNotification.UserUnauthorized:
result.fold(
(_) {},
(error) => authDidChangedNotifier.value = right(UserError.create()..code = ErrorCode.UserUnauthorized.value),
(error) => authDidChangedNotifier.value = right(FlowyError.create()..code = ErrorCode.UserUnauthorized.value),
);
break;
default:
@ -109,7 +109,7 @@ class IUserListenerImpl extends IUserListener {
}
}
void _userNotificationCallback(user.UserNotification ty, Either<Uint8List, UserError> result) {
void _userNotificationCallback(user.UserNotification ty, Either<Uint8List, FlowyError> result) {
switch (ty) {
case user.UserNotification.UserUnauthorized:
result.fold(

View File

@ -3,7 +3,7 @@ import 'package:app_flowy/workspace/infrastructure/repos/view_repo.dart';
import 'package:flowy_infra/notifier.dart';
import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/view_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
class IViewImpl extends IView {
ViewRepository repo;
@ -14,7 +14,7 @@ class IViewImpl extends IView {
View get view => repo.view;
@override
Future<Either<Unit, WorkspaceError>> delete() {
Future<Either<Unit, FlowyError>> delete() {
return repo.delete().then((result) {
return result.fold(
(_) => left(unit),
@ -24,12 +24,12 @@ class IViewImpl extends IView {
}
@override
Future<Either<View, WorkspaceError>> rename(String newName) {
Future<Either<View, FlowyError>> rename(String newName) {
return repo.updateView(name: newName);
}
@override
Future<Either<Unit, WorkspaceError>> duplicate() {
Future<Either<Unit, FlowyError>> duplicate() {
return repo.duplicate();
}
}

View File

@ -2,7 +2,7 @@ import 'package:app_flowy/workspace/domain/i_workspace.dart';
import 'package:app_flowy/workspace/infrastructure/repos/workspace_repo.dart';
import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/app_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
export 'package:app_flowy/workspace/domain/i_workspace.dart';
@ -13,12 +13,12 @@ class IWorkspaceImpl extends IWorkspace {
});
@override
Future<Either<App, WorkspaceError>> createApp({required String name, String? desc}) {
Future<Either<App, FlowyError>> createApp({required String name, String? desc}) {
return repo.createApp(name, desc ?? "");
}
@override
Future<Either<List<App>, WorkspaceError>> getApps() {
Future<Either<List<App>, FlowyError>> getApps() {
return repo.getApps().then((result) {
return result.fold(
(apps) => left(apps),

View File

@ -9,7 +9,7 @@ import 'package:flowy_sdk/protobuf/flowy-core-infra/app_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/app_query.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/app_update.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/view_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/observable.pb.dart';
import 'package:flowy_sdk/rust_stream.dart';
import 'helper.dart';
@ -20,13 +20,13 @@ class AppRepository {
required this.appId,
});
Future<Either<App, WorkspaceError>> getAppDesc() {
Future<Either<App, FlowyError>> getAppDesc() {
final request = QueryAppRequest.create()..appIds.add(appId);
return WorkspaceEventReadApp(request).send();
}
Future<Either<View, WorkspaceError>> createView(String name, String desc, ViewType viewType) {
Future<Either<View, FlowyError>> createView(String name, String desc, ViewType viewType) {
final request = CreateViewRequest.create()
..belongToId = appId
..name = name
@ -36,7 +36,7 @@ class AppRepository {
return WorkspaceEventCreateView(request).send();
}
Future<Either<List<View>, WorkspaceError>> getViews() {
Future<Either<List<View>, FlowyError>> getViews() {
final request = QueryAppRequest.create()..appIds.add(appId);
return WorkspaceEventReadApp(request).send().then((result) {
@ -47,12 +47,12 @@ class AppRepository {
});
}
Future<Either<Unit, WorkspaceError>> delete() {
Future<Either<Unit, FlowyError>> delete() {
final request = QueryAppRequest.create()..appIds.add(appId);
return WorkspaceEventDeleteApp(request).send();
}
Future<Either<Unit, WorkspaceError>> updateApp({String? name}) {
Future<Either<Unit, FlowyError>> updateApp({String? name}) {
UpdateAppRequest request = UpdateAppRequest.create()..appId = appId;
if (name != null) {
@ -80,7 +80,7 @@ class AppListenerRepository {
_subscription = RustStreamReceiver.listen((observable) => _parser.parse(observable));
}
void _bservableCallback(WorkspaceNotification ty, Either<Uint8List, WorkspaceError> result) {
void _bservableCallback(WorkspaceNotification ty, Either<Uint8List, FlowyError> result) {
switch (ty) {
case WorkspaceNotification.AppViewsChanged:
if (_viewsChanged != null) {

View File

@ -2,7 +2,7 @@ import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/dispatch/dispatch.dart';
import 'package:flowy_sdk/protobuf/flowy-collaboration/doc.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/view_query.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
class DocRepository {
final String docId;
@ -10,19 +10,19 @@ class DocRepository {
required this.docId,
});
Future<Either<DocDelta, WorkspaceError>> readDoc() {
Future<Either<DocDelta, FlowyError>> readDoc() {
final request = QueryViewRequest(viewIds: [docId]);
return WorkspaceEventOpenView(request).send();
}
Future<Either<DocDelta, WorkspaceError>> composeDelta({required String data}) {
Future<Either<DocDelta, FlowyError>> composeDelta({required String data}) {
final request = DocDelta.create()
..docId = docId
..data = data;
return WorkspaceEventApplyDocDelta(request).send();
}
Future<Either<Unit, WorkspaceError>> closeDoc() {
Future<Either<Unit, FlowyError>> closeDoc() {
final request = QueryViewRequest(viewIds: [docId]);
return WorkspaceEventCloseView(request).send();
}

View File

@ -2,30 +2,30 @@ import 'dart:typed_data';
import 'package:flowy_sdk/protobuf/dart-notify/protobuf.dart';
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/observable.pb.dart';
typedef UserNotificationCallback = void Function(UserNotification, Either<Uint8List, UserError>);
typedef UserNotificationCallback = void Function(UserNotification, Either<Uint8List, FlowyError>);
class UserNotificationParser extends NotificationParser<UserNotification, UserError> {
class UserNotificationParser extends NotificationParser<UserNotification, FlowyError> {
UserNotificationParser({required String id, required UserNotificationCallback callback})
: super(
id: id,
callback: callback,
tyParser: (ty) => UserNotification.valueOf(ty),
errorParser: (bytes) => UserError.fromBuffer(bytes),
errorParser: (bytes) => FlowyError.fromBuffer(bytes),
);
}
typedef NotificationCallback = void Function(WorkspaceNotification, Either<Uint8List, WorkspaceError>);
typedef NotificationCallback = void Function(WorkspaceNotification, Either<Uint8List, FlowyError>);
class WorkspaceNotificationParser extends NotificationParser<WorkspaceNotification, WorkspaceError> {
class WorkspaceNotificationParser extends NotificationParser<WorkspaceNotification, FlowyError> {
WorkspaceNotificationParser({String? id, required NotificationCallback callback})
: super(
id: id,
callback: callback,
tyParser: (ty) => WorkspaceNotification.valueOf(ty),
errorParser: (bytes) => WorkspaceError.fromBuffer(bytes),
errorParser: (bytes) => FlowyError.fromBuffer(bytes),
);
}

View File

@ -2,10 +2,10 @@ import 'dart:async';
import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/dispatch/dispatch.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/protobuf.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
class ShareRepo {
Future<Either<ExportData, WorkspaceError>> export(String docId, ExportType type) {
Future<Either<ExportData, FlowyError>> export(String docId, ExportType type) {
final request = ExportRequest.create()
..docId = docId
..exportType = type;

View File

@ -6,22 +6,22 @@ import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/dispatch/dispatch.dart';
import 'package:flowy_sdk/protobuf/dart-notify/subject.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/trash_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/observable.pb.dart';
import 'package:flowy_sdk/rust_stream.dart';
class TrashRepo {
Future<Either<RepeatedTrash, WorkspaceError>> readTrash() {
Future<Either<RepeatedTrash, FlowyError>> readTrash() {
return WorkspaceEventReadTrash().send();
}
Future<Either<Unit, WorkspaceError>> putback(String trashId) {
Future<Either<Unit, FlowyError>> putback(String trashId) {
final id = TrashIdentifier.create()..id = trashId;
return WorkspaceEventPutbackTrash(id).send();
}
Future<Either<Unit, WorkspaceError>> deleteViews(List<Tuple2<String, TrashType>> trashList) {
Future<Either<Unit, FlowyError>> deleteViews(List<Tuple2<String, TrashType>> trashList) {
final items = trashList.map((trash) {
return TrashIdentifier.create()
..id = trash.value1
@ -32,11 +32,11 @@ class TrashRepo {
return WorkspaceEventDeleteTrash(trashIdentifiers).send();
}
Future<Either<Unit, WorkspaceError>> restoreAll() {
Future<Either<Unit, FlowyError>> restoreAll() {
return WorkspaceEventRestoreAll().send();
}
Future<Either<Unit, WorkspaceError>> deleteAll() {
Future<Either<Unit, FlowyError>> deleteAll() {
return WorkspaceEventDeleteAll().send();
}
}
@ -52,7 +52,7 @@ class TrashListenerRepo {
_subscription = RustStreamReceiver.listen((observable) => _parser.parse(observable));
}
void _bservableCallback(WorkspaceNotification ty, Either<Uint8List, WorkspaceError> result) {
void _bservableCallback(WorkspaceNotification ty, Either<Uint8List, FlowyError> result) {
switch (ty) {
case WorkspaceNotification.TrashUpdated:
if (_trashUpdated != null) {

View File

@ -4,7 +4,7 @@ import 'package:flowy_sdk/dispatch/dispatch.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/workspace_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/workspace_query.pb.dart';
import 'package:app_flowy/workspace/domain/i_user.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
class UserRepo {
final UserProfile user;
@ -12,23 +12,23 @@ class UserRepo {
required this.user,
});
Future<Either<UserProfile, UserError>> fetchUserProfile({required String userId}) {
Future<Either<UserProfile, FlowyError>> fetchUserProfile({required String userId}) {
return UserEventGetUserProfile().send();
}
Future<Either<Unit, WorkspaceError>> deleteWorkspace({required String workspaceId}) {
Future<Either<Unit, FlowyError>> deleteWorkspace({required String workspaceId}) {
throw UnimplementedError();
}
Future<Either<Unit, UserError>> signOut() {
Future<Either<Unit, FlowyError>> signOut() {
return UserEventSignOut().send();
}
Future<Either<Unit, UserError>> initUser() async {
Future<Either<Unit, FlowyError>> initUser() async {
return UserEventInitUser().send();
}
Future<Either<List<Workspace>, WorkspaceError>> getWorkspaces() {
Future<Either<List<Workspace>, FlowyError>> getWorkspaces() {
final request = QueryWorkspaceRequest.create();
return WorkspaceEventReadWorkspaces(request).send().then((result) {
@ -39,7 +39,7 @@ class UserRepo {
});
}
Future<Either<Workspace, WorkspaceError>> openWorkspace(String workspaceId) {
Future<Either<Workspace, FlowyError>> openWorkspace(String workspaceId) {
final request = QueryWorkspaceRequest.create()..workspaceId = workspaceId;
return WorkspaceEventOpenWorkspace(request).send().then((result) {
return result.fold(
@ -49,7 +49,7 @@ class UserRepo {
});
}
Future<Either<Workspace, WorkspaceError>> createWorkspace(String name, String desc) {
Future<Either<Workspace, FlowyError>> createWorkspace(String name, String desc) {
final request = CreateWorkspaceRequest.create()
..name = name
..desc = desc;

View File

@ -6,7 +6,7 @@ import 'package:flowy_sdk/protobuf/dart-notify/subject.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/view_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/view_query.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/view_update.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/observable.pb.dart';
import 'package:flowy_sdk/rust_stream.dart';
@ -21,12 +21,12 @@ class ViewRepository {
required this.view,
});
Future<Either<View, WorkspaceError>> readView() {
Future<Either<View, FlowyError>> readView() {
final request = QueryViewRequest(viewIds: [view.id]);
return WorkspaceEventReadView(request).send();
}
Future<Either<View, WorkspaceError>> updateView({String? name, String? desc}) {
Future<Either<View, FlowyError>> updateView({String? name, String? desc}) {
final request = UpdateViewRequest.create()..viewId = view.id;
if (name != null) {
@ -40,12 +40,12 @@ class ViewRepository {
return WorkspaceEventUpdateView(request).send();
}
Future<Either<Unit, WorkspaceError>> delete() {
Future<Either<Unit, FlowyError>> delete() {
final request = QueryViewRequest.create()..viewIds.add(view.id);
return WorkspaceEventDeleteView(request).send();
}
Future<Either<Unit, WorkspaceError>> duplicate() {
Future<Either<Unit, FlowyError>> duplicate() {
final request = QueryViewRequest.create()..viewIds.add(view.id);
return WorkspaceEventDuplicateView(request).send();
}
@ -74,7 +74,7 @@ class ViewListenerRepository {
_subscription = RustStreamReceiver.listen((observable) => _parser.parse(observable));
}
void _handleObservableType(WorkspaceNotification ty, Either<Uint8List, WorkspaceError> result) {
void _handleObservableType(WorkspaceNotification ty, Either<Uint8List, FlowyError> result) {
switch (ty) {
case WorkspaceNotification.ViewUpdated:
result.fold(

View File

@ -10,7 +10,7 @@ import 'package:flowy_sdk/protobuf/flowy-user-infra/protobuf.dart' show UserProf
import 'package:flowy_sdk/protobuf/flowy-core-infra/app_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/workspace_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/workspace_query.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/observable.pb.dart';
import 'package:flowy_sdk/rust_stream.dart';
@ -27,7 +27,7 @@ class WorkspaceRepo {
required this.workspaceId,
});
Future<Either<App, WorkspaceError>> createApp(String appName, String desc) {
Future<Either<App, FlowyError>> createApp(String appName, String desc) {
final request = CreateAppRequest.create()
..name = appName
..workspaceId = workspaceId
@ -35,7 +35,7 @@ class WorkspaceRepo {
return WorkspaceEventCreateApp(request).send();
}
Future<Either<Workspace, WorkspaceError>> getWorkspace() {
Future<Either<Workspace, FlowyError>> getWorkspace() {
final request = QueryWorkspaceRequest.create()..workspaceId = workspaceId;
return WorkspaceEventReadWorkspaces(request).send().then((result) {
return result.fold(
@ -43,7 +43,7 @@ class WorkspaceRepo {
assert(workspaces.items.length == 1);
if (workspaces.items.isEmpty) {
return right(WorkspaceError.create()..msg = LocaleKeys.workspace_notFoundError.tr());
return right(FlowyError.create()..msg = LocaleKeys.workspace_notFoundError.tr());
} else {
return left(workspaces.items[0]);
}
@ -53,7 +53,7 @@ class WorkspaceRepo {
});
}
Future<Either<List<App>, WorkspaceError>> getApps() {
Future<Either<List<App>, FlowyError>> getApps() {
final request = QueryWorkspaceRequest.create()..workspaceId = workspaceId;
return WorkspaceEventReadWorkspaceApps(request).send().then((result) {
return result.fold(
@ -94,7 +94,7 @@ class WorkspaceListenerRepo {
_subscription = RustStreamReceiver.listen((observable) => _parser.parse(observable));
}
void _handleObservableType(WorkspaceNotification ty, Either<Uint8List, WorkspaceError> result) {
void _handleObservableType(WorkspaceNotification ty, Either<Uint8List, FlowyError> result) {
switch (ty) {
case WorkspaceNotification.WorkspaceUpdated:
if (_update != null) {

View File

@ -14,7 +14,7 @@ import 'package:flowy_infra_ui/widget/rounded_button.dart';
import 'package:flowy_log/flowy_log.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/export.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core-infra/view_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flutter/material.dart';
import 'package:dartz/dartz.dart' as dartz;
import 'package:flutter_bloc/flutter_bloc.dart';
@ -200,7 +200,7 @@ class DocShareButton extends StatelessWidget {
}
}
void _handleExportError(WorkspaceError error) {}
void _handleExportError(FlowyError error) {}
void _showActionList(BuildContext context, Offset offset) {
final actionList = ShareActions(onSelected: (result) {

View File

@ -6,7 +6,7 @@ class WorkspaceEventCreateWorkspace {
CreateWorkspaceRequest request;
WorkspaceEventCreateWorkspace(this.request);
Future<Either<Workspace, WorkspaceError>> send() {
Future<Either<Workspace, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.CreateWorkspace.toString()
..payload = requestToBytes(this.request);
@ -14,7 +14,7 @@ class WorkspaceEventCreateWorkspace {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(Workspace.fromBuffer(okBytes)),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -22,13 +22,13 @@ class WorkspaceEventCreateWorkspace {
class WorkspaceEventReadCurWorkspace {
WorkspaceEventReadCurWorkspace();
Future<Either<CurrentWorkspaceSetting, WorkspaceError>> send() {
Future<Either<CurrentWorkspaceSetting, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.ReadCurWorkspace.toString();
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
(okBytes) => left(CurrentWorkspaceSetting.fromBuffer(okBytes)),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -37,7 +37,7 @@ class WorkspaceEventReadWorkspaces {
QueryWorkspaceRequest request;
WorkspaceEventReadWorkspaces(this.request);
Future<Either<RepeatedWorkspace, WorkspaceError>> send() {
Future<Either<RepeatedWorkspace, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.ReadWorkspaces.toString()
..payload = requestToBytes(this.request);
@ -45,7 +45,7 @@ class WorkspaceEventReadWorkspaces {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(RepeatedWorkspace.fromBuffer(okBytes)),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -54,7 +54,7 @@ class WorkspaceEventDeleteWorkspace {
QueryWorkspaceRequest request;
WorkspaceEventDeleteWorkspace(this.request);
Future<Either<Unit, WorkspaceError>> send() {
Future<Either<Unit, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.DeleteWorkspace.toString()
..payload = requestToBytes(this.request);
@ -62,7 +62,7 @@ class WorkspaceEventDeleteWorkspace {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(bytes) => left(unit),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -71,7 +71,7 @@ class WorkspaceEventOpenWorkspace {
QueryWorkspaceRequest request;
WorkspaceEventOpenWorkspace(this.request);
Future<Either<Workspace, WorkspaceError>> send() {
Future<Either<Workspace, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.OpenWorkspace.toString()
..payload = requestToBytes(this.request);
@ -79,7 +79,7 @@ class WorkspaceEventOpenWorkspace {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(Workspace.fromBuffer(okBytes)),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -88,7 +88,7 @@ class WorkspaceEventReadWorkspaceApps {
QueryWorkspaceRequest request;
WorkspaceEventReadWorkspaceApps(this.request);
Future<Either<RepeatedApp, WorkspaceError>> send() {
Future<Either<RepeatedApp, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.ReadWorkspaceApps.toString()
..payload = requestToBytes(this.request);
@ -96,7 +96,7 @@ class WorkspaceEventReadWorkspaceApps {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(RepeatedApp.fromBuffer(okBytes)),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -105,7 +105,7 @@ class WorkspaceEventCreateApp {
CreateAppRequest request;
WorkspaceEventCreateApp(this.request);
Future<Either<App, WorkspaceError>> send() {
Future<Either<App, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.CreateApp.toString()
..payload = requestToBytes(this.request);
@ -113,7 +113,7 @@ class WorkspaceEventCreateApp {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(App.fromBuffer(okBytes)),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -122,7 +122,7 @@ class WorkspaceEventDeleteApp {
QueryAppRequest request;
WorkspaceEventDeleteApp(this.request);
Future<Either<Unit, WorkspaceError>> send() {
Future<Either<Unit, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.DeleteApp.toString()
..payload = requestToBytes(this.request);
@ -130,7 +130,7 @@ class WorkspaceEventDeleteApp {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(bytes) => left(unit),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -139,7 +139,7 @@ class WorkspaceEventReadApp {
QueryAppRequest request;
WorkspaceEventReadApp(this.request);
Future<Either<App, WorkspaceError>> send() {
Future<Either<App, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.ReadApp.toString()
..payload = requestToBytes(this.request);
@ -147,7 +147,7 @@ class WorkspaceEventReadApp {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(App.fromBuffer(okBytes)),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -156,7 +156,7 @@ class WorkspaceEventUpdateApp {
UpdateAppRequest request;
WorkspaceEventUpdateApp(this.request);
Future<Either<Unit, WorkspaceError>> send() {
Future<Either<Unit, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.UpdateApp.toString()
..payload = requestToBytes(this.request);
@ -164,7 +164,7 @@ class WorkspaceEventUpdateApp {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(bytes) => left(unit),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -173,7 +173,7 @@ class WorkspaceEventCreateView {
CreateViewRequest request;
WorkspaceEventCreateView(this.request);
Future<Either<View, WorkspaceError>> send() {
Future<Either<View, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.CreateView.toString()
..payload = requestToBytes(this.request);
@ -181,7 +181,7 @@ class WorkspaceEventCreateView {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(View.fromBuffer(okBytes)),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -190,7 +190,7 @@ class WorkspaceEventReadView {
QueryViewRequest request;
WorkspaceEventReadView(this.request);
Future<Either<View, WorkspaceError>> send() {
Future<Either<View, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.ReadView.toString()
..payload = requestToBytes(this.request);
@ -198,7 +198,7 @@ class WorkspaceEventReadView {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(View.fromBuffer(okBytes)),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -207,7 +207,7 @@ class WorkspaceEventUpdateView {
UpdateViewRequest request;
WorkspaceEventUpdateView(this.request);
Future<Either<View, WorkspaceError>> send() {
Future<Either<View, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.UpdateView.toString()
..payload = requestToBytes(this.request);
@ -215,7 +215,7 @@ class WorkspaceEventUpdateView {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(View.fromBuffer(okBytes)),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -224,7 +224,7 @@ class WorkspaceEventDeleteView {
QueryViewRequest request;
WorkspaceEventDeleteView(this.request);
Future<Either<Unit, WorkspaceError>> send() {
Future<Either<Unit, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.DeleteView.toString()
..payload = requestToBytes(this.request);
@ -232,7 +232,7 @@ class WorkspaceEventDeleteView {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(bytes) => left(unit),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -241,7 +241,7 @@ class WorkspaceEventDuplicateView {
QueryViewRequest request;
WorkspaceEventDuplicateView(this.request);
Future<Either<Unit, WorkspaceError>> send() {
Future<Either<Unit, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.DuplicateView.toString()
..payload = requestToBytes(this.request);
@ -249,7 +249,7 @@ class WorkspaceEventDuplicateView {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(bytes) => left(unit),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -257,13 +257,13 @@ class WorkspaceEventDuplicateView {
class WorkspaceEventCopyLink {
WorkspaceEventCopyLink();
Future<Either<Unit, WorkspaceError>> send() {
Future<Either<Unit, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.CopyLink.toString();
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
(bytes) => left(unit),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -272,7 +272,7 @@ class WorkspaceEventOpenView {
QueryViewRequest request;
WorkspaceEventOpenView(this.request);
Future<Either<DocDelta, WorkspaceError>> send() {
Future<Either<DocDelta, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.OpenView.toString()
..payload = requestToBytes(this.request);
@ -280,7 +280,7 @@ class WorkspaceEventOpenView {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(DocDelta.fromBuffer(okBytes)),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -289,7 +289,7 @@ class WorkspaceEventCloseView {
QueryViewRequest request;
WorkspaceEventCloseView(this.request);
Future<Either<Unit, WorkspaceError>> send() {
Future<Either<Unit, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.CloseView.toString()
..payload = requestToBytes(this.request);
@ -297,7 +297,7 @@ class WorkspaceEventCloseView {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(bytes) => left(unit),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -305,13 +305,13 @@ class WorkspaceEventCloseView {
class WorkspaceEventReadTrash {
WorkspaceEventReadTrash();
Future<Either<RepeatedTrash, WorkspaceError>> send() {
Future<Either<RepeatedTrash, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.ReadTrash.toString();
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
(okBytes) => left(RepeatedTrash.fromBuffer(okBytes)),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -320,7 +320,7 @@ class WorkspaceEventPutbackTrash {
TrashIdentifier request;
WorkspaceEventPutbackTrash(this.request);
Future<Either<Unit, WorkspaceError>> send() {
Future<Either<Unit, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.PutbackTrash.toString()
..payload = requestToBytes(this.request);
@ -328,7 +328,7 @@ class WorkspaceEventPutbackTrash {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(bytes) => left(unit),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -337,7 +337,7 @@ class WorkspaceEventDeleteTrash {
TrashIdentifiers request;
WorkspaceEventDeleteTrash(this.request);
Future<Either<Unit, WorkspaceError>> send() {
Future<Either<Unit, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.DeleteTrash.toString()
..payload = requestToBytes(this.request);
@ -345,7 +345,7 @@ class WorkspaceEventDeleteTrash {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(bytes) => left(unit),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -353,13 +353,13 @@ class WorkspaceEventDeleteTrash {
class WorkspaceEventRestoreAll {
WorkspaceEventRestoreAll();
Future<Either<Unit, WorkspaceError>> send() {
Future<Either<Unit, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.RestoreAll.toString();
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
(bytes) => left(unit),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -367,13 +367,13 @@ class WorkspaceEventRestoreAll {
class WorkspaceEventDeleteAll {
WorkspaceEventDeleteAll();
Future<Either<Unit, WorkspaceError>> send() {
Future<Either<Unit, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.DeleteAll.toString();
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
(bytes) => left(unit),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -382,7 +382,7 @@ class WorkspaceEventApplyDocDelta {
DocDelta request;
WorkspaceEventApplyDocDelta(this.request);
Future<Either<DocDelta, WorkspaceError>> send() {
Future<Either<DocDelta, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.ApplyDocDelta.toString()
..payload = requestToBytes(this.request);
@ -390,7 +390,7 @@ class WorkspaceEventApplyDocDelta {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(DocDelta.fromBuffer(okBytes)),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -399,7 +399,7 @@ class WorkspaceEventExportDocument {
ExportRequest request;
WorkspaceEventExportDocument(this.request);
Future<Either<ExportData, WorkspaceError>> send() {
Future<Either<ExportData, FlowyError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.ExportDocument.toString()
..payload = requestToBytes(this.request);
@ -407,7 +407,7 @@ class WorkspaceEventExportDocument {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(ExportData.fromBuffer(okBytes)),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -432,13 +432,13 @@ class NetworkEventUpdateNetworkType {
class UserEventInitUser {
UserEventInitUser();
Future<Either<Unit, UserError>> send() {
Future<Either<Unit, FlowyError>> send() {
final request = FFIRequest.create()
..event = UserEvent.InitUser.toString();
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
(bytes) => left(unit),
(errBytes) => right(UserError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -447,7 +447,7 @@ class UserEventSignIn {
SignInRequest request;
UserEventSignIn(this.request);
Future<Either<UserProfile, UserError>> send() {
Future<Either<UserProfile, FlowyError>> send() {
final request = FFIRequest.create()
..event = UserEvent.SignIn.toString()
..payload = requestToBytes(this.request);
@ -455,7 +455,7 @@ class UserEventSignIn {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(UserProfile.fromBuffer(okBytes)),
(errBytes) => right(UserError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -464,7 +464,7 @@ class UserEventSignUp {
SignUpRequest request;
UserEventSignUp(this.request);
Future<Either<UserProfile, UserError>> send() {
Future<Either<UserProfile, FlowyError>> send() {
final request = FFIRequest.create()
..event = UserEvent.SignUp.toString()
..payload = requestToBytes(this.request);
@ -472,7 +472,7 @@ class UserEventSignUp {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(UserProfile.fromBuffer(okBytes)),
(errBytes) => right(UserError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -480,13 +480,13 @@ class UserEventSignUp {
class UserEventSignOut {
UserEventSignOut();
Future<Either<Unit, UserError>> send() {
Future<Either<Unit, FlowyError>> send() {
final request = FFIRequest.create()
..event = UserEvent.SignOut.toString();
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
(bytes) => left(unit),
(errBytes) => right(UserError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -495,7 +495,7 @@ class UserEventUpdateUser {
UpdateUserRequest request;
UserEventUpdateUser(this.request);
Future<Either<Unit, UserError>> send() {
Future<Either<Unit, FlowyError>> send() {
final request = FFIRequest.create()
..event = UserEvent.UpdateUser.toString()
..payload = requestToBytes(this.request);
@ -503,7 +503,7 @@ class UserEventUpdateUser {
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(bytes) => left(unit),
(errBytes) => right(UserError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -511,13 +511,13 @@ class UserEventUpdateUser {
class UserEventGetUserProfile {
UserEventGetUserProfile();
Future<Either<UserProfile, UserError>> send() {
Future<Either<UserProfile, FlowyError>> send() {
final request = FFIRequest.create()
..event = UserEvent.GetUserProfile.toString();
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
(okBytes) => left(UserProfile.fromBuffer(okBytes)),
(errBytes) => right(UserError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}
@ -525,13 +525,13 @@ class UserEventGetUserProfile {
class UserEventCheckUser {
UserEventCheckUser();
Future<Either<UserProfile, UserError>> send() {
Future<Either<UserProfile, FlowyError>> send() {
final request = FFIRequest.create()
..event = UserEvent.CheckUser.toString();
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
(okBytes) => left(UserProfile.fromBuffer(okBytes)),
(errBytes) => right(UserError.fromBuffer(errBytes)),
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
));
}
}

View File

@ -6,9 +6,7 @@ import 'package:flowy_sdk/protobuf/dart-ffi/ffi_response.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-net/event.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-net/network_state.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-user/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-user/event.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/errors.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-core/event.pb.dart';
import 'package:isolates/isolates.dart';
import 'package:isolates/ports.dart';

View File

@ -1,7 +1,11 @@
///
// Generated code. Do not modify.
// source: errors.proto
// source: error_code.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
import 'dart:core' as $core;
export 'error_code.pbenum.dart';

View File

@ -0,0 +1,82 @@
///
// Generated code. Do not modify.
// source: error_code.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
// ignore_for_file: UNDEFINED_SHOWN_NAME
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
class ErrorCode extends $pb.ProtobufEnum {
static const ErrorCode Internal = ErrorCode._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'Internal');
static const ErrorCode UserUnauthorized = ErrorCode._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserUnauthorized');
static const ErrorCode RecordNotFound = ErrorCode._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'RecordNotFound');
static const ErrorCode WorkspaceNameInvalid = ErrorCode._(100, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceNameInvalid');
static const ErrorCode WorkspaceIdInvalid = ErrorCode._(101, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceIdInvalid');
static const ErrorCode AppColorStyleInvalid = ErrorCode._(102, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppColorStyleInvalid');
static const ErrorCode WorkspaceDescTooLong = ErrorCode._(103, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceDescTooLong');
static const ErrorCode WorkspaceNameTooLong = ErrorCode._(104, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceNameTooLong');
static const ErrorCode AppIdInvalid = ErrorCode._(110, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppIdInvalid');
static const ErrorCode AppNameInvalid = ErrorCode._(111, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppNameInvalid');
static const ErrorCode ViewNameInvalid = ErrorCode._(120, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewNameInvalid');
static const ErrorCode ViewThumbnailInvalid = ErrorCode._(121, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewThumbnailInvalid');
static const ErrorCode ViewIdInvalid = ErrorCode._(122, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewIdInvalid');
static const ErrorCode ViewDescTooLong = ErrorCode._(123, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewDescTooLong');
static const ErrorCode ViewDataInvalid = ErrorCode._(124, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewDataInvalid');
static const ErrorCode ViewNameTooLong = ErrorCode._(125, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewNameTooLong');
static const ErrorCode ConnectError = ErrorCode._(200, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ConnectError');
static const ErrorCode EmailIsEmpty = ErrorCode._(300, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'EmailIsEmpty');
static const ErrorCode EmailFormatInvalid = ErrorCode._(301, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'EmailFormatInvalid');
static const ErrorCode EmailAlreadyExists = ErrorCode._(302, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'EmailAlreadyExists');
static const ErrorCode PasswordIsEmpty = ErrorCode._(303, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'PasswordIsEmpty');
static const ErrorCode PasswordTooLong = ErrorCode._(304, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'PasswordTooLong');
static const ErrorCode PasswordContainsForbidCharacters = ErrorCode._(305, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'PasswordContainsForbidCharacters');
static const ErrorCode PasswordFormatInvalid = ErrorCode._(306, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'PasswordFormatInvalid');
static const ErrorCode PasswordNotMatch = ErrorCode._(307, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'PasswordNotMatch');
static const ErrorCode UserNameTooLong = ErrorCode._(308, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserNameTooLong');
static const ErrorCode UserNameContainForbiddenCharacters = ErrorCode._(309, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserNameContainForbiddenCharacters');
static const ErrorCode UserNameIsEmpty = ErrorCode._(310, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserNameIsEmpty');
static const ErrorCode UserIdInvalid = ErrorCode._(311, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserIdInvalid');
static const ErrorCode UserNotExist = ErrorCode._(312, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserNotExist');
static const $core.List<ErrorCode> values = <ErrorCode> [
Internal,
UserUnauthorized,
RecordNotFound,
WorkspaceNameInvalid,
WorkspaceIdInvalid,
AppColorStyleInvalid,
WorkspaceDescTooLong,
WorkspaceNameTooLong,
AppIdInvalid,
AppNameInvalid,
ViewNameInvalid,
ViewThumbnailInvalid,
ViewIdInvalid,
ViewDescTooLong,
ViewDataInvalid,
ViewNameTooLong,
ConnectError,
EmailIsEmpty,
EmailFormatInvalid,
EmailAlreadyExists,
PasswordIsEmpty,
PasswordTooLong,
PasswordContainsForbidCharacters,
PasswordFormatInvalid,
PasswordNotMatch,
UserNameTooLong,
UserNameContainForbiddenCharacters,
UserNameIsEmpty,
UserIdInvalid,
UserNotExist,
];
static final $core.Map<$core.int, ErrorCode> _byValue = $pb.ProtobufEnum.initByValue(values);
static ErrorCode? valueOf($core.int value) => _byValue[value];
const ErrorCode._($core.int v, $core.String n) : super(v, n);
}

View File

@ -0,0 +1,49 @@
///
// Generated code. Do not modify.
// source: error_code.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
import 'dart:core' as $core;
import 'dart:convert' as $convert;
import 'dart:typed_data' as $typed_data;
@$core.Deprecated('Use errorCodeDescriptor instead')
const ErrorCode$json = const {
'1': 'ErrorCode',
'2': const [
const {'1': 'Internal', '2': 0},
const {'1': 'UserUnauthorized', '2': 2},
const {'1': 'RecordNotFound', '2': 3},
const {'1': 'WorkspaceNameInvalid', '2': 100},
const {'1': 'WorkspaceIdInvalid', '2': 101},
const {'1': 'AppColorStyleInvalid', '2': 102},
const {'1': 'WorkspaceDescTooLong', '2': 103},
const {'1': 'WorkspaceNameTooLong', '2': 104},
const {'1': 'AppIdInvalid', '2': 110},
const {'1': 'AppNameInvalid', '2': 111},
const {'1': 'ViewNameInvalid', '2': 120},
const {'1': 'ViewThumbnailInvalid', '2': 121},
const {'1': 'ViewIdInvalid', '2': 122},
const {'1': 'ViewDescTooLong', '2': 123},
const {'1': 'ViewDataInvalid', '2': 124},
const {'1': 'ViewNameTooLong', '2': 125},
const {'1': 'ConnectError', '2': 200},
const {'1': 'EmailIsEmpty', '2': 300},
const {'1': 'EmailFormatInvalid', '2': 301},
const {'1': 'EmailAlreadyExists', '2': 302},
const {'1': 'PasswordIsEmpty', '2': 303},
const {'1': 'PasswordTooLong', '2': 304},
const {'1': 'PasswordContainsForbidCharacters', '2': 305},
const {'1': 'PasswordFormatInvalid', '2': 306},
const {'1': 'PasswordNotMatch', '2': 307},
const {'1': 'UserNameTooLong', '2': 308},
const {'1': 'UserNameContainForbiddenCharacters', '2': 309},
const {'1': 'UserNameIsEmpty', '2': 310},
const {'1': 'UserIdInvalid', '2': 311},
const {'1': 'UserNotExist', '2': 312},
],
};
/// Descriptor for `ErrorCode`. Decode as a `google.protobuf.EnumDescriptorProto`.
final $typed_data.Uint8List errorCodeDescriptor = $convert.base64Decode('CglFcnJvckNvZGUSDAoISW50ZXJuYWwQABIUChBVc2VyVW5hdXRob3JpemVkEAISEgoOUmVjb3JkTm90Rm91bmQQAxIYChRXb3Jrc3BhY2VOYW1lSW52YWxpZBBkEhYKEldvcmtzcGFjZUlkSW52YWxpZBBlEhgKFEFwcENvbG9yU3R5bGVJbnZhbGlkEGYSGAoUV29ya3NwYWNlRGVzY1Rvb0xvbmcQZxIYChRXb3Jrc3BhY2VOYW1lVG9vTG9uZxBoEhAKDEFwcElkSW52YWxpZBBuEhIKDkFwcE5hbWVJbnZhbGlkEG8SEwoPVmlld05hbWVJbnZhbGlkEHgSGAoUVmlld1RodW1ibmFpbEludmFsaWQQeRIRCg1WaWV3SWRJbnZhbGlkEHoSEwoPVmlld0Rlc2NUb29Mb25nEHsSEwoPVmlld0RhdGFJbnZhbGlkEHwSEwoPVmlld05hbWVUb29Mb25nEH0SEQoMQ29ubmVjdEVycm9yEMgBEhEKDEVtYWlsSXNFbXB0eRCsAhIXChJFbWFpbEZvcm1hdEludmFsaWQQrQISFwoSRW1haWxBbHJlYWR5RXhpc3RzEK4CEhQKD1Bhc3N3b3JkSXNFbXB0eRCvAhIUCg9QYXNzd29yZFRvb0xvbmcQsAISJQogUGFzc3dvcmRDb250YWluc0ZvcmJpZENoYXJhY3RlcnMQsQISGgoVUGFzc3dvcmRGb3JtYXRJbnZhbGlkELICEhUKEFBhc3N3b3JkTm90TWF0Y2gQswISFAoPVXNlck5hbWVUb29Mb25nELQCEicKIlVzZXJOYW1lQ29udGFpbkZvcmJpZGRlbkNoYXJhY3RlcnMQtQISFAoPVXNlck5hbWVJc0VtcHR5ELYCEhIKDVVzZXJJZEludmFsaWQQtwISEQoMVXNlck5vdEV4aXN0ELgC');

View File

@ -1,9 +1,9 @@
///
// Generated code. Do not modify.
// source: errors.proto
// source: error_code.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
export 'errors.pb.dart';
export 'error_code.pb.dart';

View File

@ -0,0 +1,2 @@
// Auto-generated, do not edit
export './error_code.pb.dart';

View File

@ -1,72 +0,0 @@
///
// Generated code. Do not modify.
// source: errors.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
class WorkspaceError extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'WorkspaceError', createEmptyInstance: create)
..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'code', $pb.PbFieldType.O3)
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'msg')
..hasRequiredFields = false
;
WorkspaceError._() : super();
factory WorkspaceError({
$core.int? code,
$core.String? msg,
}) {
final _result = create();
if (code != null) {
_result.code = code;
}
if (msg != null) {
_result.msg = msg;
}
return _result;
}
factory WorkspaceError.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory WorkspaceError.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
WorkspaceError clone() => WorkspaceError()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
WorkspaceError copyWith(void Function(WorkspaceError) updates) => super.copyWith((message) => updates(message as WorkspaceError)) as WorkspaceError; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static WorkspaceError create() => WorkspaceError._();
WorkspaceError createEmptyInstance() => create();
static $pb.PbList<WorkspaceError> createRepeated() => $pb.PbList<WorkspaceError>();
@$core.pragma('dart2js:noInline')
static WorkspaceError getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<WorkspaceError>(create);
static WorkspaceError? _defaultInstance;
@$pb.TagNumber(1)
$core.int get code => $_getIZ(0);
@$pb.TagNumber(1)
set code($core.int v) { $_setSignedInt32(0, v); }
@$pb.TagNumber(1)
$core.bool hasCode() => $_has(0);
@$pb.TagNumber(1)
void clearCode() => clearField(1);
@$pb.TagNumber(2)
$core.String get msg => $_getSZ(1);
@$pb.TagNumber(2)
set msg($core.String v) { $_setString(1, v); }
@$pb.TagNumber(2)
$core.bool hasMsg() => $_has(1);
@$pb.TagNumber(2)
void clearMsg() => clearField(2);
}

View File

@ -1,21 +0,0 @@
///
// Generated code. Do not modify.
// source: errors.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
import 'dart:core' as $core;
import 'dart:convert' as $convert;
import 'dart:typed_data' as $typed_data;
@$core.Deprecated('Use workspaceErrorDescriptor instead')
const WorkspaceError$json = const {
'1': 'WorkspaceError',
'2': const [
const {'1': 'code', '3': 1, '4': 1, '5': 5, '10': 'code'},
const {'1': 'msg', '3': 2, '4': 1, '5': 9, '10': 'msg'},
],
};
/// Descriptor for `WorkspaceError`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List workspaceErrorDescriptor = $convert.base64Decode('Cg5Xb3Jrc3BhY2VFcnJvchISCgRjb2RlGAEgASgFUgRjb2RlEhAKA21zZxgCIAEoCVIDbXNn');

View File

@ -1,9 +0,0 @@
///
// Generated code. Do not modify.
// source: errors.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
export 'errors.pb.dart';

View File

@ -1,4 +1,3 @@
// Auto-generated, do not edit
export './observable.pb.dart';
export './errors.pb.dart';
export './event.pb.dart';

View File

@ -1,76 +0,0 @@
///
// Generated code. Do not modify.
// source: errors.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
import 'errors.pbenum.dart';
export 'errors.pbenum.dart';
class DocError extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'DocError', createEmptyInstance: create)
..e<ErrorCode>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'code', $pb.PbFieldType.OE, defaultOrMaker: ErrorCode.WsConnectError, valueOf: ErrorCode.valueOf, enumValues: ErrorCode.values)
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'msg')
..hasRequiredFields = false
;
DocError._() : super();
factory DocError({
ErrorCode? code,
$core.String? msg,
}) {
final _result = create();
if (code != null) {
_result.code = code;
}
if (msg != null) {
_result.msg = msg;
}
return _result;
}
factory DocError.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory DocError.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
DocError clone() => DocError()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
DocError copyWith(void Function(DocError) updates) => super.copyWith((message) => updates(message as DocError)) as DocError; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static DocError create() => DocError._();
DocError createEmptyInstance() => create();
static $pb.PbList<DocError> createRepeated() => $pb.PbList<DocError>();
@$core.pragma('dart2js:noInline')
static DocError getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<DocError>(create);
static DocError? _defaultInstance;
@$pb.TagNumber(1)
ErrorCode get code => $_getN(0);
@$pb.TagNumber(1)
set code(ErrorCode v) { setField(1, v); }
@$pb.TagNumber(1)
$core.bool hasCode() => $_has(0);
@$pb.TagNumber(1)
void clearCode() => clearField(1);
@$pb.TagNumber(2)
$core.String get msg => $_getSZ(1);
@$pb.TagNumber(2)
set msg($core.String v) { $_setString(1, v); }
@$pb.TagNumber(2)
$core.bool hasMsg() => $_has(1);
@$pb.TagNumber(2)
void clearMsg() => clearField(2);
}

View File

@ -1,32 +0,0 @@
///
// Generated code. Do not modify.
// source: errors.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
// ignore_for_file: UNDEFINED_SHOWN_NAME
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
class ErrorCode extends $pb.ProtobufEnum {
static const ErrorCode WsConnectError = ErrorCode._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WsConnectError');
static const ErrorCode DocNotfound = ErrorCode._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DocNotfound');
static const ErrorCode DuplicateRevision = ErrorCode._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DuplicateRevision');
static const ErrorCode UserUnauthorized = ErrorCode._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserUnauthorized');
static const ErrorCode InternalError = ErrorCode._(1000, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'InternalError');
static const $core.List<ErrorCode> values = <ErrorCode> [
WsConnectError,
DocNotfound,
DuplicateRevision,
UserUnauthorized,
InternalError,
];
static final $core.Map<$core.int, ErrorCode> _byValue = $pb.ProtobufEnum.initByValue(values);
static ErrorCode? valueOf($core.int value) => _byValue[value];
const ErrorCode._($core.int v, $core.String n) : super(v, n);
}

View File

@ -1,35 +0,0 @@
///
// Generated code. Do not modify.
// source: errors.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
import 'dart:core' as $core;
import 'dart:convert' as $convert;
import 'dart:typed_data' as $typed_data;
@$core.Deprecated('Use errorCodeDescriptor instead')
const ErrorCode$json = const {
'1': 'ErrorCode',
'2': const [
const {'1': 'WsConnectError', '2': 0},
const {'1': 'DocNotfound', '2': 1},
const {'1': 'DuplicateRevision', '2': 2},
const {'1': 'UserUnauthorized', '2': 10},
const {'1': 'InternalError', '2': 1000},
],
};
/// Descriptor for `ErrorCode`. Decode as a `google.protobuf.EnumDescriptorProto`.
final $typed_data.Uint8List errorCodeDescriptor = $convert.base64Decode('CglFcnJvckNvZGUSEgoOV3NDb25uZWN0RXJyb3IQABIPCgtEb2NOb3Rmb3VuZBABEhUKEUR1cGxpY2F0ZVJldmlzaW9uEAISFAoQVXNlclVuYXV0aG9yaXplZBAKEhIKDUludGVybmFsRXJyb3IQ6Ac=');
@$core.Deprecated('Use docErrorDescriptor instead')
const DocError$json = const {
'1': 'DocError',
'2': const [
const {'1': 'code', '3': 1, '4': 1, '5': 14, '6': '.ErrorCode', '10': 'code'},
const {'1': 'msg', '3': 2, '4': 1, '5': 9, '10': 'msg'},
],
};
/// Descriptor for `DocError`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List docErrorDescriptor = $convert.base64Decode('CghEb2NFcnJvchIeCgRjb2RlGAEgASgOMgouRXJyb3JDb2RlUgRjb2RlEhAKA21zZxgCIAEoCVIDbXNn');

View File

@ -1,3 +1,2 @@
// Auto-generated, do not edit
export './observable.pb.dart';
export './errors.pb.dart';

View File

@ -9,8 +9,6 @@ import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
export 'errors.pbenum.dart';
class FlowyError extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'FlowyError', createEmptyInstance: create)
..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'code', $pb.PbFieldType.O3)

View File

@ -5,20 +5,3 @@
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
// ignore_for_file: UNDEFINED_SHOWN_NAME
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
class ErrorCode extends $pb.ProtobufEnum {
static const ErrorCode Internal = ErrorCode._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'Internal');
static const $core.List<ErrorCode> values = <ErrorCode> [
Internal,
];
static final $core.Map<$core.int, ErrorCode> _byValue = $pb.ProtobufEnum.initByValue(values);
static ErrorCode? valueOf($core.int value) => _byValue[value];
const ErrorCode._($core.int v, $core.String n) : super(v, n);
}

View File

@ -8,16 +8,6 @@
import 'dart:core' as $core;
import 'dart:convert' as $convert;
import 'dart:typed_data' as $typed_data;
@$core.Deprecated('Use errorCodeDescriptor instead')
const ErrorCode$json = const {
'1': 'ErrorCode',
'2': const [
const {'1': 'Internal', '2': 0},
],
};
/// Descriptor for `ErrorCode`. Decode as a `google.protobuf.EnumDescriptorProto`.
final $typed_data.Uint8List errorCodeDescriptor = $convert.base64Decode('CglFcnJvckNvZGUSDAoISW50ZXJuYWwQAA==');
@$core.Deprecated('Use flowyErrorDescriptor instead')
const FlowyError$json = const {
'1': 'FlowyError',

View File

@ -1,72 +0,0 @@
///
// Generated code. Do not modify.
// source: errors.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
class UserError extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UserError', createEmptyInstance: create)
..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'code', $pb.PbFieldType.O3)
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'msg')
..hasRequiredFields = false
;
UserError._() : super();
factory UserError({
$core.int? code,
$core.String? msg,
}) {
final _result = create();
if (code != null) {
_result.code = code;
}
if (msg != null) {
_result.msg = msg;
}
return _result;
}
factory UserError.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory UserError.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
UserError clone() => UserError()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
UserError copyWith(void Function(UserError) updates) => super.copyWith((message) => updates(message as UserError)) as UserError; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static UserError create() => UserError._();
UserError createEmptyInstance() => create();
static $pb.PbList<UserError> createRepeated() => $pb.PbList<UserError>();
@$core.pragma('dart2js:noInline')
static UserError getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<UserError>(create);
static UserError? _defaultInstance;
@$pb.TagNumber(1)
$core.int get code => $_getIZ(0);
@$pb.TagNumber(1)
set code($core.int v) { $_setSignedInt32(0, v); }
@$pb.TagNumber(1)
$core.bool hasCode() => $_has(0);
@$pb.TagNumber(1)
void clearCode() => clearField(1);
@$pb.TagNumber(2)
$core.String get msg => $_getSZ(1);
@$pb.TagNumber(2)
set msg($core.String v) { $_setString(1, v); }
@$pb.TagNumber(2)
$core.bool hasMsg() => $_has(1);
@$pb.TagNumber(2)
void clearMsg() => clearField(2);
}

View File

@ -1,7 +0,0 @@
///
// Generated code. Do not modify.
// source: errors.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields

View File

@ -1,21 +0,0 @@
///
// Generated code. Do not modify.
// source: errors.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
import 'dart:core' as $core;
import 'dart:convert' as $convert;
import 'dart:typed_data' as $typed_data;
@$core.Deprecated('Use userErrorDescriptor instead')
const UserError$json = const {
'1': 'UserError',
'2': const [
const {'1': 'code', '3': 1, '4': 1, '5': 5, '10': 'code'},
const {'1': 'msg', '3': 2, '4': 1, '5': 9, '10': 'msg'},
],
};
/// Descriptor for `UserError`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List userErrorDescriptor = $convert.base64Decode('CglVc2VyRXJyb3ISEgoEY29kZRgBIAEoBVIEY29kZRIQCgNtc2cYAiABKAlSA21zZw==');

View File

@ -1,9 +0,0 @@
///
// Generated code. Do not modify.
// source: errors.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
export 'errors.pb.dart';

View File

@ -1,4 +1,3 @@
// Auto-generated, do not edit
export './observable.pb.dart';
export './errors.pb.dart';
export './event.pb.dart';

View File

@ -16,6 +16,7 @@ lib-infra = { path = "../../../shared-lib/lib-infra" }
flowy-document = { path = "../flowy-document" }
flowy-database = { path = "../flowy-database" }
flowy-error = { path = "../flowy-error", features = ["db", "backend"]}
flowy-net = { path = "../flowy-net" }
dart-notify = { path = "../dart-notify" }
lib-dispatch = { path = "../lib-dispatch" }

View File

@ -1,6 +1,6 @@
use crate::{
core::CoreContext,
errors::WorkspaceError,
errors::FlowyError,
notify::{send_dart_notification, WorkspaceNotification},
services::workspace::sql::{WorkspaceTable, WorkspaceTableSql},
};
@ -13,7 +13,7 @@ pub fn read_workspaces_on_server(
core: Unit<Arc<CoreContext>>,
user_id: String,
params: WorkspaceIdentifier,
) -> Result<(), WorkspaceError> {
) -> Result<(), FlowyError> {
let (token, server) = (core.user.token()?, core.server.clone());
let app_ctrl = core.app_controller.clone();
let view_ctrl = core.view_controller.clone();
@ -22,7 +22,7 @@ pub fn read_workspaces_on_server(
tokio::spawn(async move {
// Opti: handle the error and retry?
let workspaces = server.read_workspace(&token, params).await?;
let _ = (&*conn).immediate_transaction::<_, WorkspaceError, _>(|| {
let _ = (&*conn).immediate_transaction::<_, FlowyError, _>(|| {
tracing::debug!("Save {} workspace", workspaces.len());
for workspace in &workspaces.items {
let m_workspace = workspace.clone();
@ -53,7 +53,7 @@ pub fn read_workspaces_on_server(
send_dart_notification(&token, WorkspaceNotification::WorkspaceListUpdated)
.payload(workspaces)
.send();
Result::<(), WorkspaceError>::Ok(())
Result::<(), FlowyError>::Ok(())
});
Ok(())

View File

@ -10,7 +10,7 @@ use flowy_net::entities::NetworkType;
use crate::{
entities::workspace::RepeatedWorkspace,
errors::{WorkspaceError, WorkspaceResult},
errors::{FlowyError, FlowyResult},
module::{WorkspaceDatabase, WorkspaceUser},
notify::{send_dart_notification, WorkspaceNotification},
services::{server::Server, AppController, TrashController, ViewController, WorkspaceController},
@ -64,7 +64,7 @@ impl CoreContext {
}
}
pub async fn user_did_sign_in(&self, token: &str) -> WorkspaceResult<()> {
pub async fn user_did_sign_in(&self, token: &str) -> FlowyResult<()> {
log::debug!("workspace initialize after sign in");
let _ = self.init(token).await?;
Ok(())
@ -78,7 +78,7 @@ impl CoreContext {
// TODO: (nathan) do something here
}
pub async fn user_did_sign_up(&self, _token: &str) -> WorkspaceResult<()> {
pub async fn user_did_sign_up(&self, _token: &str) -> FlowyResult<()> {
log::debug!("Create user default workspace");
let time = Utc::now();
let mut workspace = user_default::create_default_workspace(time);
@ -120,7 +120,7 @@ impl CoreContext {
Ok(())
}
async fn init(&self, token: &str) -> Result<(), WorkspaceError> {
async fn init(&self, token: &str) -> Result<(), FlowyError> {
if let Some(is_init) = INIT_WORKSPACE.read().get(token) {
if *is_init {
return Ok(());

View File

@ -1,6 +1,6 @@
use crate::{
core::{aggregate_tasks::read_workspaces_on_server, CoreContext},
errors::WorkspaceError,
errors::FlowyError,
services::{get_current_workspace, read_local_workspace_apps},
};
use flowy_core_infra::entities::{
@ -14,14 +14,14 @@ use std::{convert::TryInto, sync::Arc};
pub(crate) async fn read_workspaces_handler(
data: Data<QueryWorkspaceRequest>,
core: Unit<Arc<CoreContext>>,
) -> DataResult<RepeatedWorkspace, WorkspaceError> {
) -> DataResult<RepeatedWorkspace, FlowyError> {
let params: WorkspaceIdentifier = data.into_inner().try_into()?;
let user_id = core.user.user_id()?;
let conn = &*core.database.db_connection()?;
let workspace_controller = core.workspace_controller.clone();
let trash_controller = core.trash_controller.clone();
let workspaces = conn.immediate_transaction::<_, WorkspaceError, _>(|| {
let workspaces = conn.immediate_transaction::<_, FlowyError, _>(|| {
let mut workspaces = workspace_controller.read_local_workspaces(params.workspace_id.clone(), &user_id, conn)?;
for workspace in workspaces.iter_mut() {
let apps = read_local_workspace_apps(&workspace.id, trash_controller.clone(), conn)?.into_inner();
@ -38,7 +38,7 @@ pub(crate) async fn read_workspaces_handler(
#[tracing::instrument(skip(core), err)]
pub async fn read_cur_workspace_handler(
core: Unit<Arc<CoreContext>>,
) -> DataResult<CurrentWorkspaceSetting, WorkspaceError> {
) -> DataResult<CurrentWorkspaceSetting, FlowyError> {
let workspace_id = get_current_workspace()?;
let user_id = core.user.user_id()?;
let params = WorkspaceIdentifier {

View File

@ -1,106 +0,0 @@
use bytes::Bytes;
use backend_service::errors::ErrorCode as ServerErrorCode;
pub use flowy_core_infra::errors::ErrorCode;
use flowy_derive::ProtoBuf;
use flowy_document::errors::DocError;
use lib_dispatch::prelude::{EventResponse, ResponseBuilder};
use std::{convert::TryInto, fmt, fmt::Debug};
pub type WorkspaceResult<T> = std::result::Result<T, WorkspaceError>;
#[derive(Debug, Default, Clone, ProtoBuf)]
pub struct WorkspaceError {
#[pb(index = 1)]
pub code: i32,
#[pb(index = 2)]
pub msg: String,
}
macro_rules! static_workspace_error {
($name:ident, $code:expr) => {
#[allow(non_snake_case, missing_docs)]
pub fn $name() -> WorkspaceError { $code.into() }
};
}
impl WorkspaceError {
pub fn new(code: ErrorCode, msg: &str) -> Self {
Self {
code: code.value(),
msg: msg.to_owned(),
}
}
static_workspace_error!(workspace_name, ErrorCode::WorkspaceNameInvalid);
static_workspace_error!(workspace_id, ErrorCode::WorkspaceIdInvalid);
static_workspace_error!(color_style, ErrorCode::AppColorStyleInvalid);
static_workspace_error!(workspace_desc, ErrorCode::WorkspaceDescTooLong);
static_workspace_error!(app_name, ErrorCode::AppNameInvalid);
static_workspace_error!(invalid_app_id, ErrorCode::AppIdInvalid);
static_workspace_error!(view_name, ErrorCode::ViewNameInvalid);
static_workspace_error!(view_thumbnail, ErrorCode::ViewThumbnailInvalid);
static_workspace_error!(invalid_view_id, ErrorCode::ViewIdInvalid);
static_workspace_error!(view_desc, ErrorCode::ViewDescTooLong);
static_workspace_error!(view_data, ErrorCode::ViewDataInvalid);
static_workspace_error!(unauthorized, ErrorCode::UserUnauthorized);
static_workspace_error!(internal, ErrorCode::InternalError);
static_workspace_error!(record_not_found, ErrorCode::RecordNotFound);
static_workspace_error!(ws, ErrorCode::WsConnectError);
pub fn context<T: Debug>(mut self, error: T) -> Self {
self.msg = format!("{:?}", error);
self
}
}
pub fn internal_error<T>(e: T) -> WorkspaceError
where
T: std::fmt::Debug,
{
WorkspaceError::internal().context(e)
}
impl std::convert::From<ErrorCode> for WorkspaceError {
fn from(code: ErrorCode) -> Self {
WorkspaceError {
code: code.value(),
msg: format!("{}", code),
}
}
}
impl std::convert::From<flowy_document::errors::DocError> for WorkspaceError {
fn from(error: DocError) -> Self { WorkspaceError::internal().context(error) }
}
impl std::convert::From<backend_service::errors::ServerError> for WorkspaceError {
fn from(error: backend_service::errors::ServerError) -> Self {
let code = server_error_to_workspace_error(error.code);
WorkspaceError::new(code, &error.msg)
}
}
impl std::convert::From<flowy_database::Error> for WorkspaceError {
fn from(error: flowy_database::Error) -> Self { WorkspaceError::internal().context(error) }
}
impl lib_dispatch::Error for WorkspaceError {
fn as_response(&self) -> EventResponse {
let bytes: Bytes = self.clone().try_into().unwrap();
ResponseBuilder::Err().data(bytes).build()
}
}
impl fmt::Display for WorkspaceError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{:?}: {}", &self.code, &self.msg) }
}
fn server_error_to_workspace_error(code: ServerErrorCode) -> ErrorCode {
match code {
ServerErrorCode::UserUnauthorized => ErrorCode::UserUnauthorized,
ServerErrorCode::RecordNotFound => ErrorCode::RecordNotFound,
_ => ErrorCode::InternalError,
}
}

View File

@ -2,7 +2,7 @@ use flowy_derive::{Flowy_Event, ProtoBuf_Enum};
use strum_macros::Display;
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
#[event_err = "WorkspaceError"]
#[event_err = "FlowyError"]
pub enum WorkspaceEvent {
#[event(input = "CreateWorkspaceRequest", output = "Workspace")]
CreateWorkspace = 0,

View File

@ -11,7 +11,7 @@ mod macros;
extern crate flowy_database;
pub mod core;
pub mod errors;
mod notify;
pub mod protobuf;
mod util;
@ -21,3 +21,7 @@ pub mod prelude {
pub use crate::{core::*, errors::*, module::*};
}
pub mod errors {
pub use flowy_error::{internal_error, ErrorCode, FlowyError, FlowyResult};
}

View File

@ -1,7 +1,7 @@
// #[macro_export]
// macro_rules! impl_save_func {
// ($func_name:ident, $target:ident, $table_name:expr, $conn:ident) => {
// fn $func_name(object: $target) -> Result<(), WorkspaceError> {
// fn $func_name(object: $target) -> Result<(), FlowyError> {
// let _ = diesel::insert_into($table_name)
// .values($target)
// .execute(&*($conn))?;

View File

@ -8,7 +8,7 @@ use lib_sqlite::ConnectionPool;
use crate::{
core::{event_handler::*, CoreContext},
errors::WorkspaceError,
errors::FlowyError,
event::WorkspaceEvent,
services::{
app::event_handler::*,
@ -26,16 +26,16 @@ use crate::{
pub trait WorkspaceDeps: WorkspaceUser + WorkspaceDatabase {}
pub trait WorkspaceUser: Send + Sync {
fn user_id(&self) -> Result<String, WorkspaceError>;
fn token(&self) -> Result<String, WorkspaceError>;
fn user_id(&self) -> Result<String, FlowyError>;
fn token(&self) -> Result<String, FlowyError>;
}
pub trait WorkspaceDatabase: Send + Sync {
fn db_pool(&self) -> Result<Arc<ConnectionPool>, WorkspaceError>;
fn db_pool(&self) -> Result<Arc<ConnectionPool>, FlowyError>;
fn db_connection(&self) -> Result<DBConnection, WorkspaceError> {
fn db_connection(&self) -> Result<DBConnection, FlowyError> {
let pool = self.db_pool()?;
let conn = pool.get().map_err(|e| WorkspaceError::internal().context(e))?;
let conn = pool.get().map_err(|e| FlowyError::internal().context(e))?;
Ok(conn)
}
}

View File

@ -1,243 +0,0 @@
// This file is generated by rust-protobuf 2.22.1. Do not edit
// @generated
// https://github.com/rust-lang/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]
#![allow(unused_attributes)]
#![cfg_attr(rustfmt, rustfmt::skip)]
#![allow(box_pointers)]
#![allow(dead_code)]
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(trivial_casts)]
#![allow(unused_imports)]
#![allow(unused_results)]
//! Generated file from `errors.proto`
/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1;
#[derive(PartialEq,Clone,Default)]
pub struct WorkspaceError {
// message fields
pub code: i32,
pub msg: ::std::string::String,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
}
impl<'a> ::std::default::Default for &'a WorkspaceError {
fn default() -> &'a WorkspaceError {
<WorkspaceError as ::protobuf::Message>::default_instance()
}
}
impl WorkspaceError {
pub fn new() -> WorkspaceError {
::std::default::Default::default()
}
// int32 code = 1;
pub fn get_code(&self) -> i32 {
self.code
}
pub fn clear_code(&mut self) {
self.code = 0;
}
// Param is passed by value, moved
pub fn set_code(&mut self, v: i32) {
self.code = v;
}
// string msg = 2;
pub fn get_msg(&self) -> &str {
&self.msg
}
pub fn clear_msg(&mut self) {
self.msg.clear();
}
// Param is passed by value, moved
pub fn set_msg(&mut self, v: ::std::string::String) {
self.msg = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_msg(&mut self) -> &mut ::std::string::String {
&mut self.msg
}
// Take field
pub fn take_msg(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.msg, ::std::string::String::new())
}
}
impl ::protobuf::Message for WorkspaceError {
fn is_initialized(&self) -> bool {
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> {
while !is.eof()? {
let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number {
1 => {
if wire_type != ::protobuf::wire_format::WireTypeVarint {
return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type));
}
let tmp = is.read_int32()?;
self.code = tmp;
},
2 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.msg)?;
},
_ => {
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u32 {
let mut my_size = 0;
if self.code != 0 {
my_size += ::protobuf::rt::value_size(1, self.code, ::protobuf::wire_format::WireTypeVarint);
}
if !self.msg.is_empty() {
my_size += ::protobuf::rt::string_size(2, &self.msg);
}
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
if self.code != 0 {
os.write_int32(1, self.code)?;
}
if !self.msg.is_empty() {
os.write_string(2, &self.msg)?;
}
os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(())
}
fn get_cached_size(&self) -> u32 {
self.cached_size.get()
}
fn get_unknown_fields(&self) -> &::protobuf::UnknownFields {
&self.unknown_fields
}
fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields {
&mut self.unknown_fields
}
fn as_any(&self) -> &dyn (::std::any::Any) {
self as &dyn (::std::any::Any)
}
fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
self as &mut dyn (::std::any::Any)
}
fn into_any(self: ::std::boxed::Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
self
}
fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor {
Self::descriptor_static()
}
fn new() -> WorkspaceError {
WorkspaceError::new()
}
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT;
descriptor.get(|| {
let mut fields = ::std::vec::Vec::new();
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt32>(
"code",
|m: &WorkspaceError| { &m.code },
|m: &mut WorkspaceError| { &mut m.code },
));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"msg",
|m: &WorkspaceError| { &m.msg },
|m: &mut WorkspaceError| { &mut m.msg },
));
::protobuf::reflect::MessageDescriptor::new_pb_name::<WorkspaceError>(
"WorkspaceError",
fields,
file_descriptor_proto()
)
})
}
fn default_instance() -> &'static WorkspaceError {
static instance: ::protobuf::rt::LazyV2<WorkspaceError> = ::protobuf::rt::LazyV2::INIT;
instance.get(WorkspaceError::new)
}
}
impl ::protobuf::Clear for WorkspaceError {
fn clear(&mut self) {
self.code = 0;
self.msg.clear();
self.unknown_fields.clear();
}
}
impl ::std::fmt::Debug for WorkspaceError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for WorkspaceError {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
::protobuf::reflect::ReflectValueRef::Message(self)
}
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x0cerrors.proto\"6\n\x0eWorkspaceError\x12\x12\n\x04code\x18\x01\x20\
\x01(\x05R\x04code\x12\x10\n\x03msg\x18\x02\x20\x01(\tR\x03msgJ\x98\x01\
\n\x06\x12\x04\0\0\x05\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x04\
\0\x12\x04\x02\0\x05\x01\n\n\n\x03\x04\0\x01\x12\x03\x02\x08\x16\n\x0b\n\
\x04\x04\0\x02\0\x12\x03\x03\x04\x13\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\
\x03\x04\t\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\n\x0e\n\x0c\n\x05\x04\
\0\x02\0\x03\x12\x03\x03\x11\x12\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x04\
\x04\x13\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x04\x04\n\n\x0c\n\x05\x04\
\0\x02\x01\x01\x12\x03\x04\x0b\x0e\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\
\x04\x11\x12b\x06proto3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto {
::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap()
}
pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto {
file_descriptor_proto_lazy.get(|| {
parse_descriptor_proto()
})
}

View File

@ -4,8 +4,5 @@
mod observable;
pub use observable::*;
mod errors;
pub use errors::*;
mod event;
pub use event::*;

View File

@ -1,6 +0,0 @@
syntax = "proto3";
message WorkspaceError {
int32 code = 1;
string msg = 2;
}

View File

@ -39,20 +39,20 @@ impl AppController {
}
}
pub fn init(&self) -> Result<(), WorkspaceError> {
pub fn init(&self) -> Result<(), FlowyError> {
self.listen_trash_can_event();
Ok(())
}
#[tracing::instrument(level = "debug", skip(self, params), fields(name = %params.name) err)]
pub(crate) async fn create_app_from_params(&self, params: CreateAppParams) -> Result<App, WorkspaceError> {
pub(crate) async fn create_app_from_params(&self, params: CreateAppParams) -> Result<App, FlowyError> {
let app = self.create_app_on_server(params).await?;
self.create_app(app).await
}
pub(crate) async fn create_app(&self, app: App) -> Result<App, WorkspaceError> {
pub(crate) async fn create_app(&self, app: App) -> Result<App, FlowyError> {
let conn = &*self.database.db_connection()?;
conn.immediate_transaction::<_, WorkspaceError, _>(|| {
conn.immediate_transaction::<_, FlowyError, _>(|| {
let _ = self.save_app(app.clone(), &*conn)?;
let _ = notify_apps_changed(&app.workspace_id, self.trash_can.clone(), conn)?;
Ok(())
@ -61,30 +61,30 @@ impl AppController {
Ok(app)
}
pub(crate) fn save_app(&self, app: App, conn: &SqliteConnection) -> Result<(), WorkspaceError> {
pub(crate) fn save_app(&self, app: App, conn: &SqliteConnection) -> Result<(), FlowyError> {
let app_table = AppTable::new(app);
let _ = AppTableSql::create_app(app_table, &*conn)?;
Ok(())
}
pub(crate) async fn read_app(&self, params: AppIdentifier) -> Result<App, WorkspaceError> {
pub(crate) async fn read_app(&self, params: AppIdentifier) -> Result<App, FlowyError> {
let conn = self.database.db_connection()?;
let app_table = AppTableSql::read_app(&params.app_id, &*conn)?;
let trash_ids = self.trash_can.trash_ids(&conn)?;
if trash_ids.contains(&app_table.id) {
return Err(WorkspaceError::record_not_found());
return Err(FlowyError::record_not_found());
}
let _ = self.read_app_on_server(params)?;
Ok(app_table.into())
}
pub(crate) async fn update_app(&self, params: UpdateAppParams) -> Result<(), WorkspaceError> {
pub(crate) async fn update_app(&self, params: UpdateAppParams) -> Result<(), FlowyError> {
let changeset = AppTableChangeset::new(params.clone());
let app_id = changeset.id.clone();
let conn = &*self.database.db_connection()?;
conn.immediate_transaction::<_, WorkspaceError, _>(|| {
conn.immediate_transaction::<_, FlowyError, _>(|| {
let _ = AppTableSql::update_app(changeset, conn)?;
let app: App = AppTableSql::read_app(&app_id, conn)?.into();
send_dart_notification(&app_id, WorkspaceNotification::AppUpdated)
@ -97,10 +97,10 @@ impl AppController {
Ok(())
}
pub(crate) fn read_app_tables(&self, ids: Vec<String>) -> Result<Vec<AppTable>, WorkspaceError> {
pub(crate) fn read_app_tables(&self, ids: Vec<String>) -> Result<Vec<AppTable>, FlowyError> {
let conn = &*self.database.db_connection()?;
let mut app_tables = vec![];
conn.immediate_transaction::<_, WorkspaceError, _>(|| {
conn.immediate_transaction::<_, FlowyError, _>(|| {
for app_id in ids {
app_tables.push(AppTableSql::read_app(&app_id, conn)?);
}
@ -113,14 +113,14 @@ impl AppController {
impl AppController {
#[tracing::instrument(level = "debug", skip(self), err)]
async fn create_app_on_server(&self, params: CreateAppParams) -> Result<App, WorkspaceError> {
async fn create_app_on_server(&self, params: CreateAppParams) -> Result<App, FlowyError> {
let token = self.user.token()?;
let app = self.server.create_app(&token, params).await?;
Ok(app)
}
#[tracing::instrument(level = "debug", skip(self), err)]
fn update_app_on_server(&self, params: UpdateAppParams) -> Result<(), WorkspaceError> {
fn update_app_on_server(&self, params: UpdateAppParams) -> Result<(), FlowyError> {
let token = self.user.token()?;
let server = self.server.clone();
tokio::spawn(async move {
@ -136,7 +136,7 @@ impl AppController {
}
#[tracing::instrument(level = "debug", skip(self), err)]
fn read_app_on_server(&self, params: AppIdentifier) -> Result<(), WorkspaceError> {
fn read_app_on_server(&self, params: AppIdentifier) -> Result<(), FlowyError> {
let token = self.user.token()?;
let server = self.server.clone();
let pool = self.database.db_pool()?;
@ -192,21 +192,21 @@ async fn handle_trash_event(database: Arc<dyn WorkspaceDatabase>, trash_can: Arc
TrashEvent::NewTrash(identifiers, ret) | TrashEvent::Putback(identifiers, ret) => {
let result = || {
let conn = &*db_result?;
let _ = conn.immediate_transaction::<_, WorkspaceError, _>(|| {
let _ = conn.immediate_transaction::<_, FlowyError, _>(|| {
for identifier in identifiers.items {
let app_table = AppTableSql::read_app(&identifier.id, conn)?;
let _ = notify_apps_changed(&app_table.workspace_id, trash_can.clone(), conn)?;
}
Ok(())
})?;
Ok::<(), WorkspaceError>(())
Ok::<(), FlowyError>(())
};
let _ = ret.send(result()).await;
},
TrashEvent::Delete(identifiers, ret) => {
let result = || {
let conn = &*db_result?;
let _ = conn.immediate_transaction::<_, WorkspaceError, _>(|| {
let _ = conn.immediate_transaction::<_, FlowyError, _>(|| {
let mut notify_ids = HashSet::new();
for identifier in identifiers.items {
let app_table = AppTableSql::read_app(&identifier.id, conn)?;
@ -219,7 +219,7 @@ async fn handle_trash_event(database: Arc<dyn WorkspaceDatabase>, trash_can: Arc
}
Ok(())
})?;
Ok::<(), WorkspaceError>(())
Ok::<(), FlowyError>(())
};
let _ = ret.send(result()).await;
},
@ -231,7 +231,7 @@ fn notify_apps_changed(
workspace_id: &str,
trash_can: Arc<TrashController>,
conn: &SqliteConnection,
) -> WorkspaceResult<()> {
) -> FlowyResult<()> {
let repeated_app = read_local_workspace_apps(workspace_id, trash_can, conn)?;
send_dart_notification(workspace_id, WorkspaceNotification::WorkspaceAppsChanged)
.payload(repeated_app)
@ -243,7 +243,7 @@ pub fn read_local_workspace_apps(
workspace_id: &str,
trash_controller: Arc<TrashController>,
conn: &SqliteConnection,
) -> Result<RepeatedApp, WorkspaceError> {
) -> Result<RepeatedApp, FlowyError> {
let mut app_tables = AppTableSql::read_workspace_apps(workspace_id, false, conn)?;
let trash_ids = trash_controller.trash_ids(conn)?;
app_tables.retain(|app_table| !trash_ids.contains(&app_table.id));
@ -254,8 +254,8 @@ pub fn read_local_workspace_apps(
// #[tracing::instrument(level = "debug", skip(self), err)]
// pub(crate) async fn delete_app(&self, app_id: &str) -> Result<(),
// WorkspaceError> { let conn = &*self.database.db_connection()?;
// conn.immediate_transaction::<_, WorkspaceError, _>(|| {
// FlowyError> { let conn = &*self.database.db_connection()?;
// conn.immediate_transaction::<_, FlowyError, _>(|| {
// let app = AppTableSql::delete_app(app_id, &*conn)?;
// let apps = self.read_local_apps(&app.workspace_id, &*conn)?;
// send_dart_notification(&app.workspace_id,
@ -269,7 +269,7 @@ pub fn read_local_workspace_apps(
// }
//
// #[tracing::instrument(level = "debug", skip(self), err)]
// fn delete_app_on_server(&self, app_id: &str) -> Result<(), WorkspaceError> {
// fn delete_app_on_server(&self, app_id: &str) -> Result<(), FlowyError> {
// let token = self.user.token()?;
// let server = self.server.clone();
// let params = DeleteAppParams {
@ -291,7 +291,7 @@ pub fn read_local_workspace_apps(
// // Ok(_) => {},
// // Err(e) => log::error!("Delete app failed: {:?}", e),
// // }
// // Ok::<(), WorkspaceError>(())
// // Ok::<(), FlowyError>(())
// // }
// // });
// //

View File

@ -11,7 +11,7 @@ use crate::{
},
trash::Trash,
},
errors::WorkspaceError,
errors::FlowyError,
services::{AppController, TrashController, ViewController},
};
use lib_dispatch::prelude::{data_result, Data, DataResult, Unit};
@ -20,7 +20,7 @@ use std::{convert::TryInto, sync::Arc};
pub(crate) async fn create_app_handler(
data: Data<CreateAppRequest>,
controller: Unit<Arc<AppController>>,
) -> DataResult<App, WorkspaceError> {
) -> DataResult<App, FlowyError> {
let params: CreateAppParams = data.into_inner().try_into()?;
let detail = controller.create_app_from_params(params).await?;
@ -31,7 +31,7 @@ pub(crate) async fn delete_app_handler(
data: Data<QueryAppRequest>,
controller: Unit<Arc<AppController>>,
trash_can: Unit<Arc<TrashController>>,
) -> Result<(), WorkspaceError> {
) -> Result<(), FlowyError> {
let params: AppIdentifier = data.into_inner().try_into()?;
let trash = controller
.read_app_tables(vec![params.app_id])?
@ -47,7 +47,7 @@ pub(crate) async fn delete_app_handler(
pub(crate) async fn update_app_handler(
data: Data<UpdateAppRequest>,
controller: Unit<Arc<AppController>>,
) -> Result<(), WorkspaceError> {
) -> Result<(), FlowyError> {
let params: UpdateAppParams = data.into_inner().try_into()?;
let _ = controller.update_app(params).await?;
Ok(())
@ -58,7 +58,7 @@ pub(crate) async fn read_app_handler(
data: Data<QueryAppRequest>,
app_controller: Unit<Arc<AppController>>,
view_controller: Unit<Arc<ViewController>>,
) -> DataResult<App, WorkspaceError> {
) -> DataResult<App, FlowyError> {
let params: AppIdentifier = data.into_inner().try_into()?;
let mut app = app_controller.read_app(params.clone()).await?;
app.belongings = view_controller.read_views_belong_to(&params.app_id).await?;

View File

@ -15,12 +15,12 @@ use flowy_database::{
use serde::{Deserialize, Serialize, __private::TryFrom};
use std::convert::TryInto;
use crate::errors::WorkspaceError;
use crate::errors::FlowyError;
pub struct AppTableSql {}
impl AppTableSql {
pub(crate) fn create_app(app_table: AppTable, conn: &SqliteConnection) -> Result<(), WorkspaceError> {
pub(crate) fn create_app(app_table: AppTable, conn: &SqliteConnection) -> Result<(), FlowyError> {
match diesel_record_count!(app_table, &app_table.id, conn) {
0 => diesel_insert_table!(app_table, &app_table, conn),
_ => {
@ -31,12 +31,12 @@ impl AppTableSql {
Ok(())
}
pub(crate) fn update_app(changeset: AppTableChangeset, conn: &SqliteConnection) -> Result<(), WorkspaceError> {
pub(crate) fn update_app(changeset: AppTableChangeset, conn: &SqliteConnection) -> Result<(), FlowyError> {
diesel_update_table!(app_table, changeset, conn);
Ok(())
}
pub(crate) fn read_app(app_id: &str, conn: &SqliteConnection) -> Result<AppTable, WorkspaceError> {
pub(crate) fn read_app(app_id: &str, conn: &SqliteConnection) -> Result<AppTable, FlowyError> {
let filter = dsl::app_table.filter(app_table::id.eq(app_id)).into_boxed();
let app_table = filter.first::<AppTable>(conn)?;
Ok(app_table)
@ -46,7 +46,7 @@ impl AppTableSql {
workspace_id: &str,
is_trash: bool,
conn: &SqliteConnection,
) -> Result<Vec<AppTable>, WorkspaceError> {
) -> Result<Vec<AppTable>, FlowyError> {
let app_table = dsl::app_table
.filter(app_table::workspace_id.eq(workspace_id))
.filter(app_table::is_trash.eq(is_trash))
@ -56,7 +56,7 @@ impl AppTableSql {
Ok(app_table)
}
pub(crate) fn delete_app(app_id: &str, conn: &SqliteConnection) -> Result<AppTable, WorkspaceError> {
pub(crate) fn delete_app(app_id: &str, conn: &SqliteConnection) -> Result<AppTable, FlowyError> {
let app_table = dsl::app_table
.filter(app_table::id.eq(app_id))
.first::<AppTable>(conn)?;
@ -67,10 +67,10 @@ impl AppTableSql {
// pub(crate) fn read_views_belong_to_app(
// &self,
// app_id: &str,
// ) -> Result<Vec<ViewTable>, WorkspaceError> {
// ) -> Result<Vec<ViewTable>, FlowyError> {
// let conn = self.database.db_connection()?;
//
// let views = conn.immediate_transaction::<_, WorkspaceError, _>(|| {
// let views = conn.immediate_transaction::<_, FlowyError, _>(|| {
// let app_table: AppTable = dsl::app_table
// .filter(app_table::id.eq(app_id))
// .first::<AppTable>(&*(conn))?;

View File

@ -12,7 +12,7 @@ use crate::{
view::{CreateViewParams, UpdateViewParams, View, ViewIdentifier, ViewIdentifiers},
workspace::{CreateWorkspaceParams, RepeatedWorkspace, UpdateWorkspaceParams, Workspace, WorkspaceIdentifier},
},
errors::WorkspaceError,
errors::FlowyError,
};
use backend_service::configuration::ClientServerConfiguration;
use lib_infra::future::FutureResult;
@ -24,42 +24,38 @@ pub trait WorkspaceServerAPI {
fn init(&self);
// Workspace
fn create_workspace(&self, token: &str, params: CreateWorkspaceParams) -> FutureResult<Workspace, WorkspaceError>;
fn create_workspace(&self, token: &str, params: CreateWorkspaceParams) -> FutureResult<Workspace, FlowyError>;
fn read_workspace(
&self,
token: &str,
params: WorkspaceIdentifier,
) -> FutureResult<RepeatedWorkspace, WorkspaceError>;
fn read_workspace(&self, token: &str, params: WorkspaceIdentifier) -> FutureResult<RepeatedWorkspace, FlowyError>;
fn update_workspace(&self, token: &str, params: UpdateWorkspaceParams) -> FutureResult<(), WorkspaceError>;
fn update_workspace(&self, token: &str, params: UpdateWorkspaceParams) -> FutureResult<(), FlowyError>;
fn delete_workspace(&self, token: &str, params: WorkspaceIdentifier) -> FutureResult<(), WorkspaceError>;
fn delete_workspace(&self, token: &str, params: WorkspaceIdentifier) -> FutureResult<(), FlowyError>;
// View
fn create_view(&self, token: &str, params: CreateViewParams) -> FutureResult<View, WorkspaceError>;
fn create_view(&self, token: &str, params: CreateViewParams) -> FutureResult<View, FlowyError>;
fn read_view(&self, token: &str, params: ViewIdentifier) -> FutureResult<Option<View>, WorkspaceError>;
fn read_view(&self, token: &str, params: ViewIdentifier) -> FutureResult<Option<View>, FlowyError>;
fn delete_view(&self, token: &str, params: ViewIdentifiers) -> FutureResult<(), WorkspaceError>;
fn delete_view(&self, token: &str, params: ViewIdentifiers) -> FutureResult<(), FlowyError>;
fn update_view(&self, token: &str, params: UpdateViewParams) -> FutureResult<(), WorkspaceError>;
fn update_view(&self, token: &str, params: UpdateViewParams) -> FutureResult<(), FlowyError>;
// App
fn create_app(&self, token: &str, params: CreateAppParams) -> FutureResult<App, WorkspaceError>;
fn create_app(&self, token: &str, params: CreateAppParams) -> FutureResult<App, FlowyError>;
fn read_app(&self, token: &str, params: AppIdentifier) -> FutureResult<Option<App>, WorkspaceError>;
fn read_app(&self, token: &str, params: AppIdentifier) -> FutureResult<Option<App>, FlowyError>;
fn update_app(&self, token: &str, params: UpdateAppParams) -> FutureResult<(), WorkspaceError>;
fn update_app(&self, token: &str, params: UpdateAppParams) -> FutureResult<(), FlowyError>;
fn delete_app(&self, token: &str, params: AppIdentifier) -> FutureResult<(), WorkspaceError>;
fn delete_app(&self, token: &str, params: AppIdentifier) -> FutureResult<(), FlowyError>;
// Trash
fn create_trash(&self, token: &str, params: TrashIdentifiers) -> FutureResult<(), WorkspaceError>;
fn create_trash(&self, token: &str, params: TrashIdentifiers) -> FutureResult<(), FlowyError>;
fn delete_trash(&self, token: &str, params: TrashIdentifiers) -> FutureResult<(), WorkspaceError>;
fn delete_trash(&self, token: &str, params: TrashIdentifiers) -> FutureResult<(), FlowyError>;
fn read_trash(&self, token: &str) -> FutureResult<RepeatedTrash, WorkspaceError>;
fn read_trash(&self, token: &str) -> FutureResult<RepeatedTrash, FlowyError>;
}
pub(crate) fn construct_workspace_server(

View File

@ -5,12 +5,11 @@ use crate::{
view::{CreateViewParams, UpdateViewParams, View, ViewIdentifier, ViewIdentifiers},
workspace::{CreateWorkspaceParams, RepeatedWorkspace, UpdateWorkspaceParams, Workspace, WorkspaceIdentifier},
},
errors::WorkspaceError,
errors::{ErrorCode, FlowyError},
notify::{send_dart_notification, WorkspaceNotification},
services::server::WorkspaceServerAPI,
};
use backend_service::{configuration::ClientServerConfiguration, middleware::*, workspace_request::*};
use flowy_core_infra::errors::ErrorCode;
use lib_infra::future::FutureResult;
pub struct WorkspaceHttpServer {
@ -26,7 +25,7 @@ impl WorkspaceServerAPI for WorkspaceHttpServer {
let mut rx = BACKEND_API_MIDDLEWARE.invalid_token_subscribe();
tokio::spawn(async move {
while let Ok(invalid_token) = rx.recv().await {
let error = WorkspaceError::new(ErrorCode::UserUnauthorized, "");
let error = FlowyError::new(ErrorCode::UserUnauthorized, "");
send_dart_notification(&invalid_token, WorkspaceNotification::UserUnauthorized)
.error(error)
.send()
@ -34,7 +33,7 @@ impl WorkspaceServerAPI for WorkspaceHttpServer {
});
}
fn create_workspace(&self, token: &str, params: CreateWorkspaceParams) -> FutureResult<Workspace, WorkspaceError> {
fn create_workspace(&self, token: &str, params: CreateWorkspaceParams) -> FutureResult<Workspace, FlowyError> {
let token = token.to_owned();
let url = self.config.workspace_url();
FutureResult::new(async move {
@ -43,11 +42,7 @@ impl WorkspaceServerAPI for WorkspaceHttpServer {
})
}
fn read_workspace(
&self,
token: &str,
params: WorkspaceIdentifier,
) -> FutureResult<RepeatedWorkspace, WorkspaceError> {
fn read_workspace(&self, token: &str, params: WorkspaceIdentifier) -> FutureResult<RepeatedWorkspace, FlowyError> {
let token = token.to_owned();
let url = self.config.workspace_url();
FutureResult::new(async move {
@ -56,7 +51,7 @@ impl WorkspaceServerAPI for WorkspaceHttpServer {
})
}
fn update_workspace(&self, token: &str, params: UpdateWorkspaceParams) -> FutureResult<(), WorkspaceError> {
fn update_workspace(&self, token: &str, params: UpdateWorkspaceParams) -> FutureResult<(), FlowyError> {
let token = token.to_owned();
let url = self.config.workspace_url();
FutureResult::new(async move {
@ -65,7 +60,7 @@ impl WorkspaceServerAPI for WorkspaceHttpServer {
})
}
fn delete_workspace(&self, token: &str, params: WorkspaceIdentifier) -> FutureResult<(), WorkspaceError> {
fn delete_workspace(&self, token: &str, params: WorkspaceIdentifier) -> FutureResult<(), FlowyError> {
let token = token.to_owned();
let url = self.config.workspace_url();
FutureResult::new(async move {
@ -74,7 +69,7 @@ impl WorkspaceServerAPI for WorkspaceHttpServer {
})
}
fn create_view(&self, token: &str, params: CreateViewParams) -> FutureResult<View, WorkspaceError> {
fn create_view(&self, token: &str, params: CreateViewParams) -> FutureResult<View, FlowyError> {
let token = token.to_owned();
let url = self.config.view_url();
FutureResult::new(async move {
@ -83,7 +78,7 @@ impl WorkspaceServerAPI for WorkspaceHttpServer {
})
}
fn read_view(&self, token: &str, params: ViewIdentifier) -> FutureResult<Option<View>, WorkspaceError> {
fn read_view(&self, token: &str, params: ViewIdentifier) -> FutureResult<Option<View>, FlowyError> {
let token = token.to_owned();
let url = self.config.view_url();
FutureResult::new(async move {
@ -92,7 +87,7 @@ impl WorkspaceServerAPI for WorkspaceHttpServer {
})
}
fn delete_view(&self, token: &str, params: ViewIdentifiers) -> FutureResult<(), WorkspaceError> {
fn delete_view(&self, token: &str, params: ViewIdentifiers) -> FutureResult<(), FlowyError> {
let token = token.to_owned();
let url = self.config.view_url();
FutureResult::new(async move {
@ -101,7 +96,7 @@ impl WorkspaceServerAPI for WorkspaceHttpServer {
})
}
fn update_view(&self, token: &str, params: UpdateViewParams) -> FutureResult<(), WorkspaceError> {
fn update_view(&self, token: &str, params: UpdateViewParams) -> FutureResult<(), FlowyError> {
let token = token.to_owned();
let url = self.config.view_url();
FutureResult::new(async move {
@ -110,7 +105,7 @@ impl WorkspaceServerAPI for WorkspaceHttpServer {
})
}
fn create_app(&self, token: &str, params: CreateAppParams) -> FutureResult<App, WorkspaceError> {
fn create_app(&self, token: &str, params: CreateAppParams) -> FutureResult<App, FlowyError> {
let token = token.to_owned();
let url = self.config.app_url();
FutureResult::new(async move {
@ -119,7 +114,7 @@ impl WorkspaceServerAPI for WorkspaceHttpServer {
})
}
fn read_app(&self, token: &str, params: AppIdentifier) -> FutureResult<Option<App>, WorkspaceError> {
fn read_app(&self, token: &str, params: AppIdentifier) -> FutureResult<Option<App>, FlowyError> {
let token = token.to_owned();
let url = self.config.app_url();
FutureResult::new(async move {
@ -128,7 +123,7 @@ impl WorkspaceServerAPI for WorkspaceHttpServer {
})
}
fn update_app(&self, token: &str, params: UpdateAppParams) -> FutureResult<(), WorkspaceError> {
fn update_app(&self, token: &str, params: UpdateAppParams) -> FutureResult<(), FlowyError> {
let token = token.to_owned();
let url = self.config.app_url();
FutureResult::new(async move {
@ -137,7 +132,7 @@ impl WorkspaceServerAPI for WorkspaceHttpServer {
})
}
fn delete_app(&self, token: &str, params: AppIdentifier) -> FutureResult<(), WorkspaceError> {
fn delete_app(&self, token: &str, params: AppIdentifier) -> FutureResult<(), FlowyError> {
let token = token.to_owned();
let url = self.config.app_url();
FutureResult::new(async move {
@ -146,7 +141,7 @@ impl WorkspaceServerAPI for WorkspaceHttpServer {
})
}
fn create_trash(&self, token: &str, params: TrashIdentifiers) -> FutureResult<(), WorkspaceError> {
fn create_trash(&self, token: &str, params: TrashIdentifiers) -> FutureResult<(), FlowyError> {
let token = token.to_owned();
let url = self.config.trash_url();
FutureResult::new(async move {
@ -155,7 +150,7 @@ impl WorkspaceServerAPI for WorkspaceHttpServer {
})
}
fn delete_trash(&self, token: &str, params: TrashIdentifiers) -> FutureResult<(), WorkspaceError> {
fn delete_trash(&self, token: &str, params: TrashIdentifiers) -> FutureResult<(), FlowyError> {
let token = token.to_owned();
let url = self.config.trash_url();
FutureResult::new(async move {
@ -164,7 +159,7 @@ impl WorkspaceServerAPI for WorkspaceHttpServer {
})
}
fn read_trash(&self, token: &str) -> FutureResult<RepeatedTrash, WorkspaceError> {
fn read_trash(&self, token: &str) -> FutureResult<RepeatedTrash, FlowyError> {
let token = token.to_owned();
let url = self.config.trash_url();
FutureResult::new(async move {

View File

@ -5,7 +5,7 @@ use crate::{
view::{CreateViewParams, RepeatedView, UpdateViewParams, View, ViewIdentifier, ViewIdentifiers},
workspace::{CreateWorkspaceParams, RepeatedWorkspace, UpdateWorkspaceParams, Workspace, WorkspaceIdentifier},
},
errors::WorkspaceError,
errors::FlowyError,
services::server::WorkspaceServerAPI,
};
use lib_infra::{future::FutureResult, timestamp, uuid};
@ -15,7 +15,7 @@ pub struct WorkspaceServerMock {}
impl WorkspaceServerAPI for WorkspaceServerMock {
fn init(&self) {}
fn create_workspace(&self, _token: &str, params: CreateWorkspaceParams) -> FutureResult<Workspace, WorkspaceError> {
fn create_workspace(&self, _token: &str, params: CreateWorkspaceParams) -> FutureResult<Workspace, FlowyError> {
let time = timestamp();
let workspace = Workspace {
id: uuid(),
@ -33,22 +33,22 @@ impl WorkspaceServerAPI for WorkspaceServerMock {
&self,
_token: &str,
_params: WorkspaceIdentifier,
) -> FutureResult<RepeatedWorkspace, WorkspaceError> {
) -> FutureResult<RepeatedWorkspace, FlowyError> {
FutureResult::new(async {
let repeated_workspace = RepeatedWorkspace { items: vec![] };
Ok(repeated_workspace)
})
}
fn update_workspace(&self, _token: &str, _params: UpdateWorkspaceParams) -> FutureResult<(), WorkspaceError> {
fn update_workspace(&self, _token: &str, _params: UpdateWorkspaceParams) -> FutureResult<(), FlowyError> {
FutureResult::new(async { Ok(()) })
}
fn delete_workspace(&self, _token: &str, _params: WorkspaceIdentifier) -> FutureResult<(), WorkspaceError> {
fn delete_workspace(&self, _token: &str, _params: WorkspaceIdentifier) -> FutureResult<(), FlowyError> {
FutureResult::new(async { Ok(()) })
}
fn create_view(&self, _token: &str, params: CreateViewParams) -> FutureResult<View, WorkspaceError> {
fn create_view(&self, _token: &str, params: CreateViewParams) -> FutureResult<View, FlowyError> {
let time = timestamp();
let view = View {
id: uuid(),
@ -64,19 +64,19 @@ impl WorkspaceServerAPI for WorkspaceServerMock {
FutureResult::new(async { Ok(view) })
}
fn read_view(&self, _token: &str, _params: ViewIdentifier) -> FutureResult<Option<View>, WorkspaceError> {
fn read_view(&self, _token: &str, _params: ViewIdentifier) -> FutureResult<Option<View>, FlowyError> {
FutureResult::new(async { Ok(None) })
}
fn delete_view(&self, _token: &str, _params: ViewIdentifiers) -> FutureResult<(), WorkspaceError> {
fn delete_view(&self, _token: &str, _params: ViewIdentifiers) -> FutureResult<(), FlowyError> {
FutureResult::new(async { Ok(()) })
}
fn update_view(&self, _token: &str, _params: UpdateViewParams) -> FutureResult<(), WorkspaceError> {
fn update_view(&self, _token: &str, _params: UpdateViewParams) -> FutureResult<(), FlowyError> {
FutureResult::new(async { Ok(()) })
}
fn create_app(&self, _token: &str, params: CreateAppParams) -> FutureResult<App, WorkspaceError> {
fn create_app(&self, _token: &str, params: CreateAppParams) -> FutureResult<App, FlowyError> {
let time = timestamp();
let app = App {
id: uuid(),
@ -91,27 +91,27 @@ impl WorkspaceServerAPI for WorkspaceServerMock {
FutureResult::new(async { Ok(app) })
}
fn read_app(&self, _token: &str, _params: AppIdentifier) -> FutureResult<Option<App>, WorkspaceError> {
fn read_app(&self, _token: &str, _params: AppIdentifier) -> FutureResult<Option<App>, FlowyError> {
FutureResult::new(async { Ok(None) })
}
fn update_app(&self, _token: &str, _params: UpdateAppParams) -> FutureResult<(), WorkspaceError> {
fn update_app(&self, _token: &str, _params: UpdateAppParams) -> FutureResult<(), FlowyError> {
FutureResult::new(async { Ok(()) })
}
fn delete_app(&self, _token: &str, _params: AppIdentifier) -> FutureResult<(), WorkspaceError> {
fn delete_app(&self, _token: &str, _params: AppIdentifier) -> FutureResult<(), FlowyError> {
FutureResult::new(async { Ok(()) })
}
fn create_trash(&self, _token: &str, _params: TrashIdentifiers) -> FutureResult<(), WorkspaceError> {
fn create_trash(&self, _token: &str, _params: TrashIdentifiers) -> FutureResult<(), FlowyError> {
FutureResult::new(async { Ok(()) })
}
fn delete_trash(&self, _token: &str, _params: TrashIdentifiers) -> FutureResult<(), WorkspaceError> {
fn delete_trash(&self, _token: &str, _params: TrashIdentifiers) -> FutureResult<(), FlowyError> {
FutureResult::new(async { Ok(()) })
}
fn read_trash(&self, _token: &str) -> FutureResult<RepeatedTrash, WorkspaceError> {
fn read_trash(&self, _token: &str) -> FutureResult<RepeatedTrash, FlowyError> {
FutureResult::new(async {
let repeated_trash = RepeatedTrash { items: vec![] };
Ok(repeated_trash)

View File

@ -1,6 +1,6 @@
use crate::{
entities::trash::{RepeatedTrash, Trash, TrashIdentifier, TrashIdentifiers, TrashType},
errors::{WorkspaceError, WorkspaceResult},
errors::{FlowyError, FlowyResult},
module::{WorkspaceDatabase, WorkspaceUser},
notify::{send_anonymous_dart_notification, WorkspaceNotification},
services::{server::Server, trash::sql::TrashTableSql},
@ -29,21 +29,21 @@ impl TrashController {
}
}
pub(crate) fn init(&self) -> Result<(), WorkspaceError> { Ok(()) }
pub(crate) fn init(&self) -> Result<(), FlowyError> { Ok(()) }
#[tracing::instrument(level = "debug", skip(self), fields(putback) err)]
pub async fn putback(&self, trash_id: &str) -> WorkspaceResult<()> {
let (tx, mut rx) = mpsc::channel::<WorkspaceResult<()>>(1);
pub async fn putback(&self, trash_id: &str) -> FlowyResult<()> {
let (tx, mut rx) = mpsc::channel::<FlowyResult<()>>(1);
let trash_table = TrashTableSql::read(trash_id, &*self.database.db_connection()?)?;
let _ = thread::scope(|_s| {
let conn = self.database.db_connection()?;
conn.immediate_transaction::<_, WorkspaceError, _>(|| {
conn.immediate_transaction::<_, FlowyError, _>(|| {
let _ = TrashTableSql::delete_trash(trash_id, &*conn)?;
notify_trash_changed(TrashTableSql::read_all(&conn)?);
Ok(())
})?;
Ok::<(), WorkspaceError>(())
Ok::<(), FlowyError>(())
})
.unwrap()?;
@ -64,10 +64,10 @@ impl TrashController {
}
#[tracing::instrument(level = "debug", skip(self) err)]
pub async fn restore_all(&self) -> WorkspaceResult<()> {
pub async fn restore_all(&self) -> FlowyResult<()> {
let repeated_trash = thread::scope(|_s| {
let conn = self.database.db_connection()?;
conn.immediate_transaction::<_, WorkspaceError, _>(|| {
conn.immediate_transaction::<_, FlowyError, _>(|| {
let repeated_trash = TrashTableSql::read_all(&*conn)?;
let _ = TrashTableSql::delete_all(&*conn)?;
Ok(repeated_trash)
@ -76,7 +76,7 @@ impl TrashController {
.unwrap()?;
let identifiers: TrashIdentifiers = repeated_trash.items.clone().into();
let (tx, mut rx) = mpsc::channel::<WorkspaceResult<()>>(1);
let (tx, mut rx) = mpsc::channel::<FlowyResult<()>>(1);
let _ = self.notify.send(TrashEvent::Putback(identifiers, tx));
let _ = rx.recv().await;
@ -86,7 +86,7 @@ impl TrashController {
}
#[tracing::instrument(level = "debug", skip(self), err)]
pub async fn delete_all(&self) -> WorkspaceResult<()> {
pub async fn delete_all(&self) -> FlowyResult<()> {
let repeated_trash = TrashTableSql::read_all(&*(self.database.db_connection()?))?;
let trash_identifiers: TrashIdentifiers = repeated_trash.items.clone().into();
let _ = self.delete_with_identifiers(trash_identifiers.clone()).await?;
@ -97,7 +97,7 @@ impl TrashController {
}
#[tracing::instrument(level = "debug", skip(self), err)]
pub async fn delete(&self, trash_identifiers: TrashIdentifiers) -> WorkspaceResult<()> {
pub async fn delete(&self, trash_identifiers: TrashIdentifiers) -> FlowyResult<()> {
let _ = self.delete_with_identifiers(trash_identifiers.clone()).await?;
notify_trash_changed(TrashTableSql::read_all(&*(self.database.db_connection()?))?);
let _ = self.delete_trash_on_server(trash_identifiers)?;
@ -106,8 +106,8 @@ impl TrashController {
}
#[tracing::instrument(level = "debug", skip(self), fields(delete_trash_ids), err)]
pub async fn delete_with_identifiers(&self, trash_identifiers: TrashIdentifiers) -> WorkspaceResult<()> {
let (tx, mut rx) = mpsc::channel::<WorkspaceResult<()>>(1);
pub async fn delete_with_identifiers(&self, trash_identifiers: TrashIdentifiers) -> FlowyResult<()> {
let (tx, mut rx) = mpsc::channel::<FlowyResult<()>>(1);
tracing::Span::current().record("delete_trash_ids", &format!("{}", trash_identifiers).as_str());
let _ = self.notify.send(TrashEvent::Delete(trash_identifiers.clone(), tx));
@ -120,7 +120,7 @@ impl TrashController {
}
let conn = self.database.db_connection()?;
conn.immediate_transaction::<_, WorkspaceError, _>(|| {
conn.immediate_transaction::<_, FlowyError, _>(|| {
for trash_identifier in &trash_identifiers.items {
let _ = TrashTableSql::delete_trash(&trash_identifier.id, &conn)?;
}
@ -136,8 +136,8 @@ impl TrashController {
// CREATE and DROP tables operations because those are auto-commit in the
// database.
#[tracing::instrument(name = "add_trash", level = "debug", skip(self, trash), fields(trash_ids), err)]
pub async fn add<T: Into<Trash>>(&self, trash: Vec<T>) -> Result<(), WorkspaceError> {
let (tx, mut rx) = mpsc::channel::<WorkspaceResult<()>>(1);
pub async fn add<T: Into<Trash>>(&self, trash: Vec<T>) -> Result<(), FlowyError> {
let (tx, mut rx) = mpsc::channel::<FlowyResult<()>>(1);
let repeated_trash = trash.into_iter().map(|t| t.into()).collect::<Vec<Trash>>();
let identifiers = repeated_trash
.iter()
@ -157,14 +157,14 @@ impl TrashController {
);
let _ = thread::scope(|_s| {
let conn = self.database.db_connection()?;
conn.immediate_transaction::<_, WorkspaceError, _>(|| {
conn.immediate_transaction::<_, FlowyError, _>(|| {
let _ = TrashTableSql::create_trash(repeated_trash.clone(), &*conn)?;
let _ = self.create_trash_on_server(repeated_trash);
notify_trash_changed(TrashTableSql::read_all(&conn)?);
Ok(())
})?;
Ok::<(), WorkspaceError>(())
Ok::<(), FlowyError>(())
})
.unwrap()?;
@ -176,13 +176,13 @@ impl TrashController {
pub fn subscribe(&self) -> broadcast::Receiver<TrashEvent> { self.notify.subscribe() }
pub fn read_trash(&self, conn: &SqliteConnection) -> Result<RepeatedTrash, WorkspaceError> {
pub fn read_trash(&self, conn: &SqliteConnection) -> Result<RepeatedTrash, FlowyError> {
let repeated_trash = TrashTableSql::read_all(&*conn)?;
let _ = self.read_trash_on_server()?;
Ok(repeated_trash)
}
pub fn trash_ids(&self, conn: &SqliteConnection) -> Result<Vec<String>, WorkspaceError> {
pub fn trash_ids(&self, conn: &SqliteConnection) -> Result<Vec<String>, FlowyError> {
let ids = TrashTableSql::read_all(&*conn)?
.into_inner()
.into_iter()
@ -194,7 +194,7 @@ impl TrashController {
impl TrashController {
#[tracing::instrument(level = "debug", skip(self, trash), err)]
fn create_trash_on_server<T: Into<TrashIdentifiers>>(&self, trash: T) -> WorkspaceResult<()> {
fn create_trash_on_server<T: Into<TrashIdentifiers>>(&self, trash: T) -> FlowyResult<()> {
let token = self.user.token()?;
let trash_identifiers = trash.into();
let server = self.server.clone();
@ -209,7 +209,7 @@ impl TrashController {
}
#[tracing::instrument(level = "debug", skip(self, trash), err)]
fn delete_trash_on_server<T: Into<TrashIdentifiers>>(&self, trash: T) -> WorkspaceResult<()> {
fn delete_trash_on_server<T: Into<TrashIdentifiers>>(&self, trash: T) -> FlowyResult<()> {
let token = self.user.token()?;
let trash_identifiers = trash.into();
let server = self.server.clone();
@ -223,7 +223,7 @@ impl TrashController {
}
#[tracing::instrument(level = "debug", skip(self), err)]
fn read_trash_on_server(&self) -> WorkspaceResult<()> {
fn read_trash_on_server(&self) -> FlowyResult<()> {
let token = self.user.token()?;
let server = self.server.clone();
let pool = self.database.db_pool()?;
@ -234,7 +234,7 @@ impl TrashController {
tracing::debug!("Remote trash count: {}", repeated_trash.items.len());
match pool.get() {
Ok(conn) => {
let result = conn.immediate_transaction::<_, WorkspaceError, _>(|| {
let result = conn.immediate_transaction::<_, FlowyError, _>(|| {
let _ = TrashTableSql::create_trash(repeated_trash.items.clone(), &*conn)?;
TrashTableSql::read_all(&conn)
});
@ -256,7 +256,7 @@ impl TrashController {
}
#[tracing::instrument(level = "debug", skip(self), err)]
async fn delete_all_trash_on_server(&self) -> WorkspaceResult<()> {
async fn delete_all_trash_on_server(&self) -> FlowyResult<()> {
let token = self.user.token()?;
let server = self.server.clone();
server.delete_trash(&token, TrashIdentifiers::all()).await
@ -273,9 +273,9 @@ fn notify_trash_changed(repeated_trash: RepeatedTrash) {
#[derive(Clone)]
pub enum TrashEvent {
NewTrash(TrashIdentifiers, mpsc::Sender<WorkspaceResult<()>>),
Putback(TrashIdentifiers, mpsc::Sender<WorkspaceResult<()>>),
Delete(TrashIdentifiers, mpsc::Sender<WorkspaceResult<()>>),
NewTrash(TrashIdentifiers, mpsc::Sender<FlowyResult<()>>),
Putback(TrashIdentifiers, mpsc::Sender<FlowyResult<()>>),
Delete(TrashIdentifiers, mpsc::Sender<FlowyResult<()>>),
}
impl std::fmt::Debug for TrashEvent {

View File

@ -1,6 +1,6 @@
use crate::{
entities::trash::{RepeatedTrash, TrashIdentifier, TrashIdentifiers},
errors::WorkspaceError,
errors::FlowyError,
services::TrashController,
};
use lib_dispatch::prelude::{data_result, Data, DataResult, Unit};
@ -9,7 +9,7 @@ use std::sync::Arc;
#[tracing::instrument(skip(controller), err)]
pub(crate) async fn read_trash_handler(
controller: Unit<Arc<TrashController>>,
) -> DataResult<RepeatedTrash, WorkspaceError> {
) -> DataResult<RepeatedTrash, FlowyError> {
let conn = controller.database.db_connection()?;
let repeated_trash = controller.read_trash(&conn)?;
data_result(repeated_trash)
@ -19,7 +19,7 @@ pub(crate) async fn read_trash_handler(
pub(crate) async fn putback_trash_handler(
identifier: Data<TrashIdentifier>,
controller: Unit<Arc<TrashController>>,
) -> Result<(), WorkspaceError> {
) -> Result<(), FlowyError> {
let _ = controller.putback(&identifier.id).await?;
Ok(())
}
@ -28,19 +28,19 @@ pub(crate) async fn putback_trash_handler(
pub(crate) async fn delete_trash_handler(
identifiers: Data<TrashIdentifiers>,
controller: Unit<Arc<TrashController>>,
) -> Result<(), WorkspaceError> {
) -> Result<(), FlowyError> {
let _ = controller.delete(identifiers.into_inner()).await?;
Ok(())
}
#[tracing::instrument(skip(controller), err)]
pub(crate) async fn restore_all_handler(controller: Unit<Arc<TrashController>>) -> Result<(), WorkspaceError> {
pub(crate) async fn restore_all_handler(controller: Unit<Arc<TrashController>>) -> Result<(), FlowyError> {
let _ = controller.restore_all().await?;
Ok(())
}
#[tracing::instrument(skip(controller), err)]
pub(crate) async fn delete_all_handler(controller: Unit<Arc<TrashController>>) -> Result<(), WorkspaceError> {
pub(crate) async fn delete_all_handler(controller: Unit<Arc<TrashController>>) -> Result<(), FlowyError> {
let _ = controller.delete_all().await?;
Ok(())
}

View File

@ -1,6 +1,6 @@
use crate::{
entities::trash::{RepeatedTrash, Trash, TrashType},
errors::WorkspaceError,
errors::FlowyError,
};
use diesel::sql_types::Integer;
use flowy_database::{
@ -12,7 +12,7 @@ use flowy_database::{
pub struct TrashTableSql {}
impl TrashTableSql {
pub(crate) fn create_trash(repeated_trash: Vec<Trash>, conn: &SqliteConnection) -> Result<(), WorkspaceError> {
pub(crate) fn create_trash(repeated_trash: Vec<Trash>, conn: &SqliteConnection) -> Result<(), FlowyError> {
for trash in repeated_trash {
let trash_table: TrashTable = trash.into();
match diesel_record_count!(trash_table, &trash_table.id, conn) {
@ -27,25 +27,25 @@ impl TrashTableSql {
Ok(())
}
pub(crate) fn read_all(conn: &SqliteConnection) -> Result<RepeatedTrash, WorkspaceError> {
pub(crate) fn read_all(conn: &SqliteConnection) -> Result<RepeatedTrash, FlowyError> {
let trash_tables = dsl::trash_table.load::<TrashTable>(conn)?;
let items = trash_tables.into_iter().map(|t| t.into()).collect::<Vec<Trash>>();
Ok(RepeatedTrash { items })
}
pub(crate) fn delete_all(conn: &SqliteConnection) -> Result<(), WorkspaceError> {
pub(crate) fn delete_all(conn: &SqliteConnection) -> Result<(), FlowyError> {
let _ = diesel::delete(dsl::trash_table).execute(conn)?;
Ok(())
}
pub(crate) fn read(trash_id: &str, conn: &SqliteConnection) -> Result<TrashTable, WorkspaceError> {
pub(crate) fn read(trash_id: &str, conn: &SqliteConnection) -> Result<TrashTable, FlowyError> {
let trash_table = dsl::trash_table
.filter(trash_table::id.eq(trash_id))
.first::<TrashTable>(conn)?;
Ok(trash_table)
}
pub(crate) fn delete_trash(trash_id: &str, conn: &SqliteConnection) -> Result<(), WorkspaceError> {
pub(crate) fn delete_trash(trash_id: &str, conn: &SqliteConnection) -> Result<(), FlowyError> {
diesel_delete_table!(trash_table, trash_id, conn);
Ok(())
}

View File

@ -8,7 +8,7 @@ use crate::{
trash::{TrashIdentifiers, TrashType},
view::{CreateViewParams, RepeatedView, UpdateViewParams, View, ViewIdentifier},
},
errors::{internal_error, WorkspaceError, WorkspaceResult},
errors::{internal_error, FlowyError, FlowyResult},
module::{WorkspaceDatabase, WorkspaceUser},
notify::{send_dart_notification, WorkspaceNotification},
services::{
@ -49,23 +49,23 @@ impl ViewController {
}
}
pub(crate) fn init(&self) -> Result<(), WorkspaceError> {
pub(crate) fn init(&self) -> Result<(), FlowyError> {
let _ = self.document.init()?;
self.listen_trash_can_event();
Ok(())
}
#[tracing::instrument(level = "debug", skip(self, params), fields(name = %params.name), err)]
pub(crate) async fn create_view_from_params(&self, params: CreateViewParams) -> Result<View, WorkspaceError> {
pub(crate) async fn create_view_from_params(&self, params: CreateViewParams) -> Result<View, FlowyError> {
let view = self.create_view_on_server(params.clone()).await?;
self.create_view(view).await
}
pub(crate) async fn create_view(&self, view: View) -> Result<View, WorkspaceError> {
pub(crate) async fn create_view(&self, view: View) -> Result<View, FlowyError> {
let conn = &*self.database.db_connection()?;
let trash_can = self.trash_can.clone();
conn.immediate_transaction::<_, WorkspaceError, _>(|| {
conn.immediate_transaction::<_, FlowyError, _>(|| {
let _ = self.save_view(view.clone(), conn)?;
let _ = notify_views_changed(&view.belong_to_id, trash_can, &conn)?;
@ -75,20 +75,20 @@ impl ViewController {
Ok(view)
}
pub(crate) fn save_view(&self, view: View, conn: &SqliteConnection) -> Result<(), WorkspaceError> {
pub(crate) fn save_view(&self, view: View, conn: &SqliteConnection) -> Result<(), FlowyError> {
let view_table = ViewTable::new(view);
let _ = ViewTableSql::create_view(view_table, conn)?;
Ok(())
}
#[tracing::instrument(skip(self, params), fields(view_id = %params.view_id), err)]
pub(crate) async fn read_view(&self, params: ViewIdentifier) -> Result<View, WorkspaceError> {
pub(crate) async fn read_view(&self, params: ViewIdentifier) -> Result<View, FlowyError> {
let conn = self.database.db_connection()?;
let view_table = ViewTableSql::read_view(&params.view_id, &*conn)?;
let trash_ids = self.trash_can.trash_ids(&conn)?;
if trash_ids.contains(&view_table.id) {
return Err(WorkspaceError::record_not_found());
return Err(FlowyError::record_not_found());
}
let view: View = view_table.into();
@ -96,10 +96,10 @@ impl ViewController {
Ok(view)
}
pub(crate) fn read_view_tables(&self, ids: Vec<String>) -> Result<Vec<ViewTable>, WorkspaceError> {
pub(crate) fn read_view_tables(&self, ids: Vec<String>) -> Result<Vec<ViewTable>, FlowyError> {
let conn = &*self.database.db_connection()?;
let mut view_tables = vec![];
conn.immediate_transaction::<_, WorkspaceError, _>(|| {
conn.immediate_transaction::<_, FlowyError, _>(|| {
for view_id in ids {
view_tables.push(ViewTableSql::read_view(&view_id, conn)?);
}
@ -110,7 +110,7 @@ impl ViewController {
}
#[tracing::instrument(level = "debug", skip(self, params), fields(doc_id = %params.doc_id), err)]
pub(crate) async fn open_view(&self, params: DocIdentifier) -> Result<DocDelta, WorkspaceError> {
pub(crate) async fn open_view(&self, params: DocIdentifier) -> Result<DocDelta, FlowyError> {
let doc_id = params.doc_id.clone();
let edit_context = self.document.open(params).await?;
@ -119,13 +119,13 @@ impl ViewController {
}
#[tracing::instrument(level = "debug", skip(self,params), fields(doc_id = %params.doc_id), err)]
pub(crate) async fn close_view(&self, params: DocIdentifier) -> Result<(), WorkspaceError> {
pub(crate) async fn close_view(&self, params: DocIdentifier) -> Result<(), FlowyError> {
let _ = self.document.close(params).await?;
Ok(())
}
#[tracing::instrument(level = "debug", skip(self,params), fields(doc_id = %params.doc_id), err)]
pub(crate) async fn delete_view(&self, params: DocIdentifier) -> Result<(), WorkspaceError> {
pub(crate) async fn delete_view(&self, params: DocIdentifier) -> Result<(), FlowyError> {
if let Some(view_id) = KV::get_str(LATEST_VIEW_ID) {
if view_id == params.doc_id {
let _ = KV::remove(LATEST_VIEW_ID);
@ -136,7 +136,7 @@ impl ViewController {
}
#[tracing::instrument(level = "debug", skip(self, params), fields(doc_id = %params.doc_id), err)]
pub(crate) async fn duplicate_view(&self, params: DocIdentifier) -> Result<(), WorkspaceError> {
pub(crate) async fn duplicate_view(&self, params: DocIdentifier) -> Result<(), FlowyError> {
let view: View = ViewTableSql::read_view(&params.doc_id, &*self.database.db_connection()?)?.into();
let delta_data = self
.document
@ -157,7 +157,7 @@ impl ViewController {
}
#[tracing::instrument(level = "debug", skip(self, params), err)]
pub(crate) async fn export_doc(&self, params: ExportParams) -> Result<ExportData, WorkspaceError> {
pub(crate) async fn export_doc(&self, params: ExportParams) -> Result<ExportData, FlowyError> {
let doc_identifier: DocIdentifier = params.doc_id.into();
let doc = self
.document
@ -172,7 +172,7 @@ impl ViewController {
// belong_to_id will be the app_id or view_id.
#[tracing::instrument(level = "debug", skip(self), err)]
pub(crate) async fn read_views_belong_to(&self, belong_to_id: &str) -> Result<RepeatedView, WorkspaceError> {
pub(crate) async fn read_views_belong_to(&self, belong_to_id: &str) -> Result<RepeatedView, FlowyError> {
// TODO: read from server
let conn = self.database.db_connection()?;
let repeated_view = read_local_belonging_view(belong_to_id, self.trash_can.clone(), &conn)?;
@ -180,12 +180,12 @@ impl ViewController {
}
#[tracing::instrument(level = "debug", skip(self, params), err)]
pub(crate) async fn update_view(&self, params: UpdateViewParams) -> Result<View, WorkspaceError> {
pub(crate) async fn update_view(&self, params: UpdateViewParams) -> Result<View, FlowyError> {
let conn = &*self.database.db_connection()?;
let changeset = ViewTableChangeset::new(params.clone());
let view_id = changeset.id.clone();
let updated_view = conn.immediate_transaction::<_, WorkspaceError, _>(|| {
let updated_view = conn.immediate_transaction::<_, FlowyError, _>(|| {
let _ = ViewTableSql::update_view(changeset, conn)?;
let view: View = ViewTableSql::read_view(&view_id, conn)?.into();
Ok(view)
@ -201,12 +201,12 @@ impl ViewController {
Ok(updated_view)
}
pub(crate) async fn apply_doc_delta(&self, params: DocDelta) -> Result<DocDelta, WorkspaceError> {
pub(crate) async fn apply_doc_delta(&self, params: DocDelta) -> Result<DocDelta, FlowyError> {
let doc = self.document.apply_doc_delta(params).await?;
Ok(doc)
}
pub(crate) fn latest_visit_view(&self) -> WorkspaceResult<Option<View>> {
pub(crate) fn latest_visit_view(&self) -> FlowyResult<Option<View>> {
match KV::get_str(LATEST_VIEW_ID) {
None => Ok(None),
Some(view_id) => {
@ -222,14 +222,14 @@ impl ViewController {
impl ViewController {
#[tracing::instrument(skip(self), err)]
async fn create_view_on_server(&self, params: CreateViewParams) -> Result<View, WorkspaceError> {
async fn create_view_on_server(&self, params: CreateViewParams) -> Result<View, FlowyError> {
let token = self.user.token()?;
let view = self.server.create_view(&token, params).await?;
Ok(view)
}
#[tracing::instrument(skip(self), err)]
fn update_view_on_server(&self, params: UpdateViewParams) -> Result<(), WorkspaceError> {
fn update_view_on_server(&self, params: UpdateViewParams) -> Result<(), FlowyError> {
let token = self.user.token()?;
let server = self.server.clone();
tokio::spawn(async move {
@ -245,7 +245,7 @@ impl ViewController {
}
#[tracing::instrument(skip(self), err)]
fn read_view_on_server(&self, params: ViewIdentifier) -> Result<(), WorkspaceError> {
fn read_view_on_server(&self, params: ViewIdentifier) -> Result<(), FlowyError> {
let token = self.user.token()?;
let server = self.server.clone();
let pool = self.database.db_pool()?;
@ -314,7 +314,7 @@ async fn handle_trash_event(
let _ = notify_views_changed(&view_table.belong_to_id, trash_can.clone(), conn)?;
notify_dart(view_table, WorkspaceNotification::ViewDeleted);
}
Ok::<(), WorkspaceError>(())
Ok::<(), FlowyError>(())
};
let _ = ret.send(result()).await;
},
@ -326,14 +326,14 @@ async fn handle_trash_event(
let _ = notify_views_changed(&view_table.belong_to_id, trash_can.clone(), conn)?;
notify_dart(view_table, WorkspaceNotification::ViewRestored);
}
Ok::<(), WorkspaceError>(())
Ok::<(), FlowyError>(())
};
let _ = ret.send(result()).await;
},
TrashEvent::Delete(identifiers, ret) => {
let result = || {
let conn = &*db_result?;
let _ = conn.immediate_transaction::<_, WorkspaceError, _>(|| {
let _ = conn.immediate_transaction::<_, FlowyError, _>(|| {
let mut notify_ids = HashSet::new();
for identifier in identifiers.items {
let view_table = ViewTableSql::read_view(&identifier.id, conn)?;
@ -348,19 +348,16 @@ async fn handle_trash_event(
Ok(())
})?;
Ok::<(), WorkspaceError>(())
Ok::<(), FlowyError>(())
};
let _ = ret.send(result()).await;
},
}
}
fn get_view_table_from(
identifiers: TrashIdentifiers,
conn: &SqliteConnection,
) -> Result<Vec<ViewTable>, WorkspaceError> {
fn get_view_table_from(identifiers: TrashIdentifiers, conn: &SqliteConnection) -> Result<Vec<ViewTable>, FlowyError> {
let mut view_tables = vec![];
let _ = conn.immediate_transaction::<_, WorkspaceError, _>(|| {
let _ = conn.immediate_transaction::<_, FlowyError, _>(|| {
for identifier in identifiers.items {
let view_table = ViewTableSql::read_view(&identifier.id, conn)?;
view_tables.push(view_table);
@ -380,7 +377,7 @@ fn notify_views_changed(
belong_to_id: &str,
trash_can: Arc<TrashController>,
conn: &SqliteConnection,
) -> WorkspaceResult<()> {
) -> FlowyResult<()> {
let repeated_view = read_local_belonging_view(belong_to_id, trash_can.clone(), conn)?;
tracing::Span::current().record("view_count", &format!("{}", repeated_view.len()).as_str());
send_dart_notification(&belong_to_id, WorkspaceNotification::AppViewsChanged)
@ -393,7 +390,7 @@ fn read_local_belonging_view(
belong_to_id: &str,
trash_can: Arc<TrashController>,
conn: &SqliteConnection,
) -> WorkspaceResult<RepeatedView> {
) -> FlowyResult<RepeatedView> {
let mut view_tables = ViewTableSql::read_views(belong_to_id, conn)?;
let trash_ids = trash_can.trash_ids(conn)?;
view_tables.retain(|view_table| !trash_ids.contains(&view_table.id));

View File

@ -12,7 +12,7 @@ use crate::{
ViewIdentifiers,
},
},
errors::WorkspaceError,
errors::FlowyError,
services::{TrashController, ViewController},
};
use flowy_collaboration::entities::doc::DocDelta;
@ -23,7 +23,7 @@ use std::{convert::TryInto, sync::Arc};
pub(crate) async fn create_view_handler(
data: Data<CreateViewRequest>,
controller: Unit<Arc<ViewController>>,
) -> DataResult<View, WorkspaceError> {
) -> DataResult<View, FlowyError> {
let params: CreateViewParams = data.into_inner().try_into()?;
let view = controller.create_view_from_params(params).await?;
data_result(view)
@ -32,7 +32,7 @@ pub(crate) async fn create_view_handler(
pub(crate) async fn read_view_handler(
data: Data<QueryViewRequest>,
controller: Unit<Arc<ViewController>>,
) -> DataResult<View, WorkspaceError> {
) -> DataResult<View, FlowyError> {
let params: ViewIdentifier = data.into_inner().try_into()?;
let mut view = controller.read_view(params.clone()).await?;
view.belongings = controller.read_views_belong_to(&params.view_id).await?;
@ -44,7 +44,7 @@ pub(crate) async fn read_view_handler(
pub(crate) async fn update_view_handler(
data: Data<UpdateViewRequest>,
controller: Unit<Arc<ViewController>>,
) -> Result<(), WorkspaceError> {
) -> Result<(), FlowyError> {
let params: UpdateViewParams = data.into_inner().try_into()?;
let _ = controller.update_view(params).await?;
@ -54,7 +54,7 @@ pub(crate) async fn update_view_handler(
pub(crate) async fn apply_doc_delta_handler(
data: Data<DocDelta>,
controller: Unit<Arc<ViewController>>,
) -> DataResult<DocDelta, WorkspaceError> {
) -> DataResult<DocDelta, FlowyError> {
// let params: DocDelta = data.into_inner().try_into()?;
let doc = controller.apply_doc_delta(data.into_inner()).await?;
data_result(doc)
@ -64,7 +64,7 @@ pub(crate) async fn delete_view_handler(
data: Data<QueryViewRequest>,
controller: Unit<Arc<ViewController>>,
trash_can: Unit<Arc<TrashController>>,
) -> Result<(), WorkspaceError> {
) -> Result<(), FlowyError> {
let params: ViewIdentifiers = data.into_inner().try_into()?;
for view_id in &params.view_ids {
let _ = controller.delete_view(view_id.into()).await;
@ -83,7 +83,7 @@ pub(crate) async fn delete_view_handler(
pub(crate) async fn open_view_handler(
data: Data<QueryViewRequest>,
controller: Unit<Arc<ViewController>>,
) -> DataResult<DocDelta, WorkspaceError> {
) -> DataResult<DocDelta, FlowyError> {
let params: ViewIdentifier = data.into_inner().try_into()?;
let doc = controller.open_view(params.into()).await?;
data_result(doc)
@ -92,7 +92,7 @@ pub(crate) async fn open_view_handler(
pub(crate) async fn close_view_handler(
data: Data<QueryViewRequest>,
controller: Unit<Arc<ViewController>>,
) -> Result<(), WorkspaceError> {
) -> Result<(), FlowyError> {
let params: ViewIdentifier = data.into_inner().try_into()?;
let _ = controller.close_view(params.into()).await?;
Ok(())
@ -102,7 +102,7 @@ pub(crate) async fn close_view_handler(
pub(crate) async fn duplicate_view_handler(
data: Data<QueryViewRequest>,
controller: Unit<Arc<ViewController>>,
) -> Result<(), WorkspaceError> {
) -> Result<(), FlowyError> {
let params: ViewIdentifier = data.into_inner().try_into()?;
let _ = controller.duplicate_view(params.into()).await?;
Ok(())
@ -112,7 +112,7 @@ pub(crate) async fn duplicate_view_handler(
pub(crate) async fn export_handler(
data: Data<ExportRequest>,
controller: Unit<Arc<ViewController>>,
) -> DataResult<ExportData, WorkspaceError> {
) -> DataResult<ExportData, FlowyError> {
let params: ExportParams = data.into_inner().try_into()?;
let data = controller.export_doc(params).await?;
data_result(data)

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