diff --git a/app_flowy/lib/workspace/infrastructure/i_app_impl.dart b/app_flowy/lib/workspace/infrastructure/i_app_impl.dart index ac19453819..9f5cb7ed7c 100644 --- a/app_flowy/lib/workspace/infrastructure/i_app_impl.dart +++ b/app_flowy/lib/workspace/infrastructure/i_app_impl.dart @@ -35,8 +35,7 @@ class IAppImpl extends IApp { final result = await docRepo.createDoc( name: view.name, desc: "", text: "[{\"insert\":\"\\n\"}]"); return result.fold((l) => left(view), (r) { - return right( - WorkspaceError(code: WorkspaceErrorCode.Unknown, msg: r.msg)); + return right(WorkspaceError(code: WsErrCode.Unknown, msg: r.msg)); }); default: return left(view); diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pb.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pb.dart index 8a9e17b84a..e60cd65aa0 100644 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pb.dart +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pb.dart @@ -15,14 +15,14 @@ export 'errors.pbenum.dart'; class UserError extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UserError', createEmptyInstance: create) - ..e(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'code', $pb.PbFieldType.OE, defaultOrMaker: UserErrorCode.Unknown, valueOf: UserErrorCode.valueOf, enumValues: UserErrorCode.values) + ..e(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'code', $pb.PbFieldType.OE, defaultOrMaker: UserErrCode.Unknown, valueOf: UserErrCode.valueOf, enumValues: UserErrCode.values) ..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'msg') ..hasRequiredFields = false ; UserError._() : super(); factory UserError({ - UserErrorCode? code, + UserErrCode? code, $core.String? msg, }) { final _result = create(); @@ -56,9 +56,9 @@ class UserError extends $pb.GeneratedMessage { static UserError? _defaultInstance; @$pb.TagNumber(1) - UserErrorCode get code => $_getN(0); + UserErrCode get code => $_getN(0); @$pb.TagNumber(1) - set code(UserErrorCode v) { setField(1, v); } + set code(UserErrCode v) { setField(1, v); } @$pb.TagNumber(1) $core.bool hasCode() => $_has(0); @$pb.TagNumber(1) diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbenum.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbenum.dart index 791039fce8..1158167d22 100644 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbenum.dart +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbenum.dart @@ -9,26 +9,26 @@ import 'dart:core' as $core; import 'package:protobuf/protobuf.dart' as $pb; -class UserErrorCode extends $pb.ProtobufEnum { - static const UserErrorCode Unknown = UserErrorCode._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'Unknown'); - static const UserErrorCode UserDatabaseInitFailed = UserErrorCode._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserDatabaseInitFailed'); - static const UserErrorCode UserDatabaseWriteLocked = UserErrorCode._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserDatabaseWriteLocked'); - static const UserErrorCode UserDatabaseReadLocked = UserErrorCode._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserDatabaseReadLocked'); - static const UserErrorCode UserDatabaseDidNotMatch = UserErrorCode._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserDatabaseDidNotMatch'); - static const UserErrorCode UserDatabaseInternalError = UserErrorCode._(5, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserDatabaseInternalError'); - static const UserErrorCode SqlInternalError = UserErrorCode._(6, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SqlInternalError'); - static const UserErrorCode UserNotLoginYet = UserErrorCode._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserNotLoginYet'); - static const UserErrorCode ReadCurrentIdFailed = UserErrorCode._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ReadCurrentIdFailed'); - static const UserErrorCode WriteCurrentIdFailed = UserErrorCode._(12, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WriteCurrentIdFailed'); - static const UserErrorCode EmailInvalid = UserErrorCode._(20, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'EmailInvalid'); - static const UserErrorCode PasswordInvalid = UserErrorCode._(21, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'PasswordInvalid'); - static const UserErrorCode UserNameInvalid = UserErrorCode._(22, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserNameInvalid'); - static const UserErrorCode UserWorkspaceInvalid = UserErrorCode._(23, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserWorkspaceInvalid'); - static const UserErrorCode UserIdInvalid = UserErrorCode._(24, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserIdInvalid'); - static const UserErrorCode CreateDefaultWorkspaceFailed = UserErrorCode._(25, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CreateDefaultWorkspaceFailed'); - static const UserErrorCode DefaultWorkspaceAlreadyExist = UserErrorCode._(26, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DefaultWorkspaceAlreadyExist'); +class UserErrCode extends $pb.ProtobufEnum { + static const UserErrCode Unknown = UserErrCode._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'Unknown'); + static const UserErrCode UserDatabaseInitFailed = UserErrCode._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserDatabaseInitFailed'); + static const UserErrCode UserDatabaseWriteLocked = UserErrCode._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserDatabaseWriteLocked'); + static const UserErrCode UserDatabaseReadLocked = UserErrCode._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserDatabaseReadLocked'); + static const UserErrCode UserDatabaseDidNotMatch = UserErrCode._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserDatabaseDidNotMatch'); + static const UserErrCode UserDatabaseInternalError = UserErrCode._(5, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserDatabaseInternalError'); + static const UserErrCode SqlInternalError = UserErrCode._(6, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SqlInternalError'); + static const UserErrCode UserNotLoginYet = UserErrCode._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserNotLoginYet'); + static const UserErrCode ReadCurrentIdFailed = UserErrCode._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ReadCurrentIdFailed'); + static const UserErrCode WriteCurrentIdFailed = UserErrCode._(12, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WriteCurrentIdFailed'); + static const UserErrCode EmailInvalid = UserErrCode._(20, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'EmailInvalid'); + static const UserErrCode PasswordInvalid = UserErrCode._(21, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'PasswordInvalid'); + static const UserErrCode UserNameInvalid = UserErrCode._(22, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserNameInvalid'); + static const UserErrCode UserWorkspaceInvalid = UserErrCode._(23, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserWorkspaceInvalid'); + static const UserErrCode UserIdInvalid = UserErrCode._(24, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserIdInvalid'); + static const UserErrCode CreateDefaultWorkspaceFailed = UserErrCode._(25, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'CreateDefaultWorkspaceFailed'); + static const UserErrCode DefaultWorkspaceAlreadyExist = UserErrCode._(26, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DefaultWorkspaceAlreadyExist'); - static const $core.List values = [ + static const $core.List values = [ Unknown, UserDatabaseInitFailed, UserDatabaseWriteLocked, @@ -48,9 +48,9 @@ class UserErrorCode extends $pb.ProtobufEnum { DefaultWorkspaceAlreadyExist, ]; - static final $core.Map<$core.int, UserErrorCode> _byValue = $pb.ProtobufEnum.initByValue(values); - static UserErrorCode? valueOf($core.int value) => _byValue[value]; + static final $core.Map<$core.int, UserErrCode> _byValue = $pb.ProtobufEnum.initByValue(values); + static UserErrCode? valueOf($core.int value) => _byValue[value]; - const UserErrorCode._($core.int v, $core.String n) : super(v, n); + const UserErrCode._($core.int v, $core.String n) : super(v, n); } diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbjson.dart index 9625ae9cff..09b44306bc 100644 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbjson.dart +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user/errors.pbjson.dart @@ -8,9 +8,9 @@ import 'dart:core' as $core; import 'dart:convert' as $convert; import 'dart:typed_data' as $typed_data; -@$core.Deprecated('Use userErrorCodeDescriptor instead') -const UserErrorCode$json = const { - '1': 'UserErrorCode', +@$core.Deprecated('Use userErrCodeDescriptor instead') +const UserErrCode$json = const { + '1': 'UserErrCode', '2': const [ const {'1': 'Unknown', '2': 0}, const {'1': 'UserDatabaseInitFailed', '2': 1}, @@ -32,16 +32,16 @@ const UserErrorCode$json = const { ], }; -/// Descriptor for `UserErrorCode`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List userErrorCodeDescriptor = $convert.base64Decode('Cg1Vc2VyRXJyb3JDb2RlEgsKB1Vua25vd24QABIaChZVc2VyRGF0YWJhc2VJbml0RmFpbGVkEAESGwoXVXNlckRhdGFiYXNlV3JpdGVMb2NrZWQQAhIaChZVc2VyRGF0YWJhc2VSZWFkTG9ja2VkEAMSGwoXVXNlckRhdGFiYXNlRGlkTm90TWF0Y2gQBBIdChlVc2VyRGF0YWJhc2VJbnRlcm5hbEVycm9yEAUSFAoQU3FsSW50ZXJuYWxFcnJvchAGEhMKD1VzZXJOb3RMb2dpbllldBAKEhcKE1JlYWRDdXJyZW50SWRGYWlsZWQQCxIYChRXcml0ZUN1cnJlbnRJZEZhaWxlZBAMEhAKDEVtYWlsSW52YWxpZBAUEhMKD1Bhc3N3b3JkSW52YWxpZBAVEhMKD1VzZXJOYW1lSW52YWxpZBAWEhgKFFVzZXJXb3Jrc3BhY2VJbnZhbGlkEBcSEQoNVXNlcklkSW52YWxpZBAYEiAKHENyZWF0ZURlZmF1bHRXb3Jrc3BhY2VGYWlsZWQQGRIgChxEZWZhdWx0V29ya3NwYWNlQWxyZWFkeUV4aXN0EBo='); +/// Descriptor for `UserErrCode`. Decode as a `google.protobuf.EnumDescriptorProto`. +final $typed_data.Uint8List userErrCodeDescriptor = $convert.base64Decode('CgtVc2VyRXJyQ29kZRILCgdVbmtub3duEAASGgoWVXNlckRhdGFiYXNlSW5pdEZhaWxlZBABEhsKF1VzZXJEYXRhYmFzZVdyaXRlTG9ja2VkEAISGgoWVXNlckRhdGFiYXNlUmVhZExvY2tlZBADEhsKF1VzZXJEYXRhYmFzZURpZE5vdE1hdGNoEAQSHQoZVXNlckRhdGFiYXNlSW50ZXJuYWxFcnJvchAFEhQKEFNxbEludGVybmFsRXJyb3IQBhITCg9Vc2VyTm90TG9naW5ZZXQQChIXChNSZWFkQ3VycmVudElkRmFpbGVkEAsSGAoUV3JpdGVDdXJyZW50SWRGYWlsZWQQDBIQCgxFbWFpbEludmFsaWQQFBITCg9QYXNzd29yZEludmFsaWQQFRITCg9Vc2VyTmFtZUludmFsaWQQFhIYChRVc2VyV29ya3NwYWNlSW52YWxpZBAXEhEKDVVzZXJJZEludmFsaWQQGBIgChxDcmVhdGVEZWZhdWx0V29ya3NwYWNlRmFpbGVkEBkSIAocRGVmYXVsdFdvcmtzcGFjZUFscmVhZHlFeGlzdBAa'); @$core.Deprecated('Use userErrorDescriptor instead') const UserError$json = const { '1': 'UserError', '2': const [ - const {'1': 'code', '3': 1, '4': 1, '5': 14, '6': '.UserErrorCode', '10': 'code'}, + const {'1': 'code', '3': 1, '4': 1, '5': 14, '6': '.UserErrCode', '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('CglVc2VyRXJyb3ISIgoEY29kZRgBIAEoDjIOLlVzZXJFcnJvckNvZGVSBGNvZGUSEAoDbXNnGAIgASgJUgNtc2c='); +final $typed_data.Uint8List userErrorDescriptor = $convert.base64Decode('CglVc2VyRXJyb3ISIAoEY29kZRgBIAEoDjIMLlVzZXJFcnJDb2RlUgRjb2RlEhAKA21zZxgCIAEoCVIDbXNn'); diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/errors.pb.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/errors.pb.dart index 5caae3229d..b03572c2e7 100644 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/errors.pb.dart +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/errors.pb.dart @@ -15,14 +15,14 @@ export 'errors.pbenum.dart'; class WorkspaceError extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'WorkspaceError', createEmptyInstance: create) - ..e(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'code', $pb.PbFieldType.OE, defaultOrMaker: WorkspaceErrorCode.Unknown, valueOf: WorkspaceErrorCode.valueOf, enumValues: WorkspaceErrorCode.values) + ..e(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'code', $pb.PbFieldType.OE, defaultOrMaker: WsErrCode.Unknown, valueOf: WsErrCode.valueOf, enumValues: WsErrCode.values) ..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'msg') ..hasRequiredFields = false ; WorkspaceError._() : super(); factory WorkspaceError({ - WorkspaceErrorCode? code, + WsErrCode? code, $core.String? msg, }) { final _result = create(); @@ -56,9 +56,9 @@ class WorkspaceError extends $pb.GeneratedMessage { static WorkspaceError? _defaultInstance; @$pb.TagNumber(1) - WorkspaceErrorCode get code => $_getN(0); + WsErrCode get code => $_getN(0); @$pb.TagNumber(1) - set code(WorkspaceErrorCode v) { setField(1, v); } + set code(WsErrCode v) { setField(1, v); } @$pb.TagNumber(1) $core.bool hasCode() => $_has(0); @$pb.TagNumber(1) diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/errors.pbenum.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/errors.pbenum.dart index 156f16249b..6c645d4eeb 100644 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/errors.pbenum.dart +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/errors.pbenum.dart @@ -9,23 +9,23 @@ import 'dart:core' as $core; import 'package:protobuf/protobuf.dart' as $pb; -class WorkspaceErrorCode extends $pb.ProtobufEnum { - static const WorkspaceErrorCode Unknown = WorkspaceErrorCode._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'Unknown'); - static const WorkspaceErrorCode WorkspaceNameInvalid = WorkspaceErrorCode._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceNameInvalid'); - static const WorkspaceErrorCode WorkspaceIdInvalid = WorkspaceErrorCode._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceIdInvalid'); - static const WorkspaceErrorCode AppColorStyleInvalid = WorkspaceErrorCode._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppColorStyleInvalid'); - static const WorkspaceErrorCode AppIdInvalid = WorkspaceErrorCode._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppIdInvalid'); - static const WorkspaceErrorCode AppNameInvalid = WorkspaceErrorCode._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppNameInvalid'); - static const WorkspaceErrorCode ViewNameInvalid = WorkspaceErrorCode._(20, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewNameInvalid'); - static const WorkspaceErrorCode ViewThumbnailInvalid = WorkspaceErrorCode._(21, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewThumbnailInvalid'); - static const WorkspaceErrorCode ViewIdInvalid = WorkspaceErrorCode._(22, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewIdInvalid'); - static const WorkspaceErrorCode ViewDescInvalid = WorkspaceErrorCode._(23, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewDescInvalid'); - static const WorkspaceErrorCode DatabaseConnectionFail = WorkspaceErrorCode._(100, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DatabaseConnectionFail'); - static const WorkspaceErrorCode WorkspaceDatabaseError = WorkspaceErrorCode._(101, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceDatabaseError'); - static const WorkspaceErrorCode UserInternalError = WorkspaceErrorCode._(102, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserInternalError'); - static const WorkspaceErrorCode UserNotLoginYet = WorkspaceErrorCode._(103, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserNotLoginYet'); +class WsErrCode extends $pb.ProtobufEnum { + static const WsErrCode Unknown = WsErrCode._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'Unknown'); + static const WsErrCode WorkspaceNameInvalid = WsErrCode._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceNameInvalid'); + static const WsErrCode WorkspaceIdInvalid = WsErrCode._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceIdInvalid'); + static const WsErrCode AppColorStyleInvalid = WsErrCode._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppColorStyleInvalid'); + static const WsErrCode AppIdInvalid = WsErrCode._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppIdInvalid'); + static const WsErrCode AppNameInvalid = WsErrCode._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppNameInvalid'); + static const WsErrCode ViewNameInvalid = WsErrCode._(20, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewNameInvalid'); + static const WsErrCode ViewThumbnailInvalid = WsErrCode._(21, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewThumbnailInvalid'); + static const WsErrCode ViewIdInvalid = WsErrCode._(22, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewIdInvalid'); + static const WsErrCode ViewDescInvalid = WsErrCode._(23, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewDescInvalid'); + static const WsErrCode DatabaseConnectionFail = WsErrCode._(100, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DatabaseConnectionFail'); + static const WsErrCode WorkspaceDatabaseError = WsErrCode._(101, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceDatabaseError'); + static const WsErrCode UserInternalError = WsErrCode._(102, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserInternalError'); + static const WsErrCode UserNotLoginYet = WsErrCode._(103, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserNotLoginYet'); - static const $core.List values = [ + static const $core.List values = [ Unknown, WorkspaceNameInvalid, WorkspaceIdInvalid, @@ -42,9 +42,9 @@ class WorkspaceErrorCode extends $pb.ProtobufEnum { UserNotLoginYet, ]; - static final $core.Map<$core.int, WorkspaceErrorCode> _byValue = $pb.ProtobufEnum.initByValue(values); - static WorkspaceErrorCode? valueOf($core.int value) => _byValue[value]; + static final $core.Map<$core.int, WsErrCode> _byValue = $pb.ProtobufEnum.initByValue(values); + static WsErrCode? valueOf($core.int value) => _byValue[value]; - const WorkspaceErrorCode._($core.int v, $core.String n) : super(v, n); + const WsErrCode._($core.int v, $core.String n) : super(v, n); } diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/errors.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/errors.pbjson.dart index 54591696e9..e422474aee 100644 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/errors.pbjson.dart +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/errors.pbjson.dart @@ -8,9 +8,9 @@ import 'dart:core' as $core; import 'dart:convert' as $convert; import 'dart:typed_data' as $typed_data; -@$core.Deprecated('Use workspaceErrorCodeDescriptor instead') -const WorkspaceErrorCode$json = const { - '1': 'WorkspaceErrorCode', +@$core.Deprecated('Use wsErrCodeDescriptor instead') +const WsErrCode$json = const { + '1': 'WsErrCode', '2': const [ const {'1': 'Unknown', '2': 0}, const {'1': 'WorkspaceNameInvalid', '2': 1}, @@ -29,16 +29,16 @@ const WorkspaceErrorCode$json = const { ], }; -/// Descriptor for `WorkspaceErrorCode`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List workspaceErrorCodeDescriptor = $convert.base64Decode('ChJXb3Jrc3BhY2VFcnJvckNvZGUSCwoHVW5rbm93bhAAEhgKFFdvcmtzcGFjZU5hbWVJbnZhbGlkEAESFgoSV29ya3NwYWNlSWRJbnZhbGlkEAISGAoUQXBwQ29sb3JTdHlsZUludmFsaWQQAxIQCgxBcHBJZEludmFsaWQQChISCg5BcHBOYW1lSW52YWxpZBALEhMKD1ZpZXdOYW1lSW52YWxpZBAUEhgKFFZpZXdUaHVtYm5haWxJbnZhbGlkEBUSEQoNVmlld0lkSW52YWxpZBAWEhMKD1ZpZXdEZXNjSW52YWxpZBAXEhoKFkRhdGFiYXNlQ29ubmVjdGlvbkZhaWwQZBIaChZXb3Jrc3BhY2VEYXRhYmFzZUVycm9yEGUSFQoRVXNlckludGVybmFsRXJyb3IQZhITCg9Vc2VyTm90TG9naW5ZZXQQZw=='); +/// Descriptor for `WsErrCode`. Decode as a `google.protobuf.EnumDescriptorProto`. +final $typed_data.Uint8List wsErrCodeDescriptor = $convert.base64Decode('CglXc0VyckNvZGUSCwoHVW5rbm93bhAAEhgKFFdvcmtzcGFjZU5hbWVJbnZhbGlkEAESFgoSV29ya3NwYWNlSWRJbnZhbGlkEAISGAoUQXBwQ29sb3JTdHlsZUludmFsaWQQAxIQCgxBcHBJZEludmFsaWQQChISCg5BcHBOYW1lSW52YWxpZBALEhMKD1ZpZXdOYW1lSW52YWxpZBAUEhgKFFZpZXdUaHVtYm5haWxJbnZhbGlkEBUSEQoNVmlld0lkSW52YWxpZBAWEhMKD1ZpZXdEZXNjSW52YWxpZBAXEhoKFkRhdGFiYXNlQ29ubmVjdGlvbkZhaWwQZBIaChZXb3Jrc3BhY2VEYXRhYmFzZUVycm9yEGUSFQoRVXNlckludGVybmFsRXJyb3IQZhITCg9Vc2VyTm90TG9naW5ZZXQQZw=='); @$core.Deprecated('Use workspaceErrorDescriptor instead') const WorkspaceError$json = const { '1': 'WorkspaceError', '2': const [ - const {'1': 'code', '3': 1, '4': 1, '5': 14, '6': '.WorkspaceErrorCode', '10': 'code'}, + const {'1': 'code', '3': 1, '4': 1, '5': 14, '6': '.WsErrCode', '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('Cg5Xb3Jrc3BhY2VFcnJvchInCgRjb2RlGAEgASgOMhMuV29ya3NwYWNlRXJyb3JDb2RlUgRjb2RlEhAKA21zZxgCIAEoCVIDbXNn'); +final $typed_data.Uint8List workspaceErrorDescriptor = $convert.base64Decode('Cg5Xb3Jrc3BhY2VFcnJvchIeCgRjb2RlGAEgASgOMgouV3NFcnJDb2RlUgRjb2RlEhAKA21zZxgCIAEoCVIDbXNn'); diff --git a/rust-lib/dart-ffi/src/lib.rs b/rust-lib/dart-ffi/src/lib.rs index aaaba4d12a..c522c0443a 100644 --- a/rust-lib/dart-ffi/src/lib.rs +++ b/rust-lib/dart-ffi/src/lib.rs @@ -9,7 +9,7 @@ use crate::{ }; use flowy_dispatch::prelude::*; use flowy_sdk::*; -use lazy_static::lazy_static; + use std::{ffi::CStr, os::raw::c_char}; #[no_mangle] diff --git a/rust-lib/dart-ffi/src/model/ffi_response.rs b/rust-lib/dart-ffi/src/model/ffi_response.rs index 29c7c01065..0a16bc4a83 100644 --- a/rust-lib/dart-ffi/src/model/ffi_response.rs +++ b/rust-lib/dart-ffi/src/model/ffi_response.rs @@ -1,5 +1,5 @@ use flowy_derive::{ProtoBuf, ProtoBuf_Enum}; -use flowy_dispatch::prelude::{DispatchError, EventResponse, Payload, StatusCode}; +use flowy_dispatch::prelude::{EventResponse, Payload, StatusCode}; #[derive(ProtoBuf_Enum, Clone, Copy)] pub enum FFIStatusCode { diff --git a/rust-lib/flowy-derive/src/derive_cache/derive_cache.rs b/rust-lib/flowy-derive/src/derive_cache/derive_cache.rs index 9829f4f522..3d0bdbc83d 100644 --- a/rust-lib/flowy-derive/src/derive_cache/derive_cache.rs +++ b/rust-lib/flowy-derive/src/derive_cache/derive_cache.rs @@ -56,12 +56,12 @@ pub fn category_from_str(type_str: &str) -> TypeCategory { | "EditorErrorCode" | "ViewType" | "WorkspaceEvent" - | "WorkspaceErrorCode" + | "WsErrCode" | "WorkspaceObservable" | "FFIStatusCode" | "UserStatus" | "UserEvent" - | "UserErrorCode" + | "UserErrCode" => TypeCategory::Enum, "Option" => TypeCategory::Opt, diff --git a/rust-lib/flowy-dispatch/src/errors/errors.rs b/rust-lib/flowy-dispatch/src/errors/errors.rs index ae7b1e6ff9..2335bde4b9 100644 --- a/rust-lib/flowy-dispatch/src/errors/errors.rs +++ b/rust-lib/flowy-dispatch/src/errors/errors.rs @@ -1,7 +1,7 @@ use crate::{ byte_trait::FromBytes, request::EventRequest, - response::{EventResponse, ResponseBuilder, StatusCode}, + response::{EventResponse, ResponseBuilder}, }; use dyn_clone::DynClone; use serde::{Serialize, Serializer}; diff --git a/rust-lib/flowy-dispatch/src/response/builder.rs b/rust-lib/flowy-dispatch/src/response/builder.rs index 2d56db4205..807561d48b 100644 --- a/rust-lib/flowy-dispatch/src/response/builder.rs +++ b/rust-lib/flowy-dispatch/src/response/builder.rs @@ -1,5 +1,4 @@ use crate::{ - errors::DispatchError, request::Payload, response::{EventResponse, StatusCode}, }; diff --git a/rust-lib/flowy-editor/src/handlers/doc_handler.rs b/rust-lib/flowy-editor/src/handlers/doc_handler.rs index 13ea1d641c..4ba6e2669c 100644 --- a/rust-lib/flowy-editor/src/handlers/doc_handler.rs +++ b/rust-lib/flowy-editor/src/handlers/doc_handler.rs @@ -4,7 +4,7 @@ use crate::{ services::{doc_controller::DocController, file_manager::FileManager}, }; use flowy_dispatch::prelude::*; -use std::{convert::TryInto, path::Path, sync::Arc}; +use std::{convert::TryInto, path::Path}; use tokio::sync::RwLock; #[tracing::instrument(name = "create_doc", skip(data, controller, manager))] @@ -67,7 +67,8 @@ pub async fn update_doc( manager .write() .await - .save(Path::new(&doc_desc.path), &s, params.id.clone()); + .save(Path::new(&doc_desc.path), &s, params.id.clone()) + .unwrap(); } if params.name.is_some() || params.desc.is_some() { diff --git a/rust-lib/flowy-editor/src/module.rs b/rust-lib/flowy-editor/src/module.rs index e3b64fcd94..afc540b414 100644 --- a/rust-lib/flowy-editor/src/module.rs +++ b/rust-lib/flowy-editor/src/module.rs @@ -2,10 +2,7 @@ use crate::{ errors::EditorError, event::EditorEvent, handlers::*, - services::{ - doc_controller::DocController, - file_manager::{create_dir_if_not_exist, FileManager}, - }, + services::{doc_controller::DocController, file_manager::FileManager}, }; use flowy_database::DBConnection; use flowy_dispatch::prelude::*; diff --git a/rust-lib/flowy-editor/src/services/doc_controller.rs b/rust-lib/flowy-editor/src/services/doc_controller.rs index 995063fe11..727459294e 100644 --- a/rust-lib/flowy-editor/src/services/doc_controller.rs +++ b/rust-lib/flowy-editor/src/services/doc_controller.rs @@ -1,5 +1,5 @@ use crate::{ - entities::doc::{CreateDocParams, DocData, DocInfo, QueryDocParams, UpdateDocParams}, + entities::doc::{CreateDocParams, DocInfo, UpdateDocParams}, errors::EditorError, module::EditorDatabase, sql_tables::doc::{DocTable, DocTableChangeset, DocTableSql}, diff --git a/rust-lib/flowy-editor/src/services/file_manager/file.rs b/rust-lib/flowy-editor/src/services/file_manager/file.rs index 610963f9cd..2e658bfde0 100644 --- a/rust-lib/flowy-editor/src/services/file_manager/file.rs +++ b/rust-lib/flowy-editor/src/services/file_manager/file.rs @@ -6,7 +6,6 @@ use std::{ io::{Read, Write}, path::{Path, PathBuf}, str, - sync::atomic::{AtomicUsize, Ordering}, time::SystemTime, }; @@ -117,6 +116,7 @@ pub(crate) fn try_decode( } } +#[allow(dead_code)] pub(crate) fn create_dir_if_not_exist(dir: &str) -> Result<(), io::Error> { let _ = fs::create_dir_all(dir)?; Ok(()) diff --git a/rust-lib/flowy-editor/src/services/file_manager/manager.rs b/rust-lib/flowy-editor/src/services/file_manager/manager.rs index b963c9a152..9d29e08193 100644 --- a/rust-lib/flowy-editor/src/services/file_manager/manager.rs +++ b/rust-lib/flowy-editor/src/services/file_manager/manager.rs @@ -1,9 +1,8 @@ use crate::{module::EditorUser, services::file_manager::*}; use std::{ collections::HashMap, - io, path::{Path, PathBuf}, - sync::{Arc, PoisonError, RwLock, RwLockReadGuard}, + sync::Arc, }; pub struct FileManager { @@ -49,6 +48,7 @@ impl FileManager { } } + #[allow(dead_code)] pub(crate) fn close(&mut self, id: T) where T: Into, @@ -71,12 +71,15 @@ impl FileManager { Ok(path) } + #[allow(dead_code)] pub(crate) fn get_info(&self, id: &FileId) -> Option<&FileInfo> { self.file_info.get(id) } + #[allow(dead_code)] pub(crate) fn get_file_id(&self, path: &Path) -> Option { self.open_files.get(path).cloned() } + #[allow(dead_code)] pub fn check_file(&mut self, path: &Path, id: &FileId) -> bool { if let Some(info) = self.file_info.get_mut(&id) { let modified_time = get_modified_time(path); diff --git a/rust-lib/flowy-editor/src/sql_tables/doc/doc_sql.rs b/rust-lib/flowy-editor/src/sql_tables/doc/doc_sql.rs index 04c41005cf..25f074feae 100644 --- a/rust-lib/flowy-editor/src/sql_tables/doc/doc_sql.rs +++ b/rust-lib/flowy-editor/src/sql_tables/doc/doc_sql.rs @@ -36,5 +36,5 @@ impl DocTableSql { Ok(doc_table) } - pub(crate) fn delete_doc(&self, view_id: &str) -> Result<(), EditorError> { unimplemented!() } + pub(crate) fn delete_doc(&self, _view_id: &str) -> Result<(), EditorError> { unimplemented!() } } diff --git a/rust-lib/flowy-editor/src/sql_tables/doc/doc_table.rs b/rust-lib/flowy-editor/src/sql_tables/doc/doc_table.rs index f1bf3dc5e3..e1c6a62999 100644 --- a/rust-lib/flowy-editor/src/sql_tables/doc/doc_table.rs +++ b/rust-lib/flowy-editor/src/sql_tables/doc/doc_table.rs @@ -1,7 +1,6 @@ use crate::entities::doc::{CreateDocParams, DocInfo, UpdateDocParams}; use flowy_database::schema::doc_table; -use flowy_infra::{timestamp, uuid}; -use std::convert::TryInto; +use flowy_infra::timestamp; #[derive(PartialEq, Clone, Debug, Queryable, Identifiable, Insertable, Associations)] #[table_name = "doc_table"] diff --git a/rust-lib/flowy-editor/src/sql_tables/doc/mod.rs b/rust-lib/flowy-editor/src/sql_tables/doc/mod.rs index 0425e372d4..3979a2f247 100644 --- a/rust-lib/flowy-editor/src/sql_tables/doc/mod.rs +++ b/rust-lib/flowy-editor/src/sql_tables/doc/mod.rs @@ -1,5 +1,5 @@ mod doc_sql; mod doc_table; -pub use doc_sql::*; -pub use doc_table::*; +pub(crate) use doc_sql::*; +pub(crate) use doc_table::*; diff --git a/rust-lib/flowy-editor/tests/editor/helper.rs b/rust-lib/flowy-editor/tests/editor/helper.rs index d68f156870..fd9ee245dc 100644 --- a/rust-lib/flowy-editor/tests/editor/helper.rs +++ b/rust-lib/flowy-editor/tests/editor/helper.rs @@ -34,6 +34,7 @@ pub fn save_doc(desc: &DocInfo, content: &str) { .sync_send(); } +#[allow(dead_code)] pub fn read_doc(doc_id: &str) -> DocInfo { let request = QueryDocRequest { doc_id: doc_id.to_string(), diff --git a/rust-lib/flowy-infra/src/kv/kv.rs b/rust-lib/flowy-infra/src/kv/kv.rs index 115de44165..3805058968 100644 --- a/rust-lib/flowy-infra/src/kv/kv.rs +++ b/rust-lib/flowy-infra/src/kv/kv.rs @@ -175,7 +175,7 @@ mod tests { std::fs::create_dir_all(dir).unwrap(); } - KVStore::init(dir); + KVStore::init(dir).unwrap(); KVStore::set_str("1", "hello".to_string()); assert_eq!(KVStore::get_str("1").unwrap(), "hello"); diff --git a/rust-lib/flowy-observable/src/entities/subject.rs b/rust-lib/flowy-observable/src/entities/subject.rs index c1a2b6d67c..89ed245db0 100644 --- a/rust-lib/flowy-observable/src/entities/subject.rs +++ b/rust-lib/flowy-observable/src/entities/subject.rs @@ -18,7 +18,10 @@ pub struct ObservableSubject { impl std::default::Default for ObservableSubject { fn default() -> Self { Self { - ..Default::default() + category: "".to_string(), + ty: 0, + subject_id: "".to_string(), + subject_payload: None, } } } diff --git a/rust-lib/flowy-sdk/src/deps_resolve/workspace_deps_impl.rs b/rust-lib/flowy-sdk/src/deps_resolve/workspace_deps_impl.rs index 67666078c7..a8fa5c7308 100644 --- a/rust-lib/flowy-sdk/src/deps_resolve/workspace_deps_impl.rs +++ b/rust-lib/flowy-sdk/src/deps_resolve/workspace_deps_impl.rs @@ -3,7 +3,7 @@ use flowy_dispatch::prelude::DispatchFuture; use flowy_user::prelude::UserSession; use flowy_workspace::{ entities::workspace::CurrentWorkspace, - errors::{ErrorBuilder, WorkspaceError, WorkspaceErrorCode}, + errors::{ErrorBuilder, WorkspaceError, WsErrCode}, module::{WorkspaceDatabase, WorkspaceUser}, }; use std::sync::Arc; @@ -25,7 +25,7 @@ impl WorkspaceUser for WorkspaceUserImpl { .set_current_workspace(&workspace_id) .await .map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::UserInternalError) + ErrorBuilder::new(WsErrCode::UserInternalError) .error(e) .build() })?; @@ -39,7 +39,7 @@ impl WorkspaceUser for WorkspaceUserImpl { DispatchFuture { fut: Box::pin(async move { let user_detail = user_session.user_detail().map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::UserNotLoginYet) + ErrorBuilder::new(WsErrCode::UserNotLoginYet) .error(e) .build() })?; @@ -60,7 +60,7 @@ pub struct WorkspaceDatabaseImpl { impl WorkspaceDatabase for WorkspaceDatabaseImpl { fn db_connection(&self) -> Result { self.user_session.get_db_connection().map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::DatabaseConnectionFail) + ErrorBuilder::new(WsErrCode::DatabaseConnectionFail) .error(e) .build() }) diff --git a/rust-lib/flowy-sdk/src/flowy_server.rs b/rust-lib/flowy-sdk/src/flowy_server.rs index 3e3a2de9c8..4e52ea5b01 100644 --- a/rust-lib/flowy-sdk/src/flowy_server.rs +++ b/rust-lib/flowy-sdk/src/flowy_server.rs @@ -7,13 +7,12 @@ use flowy_dispatch::prelude::{ }; use flowy_user::{ entities::{SignInParams, SignUpParams, UserDetail}, - errors::{ErrorBuilder, UserError, UserErrorCode}, + errors::{ErrorBuilder, UserErrCode, UserError}, prelude::UserServer, sql_tables::UserTable, }; use flowy_workspace::{ entities::workspace::{CreateWorkspaceRequest, Workspace}, - errors::WorkspaceError, event::WorkspaceEvent::CreateWorkspace, }; @@ -47,11 +46,11 @@ impl UserServer for FlowyServerMocker { } fn sign_out(&self, _user_id: &str) -> Result<(), UserError> { - Err(ErrorBuilder::new(UserErrorCode::Unknown).build()) + Err(ErrorBuilder::new(UserErrCode::Unknown).build()) } fn get_user_info(&self, _user_id: &str) -> Result { - Err(ErrorBuilder::new(UserErrorCode::Unknown).build()) + Err(ErrorBuilder::new(UserErrCode::Unknown).build()) } fn create_workspace( @@ -75,13 +74,13 @@ impl UserServer for FlowyServerMocker { .await .parse::() .map_err(|e| { - ErrorBuilder::new(UserErrorCode::CreateDefaultWorkspaceFailed) + ErrorBuilder::new(UserErrCode::CreateDefaultWorkspaceFailed) .error(e) .build() })?; let workspace = result.map_err(|e| { - ErrorBuilder::new(UserErrorCode::CreateDefaultWorkspaceFailed) + ErrorBuilder::new(UserErrCode::CreateDefaultWorkspaceFailed) .error(e) .build() })?; diff --git a/rust-lib/flowy-sdk/src/module.rs b/rust-lib/flowy-sdk/src/module.rs index a04878c8e9..3ed53cd87d 100644 --- a/rust-lib/flowy-sdk/src/module.rs +++ b/rust-lib/flowy-sdk/src/module.rs @@ -1,6 +1,6 @@ use crate::flowy_server::{ArcFlowyServer, FlowyServerMocker}; use flowy_dispatch::prelude::Module; -use flowy_editor::prelude::*; + use flowy_user::prelude::*; use crate::deps_resolve::{ diff --git a/rust-lib/flowy-user/src/entities/sign_in.rs b/rust-lib/flowy-user/src/entities/sign_in.rs index 252b2c2636..94b2851a43 100644 --- a/rust-lib/flowy-user/src/entities/sign_in.rs +++ b/rust-lib/flowy-user/src/entities/sign_in.rs @@ -24,13 +24,10 @@ impl TryInto for SignInRequest { type Error = UserError; fn try_into(self) -> Result { - let email = UserEmail::parse(self.email).map_err(|e| { - ErrorBuilder::new(UserErrorCode::EmailInvalid) - .msg(e) - .build() - })?; + let email = UserEmail::parse(self.email) + .map_err(|e| ErrorBuilder::new(UserErrCode::EmailInvalid).msg(e).build())?; let password = UserPassword::parse(self.password).map_err(|e| { - ErrorBuilder::new(UserErrorCode::PasswordInvalid) + ErrorBuilder::new(UserErrCode::PasswordInvalid) .msg(e) .build() })?; diff --git a/rust-lib/flowy-user/src/entities/sign_up.rs b/rust-lib/flowy-user/src/entities/sign_up.rs index 57c4878b87..83ba6b1ee5 100644 --- a/rust-lib/flowy-user/src/entities/sign_up.rs +++ b/rust-lib/flowy-user/src/entities/sign_up.rs @@ -1,6 +1,6 @@ use crate::{ entities::parser::*, - errors::{ErrorBuilder, UserError, UserErrorCode}, + errors::{ErrorBuilder, UserErrCode, UserError}, }; use flowy_derive::ProtoBuf; use std::convert::TryInto; @@ -20,19 +20,16 @@ impl TryInto for SignUpRequest { type Error = UserError; fn try_into(self) -> Result { - let email = UserEmail::parse(self.email).map_err(|e| { - ErrorBuilder::new(UserErrorCode::EmailInvalid) - .msg(e) - .build() - })?; + let email = UserEmail::parse(self.email) + .map_err(|e| ErrorBuilder::new(UserErrCode::EmailInvalid).msg(e).build())?; let password = UserPassword::parse(self.password).map_err(|e| { - ErrorBuilder::new(UserErrorCode::PasswordInvalid) + ErrorBuilder::new(UserErrCode::PasswordInvalid) .msg(e) .build() })?; let name = UserName::parse(self.name).map_err(|e| { - ErrorBuilder::new(UserErrorCode::UserNameInvalid) + ErrorBuilder::new(UserErrCode::UserNameInvalid) .msg(e) .build() })?; diff --git a/rust-lib/flowy-user/src/entities/user_update.rs b/rust-lib/flowy-user/src/entities/user_update.rs index ab072bd22f..708c64375f 100644 --- a/rust-lib/flowy-user/src/entities/user_update.rs +++ b/rust-lib/flowy-user/src/entities/user_update.rs @@ -1,6 +1,6 @@ use crate::{ entities::parser::*, - errors::{ErrorBuilder, UserError, UserErrorCode}, + errors::{ErrorBuilder, UserErrCode, UserError}, }; use flowy_derive::ProtoBuf; use std::convert::TryInto; @@ -65,11 +65,7 @@ impl TryInto for UpdateUserRequest { fn try_into(self) -> Result { let id = UserId::parse(self.id) - .map_err(|e| { - ErrorBuilder::new(UserErrorCode::UserIdInvalid) - .msg(e) - .build() - })? + .map_err(|e| ErrorBuilder::new(UserErrCode::UserIdInvalid).msg(e).build())? .0; let name = match self.name { @@ -77,7 +73,7 @@ impl TryInto for UpdateUserRequest { Some(name) => Some( UserName::parse(name) .map_err(|e| { - ErrorBuilder::new(UserErrorCode::UserNameInvalid) + ErrorBuilder::new(UserErrCode::UserNameInvalid) .msg(e) .build() })? @@ -89,11 +85,7 @@ impl TryInto for UpdateUserRequest { None => None, Some(email) => Some( UserEmail::parse(email) - .map_err(|e| { - ErrorBuilder::new(UserErrorCode::EmailInvalid) - .msg(e) - .build() - })? + .map_err(|e| ErrorBuilder::new(UserErrCode::EmailInvalid).msg(e).build())? .0, ), }; @@ -103,7 +95,7 @@ impl TryInto for UpdateUserRequest { Some(workspace) => Some( UserWorkspace::parse(workspace) .map_err(|e| { - ErrorBuilder::new(UserErrorCode::UserWorkspaceInvalid) + ErrorBuilder::new(UserErrCode::UserWorkspaceInvalid) .msg(e) .build() })? @@ -116,7 +108,7 @@ impl TryInto for UpdateUserRequest { Some(password) => Some( UserPassword::parse(password) .map_err(|e| { - ErrorBuilder::new(UserErrorCode::PasswordInvalid) + ErrorBuilder::new(UserErrCode::PasswordInvalid) .msg(e) .build() })? diff --git a/rust-lib/flowy-user/src/errors.rs b/rust-lib/flowy-user/src/errors.rs index a1ff441cc3..793aeedd97 100644 --- a/rust-lib/flowy-user/src/errors.rs +++ b/rust-lib/flowy-user/src/errors.rs @@ -6,14 +6,14 @@ use std::convert::TryInto; #[derive(Debug, Default, Clone, ProtoBuf)] pub struct UserError { #[pb(index = 1)] - pub code: UserErrorCode, + pub code: UserErrCode, #[pb(index = 2)] pub msg: String, } impl UserError { - fn new(code: UserErrorCode, msg: &str) -> Self { + fn new(code: UserErrCode, msg: &str) -> Self { Self { code, msg: msg.to_owned(), @@ -22,7 +22,7 @@ impl UserError { } #[derive(Debug, Clone, ProtoBuf_Enum, Display, PartialEq, Eq)] -pub enum UserErrorCode { +pub enum UserErrCode { #[display(fmt = "Unknown")] Unknown = 0, #[display(fmt = "Database init failed")] @@ -63,13 +63,13 @@ pub enum UserErrorCode { DefaultWorkspaceAlreadyExist = 26, } -impl std::default::Default for UserErrorCode { - fn default() -> Self { UserErrorCode::Unknown } +impl std::default::Default for UserErrCode { + fn default() -> Self { UserErrCode::Unknown } } impl std::convert::From for UserError { fn from(error: flowy_database::result::Error) -> Self { - ErrorBuilder::new(UserErrorCode::UserDatabaseInternalError) + ErrorBuilder::new(UserErrCode::UserDatabaseInternalError) .error(error) .build() } @@ -106,7 +106,7 @@ impl std::convert::From for UserError { // ErrorKind::__Nonexhaustive { .. } => {}, // } - ErrorBuilder::new(UserErrorCode::SqlInternalError) + ErrorBuilder::new(UserErrCode::SqlInternalError) .error(error) .build() } @@ -120,12 +120,12 @@ impl flowy_dispatch::Error for UserError { } pub struct ErrorBuilder { - pub code: UserErrorCode, + pub code: UserErrCode, pub msg: Option, } impl ErrorBuilder { - pub fn new(code: UserErrorCode) -> Self { ErrorBuilder { code, msg: None } } + pub fn new(code: UserErrCode) -> Self { ErrorBuilder { code, msg: None } } pub fn msg(mut self, msg: T) -> Self where diff --git a/rust-lib/flowy-user/src/handlers/auth_handler.rs b/rust-lib/flowy-user/src/handlers/auth_handler.rs index 97073f4096..44813984b4 100644 --- a/rust-lib/flowy-user/src/handlers/auth_handler.rs +++ b/rust-lib/flowy-user/src/handlers/auth_handler.rs @@ -3,8 +3,8 @@ use flowy_dispatch::prelude::*; use std::{convert::TryInto, sync::Arc}; // tracing instrument 👉🏻 https://docs.rs/tracing/0.1.26/tracing/attr.instrument.html -#[tracing::instrument(name = "user_sign_in", skip(data, session), fields(email = %data.email))] -pub async fn user_sign_in_handler( +#[tracing::instrument(name = "sign_in", skip(data, session), fields(email = %data.email))] +pub async fn sign_in( data: Data, session: Unit>, ) -> ResponseResult { @@ -15,14 +15,14 @@ pub async fn user_sign_in_handler( } #[tracing::instrument( - name = "user_sign_up", + name = "sign_up", skip(data, session), fields( email = %data.email, name = %data.name, ) )] -pub async fn user_sign_up_handler( +pub async fn sign_up( data: Data, session: Unit>, ) -> ResponseResult { diff --git a/rust-lib/flowy-user/src/handlers/user_handler.rs b/rust-lib/flowy-user/src/handlers/user_handler.rs index 7922efd03e..e5c0af0a8a 100644 --- a/rust-lib/flowy-user/src/handlers/user_handler.rs +++ b/rust-lib/flowy-user/src/handlers/user_handler.rs @@ -2,19 +2,22 @@ use crate::{entities::*, errors::UserError, services::user_session::UserSession} use flowy_dispatch::prelude::*; use std::{convert::TryInto, sync::Arc}; -pub async fn user_get_status_handler( +#[tracing::instrument(name = "get_user_status", skip(session))] +pub async fn get_user_status( session: Unit>, ) -> ResponseResult { let user_detail = session.user_detail()?; response_ok(user_detail) } -pub async fn sign_out_handler(session: Unit>) -> Result<(), UserError> { +#[tracing::instrument(name = "sign_out", skip(session))] +pub async fn sign_out(session: Unit>) -> Result<(), UserError> { let _ = session.sign_out()?; Ok(()) } -pub async fn update_user_handler( +#[tracing::instrument(name = "update_user", skip(data, session))] +pub async fn update_user( data: Data, session: Unit>, ) -> ResponseResult { diff --git a/rust-lib/flowy-user/src/module.rs b/rust-lib/flowy-user/src/module.rs index 699a25dd22..07aeb29c94 100644 --- a/rust-lib/flowy-user/src/module.rs +++ b/rust-lib/flowy-user/src/module.rs @@ -7,9 +7,9 @@ pub fn create(user_session: Arc) -> Module { Module::new() .name("Flowy-User") .data(user_session) - .event(UserEvent::SignIn, user_sign_in_handler) - .event(UserEvent::SignUp, user_sign_up_handler) - .event(UserEvent::GetStatus, user_get_status_handler) - .event(UserEvent::SignOut, sign_out_handler) - .event(UserEvent::UpdateUser, update_user_handler) + .event(UserEvent::SignIn, sign_in) + .event(UserEvent::SignUp, sign_up) + .event(UserEvent::GetStatus, get_user_status) + .event(UserEvent::SignOut, sign_out) + .event(UserEvent::UpdateUser, update_user) } diff --git a/rust-lib/flowy-user/src/protobuf/model/errors.rs b/rust-lib/flowy-user/src/protobuf/model/errors.rs index 657a1837a7..ea9b238dde 100644 --- a/rust-lib/flowy-user/src/protobuf/model/errors.rs +++ b/rust-lib/flowy-user/src/protobuf/model/errors.rs @@ -26,7 +26,7 @@ #[derive(PartialEq,Clone,Default)] pub struct UserError { // message fields - pub code: UserErrorCode, + pub code: UserErrCode, pub msg: ::std::string::String, // special fields pub unknown_fields: ::protobuf::UnknownFields, @@ -44,18 +44,18 @@ impl UserError { ::std::default::Default::default() } - // .UserErrorCode code = 1; + // .UserErrCode code = 1; - pub fn get_code(&self) -> UserErrorCode { + pub fn get_code(&self) -> UserErrCode { self.code } pub fn clear_code(&mut self) { - self.code = UserErrorCode::Unknown; + self.code = UserErrCode::Unknown; } // Param is passed by value, moved - pub fn set_code(&mut self, v: UserErrorCode) { + pub fn set_code(&mut self, v: UserErrCode) { self.code = v; } @@ -113,7 +113,7 @@ impl ::protobuf::Message for UserError { #[allow(unused_variables)] fn compute_size(&self) -> u32 { let mut my_size = 0; - if self.code != UserErrorCode::Unknown { + if self.code != UserErrCode::Unknown { my_size += ::protobuf::rt::enum_size(1, self.code); } if !self.msg.is_empty() { @@ -125,7 +125,7 @@ impl ::protobuf::Message for UserError { } fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - if self.code != UserErrorCode::Unknown { + if self.code != UserErrCode::Unknown { os.write_enum(1, ::protobuf::ProtobufEnum::value(&self.code))?; } if !self.msg.is_empty() { @@ -169,7 +169,7 @@ impl ::protobuf::Message for UserError { 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::ProtobufTypeEnum>( + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( "code", |m: &UserError| { &m.code }, |m: &mut UserError| { &mut m.code }, @@ -195,7 +195,7 @@ impl ::protobuf::Message for UserError { impl ::protobuf::Clear for UserError { fn clear(&mut self) { - self.code = UserErrorCode::Unknown; + self.code = UserErrCode::Unknown; self.msg.clear(); self.unknown_fields.clear(); } @@ -214,7 +214,7 @@ impl ::protobuf::reflect::ProtobufValue for UserError { } #[derive(Clone,PartialEq,Eq,Debug,Hash)] -pub enum UserErrorCode { +pub enum UserErrCode { Unknown = 0, UserDatabaseInitFailed = 1, UserDatabaseWriteLocked = 2, @@ -234,53 +234,53 @@ pub enum UserErrorCode { DefaultWorkspaceAlreadyExist = 26, } -impl ::protobuf::ProtobufEnum for UserErrorCode { +impl ::protobuf::ProtobufEnum for UserErrCode { fn value(&self) -> i32 { *self as i32 } - fn from_i32(value: i32) -> ::std::option::Option { + fn from_i32(value: i32) -> ::std::option::Option { match value { - 0 => ::std::option::Option::Some(UserErrorCode::Unknown), - 1 => ::std::option::Option::Some(UserErrorCode::UserDatabaseInitFailed), - 2 => ::std::option::Option::Some(UserErrorCode::UserDatabaseWriteLocked), - 3 => ::std::option::Option::Some(UserErrorCode::UserDatabaseReadLocked), - 4 => ::std::option::Option::Some(UserErrorCode::UserDatabaseDidNotMatch), - 5 => ::std::option::Option::Some(UserErrorCode::UserDatabaseInternalError), - 6 => ::std::option::Option::Some(UserErrorCode::SqlInternalError), - 10 => ::std::option::Option::Some(UserErrorCode::UserNotLoginYet), - 11 => ::std::option::Option::Some(UserErrorCode::ReadCurrentIdFailed), - 12 => ::std::option::Option::Some(UserErrorCode::WriteCurrentIdFailed), - 20 => ::std::option::Option::Some(UserErrorCode::EmailInvalid), - 21 => ::std::option::Option::Some(UserErrorCode::PasswordInvalid), - 22 => ::std::option::Option::Some(UserErrorCode::UserNameInvalid), - 23 => ::std::option::Option::Some(UserErrorCode::UserWorkspaceInvalid), - 24 => ::std::option::Option::Some(UserErrorCode::UserIdInvalid), - 25 => ::std::option::Option::Some(UserErrorCode::CreateDefaultWorkspaceFailed), - 26 => ::std::option::Option::Some(UserErrorCode::DefaultWorkspaceAlreadyExist), + 0 => ::std::option::Option::Some(UserErrCode::Unknown), + 1 => ::std::option::Option::Some(UserErrCode::UserDatabaseInitFailed), + 2 => ::std::option::Option::Some(UserErrCode::UserDatabaseWriteLocked), + 3 => ::std::option::Option::Some(UserErrCode::UserDatabaseReadLocked), + 4 => ::std::option::Option::Some(UserErrCode::UserDatabaseDidNotMatch), + 5 => ::std::option::Option::Some(UserErrCode::UserDatabaseInternalError), + 6 => ::std::option::Option::Some(UserErrCode::SqlInternalError), + 10 => ::std::option::Option::Some(UserErrCode::UserNotLoginYet), + 11 => ::std::option::Option::Some(UserErrCode::ReadCurrentIdFailed), + 12 => ::std::option::Option::Some(UserErrCode::WriteCurrentIdFailed), + 20 => ::std::option::Option::Some(UserErrCode::EmailInvalid), + 21 => ::std::option::Option::Some(UserErrCode::PasswordInvalid), + 22 => ::std::option::Option::Some(UserErrCode::UserNameInvalid), + 23 => ::std::option::Option::Some(UserErrCode::UserWorkspaceInvalid), + 24 => ::std::option::Option::Some(UserErrCode::UserIdInvalid), + 25 => ::std::option::Option::Some(UserErrCode::CreateDefaultWorkspaceFailed), + 26 => ::std::option::Option::Some(UserErrCode::DefaultWorkspaceAlreadyExist), _ => ::std::option::Option::None } } fn values() -> &'static [Self] { - static values: &'static [UserErrorCode] = &[ - UserErrorCode::Unknown, - UserErrorCode::UserDatabaseInitFailed, - UserErrorCode::UserDatabaseWriteLocked, - UserErrorCode::UserDatabaseReadLocked, - UserErrorCode::UserDatabaseDidNotMatch, - UserErrorCode::UserDatabaseInternalError, - UserErrorCode::SqlInternalError, - UserErrorCode::UserNotLoginYet, - UserErrorCode::ReadCurrentIdFailed, - UserErrorCode::WriteCurrentIdFailed, - UserErrorCode::EmailInvalid, - UserErrorCode::PasswordInvalid, - UserErrorCode::UserNameInvalid, - UserErrorCode::UserWorkspaceInvalid, - UserErrorCode::UserIdInvalid, - UserErrorCode::CreateDefaultWorkspaceFailed, - UserErrorCode::DefaultWorkspaceAlreadyExist, + static values: &'static [UserErrCode] = &[ + UserErrCode::Unknown, + UserErrCode::UserDatabaseInitFailed, + UserErrCode::UserDatabaseWriteLocked, + UserErrCode::UserDatabaseReadLocked, + UserErrCode::UserDatabaseDidNotMatch, + UserErrCode::UserDatabaseInternalError, + UserErrCode::SqlInternalError, + UserErrCode::UserNotLoginYet, + UserErrCode::ReadCurrentIdFailed, + UserErrCode::WriteCurrentIdFailed, + UserErrCode::EmailInvalid, + UserErrCode::PasswordInvalid, + UserErrCode::UserNameInvalid, + UserErrCode::UserWorkspaceInvalid, + UserErrCode::UserIdInvalid, + UserErrCode::CreateDefaultWorkspaceFailed, + UserErrCode::DefaultWorkspaceAlreadyExist, ]; values } @@ -288,31 +288,31 @@ impl ::protobuf::ProtobufEnum for UserErrorCode { fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::LazyV2::INIT; descriptor.get(|| { - ::protobuf::reflect::EnumDescriptor::new_pb_name::("UserErrorCode", file_descriptor_proto()) + ::protobuf::reflect::EnumDescriptor::new_pb_name::("UserErrCode", file_descriptor_proto()) }) } } -impl ::std::marker::Copy for UserErrorCode { +impl ::std::marker::Copy for UserErrCode { } -impl ::std::default::Default for UserErrorCode { +impl ::std::default::Default for UserErrCode { fn default() -> Self { - UserErrorCode::Unknown + UserErrCode::Unknown } } -impl ::protobuf::reflect::ProtobufValue for UserErrorCode { +impl ::protobuf::reflect::ProtobufValue for UserErrCode { fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { ::protobuf::reflect::ReflectValueRef::Enum(::protobuf::ProtobufEnum::descriptor(self)) } } static file_descriptor_proto_data: &'static [u8] = b"\ - \n\x0cerrors.proto\"A\n\tUserError\x12\"\n\x04code\x18\x01\x20\x01(\x0e2\ - \x0e.UserErrorCodeR\x04code\x12\x10\n\x03msg\x18\x02\x20\x01(\tR\x03msg*\ - \xb8\x03\n\rUserErrorCode\x12\x0b\n\x07Unknown\x10\0\x12\x1a\n\x16UserDa\ - tabaseInitFailed\x10\x01\x12\x1b\n\x17UserDatabaseWriteLocked\x10\x02\ + \n\x0cerrors.proto\"?\n\tUserError\x12\x20\n\x04code\x18\x01\x20\x01(\ + \x0e2\x0c.UserErrCodeR\x04code\x12\x10\n\x03msg\x18\x02\x20\x01(\tR\x03m\ + sg*\xb6\x03\n\x0bUserErrCode\x12\x0b\n\x07Unknown\x10\0\x12\x1a\n\x16Use\ + rDatabaseInitFailed\x10\x01\x12\x1b\n\x17UserDatabaseWriteLocked\x10\x02\ \x12\x1a\n\x16UserDatabaseReadLocked\x10\x03\x12\x1b\n\x17UserDatabaseDi\ dNotMatch\x10\x04\x12\x1d\n\x19UserDatabaseInternalError\x10\x05\x12\x14\ \n\x10SqlInternalError\x10\x06\x12\x13\n\x0fUserNotLoginYet\x10\n\x12\ @@ -323,13 +323,13 @@ static file_descriptor_proto_data: &'static [u8] = b"\ ultWorkspaceFailed\x10\x19\x12\x20\n\x1cDefaultWorkspaceAlreadyExist\x10\ \x1aJ\xe9\x06\n\x06\x12\x04\0\0\x18\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\x11\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x1b\n\x0c\n\x05\x04\0\ - \x02\0\x06\x12\x03\x03\x04\x11\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\ - \x12\x16\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x19\x1a\n\x0b\n\x04\x04\ + \x08\x11\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x19\n\x0c\n\x05\x04\0\ + \x02\0\x06\x12\x03\x03\x04\x0f\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\ + \x10\x14\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x17\x18\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\x12\n\n\n\x02\x05\0\x12\x04\x06\0\x18\x01\ - \n\n\n\x03\x05\0\x01\x12\x03\x06\x05\x12\n\x0b\n\x04\x05\0\x02\0\x12\x03\ + \n\n\n\x03\x05\0\x01\x12\x03\x06\x05\x10\n\x0b\n\x04\x05\0\x02\0\x12\x03\ \x07\x04\x10\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x07\x04\x0b\n\x0c\n\x05\ \x05\0\x02\0\x02\x12\x03\x07\x0e\x0f\n\x0b\n\x04\x05\0\x02\x01\x12\x03\ \x08\x04\x1f\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x08\x04\x1a\n\x0c\n\ diff --git a/rust-lib/flowy-user/src/protobuf/proto/errors.proto b/rust-lib/flowy-user/src/protobuf/proto/errors.proto index 881ae87c12..9a35970949 100644 --- a/rust-lib/flowy-user/src/protobuf/proto/errors.proto +++ b/rust-lib/flowy-user/src/protobuf/proto/errors.proto @@ -1,10 +1,10 @@ syntax = "proto3"; message UserError { - UserErrorCode code = 1; + UserErrCode code = 1; string msg = 2; } -enum UserErrorCode { +enum UserErrCode { Unknown = 0; UserDatabaseInitFailed = 1; UserDatabaseWriteLocked = 2; diff --git a/rust-lib/flowy-user/src/services/user_session/database.rs b/rust-lib/flowy-user/src/services/user_session/database.rs index f286957b99..965e9dd7c1 100644 --- a/rust-lib/flowy-user/src/services/user_session/database.rs +++ b/rust-lib/flowy-user/src/services/user_session/database.rs @@ -1,4 +1,4 @@ -use crate::errors::{ErrorBuilder, UserError, UserErrorCode}; +use crate::errors::{ErrorBuilder, UserErrCode, UserError}; use flowy_database::{DBConnection, Database}; use lazy_static::lazy_static; use once_cell::sync::Lazy; @@ -22,7 +22,7 @@ impl UserDB { fn open_user_db(&self, user_id: &str) -> Result<(), UserError> { if user_id.is_empty() { - return Err(ErrorBuilder::new(UserErrorCode::UserDatabaseInitFailed) + return Err(ErrorBuilder::new(UserErrCode::UserDatabaseInitFailed) .msg("user id is empty") .build()); } @@ -30,13 +30,13 @@ impl UserDB { let dir = format!("{}/{}", self.db_dir, user_id); let db = flowy_database::init(&dir).map_err(|e| { log::error!("flowy_database::init failed, {:?}", e); - ErrorBuilder::new(UserErrorCode::UserDatabaseInitFailed) + ErrorBuilder::new(UserErrCode::UserDatabaseInitFailed) .error(e) .build() })?; let mut db_map = DB_MAP.write().map_err(|e| { - ErrorBuilder::new(UserErrorCode::UserDatabaseWriteLocked) + ErrorBuilder::new(UserErrCode::UserDatabaseWriteLocked) .error(e) .build() })?; @@ -47,7 +47,7 @@ impl UserDB { pub(crate) fn close_user_db(&self, user_id: &str) -> Result<(), UserError> { let mut db_map = DB_MAP.write().map_err(|e| { - ErrorBuilder::new(UserErrorCode::UserDatabaseWriteLocked) + ErrorBuilder::new(UserErrCode::UserDatabaseWriteLocked) .msg(format!("Close user db failed. {:?}", e)) .build() })?; @@ -63,13 +63,13 @@ impl UserDB { } let db_map = DB_MAP.read().map_err(|e| { - ErrorBuilder::new(UserErrorCode::UserDatabaseReadLocked) + ErrorBuilder::new(UserErrCode::UserDatabaseReadLocked) .error(e) .build() })?; match db_map.get(user_id) { - None => Err(ErrorBuilder::new(UserErrorCode::UserDatabaseInitFailed) + None => Err(ErrorBuilder::new(UserErrCode::UserDatabaseInitFailed) .msg("Get connection failed. The database is not initialization") .build()), Some(database) => Ok(database.get_connection()?), diff --git a/rust-lib/flowy-user/src/services/user_session/user_session.rs b/rust-lib/flowy-user/src/services/user_session/user_session.rs index b1715214d4..840de4d45a 100644 --- a/rust-lib/flowy-user/src/services/user_session/user_session.rs +++ b/rust-lib/flowy-user/src/services/user_session/user_session.rs @@ -11,7 +11,7 @@ use std::sync::{Arc, RwLock}; use crate::{ entities::{SignInParams, SignUpParams, UpdateUserParams, UpdateUserRequest, UserDetail}, - errors::{ErrorBuilder, UserError, UserErrorCode}, + errors::{ErrorBuilder, UserErrCode, UserError}, event::UserEvent::*, services::user_session::{database::UserDB, user_server::UserServer}, sql_tables::{UserTable, UserTableChangeset}, @@ -140,7 +140,7 @@ impl UserSession { *write_guard = user_id; Ok(()) }, - Err(e) => Err(ErrorBuilder::new(UserErrorCode::WriteCurrentIdFailed) + Err(e) => Err(ErrorBuilder::new(UserErrCode::WriteCurrentIdFailed) .error(e) .build()), } @@ -154,7 +154,7 @@ impl UserSession { pub fn get_user_id(&self) -> Result { let mut user_id = { let read_guard = self.user_id.read().map_err(|e| { - ErrorBuilder::new(UserErrorCode::ReadCurrentIdFailed) + ErrorBuilder::new(UserErrCode::ReadCurrentIdFailed) .error(e) .build() })?; @@ -168,7 +168,7 @@ impl UserSession { } match user_id { - None => Err(ErrorBuilder::new(UserErrorCode::UserNotLoginYet).build()), + None => Err(ErrorBuilder::new(UserErrCode::UserNotLoginYet).build()), Some(user_id) => Ok(user_id), } } @@ -191,7 +191,7 @@ impl UserSession { async fn create_default_workspace_if_need(&self, user_id: &str) -> Result { let key = format!("{}{}", user_id, DEFAULT_WORKSPACE); if KVStore::get_bool(&key).unwrap_or(false) { - return Err(ErrorBuilder::new(UserErrorCode::DefaultWorkspaceAlreadyExist).build()); + return Err(ErrorBuilder::new(UserErrCode::DefaultWorkspaceAlreadyExist).build()); } KVStore::set_bool(&key, true); log::debug!("Create user:{} default workspace", user_id); @@ -205,7 +205,7 @@ impl UserSession { pub fn current_user_id() -> Result { match KVStore::get_str(USER_ID_CACHE_KEY) { - None => Err(ErrorBuilder::new(UserErrorCode::UserNotLoginYet).build()), + None => Err(ErrorBuilder::new(UserErrCode::UserNotLoginYet).build()), Some(user_id) => Ok(user_id), } } diff --git a/rust-lib/flowy-user/tests/event/sign_in_test.rs b/rust-lib/flowy-user/tests/event/sign_in_test.rs index a3a28a33f7..28185bfec4 100644 --- a/rust-lib/flowy-user/tests/event/sign_in_test.rs +++ b/rust-lib/flowy-user/tests/event/sign_in_test.rs @@ -1,5 +1,5 @@ use crate::helper::*; -use flowy_user::{errors::UserErrorCode, event::UserEvent::*, prelude::*}; +use flowy_user::{errors::UserErrCode, event::UserEvent::*, prelude::*}; use serial_test::*; #[test] @@ -35,7 +35,7 @@ fn sign_in_with_invalid_email() { .sync_send() .error() .code, - UserErrorCode::EmailInvalid + UserErrCode::EmailInvalid ); } } @@ -56,7 +56,7 @@ fn sign_in_with_invalid_password() { .sync_send() .error() .code, - UserErrorCode::PasswordInvalid + UserErrCode::PasswordInvalid ); } } diff --git a/rust-lib/flowy-user/tests/event/sign_up_test.rs b/rust-lib/flowy-user/tests/event/sign_up_test.rs index 037ed4a5b0..5e74e3ffcf 100644 --- a/rust-lib/flowy-user/tests/event/sign_up_test.rs +++ b/rust-lib/flowy-user/tests/event/sign_up_test.rs @@ -35,7 +35,7 @@ fn sign_up_with_invalid_email() { .sync_send() .error() .code, - UserErrorCode::EmailInvalid + UserErrCode::EmailInvalid ); } } @@ -56,7 +56,7 @@ fn sign_up_with_invalid_password() { .sync_send() .error() .code, - UserErrorCode::PasswordInvalid + UserErrCode::PasswordInvalid ); } } diff --git a/rust-lib/flowy-user/tests/event/user_update_test.rs b/rust-lib/flowy-user/tests/event/user_update_test.rs index 78c9ca332f..10040340c4 100644 --- a/rust-lib/flowy-user/tests/event/user_update_test.rs +++ b/rust-lib/flowy-user/tests/event/user_update_test.rs @@ -1,5 +1,5 @@ use crate::helper::*; -use flowy_user::{errors::UserErrorCode, event::UserEvent::*, prelude::*}; +use flowy_user::{errors::UserErrCode, event::UserEvent::*, prelude::*}; use serial_test::*; #[test] @@ -86,7 +86,7 @@ fn user_update_with_invalid_email() { .sync_send() .error() .code, - UserErrorCode::EmailInvalid + UserErrCode::EmailInvalid ); } } @@ -111,7 +111,7 @@ fn user_update_with_invalid_password() { .sync_send() .error() .code, - UserErrorCode::PasswordInvalid + UserErrCode::PasswordInvalid ); } } @@ -135,6 +135,6 @@ fn user_update_with_invalid_name() { .sync_send() .error() .code, - UserErrorCode::UserNameInvalid + UserErrCode::UserNameInvalid ); } diff --git a/rust-lib/flowy-workspace/src/entities/app/app_create.rs b/rust-lib/flowy-workspace/src/entities/app/app_create.rs index a7cfe093df..b91f0a8f23 100644 --- a/rust-lib/flowy-workspace/src/entities/app/app_create.rs +++ b/rust-lib/flowy-workspace/src/entities/app/app_create.rs @@ -42,20 +42,17 @@ impl TryInto for CreateAppRequest { type Error = WorkspaceError; fn try_into(self) -> Result { - let name = AppName::parse(self.name).map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::AppNameInvalid) - .msg(e) - .build() - })?; + let name = AppName::parse(self.name) + .map_err(|e| ErrorBuilder::new(WsErrCode::AppNameInvalid).msg(e).build())?; let id = WorkspaceId::parse(self.workspace_id).map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::WorkspaceIdInvalid) + ErrorBuilder::new(WsErrCode::WorkspaceIdInvalid) .msg(e) .build() })?; let color_style = AppColorStyle::parse(self.color_style).map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::AppColorStyleInvalid) + ErrorBuilder::new(WsErrCode::AppColorStyleInvalid) .msg(e) .build() })?; diff --git a/rust-lib/flowy-workspace/src/entities/app/app_query.rs b/rust-lib/flowy-workspace/src/entities/app/app_query.rs index 317e3e25f9..f27e2ce72a 100644 --- a/rust-lib/flowy-workspace/src/entities/app/app_query.rs +++ b/rust-lib/flowy-workspace/src/entities/app/app_query.rs @@ -21,11 +21,7 @@ impl TryInto for QueryAppRequest { fn try_into(self) -> Result { let app_id = AppId::parse(self.app_id) - .map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::AppIdInvalid) - .msg(e) - .build() - })? + .map_err(|e| ErrorBuilder::new(WsErrCode::AppIdInvalid).msg(e).build())? .0; Ok(QueryAppParams { diff --git a/rust-lib/flowy-workspace/src/entities/app/app_update.rs b/rust-lib/flowy-workspace/src/entities/app/app_update.rs index 6b84df2428..e1a92d0f95 100644 --- a/rust-lib/flowy-workspace/src/entities/app/app_update.rs +++ b/rust-lib/flowy-workspace/src/entities/app/app_update.rs @@ -6,7 +6,7 @@ use crate::{ }, workspace::parser::WorkspaceId, }, - errors::{ErrorBuilder, WorkspaceError, WorkspaceErrorCode}, + errors::{ErrorBuilder, WorkspaceError, WsErrCode}, }; use flowy_derive::ProtoBuf; use std::convert::TryInto; @@ -42,11 +42,7 @@ impl TryInto for UpdateAppRequest { fn try_into(self) -> Result { let app_id = AppId::parse(self.app_id) - .map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::AppIdInvalid) - .msg(e) - .build() - })? + .map_err(|e| ErrorBuilder::new(WsErrCode::AppIdInvalid).msg(e).build())? .0; let name = match self.name { @@ -54,7 +50,7 @@ impl TryInto for UpdateAppRequest { Some(name) => Some( AppName::parse(name) .map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::WorkspaceNameInvalid) + ErrorBuilder::new(WsErrCode::WorkspaceNameInvalid) .msg(e) .build() })? @@ -67,7 +63,7 @@ impl TryInto for UpdateAppRequest { Some(wid) => Some( WorkspaceId::parse(wid) .map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::WorkspaceIdInvalid) + ErrorBuilder::new(WsErrCode::WorkspaceIdInvalid) .msg(e) .build() })? @@ -80,7 +76,7 @@ impl TryInto for UpdateAppRequest { Some(color_style) => Some( AppColorStyle::parse(color_style) .map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::AppColorStyleInvalid) + ErrorBuilder::new(WsErrCode::AppColorStyleInvalid) .msg(e) .build() })? diff --git a/rust-lib/flowy-workspace/src/entities/view/view_create.rs b/rust-lib/flowy-workspace/src/entities/view/view_create.rs index a52d713e67..317ad23397 100644 --- a/rust-lib/flowy-workspace/src/entities/view/view_create.rs +++ b/rust-lib/flowy-workspace/src/entities/view/view_create.rs @@ -1,6 +1,6 @@ use crate::{ entities::{app::parser::AppId, view::parser::*}, - errors::{ErrorBuilder, WorkspaceError, WorkspaceErrorCode}, + errors::{ErrorBuilder, WorkspaceError, WsErrCode}, impl_def_and_def_mut, sql_tables::view::ViewTableType, }; @@ -48,19 +48,11 @@ impl TryInto for CreateViewRequest { fn try_into(self) -> Result { let name = ViewName::parse(self.name) - .map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::ViewNameInvalid) - .msg(e) - .build() - })? + .map_err(|e| ErrorBuilder::new(WsErrCode::ViewNameInvalid).msg(e).build())? .0; let app_id = AppId::parse(self.app_id) - .map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::AppIdInvalid) - .msg(e) - .build() - })? + .map_err(|e| ErrorBuilder::new(WsErrCode::AppIdInvalid).msg(e).build())? .0; let thumbnail = match self.thumbnail { @@ -68,7 +60,7 @@ impl TryInto for CreateViewRequest { Some(thumbnail) => { ViewThumbnail::parse(thumbnail) .map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::ViewThumbnailInvalid) + ErrorBuilder::new(WsErrCode::ViewThumbnailInvalid) .msg(e) .build() })? diff --git a/rust-lib/flowy-workspace/src/entities/view/view_query.rs b/rust-lib/flowy-workspace/src/entities/view/view_query.rs index 0e99b53e72..d989ab992e 100644 --- a/rust-lib/flowy-workspace/src/entities/view/view_query.rs +++ b/rust-lib/flowy-workspace/src/entities/view/view_query.rs @@ -1,6 +1,6 @@ use crate::{ entities::view::parser::ViewId, - errors::{ErrorBuilder, WorkspaceError, WorkspaceErrorCode}, + errors::{ErrorBuilder, WorkspaceError, WsErrCode}, }; use flowy_derive::ProtoBuf; use std::convert::TryInto; @@ -20,11 +20,7 @@ impl TryInto for QueryViewRequest { fn try_into(self) -> Result { let view_id = ViewId::parse(self.view_id) - .map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::ViewIdInvalid) - .msg(e) - .build() - })? + .map_err(|e| ErrorBuilder::new(WsErrCode::ViewIdInvalid).msg(e).build())? .0; Ok(QueryViewParams { view_id }) diff --git a/rust-lib/flowy-workspace/src/entities/view/view_update.rs b/rust-lib/flowy-workspace/src/entities/view/view_update.rs index 07719f83bc..bc83501d67 100644 --- a/rust-lib/flowy-workspace/src/entities/view/view_update.rs +++ b/rust-lib/flowy-workspace/src/entities/view/view_update.rs @@ -1,6 +1,6 @@ use crate::{ entities::view::parser::{ViewId, *}, - errors::{ErrorBuilder, WorkspaceError, WorkspaceErrorCode}, + errors::{ErrorBuilder, WorkspaceError, WsErrCode}, }; use flowy_derive::ProtoBuf; use std::convert::TryInto; @@ -32,22 +32,14 @@ impl TryInto for UpdateViewRequest { fn try_into(self) -> Result { let view_id = ViewId::parse(self.view_id) - .map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::ViewIdInvalid) - .msg(e) - .build() - })? + .map_err(|e| ErrorBuilder::new(WsErrCode::ViewIdInvalid).msg(e).build())? .0; let name = match self.name { None => None, Some(name) => Some( ViewName::parse(name) - .map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::ViewNameInvalid) - .msg(e) - .build() - })? + .map_err(|e| ErrorBuilder::new(WsErrCode::ViewNameInvalid).msg(e).build())? .0, ), }; @@ -56,11 +48,7 @@ impl TryInto for UpdateViewRequest { None => None, Some(desc) => Some( ViewDesc::parse(desc) - .map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::ViewDescInvalid) - .msg(e) - .build() - })? + .map_err(|e| ErrorBuilder::new(WsErrCode::ViewDescInvalid).msg(e).build())? .0, ), }; @@ -70,7 +58,7 @@ impl TryInto for UpdateViewRequest { Some(thumbnail) => Some( ViewThumbnail::parse(thumbnail) .map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::ViewThumbnailInvalid) + ErrorBuilder::new(WsErrCode::ViewThumbnailInvalid) .msg(e) .build() })? diff --git a/rust-lib/flowy-workspace/src/entities/workspace/workspace_create.rs b/rust-lib/flowy-workspace/src/entities/workspace/workspace_create.rs index b20240754d..f14fdec400 100644 --- a/rust-lib/flowy-workspace/src/entities/workspace/workspace_create.rs +++ b/rust-lib/flowy-workspace/src/entities/workspace/workspace_create.rs @@ -1,8 +1,5 @@ use crate::{ - entities::{ - app::{App, RepeatedApp}, - workspace::parser::*, - }, + entities::{app::RepeatedApp, workspace::parser::*}, errors::*, }; use flowy_derive::ProtoBuf; @@ -27,7 +24,7 @@ impl TryInto for CreateWorkspaceRequest { fn try_into(self) -> Result { let name = WorkspaceName::parse(self.name).map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::WorkspaceNameInvalid) + ErrorBuilder::new(WsErrCode::WorkspaceNameInvalid) .msg(e) .build() })?; diff --git a/rust-lib/flowy-workspace/src/entities/workspace/workspace_query.rs b/rust-lib/flowy-workspace/src/entities/workspace/workspace_query.rs index f801713ab5..746abea167 100644 --- a/rust-lib/flowy-workspace/src/entities/workspace/workspace_query.rs +++ b/rust-lib/flowy-workspace/src/entities/workspace/workspace_query.rs @@ -22,7 +22,7 @@ impl TryInto for QueryWorkspaceRequest { fn try_into(self) -> Result { let workspace_id = WorkspaceId::parse(self.workspace_id) .map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::WorkspaceIdInvalid) + ErrorBuilder::new(WsErrCode::WorkspaceIdInvalid) .msg(e) .build() })? diff --git a/rust-lib/flowy-workspace/src/entities/workspace/workspace_update.rs b/rust-lib/flowy-workspace/src/entities/workspace/workspace_update.rs index 3352e69890..f2297156ba 100644 --- a/rust-lib/flowy-workspace/src/entities/workspace/workspace_update.rs +++ b/rust-lib/flowy-workspace/src/entities/workspace/workspace_update.rs @@ -31,7 +31,7 @@ impl TryInto for UpdateWorkspaceRequest { Some(name) => Some( WorkspaceName::parse(name) .map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::WorkspaceNameInvalid) + ErrorBuilder::new(WsErrCode::WorkspaceNameInvalid) .msg(e) .build() })? @@ -40,7 +40,7 @@ impl TryInto for UpdateWorkspaceRequest { }; let id = WorkspaceId::parse(self.id).map_err(|e| { - ErrorBuilder::new(WorkspaceErrorCode::WorkspaceIdInvalid) + ErrorBuilder::new(WsErrCode::WorkspaceIdInvalid) .msg(e) .build() })?; diff --git a/rust-lib/flowy-workspace/src/errors.rs b/rust-lib/flowy-workspace/src/errors.rs index c97ce14c53..de1f22222a 100644 --- a/rust-lib/flowy-workspace/src/errors.rs +++ b/rust-lib/flowy-workspace/src/errors.rs @@ -6,14 +6,14 @@ use std::convert::TryInto; #[derive(Debug, Default, Clone, ProtoBuf)] pub struct WorkspaceError { #[pb(index = 1)] - pub code: WorkspaceErrorCode, + pub code: WsErrCode, #[pb(index = 2)] pub msg: String, } impl WorkspaceError { - pub fn new(code: WorkspaceErrorCode, msg: &str) -> Self { + pub fn new(code: WsErrCode, msg: &str) -> Self { Self { code, msg: msg.to_owned(), @@ -22,7 +22,7 @@ impl WorkspaceError { } #[derive(Debug, Clone, ProtoBuf_Enum, Display, PartialEq, Eq)] -pub enum WorkspaceErrorCode { +pub enum WsErrCode { #[display(fmt = "Unknown")] Unknown = 0, @@ -66,13 +66,13 @@ pub enum WorkspaceErrorCode { UserNotLoginYet = 103, } -impl std::default::Default for WorkspaceErrorCode { - fn default() -> Self { WorkspaceErrorCode::Unknown } +impl std::default::Default for WsErrCode { + fn default() -> Self { WsErrCode::Unknown } } impl std::convert::From for WorkspaceError { fn from(error: flowy_database::result::Error) -> Self { - ErrorBuilder::new(WorkspaceErrorCode::WorkspaceDatabaseError) + ErrorBuilder::new(WsErrCode::WorkspaceDatabaseError) .error(error) .build() } @@ -86,12 +86,12 @@ impl flowy_dispatch::Error for WorkspaceError { } pub struct ErrorBuilder { - pub code: WorkspaceErrorCode, + pub code: WsErrCode, pub msg: Option, } impl ErrorBuilder { - pub fn new(code: WorkspaceErrorCode) -> Self { ErrorBuilder { code, msg: None } } + pub fn new(code: WsErrCode) -> Self { ErrorBuilder { code, msg: None } } pub fn msg(mut self, msg: T) -> Self where diff --git a/rust-lib/flowy-workspace/src/lib.rs b/rust-lib/flowy-workspace/src/lib.rs index c24d413009..28d5a7f5e4 100644 --- a/rust-lib/flowy-workspace/src/lib.rs +++ b/rust-lib/flowy-workspace/src/lib.rs @@ -14,8 +14,8 @@ mod services; #[macro_use] extern crate flowy_database; -#[macro_use] -extern crate flowy_dispatch; +// #[macro_use] +// extern crate flowy_dispatch; pub mod prelude { pub use crate::{errors::*, module::*, services::*}; diff --git a/rust-lib/flowy-workspace/src/observable/mod.rs b/rust-lib/flowy-workspace/src/observable/mod.rs index 66a2058d79..73171fda02 100644 --- a/rust-lib/flowy-workspace/src/observable/mod.rs +++ b/rust-lib/flowy-workspace/src/observable/mod.rs @@ -1,3 +1,3 @@ mod observable; -pub use observable::*; +pub(crate) use observable::*; diff --git a/rust-lib/flowy-workspace/src/observable/observable.rs b/rust-lib/flowy-workspace/src/observable/observable.rs index 0533de73c8..f4d9921190 100644 --- a/rust-lib/flowy-workspace/src/observable/observable.rs +++ b/rust-lib/flowy-workspace/src/observable/observable.rs @@ -35,6 +35,7 @@ impl ObservableSender { } } + #[allow(dead_code)] pub(crate) fn payload(mut self, payload: T) -> Self where T: ToBytes, @@ -68,6 +69,7 @@ pub(crate) fn send_observable(id: &str, ty: WorkspaceObservable) { ObservableSender::new(id, ty).send(); } +#[allow(dead_code)] pub(crate) fn send_observable_with_payload(id: &str, ty: WorkspaceObservable, payload: T) where T: ToBytes, diff --git a/rust-lib/flowy-workspace/src/protobuf/model/errors.rs b/rust-lib/flowy-workspace/src/protobuf/model/errors.rs index aa3aa6a631..08f479a5ff 100644 --- a/rust-lib/flowy-workspace/src/protobuf/model/errors.rs +++ b/rust-lib/flowy-workspace/src/protobuf/model/errors.rs @@ -26,7 +26,7 @@ #[derive(PartialEq,Clone,Default)] pub struct WorkspaceError { // message fields - pub code: WorkspaceErrorCode, + pub code: WsErrCode, pub msg: ::std::string::String, // special fields pub unknown_fields: ::protobuf::UnknownFields, @@ -44,18 +44,18 @@ impl WorkspaceError { ::std::default::Default::default() } - // .WorkspaceErrorCode code = 1; + // .WsErrCode code = 1; - pub fn get_code(&self) -> WorkspaceErrorCode { + pub fn get_code(&self) -> WsErrCode { self.code } pub fn clear_code(&mut self) { - self.code = WorkspaceErrorCode::Unknown; + self.code = WsErrCode::Unknown; } // Param is passed by value, moved - pub fn set_code(&mut self, v: WorkspaceErrorCode) { + pub fn set_code(&mut self, v: WsErrCode) { self.code = v; } @@ -113,7 +113,7 @@ impl ::protobuf::Message for WorkspaceError { #[allow(unused_variables)] fn compute_size(&self) -> u32 { let mut my_size = 0; - if self.code != WorkspaceErrorCode::Unknown { + if self.code != WsErrCode::Unknown { my_size += ::protobuf::rt::enum_size(1, self.code); } if !self.msg.is_empty() { @@ -125,7 +125,7 @@ impl ::protobuf::Message for WorkspaceError { } fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - if self.code != WorkspaceErrorCode::Unknown { + if self.code != WsErrCode::Unknown { os.write_enum(1, ::protobuf::ProtobufEnum::value(&self.code))?; } if !self.msg.is_empty() { @@ -169,7 +169,7 @@ impl ::protobuf::Message for WorkspaceError { 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::ProtobufTypeEnum>( + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeEnum>( "code", |m: &WorkspaceError| { &m.code }, |m: &mut WorkspaceError| { &mut m.code }, @@ -195,7 +195,7 @@ impl ::protobuf::Message for WorkspaceError { impl ::protobuf::Clear for WorkspaceError { fn clear(&mut self) { - self.code = WorkspaceErrorCode::Unknown; + self.code = WsErrCode::Unknown; self.msg.clear(); self.unknown_fields.clear(); } @@ -214,7 +214,7 @@ impl ::protobuf::reflect::ProtobufValue for WorkspaceError { } #[derive(Clone,PartialEq,Eq,Debug,Hash)] -pub enum WorkspaceErrorCode { +pub enum WsErrCode { Unknown = 0, WorkspaceNameInvalid = 1, WorkspaceIdInvalid = 2, @@ -231,47 +231,47 @@ pub enum WorkspaceErrorCode { UserNotLoginYet = 103, } -impl ::protobuf::ProtobufEnum for WorkspaceErrorCode { +impl ::protobuf::ProtobufEnum for WsErrCode { fn value(&self) -> i32 { *self as i32 } - fn from_i32(value: i32) -> ::std::option::Option { + fn from_i32(value: i32) -> ::std::option::Option { match value { - 0 => ::std::option::Option::Some(WorkspaceErrorCode::Unknown), - 1 => ::std::option::Option::Some(WorkspaceErrorCode::WorkspaceNameInvalid), - 2 => ::std::option::Option::Some(WorkspaceErrorCode::WorkspaceIdInvalid), - 3 => ::std::option::Option::Some(WorkspaceErrorCode::AppColorStyleInvalid), - 10 => ::std::option::Option::Some(WorkspaceErrorCode::AppIdInvalid), - 11 => ::std::option::Option::Some(WorkspaceErrorCode::AppNameInvalid), - 20 => ::std::option::Option::Some(WorkspaceErrorCode::ViewNameInvalid), - 21 => ::std::option::Option::Some(WorkspaceErrorCode::ViewThumbnailInvalid), - 22 => ::std::option::Option::Some(WorkspaceErrorCode::ViewIdInvalid), - 23 => ::std::option::Option::Some(WorkspaceErrorCode::ViewDescInvalid), - 100 => ::std::option::Option::Some(WorkspaceErrorCode::DatabaseConnectionFail), - 101 => ::std::option::Option::Some(WorkspaceErrorCode::WorkspaceDatabaseError), - 102 => ::std::option::Option::Some(WorkspaceErrorCode::UserInternalError), - 103 => ::std::option::Option::Some(WorkspaceErrorCode::UserNotLoginYet), + 0 => ::std::option::Option::Some(WsErrCode::Unknown), + 1 => ::std::option::Option::Some(WsErrCode::WorkspaceNameInvalid), + 2 => ::std::option::Option::Some(WsErrCode::WorkspaceIdInvalid), + 3 => ::std::option::Option::Some(WsErrCode::AppColorStyleInvalid), + 10 => ::std::option::Option::Some(WsErrCode::AppIdInvalid), + 11 => ::std::option::Option::Some(WsErrCode::AppNameInvalid), + 20 => ::std::option::Option::Some(WsErrCode::ViewNameInvalid), + 21 => ::std::option::Option::Some(WsErrCode::ViewThumbnailInvalid), + 22 => ::std::option::Option::Some(WsErrCode::ViewIdInvalid), + 23 => ::std::option::Option::Some(WsErrCode::ViewDescInvalid), + 100 => ::std::option::Option::Some(WsErrCode::DatabaseConnectionFail), + 101 => ::std::option::Option::Some(WsErrCode::WorkspaceDatabaseError), + 102 => ::std::option::Option::Some(WsErrCode::UserInternalError), + 103 => ::std::option::Option::Some(WsErrCode::UserNotLoginYet), _ => ::std::option::Option::None } } fn values() -> &'static [Self] { - static values: &'static [WorkspaceErrorCode] = &[ - WorkspaceErrorCode::Unknown, - WorkspaceErrorCode::WorkspaceNameInvalid, - WorkspaceErrorCode::WorkspaceIdInvalid, - WorkspaceErrorCode::AppColorStyleInvalid, - WorkspaceErrorCode::AppIdInvalid, - WorkspaceErrorCode::AppNameInvalid, - WorkspaceErrorCode::ViewNameInvalid, - WorkspaceErrorCode::ViewThumbnailInvalid, - WorkspaceErrorCode::ViewIdInvalid, - WorkspaceErrorCode::ViewDescInvalid, - WorkspaceErrorCode::DatabaseConnectionFail, - WorkspaceErrorCode::WorkspaceDatabaseError, - WorkspaceErrorCode::UserInternalError, - WorkspaceErrorCode::UserNotLoginYet, + static values: &'static [WsErrCode] = &[ + WsErrCode::Unknown, + WsErrCode::WorkspaceNameInvalid, + WsErrCode::WorkspaceIdInvalid, + WsErrCode::AppColorStyleInvalid, + WsErrCode::AppIdInvalid, + WsErrCode::AppNameInvalid, + WsErrCode::ViewNameInvalid, + WsErrCode::ViewThumbnailInvalid, + WsErrCode::ViewIdInvalid, + WsErrCode::ViewDescInvalid, + WsErrCode::DatabaseConnectionFail, + WsErrCode::WorkspaceDatabaseError, + WsErrCode::UserInternalError, + WsErrCode::UserNotLoginYet, ]; values } @@ -279,74 +279,74 @@ impl ::protobuf::ProtobufEnum for WorkspaceErrorCode { fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::LazyV2::INIT; descriptor.get(|| { - ::protobuf::reflect::EnumDescriptor::new_pb_name::("WorkspaceErrorCode", file_descriptor_proto()) + ::protobuf::reflect::EnumDescriptor::new_pb_name::("WsErrCode", file_descriptor_proto()) }) } } -impl ::std::marker::Copy for WorkspaceErrorCode { +impl ::std::marker::Copy for WsErrCode { } -impl ::std::default::Default for WorkspaceErrorCode { +impl ::std::default::Default for WsErrCode { fn default() -> Self { - WorkspaceErrorCode::Unknown + WsErrCode::Unknown } } -impl ::protobuf::reflect::ProtobufValue for WorkspaceErrorCode { +impl ::protobuf::reflect::ProtobufValue for WsErrCode { fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { ::protobuf::reflect::ReflectValueRef::Enum(::protobuf::ProtobufEnum::descriptor(self)) } } static file_descriptor_proto_data: &'static [u8] = b"\ - \n\x0cerrors.proto\"K\n\x0eWorkspaceError\x12'\n\x04code\x18\x01\x20\x01\ - (\x0e2\x13.WorkspaceErrorCodeR\x04code\x12\x10\n\x03msg\x18\x02\x20\x01(\ - \tR\x03msg*\xce\x02\n\x12WorkspaceErrorCode\x12\x0b\n\x07Unknown\x10\0\ - \x12\x18\n\x14WorkspaceNameInvalid\x10\x01\x12\x16\n\x12WorkspaceIdInval\ - id\x10\x02\x12\x18\n\x14AppColorStyleInvalid\x10\x03\x12\x10\n\x0cAppIdI\ - nvalid\x10\n\x12\x12\n\x0eAppNameInvalid\x10\x0b\x12\x13\n\x0fViewNameIn\ - valid\x10\x14\x12\x18\n\x14ViewThumbnailInvalid\x10\x15\x12\x11\n\rViewI\ - dInvalid\x10\x16\x12\x13\n\x0fViewDescInvalid\x10\x17\x12\x1a\n\x16Datab\ - aseConnectionFail\x10d\x12\x1a\n\x16WorkspaceDatabaseError\x10e\x12\x15\ - \n\x11UserInternalError\x10f\x12\x13\n\x0fUserNotLoginYet\x10gJ\xee\x05\ - \n\x06\x12\x04\0\0\x15\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\x20\n\x0c\n\x05\x04\0\x02\0\x06\x12\x03\ - \x03\x04\x16\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\x17\x1b\n\x0c\n\x05\ - \x04\0\x02\0\x03\x12\x03\x03\x1e\x1f\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\x12\n\n\n\x02\x05\0\x12\x04\x06\0\x15\x01\n\n\n\x03\x05\0\ - \x01\x12\x03\x06\x05\x17\n\x0b\n\x04\x05\0\x02\0\x12\x03\x07\x04\x10\n\ - \x0c\n\x05\x05\0\x02\0\x01\x12\x03\x07\x04\x0b\n\x0c\n\x05\x05\0\x02\0\ - \x02\x12\x03\x07\x0e\x0f\n\x0b\n\x04\x05\0\x02\x01\x12\x03\x08\x04\x1d\n\ - \x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x08\x04\x18\n\x0c\n\x05\x05\0\x02\ - \x01\x02\x12\x03\x08\x1b\x1c\n\x0b\n\x04\x05\0\x02\x02\x12\x03\t\x04\x1b\ - \n\x0c\n\x05\x05\0\x02\x02\x01\x12\x03\t\x04\x16\n\x0c\n\x05\x05\0\x02\ - \x02\x02\x12\x03\t\x19\x1a\n\x0b\n\x04\x05\0\x02\x03\x12\x03\n\x04\x1d\n\ - \x0c\n\x05\x05\0\x02\x03\x01\x12\x03\n\x04\x18\n\x0c\n\x05\x05\0\x02\x03\ - \x02\x12\x03\n\x1b\x1c\n\x0b\n\x04\x05\0\x02\x04\x12\x03\x0b\x04\x16\n\ - \x0c\n\x05\x05\0\x02\x04\x01\x12\x03\x0b\x04\x10\n\x0c\n\x05\x05\0\x02\ - \x04\x02\x12\x03\x0b\x13\x15\n\x0b\n\x04\x05\0\x02\x05\x12\x03\x0c\x04\ - \x18\n\x0c\n\x05\x05\0\x02\x05\x01\x12\x03\x0c\x04\x12\n\x0c\n\x05\x05\0\ - \x02\x05\x02\x12\x03\x0c\x15\x17\n\x0b\n\x04\x05\0\x02\x06\x12\x03\r\x04\ - \x19\n\x0c\n\x05\x05\0\x02\x06\x01\x12\x03\r\x04\x13\n\x0c\n\x05\x05\0\ - \x02\x06\x02\x12\x03\r\x16\x18\n\x0b\n\x04\x05\0\x02\x07\x12\x03\x0e\x04\ - \x1e\n\x0c\n\x05\x05\0\x02\x07\x01\x12\x03\x0e\x04\x18\n\x0c\n\x05\x05\0\ - \x02\x07\x02\x12\x03\x0e\x1b\x1d\n\x0b\n\x04\x05\0\x02\x08\x12\x03\x0f\ - \x04\x17\n\x0c\n\x05\x05\0\x02\x08\x01\x12\x03\x0f\x04\x11\n\x0c\n\x05\ - \x05\0\x02\x08\x02\x12\x03\x0f\x14\x16\n\x0b\n\x04\x05\0\x02\t\x12\x03\ - \x10\x04\x19\n\x0c\n\x05\x05\0\x02\t\x01\x12\x03\x10\x04\x13\n\x0c\n\x05\ - \x05\0\x02\t\x02\x12\x03\x10\x16\x18\n\x0b\n\x04\x05\0\x02\n\x12\x03\x11\ - \x04!\n\x0c\n\x05\x05\0\x02\n\x01\x12\x03\x11\x04\x1a\n\x0c\n\x05\x05\0\ - \x02\n\x02\x12\x03\x11\x1d\x20\n\x0b\n\x04\x05\0\x02\x0b\x12\x03\x12\x04\ - !\n\x0c\n\x05\x05\0\x02\x0b\x01\x12\x03\x12\x04\x1a\n\x0c\n\x05\x05\0\ - \x02\x0b\x02\x12\x03\x12\x1d\x20\n\x0b\n\x04\x05\0\x02\x0c\x12\x03\x13\ - \x04\x1c\n\x0c\n\x05\x05\0\x02\x0c\x01\x12\x03\x13\x04\x15\n\x0c\n\x05\ - \x05\0\x02\x0c\x02\x12\x03\x13\x18\x1b\n\x0b\n\x04\x05\0\x02\r\x12\x03\ - \x14\x04\x1a\n\x0c\n\x05\x05\0\x02\r\x01\x12\x03\x14\x04\x13\n\x0c\n\x05\ - \x05\0\x02\r\x02\x12\x03\x14\x16\x19b\x06proto3\ + \n\x0cerrors.proto\"B\n\x0eWorkspaceError\x12\x1e\n\x04code\x18\x01\x20\ + \x01(\x0e2\n.WsErrCodeR\x04code\x12\x10\n\x03msg\x18\x02\x20\x01(\tR\x03\ + msg*\xc5\x02\n\tWsErrCode\x12\x0b\n\x07Unknown\x10\0\x12\x18\n\x14Worksp\ + aceNameInvalid\x10\x01\x12\x16\n\x12WorkspaceIdInvalid\x10\x02\x12\x18\n\ + \x14AppColorStyleInvalid\x10\x03\x12\x10\n\x0cAppIdInvalid\x10\n\x12\x12\ + \n\x0eAppNameInvalid\x10\x0b\x12\x13\n\x0fViewNameInvalid\x10\x14\x12\ + \x18\n\x14ViewThumbnailInvalid\x10\x15\x12\x11\n\rViewIdInvalid\x10\x16\ + \x12\x13\n\x0fViewDescInvalid\x10\x17\x12\x1a\n\x16DatabaseConnectionFai\ + l\x10d\x12\x1a\n\x16WorkspaceDatabaseError\x10e\x12\x15\n\x11UserInterna\ + lError\x10f\x12\x13\n\x0fUserNotLoginYet\x10gJ\xee\x05\n\x06\x12\x04\0\0\ + \x15\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\x17\n\x0c\n\x05\x04\0\x02\0\x06\x12\x03\x03\x04\r\n\x0c\ + \n\x05\x04\0\x02\0\x01\x12\x03\x03\x0e\x12\n\x0c\n\x05\x04\0\x02\0\x03\ + \x12\x03\x03\x15\x16\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\x12\n\ + \n\n\x02\x05\0\x12\x04\x06\0\x15\x01\n\n\n\x03\x05\0\x01\x12\x03\x06\x05\ + \x0e\n\x0b\n\x04\x05\0\x02\0\x12\x03\x07\x04\x10\n\x0c\n\x05\x05\0\x02\0\ + \x01\x12\x03\x07\x04\x0b\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x07\x0e\x0f\ + \n\x0b\n\x04\x05\0\x02\x01\x12\x03\x08\x04\x1d\n\x0c\n\x05\x05\0\x02\x01\ + \x01\x12\x03\x08\x04\x18\n\x0c\n\x05\x05\0\x02\x01\x02\x12\x03\x08\x1b\ + \x1c\n\x0b\n\x04\x05\0\x02\x02\x12\x03\t\x04\x1b\n\x0c\n\x05\x05\0\x02\ + \x02\x01\x12\x03\t\x04\x16\n\x0c\n\x05\x05\0\x02\x02\x02\x12\x03\t\x19\ + \x1a\n\x0b\n\x04\x05\0\x02\x03\x12\x03\n\x04\x1d\n\x0c\n\x05\x05\0\x02\ + \x03\x01\x12\x03\n\x04\x18\n\x0c\n\x05\x05\0\x02\x03\x02\x12\x03\n\x1b\ + \x1c\n\x0b\n\x04\x05\0\x02\x04\x12\x03\x0b\x04\x16\n\x0c\n\x05\x05\0\x02\ + \x04\x01\x12\x03\x0b\x04\x10\n\x0c\n\x05\x05\0\x02\x04\x02\x12\x03\x0b\ + \x13\x15\n\x0b\n\x04\x05\0\x02\x05\x12\x03\x0c\x04\x18\n\x0c\n\x05\x05\0\ + \x02\x05\x01\x12\x03\x0c\x04\x12\n\x0c\n\x05\x05\0\x02\x05\x02\x12\x03\ + \x0c\x15\x17\n\x0b\n\x04\x05\0\x02\x06\x12\x03\r\x04\x19\n\x0c\n\x05\x05\ + \0\x02\x06\x01\x12\x03\r\x04\x13\n\x0c\n\x05\x05\0\x02\x06\x02\x12\x03\r\ + \x16\x18\n\x0b\n\x04\x05\0\x02\x07\x12\x03\x0e\x04\x1e\n\x0c\n\x05\x05\0\ + \x02\x07\x01\x12\x03\x0e\x04\x18\n\x0c\n\x05\x05\0\x02\x07\x02\x12\x03\ + \x0e\x1b\x1d\n\x0b\n\x04\x05\0\x02\x08\x12\x03\x0f\x04\x17\n\x0c\n\x05\ + \x05\0\x02\x08\x01\x12\x03\x0f\x04\x11\n\x0c\n\x05\x05\0\x02\x08\x02\x12\ + \x03\x0f\x14\x16\n\x0b\n\x04\x05\0\x02\t\x12\x03\x10\x04\x19\n\x0c\n\x05\ + \x05\0\x02\t\x01\x12\x03\x10\x04\x13\n\x0c\n\x05\x05\0\x02\t\x02\x12\x03\ + \x10\x16\x18\n\x0b\n\x04\x05\0\x02\n\x12\x03\x11\x04!\n\x0c\n\x05\x05\0\ + \x02\n\x01\x12\x03\x11\x04\x1a\n\x0c\n\x05\x05\0\x02\n\x02\x12\x03\x11\ + \x1d\x20\n\x0b\n\x04\x05\0\x02\x0b\x12\x03\x12\x04!\n\x0c\n\x05\x05\0\ + \x02\x0b\x01\x12\x03\x12\x04\x1a\n\x0c\n\x05\x05\0\x02\x0b\x02\x12\x03\ + \x12\x1d\x20\n\x0b\n\x04\x05\0\x02\x0c\x12\x03\x13\x04\x1c\n\x0c\n\x05\ + \x05\0\x02\x0c\x01\x12\x03\x13\x04\x15\n\x0c\n\x05\x05\0\x02\x0c\x02\x12\ + \x03\x13\x18\x1b\n\x0b\n\x04\x05\0\x02\r\x12\x03\x14\x04\x1a\n\x0c\n\x05\ + \x05\0\x02\r\x01\x12\x03\x14\x04\x13\n\x0c\n\x05\x05\0\x02\r\x02\x12\x03\ + \x14\x16\x19b\x06proto3\ "; static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; diff --git a/rust-lib/flowy-workspace/src/protobuf/proto/errors.proto b/rust-lib/flowy-workspace/src/protobuf/proto/errors.proto index 1103916f3b..d98904a72b 100644 --- a/rust-lib/flowy-workspace/src/protobuf/proto/errors.proto +++ b/rust-lib/flowy-workspace/src/protobuf/proto/errors.proto @@ -1,10 +1,10 @@ syntax = "proto3"; message WorkspaceError { - WorkspaceErrorCode code = 1; + WsErrCode code = 1; string msg = 2; } -enum WorkspaceErrorCode { +enum WsErrCode { Unknown = 0; WorkspaceNameInvalid = 1; WorkspaceIdInvalid = 2; diff --git a/rust-lib/flowy-workspace/src/services/workspace_controller.rs b/rust-lib/flowy-workspace/src/services/workspace_controller.rs index d98a9dfec7..a387b3cde3 100644 --- a/rust-lib/flowy-workspace/src/services/workspace_controller.rs +++ b/rust-lib/flowy-workspace/src/services/workspace_controller.rs @@ -48,7 +48,7 @@ impl WorkspaceController { Ok(()) } - pub fn delete_workspace(&self, workspace_id: &str) -> Result<(), WorkspaceError> { + pub fn delete_workspace(&self, _workspace_id: &str) -> Result<(), WorkspaceError> { unimplemented!() } diff --git a/rust-lib/flowy-workspace/src/sql_tables/app/app_sql.rs b/rust-lib/flowy-workspace/src/sql_tables/app/app_sql.rs index 2386d36fcf..a377d78393 100644 --- a/rust-lib/flowy-workspace/src/sql_tables/app/app_sql.rs +++ b/rust-lib/flowy-workspace/src/sql_tables/app/app_sql.rs @@ -4,7 +4,6 @@ use crate::{ sql_tables::{ app::{AppTable, AppTableChangeset}, view::ViewTable, - workspace::WorkspaceTable, }, }; use flowy_database::{ @@ -40,7 +39,9 @@ impl AppTableSql { Ok(app_table) } - pub(crate) fn delete_app(&self, app_id: &str) -> Result<(), WorkspaceError> { unimplemented!() } + pub(crate) fn delete_app(&self, _app_id: &str) -> Result<(), WorkspaceError> { + unimplemented!() + } pub(crate) fn read_views_belong_to_app( &self, diff --git a/rust-lib/flowy-workspace/src/sql_tables/view/view_sql.rs b/rust-lib/flowy-workspace/src/sql_tables/view/view_sql.rs index 95aad2ab47..b4d1d2194e 100644 --- a/rust-lib/flowy-workspace/src/sql_tables/view/view_sql.rs +++ b/rust-lib/flowy-workspace/src/sql_tables/view/view_sql.rs @@ -36,5 +36,5 @@ impl ViewTableSql { Ok(()) } - pub fn delete_view(&self, view_id: &str) -> Result<(), WorkspaceError> { unimplemented!() } + pub fn delete_view(&self, _view_id: &str) -> Result<(), WorkspaceError> { unimplemented!() } } diff --git a/rust-lib/flowy-workspace/src/sql_tables/workspace/workspace_sql.rs b/rust-lib/flowy-workspace/src/sql_tables/workspace/workspace_sql.rs index e612f61a4e..6112ec3a4e 100644 --- a/rust-lib/flowy-workspace/src/sql_tables/workspace/workspace_sql.rs +++ b/rust-lib/flowy-workspace/src/sql_tables/workspace/workspace_sql.rs @@ -41,7 +41,7 @@ impl WorkspaceSql { Ok(()) } - pub fn delete_workspace(&self, workspace_id: &str) -> Result<(), WorkspaceError> { + pub fn delete_workspace(&self, _workspace_id: &str) -> Result<(), WorkspaceError> { unimplemented!() } diff --git a/rust-lib/flowy-workspace/tests/event/app_test.rs b/rust-lib/flowy-workspace/tests/event/app_test.rs index 526ae6fa06..2f2dd63935 100644 --- a/rust-lib/flowy-workspace/tests/event/app_test.rs +++ b/rust-lib/flowy-workspace/tests/event/app_test.rs @@ -1,13 +1,6 @@ use crate::helper::*; -use flowy_test::builder::SingleUserTestBuilder; -use flowy_workspace::{ - entities::{ - app::{App, CreateAppRequest, QueryAppRequest}, - view::*, - workspace::Workspace, - }, - event::WorkspaceEvent::{CreateApp, GetCurWorkspace}, -}; + +use flowy_workspace::entities::{app::QueryAppRequest, view::*}; #[test] fn app_create_success() { diff --git a/rust-lib/flowy-workspace/tests/event/workspace_test.rs b/rust-lib/flowy-workspace/tests/event/workspace_test.rs index 7c1bc0ab71..2a6c2b69f1 100644 --- a/rust-lib/flowy-workspace/tests/event/workspace_test.rs +++ b/rust-lib/flowy-workspace/tests/event/workspace_test.rs @@ -1,13 +1,9 @@ use crate::helper::*; use flowy_workspace::{ - entities::{ - app::{App, CreateAppRequest}, - workspace::{CreateWorkspaceRequest, QueryWorkspaceRequest, Workspace}, - }, + entities::workspace::{CreateWorkspaceRequest, QueryWorkspaceRequest, Workspace}, event::WorkspaceEvent::*, prelude::*, }; -use serial_test::*; #[test] fn workspace_create_success() { let _ = create_workspace("First workspace", ""); } @@ -66,7 +62,7 @@ fn workspace_create_with_invalid_name_test() { .sync_send() .error() .code, - WorkspaceErrorCode::WorkspaceNameInvalid + WsErrCode::WorkspaceNameInvalid ) } } @@ -86,7 +82,7 @@ fn workspace_update_with_invalid_name_test() { .sync_send() .error() .code, - WorkspaceErrorCode::WorkspaceNameInvalid + WsErrCode::WorkspaceNameInvalid ) } } diff --git a/scripts/flowy-tool/src/proto/template/proto_file/struct_template.rs b/scripts/flowy-tool/src/proto/template/proto_file/struct_template.rs index 1d06a16a51..dd7103fa1f 100644 --- a/scripts/flowy-tool/src/proto/template/proto_file/struct_template.rs +++ b/scripts/flowy-tool/src/proto/template/proto_file/struct_template.rs @@ -1,7 +1,7 @@ use crate::util::get_tera; use flowy_ast::*; use phf::phf_map; -use syn::__private::quote::__private::Ident; + use tera::Context; // Protobuf data type : https://developers.google.com/protocol-buffers/docs/proto3