diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_create.pb.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_create.pb.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_create.pb.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_create.pb.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_create.pbenum.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_create.pbenum.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_create.pbenum.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_create.pbenum.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_create.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_create.pbjson.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_create.pbjson.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_create.pbjson.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_create.pbserver.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_create.pbserver.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_create.pbserver.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_create.pbserver.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_query.pb.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_query.pb.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_query.pb.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_query.pb.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_query.pbenum.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_query.pbenum.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_query.pbenum.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_query.pbenum.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_query.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_query.pbjson.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_query.pbjson.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_query.pbjson.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_query.pbserver.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_query.pbserver.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_query.pbserver.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_query.pbserver.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_update.pb.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_update.pb.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_update.pb.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_update.pb.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_update.pbenum.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_update.pbenum.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_update.pbenum.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_update.pbenum.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_update.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_update.pbjson.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_update.pbjson.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_update.pbjson.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_update.pbserver.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_update.pbserver.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_update.pbserver.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/app_update.pbserver.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_delete.pbenum.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/errors.pb.dart similarity index 76% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_delete.pbenum.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/errors.pb.dart index 2915cbbc4d..f2ec97799a 100644 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_delete.pbenum.dart +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/errors.pb.dart @@ -1,7 +1,11 @@ /// // Generated code. Do not modify. -// source: app_delete.proto +// source: errors.proto // // @dart = 2.12 // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields +import 'dart:core' as $core; + +export 'errors.pbenum.dart'; + diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/errors.pbenum.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/errors.pbenum.dart new file mode 100644 index 0000000000..52eb16349e --- /dev/null +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/errors.pbenum.dart @@ -0,0 +1,56 @@ +/// +// Generated code. Do not modify. +// source: errors.proto +// +// @dart = 2.12 +// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields + +// ignore_for_file: UNDEFINED_SHOWN_NAME +import 'dart:core' as $core; +import 'package:protobuf/protobuf.dart' as $pb; + +class ErrorCode extends $pb.ProtobufEnum { + static const ErrorCode WorkspaceNameInvalid = ErrorCode._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceNameInvalid'); + static const ErrorCode WorkspaceIdInvalid = ErrorCode._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceIdInvalid'); + static const ErrorCode AppColorStyleInvalid = ErrorCode._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppColorStyleInvalid'); + static const ErrorCode WorkspaceDescTooLong = ErrorCode._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceDescTooLong'); + static const ErrorCode WorkspaceNameTooLong = ErrorCode._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceNameTooLong'); + static const ErrorCode AppIdInvalid = ErrorCode._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppIdInvalid'); + static const ErrorCode AppNameInvalid = ErrorCode._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppNameInvalid'); + static const ErrorCode ViewNameInvalid = ErrorCode._(20, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewNameInvalid'); + static const ErrorCode ViewThumbnailInvalid = ErrorCode._(21, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewThumbnailInvalid'); + static const ErrorCode ViewIdInvalid = ErrorCode._(22, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewIdInvalid'); + static const ErrorCode ViewDescTooLong = ErrorCode._(23, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewDescTooLong'); + static const ErrorCode ViewDataInvalid = ErrorCode._(24, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewDataInvalid'); + static const ErrorCode ViewNameTooLong = ErrorCode._(25, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewNameTooLong'); + static const ErrorCode UserUnauthorized = ErrorCode._(100, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserUnauthorized'); + static const ErrorCode WsConnectError = ErrorCode._(200, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WsConnectError'); + static const ErrorCode InternalError = ErrorCode._(1000, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'InternalError'); + static const ErrorCode RecordNotFound = ErrorCode._(1001, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'RecordNotFound'); + + static const $core.List values = [ + WorkspaceNameInvalid, + WorkspaceIdInvalid, + AppColorStyleInvalid, + WorkspaceDescTooLong, + WorkspaceNameTooLong, + AppIdInvalid, + AppNameInvalid, + ViewNameInvalid, + ViewThumbnailInvalid, + ViewIdInvalid, + ViewDescTooLong, + ViewDataInvalid, + ViewNameTooLong, + UserUnauthorized, + WsConnectError, + InternalError, + RecordNotFound, + ]; + + static final $core.Map<$core.int, ErrorCode> _byValue = $pb.ProtobufEnum.initByValue(values); + static ErrorCode? valueOf($core.int value) => _byValue[value]; + + const ErrorCode._($core.int v, $core.String n) : super(v, n); +} + diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/errors.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/errors.pbjson.dart new file mode 100644 index 0000000000..a829c0ed5d --- /dev/null +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/errors.pbjson.dart @@ -0,0 +1,36 @@ +/// +// Generated code. Do not modify. +// source: errors.proto +// +// @dart = 2.12 +// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package + +import 'dart:core' as $core; +import 'dart:convert' as $convert; +import 'dart:typed_data' as $typed_data; +@$core.Deprecated('Use errorCodeDescriptor instead') +const ErrorCode$json = const { + '1': 'ErrorCode', + '2': const [ + const {'1': 'WorkspaceNameInvalid', '2': 0}, + const {'1': 'WorkspaceIdInvalid', '2': 1}, + const {'1': 'AppColorStyleInvalid', '2': 2}, + const {'1': 'WorkspaceDescTooLong', '2': 3}, + const {'1': 'WorkspaceNameTooLong', '2': 4}, + const {'1': 'AppIdInvalid', '2': 10}, + const {'1': 'AppNameInvalid', '2': 11}, + const {'1': 'ViewNameInvalid', '2': 20}, + const {'1': 'ViewThumbnailInvalid', '2': 21}, + const {'1': 'ViewIdInvalid', '2': 22}, + const {'1': 'ViewDescTooLong', '2': 23}, + const {'1': 'ViewDataInvalid', '2': 24}, + const {'1': 'ViewNameTooLong', '2': 25}, + const {'1': 'UserUnauthorized', '2': 100}, + const {'1': 'WsConnectError', '2': 200}, + const {'1': 'InternalError', '2': 1000}, + const {'1': 'RecordNotFound', '2': 1001}, + ], +}; + +/// Descriptor for `ErrorCode`. Decode as a `google.protobuf.EnumDescriptorProto`. +final $typed_data.Uint8List errorCodeDescriptor = $convert.base64Decode('CglFcnJvckNvZGUSGAoUV29ya3NwYWNlTmFtZUludmFsaWQQABIWChJXb3Jrc3BhY2VJZEludmFsaWQQARIYChRBcHBDb2xvclN0eWxlSW52YWxpZBACEhgKFFdvcmtzcGFjZURlc2NUb29Mb25nEAMSGAoUV29ya3NwYWNlTmFtZVRvb0xvbmcQBBIQCgxBcHBJZEludmFsaWQQChISCg5BcHBOYW1lSW52YWxpZBALEhMKD1ZpZXdOYW1lSW52YWxpZBAUEhgKFFZpZXdUaHVtYm5haWxJbnZhbGlkEBUSEQoNVmlld0lkSW52YWxpZBAWEhMKD1ZpZXdEZXNjVG9vTG9uZxAXEhMKD1ZpZXdEYXRhSW52YWxpZBAYEhMKD1ZpZXdOYW1lVG9vTG9uZxAZEhQKEFVzZXJVbmF1dGhvcml6ZWQQZBITCg5Xc0Nvbm5lY3RFcnJvchDIARISCg1JbnRlcm5hbEVycm9yEOgHEhMKDlJlY29yZE5vdEZvdW5kEOkH'); diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_delete.pbserver.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/errors.pbserver.dart similarity index 84% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_delete.pbserver.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/errors.pbserver.dart index a3cb95002d..18b02b9216 100644 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_delete.pbserver.dart +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/errors.pbserver.dart @@ -1,9 +1,9 @@ /// // Generated code. Do not modify. -// source: app_delete.proto +// source: errors.proto // // @dart = 2.12 // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package -export 'app_delete.pb.dart'; +export 'errors.pb.dart'; diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/protobuf.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/protobuf.dart new file mode 100644 index 0000000000..ebc98f6ab4 --- /dev/null +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/protobuf.dart @@ -0,0 +1,14 @@ +// Auto-generated, do not edit +export './view_update.pb.dart'; +export './app_query.pb.dart'; +export './workspace_delete.pb.dart'; +export './errors.pb.dart'; +export './workspace_update.pb.dart'; +export './app_create.pb.dart'; +export './workspace_query.pb.dart'; +export './view_create.pb.dart'; +export './workspace_user_detail.pb.dart'; +export './workspace_create.pb.dart'; +export './app_update.pb.dart'; +export './view_query.pb.dart'; +export './trash_create.pb.dart'; diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/trash_create.pb.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/trash_create.pb.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/trash_create.pb.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/trash_create.pb.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/trash_create.pbenum.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/trash_create.pbenum.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/trash_create.pbenum.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/trash_create.pbenum.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/trash_create.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/trash_create.pbjson.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/trash_create.pbjson.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/trash_create.pbjson.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/trash_create.pbserver.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/trash_create.pbserver.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/trash_create.pbserver.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/trash_create.pbserver.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_create.pb.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_create.pb.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_create.pb.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_create.pb.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_create.pbenum.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_create.pbenum.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_create.pbenum.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_create.pbenum.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_create.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_create.pbjson.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_create.pbjson.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_create.pbjson.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_create.pbserver.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_create.pbserver.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_create.pbserver.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_create.pbserver.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_query.pb.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_query.pb.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_query.pb.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_query.pb.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_query.pbenum.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_query.pbenum.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_query.pbenum.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_query.pbenum.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_query.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_query.pbjson.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_query.pbjson.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_query.pbjson.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_query.pbserver.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_query.pbserver.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_query.pbserver.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_query.pbserver.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_update.pb.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_update.pb.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_update.pb.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_update.pb.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_update.pbenum.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_update.pbenum.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_update.pbenum.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_update.pbenum.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_update.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_update.pbjson.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_update.pbjson.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_update.pbjson.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_update.pbserver.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_update.pbserver.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/view_update.pbserver.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/view_update.pbserver.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_create.pb.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_create.pb.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_create.pb.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_create.pb.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_create.pbenum.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_create.pbenum.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_create.pbenum.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_create.pbenum.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_create.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_create.pbjson.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_create.pbjson.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_create.pbjson.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_create.pbserver.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_create.pbserver.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_create.pbserver.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_create.pbserver.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_delete.pb.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_delete.pb.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_delete.pb.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_delete.pb.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_delete.pbenum.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_delete.pbenum.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_delete.pbenum.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_delete.pbenum.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_delete.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_delete.pbjson.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_delete.pbjson.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_delete.pbjson.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_delete.pbserver.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_delete.pbserver.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_delete.pbserver.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_delete.pbserver.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_query.pb.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_query.pb.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_query.pb.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_query.pb.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_query.pbenum.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_query.pbenum.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_query.pbenum.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_query.pbenum.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_query.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_query.pbjson.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_query.pbjson.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_query.pbjson.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_query.pbserver.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_query.pbserver.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_query.pbserver.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_query.pbserver.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_update.pb.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_update.pb.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_update.pb.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_update.pb.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_update.pbenum.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_update.pbenum.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_update.pbenum.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_update.pbenum.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_update.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_update.pbjson.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_update.pbjson.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_update.pbjson.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_update.pbserver.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_update.pbserver.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_update.pbserver.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_update.pbserver.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_user_detail.pb.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_user_detail.pb.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_user_detail.pb.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_user_detail.pb.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_user_detail.pbenum.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_user_detail.pbenum.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_user_detail.pbenum.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_user_detail.pbenum.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_user_detail.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_user_detail.pbjson.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_user_detail.pbjson.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_user_detail.pbjson.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_user_detail.pbserver.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_user_detail.pbserver.dart similarity index 100% rename from app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/workspace_user_detail.pbserver.dart rename to app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace-infra/workspace_user_detail.pbserver.dart diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_delete.pb.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_delete.pb.dart deleted file mode 100644 index 068a080428..0000000000 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_delete.pb.dart +++ /dev/null @@ -1,105 +0,0 @@ -/// -// Generated code. Do not modify. -// source: app_delete.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields - -import 'dart:core' as $core; - -import 'package:protobuf/protobuf.dart' as $pb; - -class DeleteAppRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'DeleteAppRequest', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'appId') - ..hasRequiredFields = false - ; - - DeleteAppRequest._() : super(); - factory DeleteAppRequest({ - $core.String? appId, - }) { - final _result = create(); - if (appId != null) { - _result.appId = appId; - } - return _result; - } - factory DeleteAppRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory DeleteAppRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - DeleteAppRequest clone() => DeleteAppRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - DeleteAppRequest copyWith(void Function(DeleteAppRequest) updates) => super.copyWith((message) => updates(message as DeleteAppRequest)) as DeleteAppRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static DeleteAppRequest create() => DeleteAppRequest._(); - DeleteAppRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static DeleteAppRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static DeleteAppRequest? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get appId => $_getSZ(0); - @$pb.TagNumber(1) - set appId($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasAppId() => $_has(0); - @$pb.TagNumber(1) - void clearAppId() => clearField(1); -} - -class DeleteAppParams extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'DeleteAppParams', createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'appId') - ..hasRequiredFields = false - ; - - DeleteAppParams._() : super(); - factory DeleteAppParams({ - $core.String? appId, - }) { - final _result = create(); - if (appId != null) { - _result.appId = appId; - } - return _result; - } - factory DeleteAppParams.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory DeleteAppParams.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - DeleteAppParams clone() => DeleteAppParams()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - DeleteAppParams copyWith(void Function(DeleteAppParams) updates) => super.copyWith((message) => updates(message as DeleteAppParams)) as DeleteAppParams; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static DeleteAppParams create() => DeleteAppParams._(); - DeleteAppParams createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static DeleteAppParams getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static DeleteAppParams? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get appId => $_getSZ(0); - @$pb.TagNumber(1) - set appId($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasAppId() => $_has(0); - @$pb.TagNumber(1) - void clearAppId() => clearField(1); -} - diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_delete.pbjson.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_delete.pbjson.dart deleted file mode 100644 index d179a7e294..0000000000 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/app_delete.pbjson.dart +++ /dev/null @@ -1,30 +0,0 @@ -/// -// Generated code. Do not modify. -// source: app_delete.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package - -import 'dart:core' as $core; -import 'dart:convert' as $convert; -import 'dart:typed_data' as $typed_data; -@$core.Deprecated('Use deleteAppRequestDescriptor instead') -const DeleteAppRequest$json = const { - '1': 'DeleteAppRequest', - '2': const [ - const {'1': 'app_id', '3': 1, '4': 1, '5': 9, '10': 'appId'}, - ], -}; - -/// Descriptor for `DeleteAppRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List deleteAppRequestDescriptor = $convert.base64Decode('ChBEZWxldGVBcHBSZXF1ZXN0EhUKBmFwcF9pZBgBIAEoCVIFYXBwSWQ='); -@$core.Deprecated('Use deleteAppParamsDescriptor instead') -const DeleteAppParams$json = const { - '1': 'DeleteAppParams', - '2': const [ - const {'1': 'app_id', '3': 1, '4': 1, '5': 9, '10': 'appId'}, - ], -}; - -/// Descriptor for `DeleteAppParams`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List deleteAppParamsDescriptor = $convert.base64Decode('Cg9EZWxldGVBcHBQYXJhbXMSFQoGYXBwX2lkGAEgASgJUgVhcHBJZA=='); 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 bf2eec2561..b03dd960be 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 @@ -9,20 +9,16 @@ import 'dart:core' as $core; import 'package:protobuf/protobuf.dart' as $pb; -import 'errors.pbenum.dart'; - -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: ErrorCode.WorkspaceNameInvalid, valueOf: ErrorCode.valueOf, enumValues: ErrorCode.values) + ..a<$core.int>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'code', $pb.PbFieldType.O3) ..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'msg') ..hasRequiredFields = false ; WorkspaceError._() : super(); factory WorkspaceError({ - ErrorCode? code, + $core.int? code, $core.String? msg, }) { final _result = create(); @@ -56,9 +52,9 @@ class WorkspaceError extends $pb.GeneratedMessage { static WorkspaceError? _defaultInstance; @$pb.TagNumber(1) - ErrorCode get code => $_getN(0); + $core.int get code => $_getIZ(0); @$pb.TagNumber(1) - set code(ErrorCode v) { setField(1, v); } + set code($core.int v) { $_setSignedInt32(0, 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 2728c16cfe..2bb3f5b53b 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 @@ -5,48 +5,3 @@ // @dart = 2.12 // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields -// ignore_for_file: UNDEFINED_SHOWN_NAME -import 'dart:core' as $core; -import 'package:protobuf/protobuf.dart' as $pb; - -class ErrorCode extends $pb.ProtobufEnum { - static const ErrorCode WorkspaceNameInvalid = ErrorCode._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceNameInvalid'); - static const ErrorCode WorkspaceIdInvalid = ErrorCode._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceIdInvalid'); - static const ErrorCode AppColorStyleInvalid = ErrorCode._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppColorStyleInvalid'); - static const ErrorCode WorkspaceDescInvalid = ErrorCode._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceDescInvalid'); - static const ErrorCode AppIdInvalid = ErrorCode._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppIdInvalid'); - static const ErrorCode AppNameInvalid = ErrorCode._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppNameInvalid'); - static const ErrorCode ViewNameInvalid = ErrorCode._(20, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewNameInvalid'); - static const ErrorCode ViewThumbnailInvalid = ErrorCode._(21, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewThumbnailInvalid'); - static const ErrorCode ViewIdInvalid = ErrorCode._(22, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewIdInvalid'); - static const ErrorCode ViewDescInvalid = ErrorCode._(23, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewDescInvalid'); - static const ErrorCode ViewDataInvalid = ErrorCode._(24, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ViewDataInvalid'); - static const ErrorCode UserUnauthorized = ErrorCode._(100, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserUnauthorized'); - static const ErrorCode WsConnectError = ErrorCode._(200, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WsConnectError'); - static const ErrorCode InternalError = ErrorCode._(1000, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'InternalError'); - static const ErrorCode RecordNotFound = ErrorCode._(1001, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'RecordNotFound'); - - static const $core.List values = [ - WorkspaceNameInvalid, - WorkspaceIdInvalid, - AppColorStyleInvalid, - WorkspaceDescInvalid, - AppIdInvalid, - AppNameInvalid, - ViewNameInvalid, - ViewThumbnailInvalid, - ViewIdInvalid, - ViewDescInvalid, - ViewDataInvalid, - UserUnauthorized, - WsConnectError, - InternalError, - RecordNotFound, - ]; - - static final $core.Map<$core.int, ErrorCode> _byValue = $pb.ProtobufEnum.initByValue(values); - static ErrorCode? valueOf($core.int value) => _byValue[value]; - - const ErrorCode._($core.int v, $core.String n) : super(v, n); -} - 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 5a13aa5857..dd6a45e8d9 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,38 +8,14 @@ import 'dart:core' as $core; import 'dart:convert' as $convert; import 'dart:typed_data' as $typed_data; -@$core.Deprecated('Use errorCodeDescriptor instead') -const ErrorCode$json = const { - '1': 'ErrorCode', - '2': const [ - const {'1': 'WorkspaceNameInvalid', '2': 0}, - const {'1': 'WorkspaceIdInvalid', '2': 1}, - const {'1': 'AppColorStyleInvalid', '2': 2}, - const {'1': 'WorkspaceDescInvalid', '2': 3}, - const {'1': 'AppIdInvalid', '2': 10}, - const {'1': 'AppNameInvalid', '2': 11}, - const {'1': 'ViewNameInvalid', '2': 20}, - const {'1': 'ViewThumbnailInvalid', '2': 21}, - const {'1': 'ViewIdInvalid', '2': 22}, - const {'1': 'ViewDescInvalid', '2': 23}, - const {'1': 'ViewDataInvalid', '2': 24}, - const {'1': 'UserUnauthorized', '2': 100}, - const {'1': 'WsConnectError', '2': 200}, - const {'1': 'InternalError', '2': 1000}, - const {'1': 'RecordNotFound', '2': 1001}, - ], -}; - -/// Descriptor for `ErrorCode`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List errorCodeDescriptor = $convert.base64Decode('CglFcnJvckNvZGUSGAoUV29ya3NwYWNlTmFtZUludmFsaWQQABIWChJXb3Jrc3BhY2VJZEludmFsaWQQARIYChRBcHBDb2xvclN0eWxlSW52YWxpZBACEhgKFFdvcmtzcGFjZURlc2NJbnZhbGlkEAMSEAoMQXBwSWRJbnZhbGlkEAoSEgoOQXBwTmFtZUludmFsaWQQCxITCg9WaWV3TmFtZUludmFsaWQQFBIYChRWaWV3VGh1bWJuYWlsSW52YWxpZBAVEhEKDVZpZXdJZEludmFsaWQQFhITCg9WaWV3RGVzY0ludmFsaWQQFxITCg9WaWV3RGF0YUludmFsaWQQGBIUChBVc2VyVW5hdXRob3JpemVkEGQSEwoOV3NDb25uZWN0RXJyb3IQyAESEgoNSW50ZXJuYWxFcnJvchDoBxITCg5SZWNvcmROb3RGb3VuZBDpBw=='); @$core.Deprecated('Use workspaceErrorDescriptor instead') const WorkspaceError$json = const { '1': 'WorkspaceError', '2': const [ - const {'1': 'code', '3': 1, '4': 1, '5': 14, '6': '.ErrorCode', '10': 'code'}, + const {'1': 'code', '3': 1, '4': 1, '5': 5, '10': 'code'}, const {'1': 'msg', '3': 2, '4': 1, '5': 9, '10': 'msg'}, ], }; /// Descriptor for `WorkspaceError`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List workspaceErrorDescriptor = $convert.base64Decode('Cg5Xb3Jrc3BhY2VFcnJvchIeCgRjb2RlGAEgASgOMgouRXJyb3JDb2RlUgRjb2RlEhAKA21zZxgCIAEoCVIDbXNn'); +final $typed_data.Uint8List workspaceErrorDescriptor = $convert.base64Decode('Cg5Xb3Jrc3BhY2VFcnJvchISCgRjb2RlGAEgASgFUgRjb2RlEhAKA21zZxgCIAEoCVIDbXNn'); diff --git a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/protobuf.dart b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/protobuf.dart index 0b0f2f3454..bb4f1f6e45 100644 --- a/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/protobuf.dart +++ b/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-workspace/protobuf.dart @@ -1,17 +1,4 @@ // Auto-generated, do not edit -export './view_update.pb.dart'; -export './app_query.pb.dart'; -export './workspace_delete.pb.dart'; export './observable.pb.dart'; export './errors.pb.dart'; -export './workspace_update.pb.dart'; -export './app_create.pb.dart'; -export './workspace_query.pb.dart'; export './event.pb.dart'; -export './view_create.pb.dart'; -export './workspace_user_detail.pb.dart'; -export './workspace_create.pb.dart'; -export './app_update.pb.dart'; -export './view_query.pb.dart'; -export './trash_create.pb.dart'; -export './app_delete.pb.dart'; diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 14cdaeab45..4ea4c08ded 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -61,7 +61,7 @@ byteorder = {version = "1.3.4"} async-stream = "0.3.2" flowy-user-infra = { path = "../rust-lib/flowy-user-infra" } -flowy-workspace = { path = "../rust-lib/flowy-workspace", default-features = false, features = ["backend_service"]} +flowy-workspace-infra = { path = "../rust-lib/flowy-workspace-infra"} flowy-document = { path = "../rust-lib/flowy-document" } flowy-ws = { path = "../rust-lib/flowy-ws" } flowy-ot = { path = "../rust-lib/flowy-ot" } diff --git a/backend/src/application.rs b/backend/src/application.rs index 217f5ee629..2268b33e1e 100644 --- a/backend/src/application.rs +++ b/backend/src/application.rs @@ -104,7 +104,6 @@ fn user_scope() -> Scope { ) .service(web::resource("/app") .route(web::post().to(app::create_handler)) - .route(web::delete().to(app::delete_handler)) .route(web::get().to(app::read_handler)) .route(web::patch().to(app::update_handler)) ) diff --git a/backend/src/entities/workspace.rs b/backend/src/entities/workspace.rs index 1017e1a7a7..6948d20758 100644 --- a/backend/src/entities/workspace.rs +++ b/backend/src/entities/workspace.rs @@ -1,5 +1,5 @@ use chrono::Utc; -use flowy_workspace::backend_service::{App, RepeatedView, Trash, TrashType, View, ViewType}; +use flowy_workspace_infra::protobuf::{App, RepeatedView, Trash, TrashType, View, ViewType}; use protobuf::ProtobufEnum; pub(crate) const WORKSPACE_TABLE: &'static str = "workspace_table"; diff --git a/backend/src/service/app/app.rs b/backend/src/service/app/app.rs index 4d03369711..81b1813f11 100644 --- a/backend/src/service/app/app.rs +++ b/backend/src/service/app/app.rs @@ -7,10 +7,10 @@ use crate::{ use crate::service::trash::read_trash_ids; use chrono::Utc; use flowy_net::errors::{invalid_params, ServerError}; -use flowy_workspace::{ - entities::{ - app::parser::{AppDesc, AppName}, - workspace::parser::WorkspaceId, +use flowy_workspace_infra::{ + parser::{ + app::{AppDesc, AppName}, + workspace::WorkspaceId, }, protobuf::{App, CreateAppParams, RepeatedView}, }; diff --git a/backend/src/service/app/router.rs b/backend/src/service/app/router.rs index 583d4bf3a2..c27d1841c1 100644 --- a/backend/src/service/app/router.rs +++ b/backend/src/service/app/router.rs @@ -3,13 +3,13 @@ use actix_web::{ HttpResponse, }; use flowy_net::errors::{invalid_params, ServerError}; -use flowy_workspace::backend_service::{AppIdentifier, CreateAppParams, DeleteAppParams, UpdateAppParams}; +use flowy_workspace_infra::protobuf::{AppIdentifier, CreateAppParams, UpdateAppParams}; use protobuf::Message; use sqlx::PgPool; use crate::service::{ app::{ - app::{create_app, delete_app, read_app, update_app}, + app::{create_app, read_app, update_app}, sql_builder::check_app_id, }, user::LoggedUser, @@ -17,7 +17,7 @@ use crate::service::{ }; use anyhow::Context; use flowy_net::response::FlowyResponse; -use flowy_workspace::entities::app::parser::{AppDesc, AppName}; +use flowy_workspace_infra::parser::app::{AppDesc, AppName}; pub async fn create_handler( payload: Payload, @@ -92,20 +92,20 @@ pub async fn update_handler(payload: Payload, pool: Data) -> Result) -> Result { - let params: DeleteAppParams = parse_from_payload(payload).await?; - let app_id = check_app_id(params.app_id.to_owned())?; - let mut transaction = pool - .begin() - .await - .context("Failed to acquire a Postgres connection to delete app")?; - - let _ = delete_app(&mut transaction, app_id).await?; - - transaction - .commit() - .await - .context("Failed to commit SQL transaction to delete app.")?; - - Ok(FlowyResponse::success().into()) -} +// pub async fn delete_handler(payload: Payload, pool: Data) -> +// Result { let params: DeleteAppParams = +// parse_from_payload(payload).await?; let app_id = +// check_app_id(params.app_id.to_owned())?; let mut transaction = pool +// .begin() +// .await +// .context("Failed to acquire a Postgres connection to delete app")?; +// +// let _ = delete_app(&mut transaction, app_id).await?; +// +// transaction +// .commit() +// .await +// .context("Failed to commit SQL transaction to delete app.")?; +// +// Ok(FlowyResponse::success().into()) +// } diff --git a/backend/src/service/app/sql_builder.rs b/backend/src/service/app/sql_builder.rs index 67993633f8..0b69057c99 100644 --- a/backend/src/service/app/sql_builder.rs +++ b/backend/src/service/app/sql_builder.rs @@ -4,8 +4,8 @@ use crate::{ }; use chrono::Utc; use flowy_net::errors::{invalid_params, ServerError}; -use flowy_workspace::{ - entities::app::parser::AppId, +use flowy_workspace_infra::{ + parser::app::AppId, protobuf::{App, ColorStyle}, }; use protobuf::Message; @@ -54,9 +54,7 @@ impl NewAppSqlBuilder { } pub fn color_style(mut self, color_style: ColorStyle) -> Self { - self.table.color_style = color_style - .write_to_bytes() - .unwrap_or(default_color_style()); + self.table.color_style = color_style.write_to_bytes().unwrap_or(default_color_style()); self } diff --git a/backend/src/service/trash/router.rs b/backend/src/service/trash/router.rs index 36e4f3fc56..fad8e053ba 100644 --- a/backend/src/service/trash/router.rs +++ b/backend/src/service/trash/router.rs @@ -13,7 +13,7 @@ use flowy_net::{ errors::{invalid_params, ServerError}, response::FlowyResponse, }; -use flowy_workspace::{entities::trash::parser::TrashId, protobuf::TrashIdentifiers}; +use flowy_workspace_infra::{parser::trash::TrashId, protobuf::TrashIdentifiers}; use sqlx::PgPool; use uuid::Uuid; diff --git a/backend/src/service/trash/trash.rs b/backend/src/service/trash/trash.rs index ba354f397a..165099262b 100644 --- a/backend/src/service/trash/trash.rs +++ b/backend/src/service/trash/trash.rs @@ -9,7 +9,7 @@ use crate::{ }; use ::protobuf::ProtobufEnum; use flowy_net::errors::ServerError; -use flowy_workspace::backend_service::{RepeatedTrash, Trash, TrashType}; +use flowy_workspace_infra::protobuf::{RepeatedTrash, Trash, TrashType}; use sqlx::{postgres::PgArguments, Postgres, Row}; use uuid::Uuid; diff --git a/backend/src/service/user/user_default.rs b/backend/src/service/user/user_default.rs index 742a6103a9..21c87e33af 100644 --- a/backend/src/service/user/user_default.rs +++ b/backend/src/service/user/user_default.rs @@ -9,7 +9,7 @@ use crate::{ use flowy_document::services::doc::doc_initial_string; use flowy_net::errors::ServerError; -use flowy_workspace::backend_service::{App, CreateViewParams, View, ViewType, Workspace}; +use flowy_workspace_infra::protobuf::{App, CreateViewParams, View, ViewType, Workspace}; pub async fn create_default_workspace( transaction: &mut DBTransaction<'_>, diff --git a/backend/src/service/view/router.rs b/backend/src/service/view/router.rs index aedefb7c8f..7d3d856dce 100644 --- a/backend/src/service/view/router.rs +++ b/backend/src/service/view/router.rs @@ -13,8 +13,8 @@ use flowy_net::{ errors::{invalid_params, ServerError}, response::FlowyResponse, }; -use flowy_workspace::{ - entities::view::parser::{ViewDesc, ViewName, ViewThumbnail}, +use flowy_workspace_infra::{ + parser::view::{ViewDesc, ViewName, ViewThumbnail}, protobuf::{CreateViewParams, QueryViewRequest, UpdateViewParams, ViewIdentifier}, }; use sqlx::PgPool; diff --git a/backend/src/service/view/sql_builder.rs b/backend/src/service/view/sql_builder.rs index e750206ec9..6c6d963e9a 100644 --- a/backend/src/service/view/sql_builder.rs +++ b/backend/src/service/view/sql_builder.rs @@ -4,8 +4,8 @@ use crate::{ }; use chrono::Utc; use flowy_net::errors::{invalid_params, ServerError}; -use flowy_workspace::{ - entities::view::parser::ViewId, +use flowy_workspace_infra::{ + parser::view::ViewId, protobuf::{View, ViewType}, }; use protobuf::ProtobufEnum; diff --git a/backend/src/service/view/view.rs b/backend/src/service/view/view.rs index f7a563086f..16ea717a2d 100644 --- a/backend/src/service/view/view.rs +++ b/backend/src/service/view/view.rs @@ -11,10 +11,10 @@ use crate::{ use chrono::Utc; use flowy_document::protobuf::CreateDocParams; use flowy_net::errors::{invalid_params, ServerError}; -use flowy_workspace::{ - entities::{ - app::parser::AppId, - view::parser::{ViewDesc, ViewName, ViewThumbnail}, +use flowy_workspace_infra::{ + parser::{ + app::AppId, + view::{ViewDesc, ViewName, ViewThumbnail}, }, protobuf::{CreateViewParams, RepeatedView, View}, }; diff --git a/backend/src/service/workspace/router.rs b/backend/src/service/workspace/router.rs index 5e77f2873d..5870be1895 100644 --- a/backend/src/service/workspace/router.rs +++ b/backend/src/service/workspace/router.rs @@ -18,8 +18,8 @@ use flowy_net::{ errors::{invalid_params, ServerError}, response::FlowyResponse, }; -use flowy_workspace::{ - entities::workspace::parser::{WorkspaceDesc, WorkspaceName}, +use flowy_workspace_infra::{ + parser::workspace::{WorkspaceDesc, WorkspaceName}, protobuf::{CreateWorkspaceParams, DeleteWorkspaceParams, QueryWorkspaceParams, UpdateWorkspaceParams}, }; use sqlx::PgPool; diff --git a/backend/src/service/workspace/sql_builder.rs b/backend/src/service/workspace/sql_builder.rs index dd2ce2dca9..e373a069bc 100644 --- a/backend/src/service/workspace/sql_builder.rs +++ b/backend/src/service/workspace/sql_builder.rs @@ -4,8 +4,8 @@ use crate::{ }; use chrono::Utc; use flowy_net::errors::{invalid_params, ServerError}; -use flowy_workspace::{ - entities::workspace::parser::WorkspaceId, +use flowy_workspace_infra::{ + parser::workspace::WorkspaceId, protobuf::{RepeatedApp, Workspace}, }; use sqlx::postgres::PgArguments; @@ -58,10 +58,7 @@ impl NewWorkspaceBuilder { } } -pub(crate) fn make_workspace_from_table( - table: WorkspaceTable, - apps: Option, -) -> Workspace { +pub(crate) fn make_workspace_from_table(table: WorkspaceTable, apps: Option) -> Workspace { let mut workspace = Workspace { id: table.id.to_string(), name: table.name, diff --git a/backend/src/service/workspace/workspace.rs b/backend/src/service/workspace/workspace.rs index d34dc05328..6d65ac30f8 100644 --- a/backend/src/service/workspace/workspace.rs +++ b/backend/src/service/workspace/workspace.rs @@ -6,8 +6,8 @@ use crate::{ }; use anyhow::Context; use flowy_net::errors::{invalid_params, ServerError}; -use flowy_workspace::{ - entities::workspace::parser::WorkspaceId, +use flowy_workspace_infra::{ + parser::workspace::WorkspaceId, protobuf::{RepeatedApp, RepeatedWorkspace, Workspace}, }; use sqlx::{postgres::PgArguments, Postgres}; diff --git a/rust-lib/Cargo.toml b/rust-lib/Cargo.toml index 32f78fb6fe..0f70fea6ff 100644 --- a/rust-lib/Cargo.toml +++ b/rust-lib/Cargo.toml @@ -13,6 +13,7 @@ members = [ "flowy-database", "flowy-infra", "flowy-workspace", + "flowy-workspace-infra", "flowy-dart-notify", "flowy-document", "flowy-ot", 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 691283a5ab..bbc72723ec 100644 --- a/rust-lib/flowy-derive/src/derive_cache/derive_cache.rs +++ b/rust-lib/flowy-derive/src/derive_cache/derive_cache.rs @@ -15,8 +15,7 @@ pub fn category_from_str(type_str: &str) -> TypeCategory { "HashMap" => TypeCategory::Map, "u8" => TypeCategory::Bytes, "String" => TypeCategory::Str, - "KeyValue" - | "QueryAppRequest" + "QueryAppRequest" | "AppIdentifier" | "CreateAppRequest" | "ColorStyle" @@ -49,6 +48,7 @@ pub fn category_from_str(type_str: &str) -> TypeCategory { | "CreateViewParams" | "View" | "RepeatedView" + | "KeyValue" | "WorkspaceError" | "WsError" | "WsMessage" @@ -80,8 +80,8 @@ pub fn category_from_str(type_str: &str) -> TypeCategory { => TypeCategory::Protobuf, "TrashType" | "ViewType" - | "WorkspaceEvent" | "ErrorCode" + | "WorkspaceEvent" | "WorkspaceNotification" | "WsModule" | "RevType" diff --git a/rust-lib/flowy-workspace-infra/Cargo.toml b/rust-lib/flowy-workspace-infra/Cargo.toml new file mode 100644 index 0000000000..9d98f73d08 --- /dev/null +++ b/rust-lib/flowy-workspace-infra/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "flowy-workspace-infra" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +flowy-derive = { path = "../flowy-derive" } +protobuf = {version = "2.18.0"} +bytes = "1.0" +unicode-segmentation = "1.7.1" +strum = "0.21" +strum_macros = "0.21" +derive_more = {version = "0.99", features = ["display"]} +log = "0.4.14" +flowy-document = { path = "../flowy-document" } \ No newline at end of file diff --git a/rust-lib/flowy-workspace-infra/Flowy.toml b/rust-lib/flowy-workspace-infra/Flowy.toml new file mode 100644 index 0000000000..d1411c4d2b --- /dev/null +++ b/rust-lib/flowy-workspace-infra/Flowy.toml @@ -0,0 +1,3 @@ + +proto_crates = ["src/entities", "src/errors.rs"] +event_files = [] \ No newline at end of file diff --git a/rust-lib/flowy-workspace/src/entities/app/app_create.rs b/rust-lib/flowy-workspace-infra/src/entities/app/app_create.rs similarity index 80% rename from rust-lib/flowy-workspace/src/entities/app/app_create.rs rename to rust-lib/flowy-workspace-infra/src/entities/app/app_create.rs index 4f4abb9488..66bac99a2d 100644 --- a/rust-lib/flowy-workspace/src/entities/app/app_create.rs +++ b/rust-lib/flowy-workspace-infra/src/entities/app/app_create.rs @@ -1,13 +1,12 @@ use crate::{ - entities::{ - app::parser::{AppColorStyle, AppName}, - view::RepeatedView, - workspace::parser::WorkspaceId, - }, + entities::view::RepeatedView, errors::*, impl_def_and_def_mut, + parser::{ + app::{AppColorStyle, AppName}, + workspace::WorkspaceId, + }, }; - use flowy_derive::ProtoBuf; use std::convert::TryInto; @@ -48,15 +47,12 @@ pub struct CreateAppParams { } impl TryInto for CreateAppRequest { - type Error = WorkspaceError; + type Error = ErrorCode; fn try_into(self) -> Result { - let name = AppName::parse(self.name).map_err(|e| WorkspaceError::app_name().context(e))?; - - let id = WorkspaceId::parse(self.workspace_id).map_err(|e| WorkspaceError::workspace_id().context(e))?; - - let color_style = AppColorStyle::parse(self.color_style.theme_color.clone()) - .map_err(|e| WorkspaceError::color_style().context(e))?; + let name = AppName::parse(self.name)?; + let id = WorkspaceId::parse(self.workspace_id)?; + let color_style = AppColorStyle::parse(self.color_style.theme_color.clone())?; Ok(CreateAppParams { workspace_id: id.0, diff --git a/rust-lib/flowy-workspace/src/entities/app/app_query.rs b/rust-lib/flowy-workspace-infra/src/entities/app/app_query.rs similarity index 69% rename from rust-lib/flowy-workspace/src/entities/app/app_query.rs rename to rust-lib/flowy-workspace-infra/src/entities/app/app_query.rs index 1079a2d086..042d6c338d 100644 --- a/rust-lib/flowy-workspace/src/entities/app/app_query.rs +++ b/rust-lib/flowy-workspace-infra/src/entities/app/app_query.rs @@ -1,4 +1,4 @@ -use crate::{entities::app::parser::AppId, errors::*}; +use crate::{errors::ErrorCode, parser::app::AppId}; use flowy_derive::ProtoBuf; use std::convert::TryInto; @@ -23,18 +23,17 @@ impl AppIdentifier { } impl TryInto for QueryAppRequest { - type Error = WorkspaceError; + type Error = ErrorCode; fn try_into(self) -> Result { debug_assert!(self.app_ids.len() == 1); if self.app_ids.len() != 1 { - return Err(WorkspaceError::invalid_view_id().context("The len of app_ids should be equal to 1")); + log::error!("The len of app_ids should be equal to 1"); + return Err(ErrorCode::AppIdInvalid); } let app_id = self.app_ids.first().unwrap().clone(); - let app_id = AppId::parse(app_id) - .map_err(|e| WorkspaceError::invalid_app_id().context(e))? - .0; + let app_id = AppId::parse(app_id)?.0; Ok(AppIdentifier { app_id }) } } diff --git a/rust-lib/flowy-workspace/src/entities/app/app_update.rs b/rust-lib/flowy-workspace-infra/src/entities/app/app_update.rs similarity index 71% rename from rust-lib/flowy-workspace/src/entities/app/app_update.rs rename to rust-lib/flowy-workspace-infra/src/entities/app/app_update.rs index 1f519a787f..32ba7a078a 100644 --- a/rust-lib/flowy-workspace/src/entities/app/app_update.rs +++ b/rust-lib/flowy-workspace-infra/src/entities/app/app_update.rs @@ -1,9 +1,7 @@ use crate::{ - entities::app::{ - parser::{AppColorStyle, AppId, AppName}, - ColorStyle, - }, - errors::WorkspaceError, + entities::app::ColorStyle, + errors::ErrorCode, + parser::app::{AppColorStyle, AppId, AppName}, }; use flowy_derive::ProtoBuf; use std::convert::TryInto; @@ -69,29 +67,19 @@ impl UpdateAppParams { } impl TryInto for UpdateAppRequest { - type Error = WorkspaceError; + type Error = ErrorCode; fn try_into(self) -> Result { - let app_id = AppId::parse(self.app_id) - .map_err(|e| WorkspaceError::invalid_app_id().context(e))? - .0; + let app_id = AppId::parse(self.app_id)?.0; let name = match self.name { None => None, - Some(name) => Some( - AppName::parse(name) - .map_err(|e| WorkspaceError::workspace_name().context(e))? - .0, - ), + Some(name) => Some(AppName::parse(name)?.0), }; let color_style = match self.color_style { None => None, - Some(color_style) => Some( - AppColorStyle::parse(color_style.theme_color.clone()) - .map_err(|e| WorkspaceError::color_style().context(e))? - .into(), - ), + Some(color_style) => Some(AppColorStyle::parse(color_style.theme_color.clone())?.into()), }; Ok(UpdateAppParams { diff --git a/rust-lib/flowy-workspace-infra/src/entities/app/mod.rs b/rust-lib/flowy-workspace-infra/src/entities/app/mod.rs new file mode 100644 index 0000000000..9b57a2fc33 --- /dev/null +++ b/rust-lib/flowy-workspace-infra/src/entities/app/mod.rs @@ -0,0 +1,6 @@ +mod app_create; +mod app_query; +mod app_update; +pub use app_create::*; +pub use app_query::*; +pub use app_update::*; diff --git a/rust-lib/flowy-workspace-infra/src/entities/mod.rs b/rust-lib/flowy-workspace-infra/src/entities/mod.rs new file mode 100644 index 0000000000..3ee0f4b591 --- /dev/null +++ b/rust-lib/flowy-workspace-infra/src/entities/mod.rs @@ -0,0 +1,4 @@ +pub mod app; +pub mod trash; +pub mod view; +pub mod workspace; diff --git a/rust-lib/flowy-workspace-infra/src/entities/trash/mod.rs b/rust-lib/flowy-workspace-infra/src/entities/trash/mod.rs new file mode 100644 index 0000000000..bd524cd0a6 --- /dev/null +++ b/rust-lib/flowy-workspace-infra/src/entities/trash/mod.rs @@ -0,0 +1,2 @@ +mod trash_create; +pub use trash_create::*; diff --git a/rust-lib/flowy-workspace/src/entities/trash/trash_create.rs b/rust-lib/flowy-workspace-infra/src/entities/trash/trash_create.rs similarity index 100% rename from rust-lib/flowy-workspace/src/entities/trash/trash_create.rs rename to rust-lib/flowy-workspace-infra/src/entities/trash/trash_create.rs diff --git a/rust-lib/flowy-workspace-infra/src/entities/view/mod.rs b/rust-lib/flowy-workspace-infra/src/entities/view/mod.rs new file mode 100644 index 0000000000..059bc4fe3f --- /dev/null +++ b/rust-lib/flowy-workspace-infra/src/entities/view/mod.rs @@ -0,0 +1,7 @@ +pub use view_create::*; +pub use view_query::*; +pub use view_update::*; + +mod view_create; +mod view_query; +mod view_update; diff --git a/rust-lib/flowy-workspace/src/entities/view/view_create.rs b/rust-lib/flowy-workspace-infra/src/entities/view/view_create.rs similarity index 82% rename from rust-lib/flowy-workspace/src/entities/view/view_create.rs rename to rust-lib/flowy-workspace-infra/src/entities/view/view_create.rs index dfa6d6fec8..2e08d7b23e 100644 --- a/rust-lib/flowy-workspace/src/entities/view/view_create.rs +++ b/rust-lib/flowy-workspace-infra/src/entities/view/view_create.rs @@ -1,11 +1,11 @@ use crate::{ - entities::{ - app::parser::AppId, - trash::{Trash, TrashType}, - view::parser::*, - }, - errors::WorkspaceError, + entities::trash::{Trash, TrashType}, + errors::ErrorCode, impl_def_and_def_mut, + parser::{ + app::AppId, + view::{ViewName, ViewThumbnail}, + }, }; use flowy_derive::{ProtoBuf, ProtoBuf_Enum}; use flowy_document::services::doc::doc_initial_string; @@ -87,24 +87,15 @@ impl CreateViewParams { } impl TryInto for CreateViewRequest { - type Error = WorkspaceError; + type Error = ErrorCode; fn try_into(self) -> Result { - let name = ViewName::parse(self.name) - .map_err(|e| WorkspaceError::view_name().context(e))? - .0; - - let belong_to_id = AppId::parse(self.belong_to_id) - .map_err(|e| WorkspaceError::invalid_app_id().context(e))? - .0; + let name = ViewName::parse(self.name)?.0; + let belong_to_id = AppId::parse(self.belong_to_id)?.0; let thumbnail = match self.thumbnail { None => "".to_string(), - Some(thumbnail) => { - ViewThumbnail::parse(thumbnail) - .map_err(|e| WorkspaceError::view_thumbnail().context(e))? - .0 - }, + Some(thumbnail) => ViewThumbnail::parse(thumbnail)?.0, }; Ok(CreateViewParams::new( diff --git a/rust-lib/flowy-workspace/src/entities/view/view_query.rs b/rust-lib/flowy-workspace-infra/src/entities/view/view_query.rs similarity index 71% rename from rust-lib/flowy-workspace/src/entities/view/view_query.rs rename to rust-lib/flowy-workspace-infra/src/entities/view/view_query.rs index fa2ed82f75..cd686d53e5 100644 --- a/rust-lib/flowy-workspace/src/entities/view/view_query.rs +++ b/rust-lib/flowy-workspace-infra/src/entities/view/view_query.rs @@ -1,4 +1,4 @@ -use crate::{entities::view::parser::ViewId, errors::WorkspaceError}; +use crate::{errors::ErrorCode, parser::view::ViewId}; use flowy_derive::ProtoBuf; use flowy_document::entities::doc::DocIdentifier; use std::convert::TryInto; @@ -24,17 +24,16 @@ impl std::convert::Into for ViewIdentifier { } impl TryInto for QueryViewRequest { - type Error = WorkspaceError; + type Error = ErrorCode; fn try_into(self) -> Result { debug_assert!(self.view_ids.len() == 1); if self.view_ids.len() != 1 { - return Err(WorkspaceError::invalid_view_id().context("The len of view_ids should be equal to 1")); + log::error!("The len of view_ids should be equal to 1"); + return Err(ErrorCode::ViewIdInvalid); } let view_id = self.view_ids.first().unwrap().clone(); - let view_id = ViewId::parse(view_id) - .map_err(|e| WorkspaceError::invalid_view_id().context(e))? - .0; + let view_id = ViewId::parse(view_id)?.0; Ok(ViewIdentifier { view_id }) } @@ -47,14 +46,12 @@ pub struct ViewIdentifiers { } impl TryInto for QueryViewRequest { - type Error = WorkspaceError; + type Error = ErrorCode; fn try_into(self) -> Result { let mut view_ids = vec![]; for view_id in self.view_ids { - let view_id = ViewId::parse(view_id) - .map_err(|e| WorkspaceError::invalid_view_id().context(e))? - .0; + let view_id = ViewId::parse(view_id)?.0; view_ids.push(view_id); } diff --git a/rust-lib/flowy-workspace/src/entities/view/view_update.rs b/rust-lib/flowy-workspace-infra/src/entities/view/view_update.rs similarity index 72% rename from rust-lib/flowy-workspace/src/entities/view/view_update.rs rename to rust-lib/flowy-workspace-infra/src/entities/view/view_update.rs index fadb038060..7205f6c39c 100644 --- a/rust-lib/flowy-workspace/src/entities/view/view_update.rs +++ b/rust-lib/flowy-workspace-infra/src/entities/view/view_update.rs @@ -1,9 +1,8 @@ use crate::{ - entities::view::parser::{ViewId, *}, - errors::WorkspaceError, + errors::ErrorCode, + parser::view::{ViewDesc, ViewId, ViewName, ViewThumbnail}, }; use flowy_derive::ProtoBuf; - use std::convert::TryInto; #[derive(Default, ProtoBuf)] @@ -56,38 +55,24 @@ impl UpdateViewParams { } impl TryInto for UpdateViewRequest { - type Error = WorkspaceError; + type Error = ErrorCode; fn try_into(self) -> Result { - let view_id = ViewId::parse(self.view_id) - .map_err(|e| WorkspaceError::invalid_view_id().context(e))? - .0; + let view_id = ViewId::parse(self.view_id)?.0; let name = match self.name { None => None, - Some(name) => Some( - ViewName::parse(name) - .map_err(|e| WorkspaceError::view_name().context(e))? - .0, - ), + Some(name) => Some(ViewName::parse(name)?.0), }; let desc = match self.desc { None => None, - Some(desc) => Some( - ViewDesc::parse(desc) - .map_err(|e| WorkspaceError::view_desc().context(e))? - .0, - ), + Some(desc) => Some(ViewDesc::parse(desc)?.0), }; let thumbnail = match self.thumbnail { None => None, - Some(thumbnail) => Some( - ViewThumbnail::parse(thumbnail) - .map_err(|e| WorkspaceError::view_thumbnail().context(e))? - .0, - ), + Some(thumbnail) => Some(ViewThumbnail::parse(thumbnail)?.0), }; Ok(UpdateViewParams { diff --git a/rust-lib/flowy-workspace-infra/src/entities/workspace/mod.rs b/rust-lib/flowy-workspace-infra/src/entities/workspace/mod.rs new file mode 100644 index 0000000000..cce1777a08 --- /dev/null +++ b/rust-lib/flowy-workspace-infra/src/entities/workspace/mod.rs @@ -0,0 +1,19 @@ +pub use workspace_create::*; + +pub use workspace_delete::*; + +pub use workspace_query::*; + +pub use workspace_update::*; + +pub use workspace_user_detail::*; + +mod workspace_create; + +mod workspace_delete; + +mod workspace_query; + +mod workspace_update; + +mod workspace_user_detail; diff --git a/rust-lib/flowy-workspace/src/entities/workspace/workspace_create.rs b/rust-lib/flowy-workspace-infra/src/entities/workspace/workspace_create.rs similarity index 79% rename from rust-lib/flowy-workspace/src/entities/workspace/workspace_create.rs rename to rust-lib/flowy-workspace-infra/src/entities/workspace/workspace_create.rs index afdceeba4e..08c3d076d0 100644 --- a/rust-lib/flowy-workspace/src/entities/workspace/workspace_create.rs +++ b/rust-lib/flowy-workspace-infra/src/entities/workspace/workspace_create.rs @@ -1,7 +1,8 @@ use crate::{ - entities::{app::RepeatedApp, workspace::parser::*}, + entities::app::RepeatedApp, errors::*, impl_def_and_def_mut, + parser::workspace::{WorkspaceDesc, WorkspaceName}, }; use flowy_derive::ProtoBuf; use std::convert::TryInto; @@ -25,11 +26,11 @@ pub struct CreateWorkspaceParams { } impl TryInto for CreateWorkspaceRequest { - type Error = WorkspaceError; + type Error = ErrorCode; fn try_into(self) -> Result { - let name = WorkspaceName::parse(self.name).map_err(|e| WorkspaceError::workspace_name().context(e))?; - let desc = WorkspaceDesc::parse(self.desc).map_err(|e| WorkspaceError::workspace_desc().context(e))?; + let name = WorkspaceName::parse(self.name)?; + let desc = WorkspaceDesc::parse(self.desc)?; Ok(CreateWorkspaceParams { name: name.0, diff --git a/rust-lib/flowy-workspace/src/entities/workspace/workspace_delete.rs b/rust-lib/flowy-workspace-infra/src/entities/workspace/workspace_delete.rs similarity index 73% rename from rust-lib/flowy-workspace/src/entities/workspace/workspace_delete.rs rename to rust-lib/flowy-workspace-infra/src/entities/workspace/workspace_delete.rs index 2963b831c4..c16dece03f 100644 --- a/rust-lib/flowy-workspace/src/entities/workspace/workspace_delete.rs +++ b/rust-lib/flowy-workspace-infra/src/entities/workspace/workspace_delete.rs @@ -1,4 +1,4 @@ -use crate::{entities::workspace::parser::WorkspaceId, errors::WorkspaceError}; +use crate::{errors::ErrorCode, parser::workspace::WorkspaceId}; use flowy_derive::ProtoBuf; use std::convert::TryInto; @@ -15,12 +15,10 @@ pub struct DeleteWorkspaceParams { } impl TryInto for DeleteWorkspaceRequest { - type Error = WorkspaceError; + type Error = ErrorCode; fn try_into(self) -> Result { - let workspace_id = WorkspaceId::parse(self.workspace_id) - .map_err(|e| WorkspaceError::workspace_id().context(e))? - .0; + let workspace_id = WorkspaceId::parse(self.workspace_id)?.0; Ok(DeleteWorkspaceParams { workspace_id }) } diff --git a/rust-lib/flowy-workspace/src/entities/workspace/workspace_query.rs b/rust-lib/flowy-workspace-infra/src/entities/workspace/workspace_query.rs similarity index 81% rename from rust-lib/flowy-workspace/src/entities/workspace/workspace_query.rs rename to rust-lib/flowy-workspace-infra/src/entities/workspace/workspace_query.rs index 41255edede..180e8b4f79 100644 --- a/rust-lib/flowy-workspace/src/entities/workspace/workspace_query.rs +++ b/rust-lib/flowy-workspace-infra/src/entities/workspace/workspace_query.rs @@ -1,4 +1,4 @@ -use crate::{entities::workspace::parser::*, errors::*}; +use crate::{errors::*, parser::workspace::WorkspaceId}; use flowy_derive::ProtoBuf; use std::convert::TryInto; @@ -40,16 +40,12 @@ impl QueryWorkspaceParams { } impl TryInto for QueryWorkspaceRequest { - type Error = WorkspaceError; + type Error = ErrorCode; fn try_into(self) -> Result { let workspace_id = match self.workspace_id { None => None, - Some(workspace_id) => Some( - WorkspaceId::parse(workspace_id) - .map_err(|e| WorkspaceError::workspace_id().context(e))? - .0, - ), + Some(workspace_id) => Some(WorkspaceId::parse(workspace_id)?.0), }; Ok(QueryWorkspaceParams { workspace_id }) diff --git a/rust-lib/flowy-workspace/src/entities/workspace/workspace_update.rs b/rust-lib/flowy-workspace-infra/src/entities/workspace/workspace_update.rs similarity index 68% rename from rust-lib/flowy-workspace/src/entities/workspace/workspace_update.rs rename to rust-lib/flowy-workspace-infra/src/entities/workspace/workspace_update.rs index ebda56ee1a..d61200ba24 100644 --- a/rust-lib/flowy-workspace/src/entities/workspace/workspace_update.rs +++ b/rust-lib/flowy-workspace-infra/src/entities/workspace/workspace_update.rs @@ -1,8 +1,9 @@ -use std::convert::TryInto; - +use crate::{ + errors::*, + parser::workspace::{WorkspaceId, WorkspaceName}, +}; use flowy_derive::ProtoBuf; - -use crate::{entities::workspace::parser::*, errors::*}; +use std::convert::TryInto; #[derive(ProtoBuf, Default)] pub struct UpdateWorkspaceRequest { @@ -29,19 +30,14 @@ pub struct UpdateWorkspaceParams { } impl TryInto for UpdateWorkspaceRequest { - type Error = WorkspaceError; + type Error = ErrorCode; fn try_into(self) -> Result { let name = match self.name { None => None, - Some(name) => Some( - WorkspaceName::parse(name) - .map_err(|e| WorkspaceError::workspace_name().context(e))? - .0, - ), + Some(name) => Some(WorkspaceName::parse(name)?.0), }; - - let id = WorkspaceId::parse(self.id).map_err(|e| WorkspaceError::workspace_id().context(e))?; + let id = WorkspaceId::parse(self.id)?; Ok(UpdateWorkspaceParams { id: id.0, diff --git a/rust-lib/flowy-workspace/src/entities/workspace/workspace_user_detail.rs b/rust-lib/flowy-workspace-infra/src/entities/workspace/workspace_user_detail.rs similarity index 100% rename from rust-lib/flowy-workspace/src/entities/workspace/workspace_user_detail.rs rename to rust-lib/flowy-workspace-infra/src/entities/workspace/workspace_user_detail.rs diff --git a/rust-lib/flowy-workspace-infra/src/errors.rs b/rust-lib/flowy-workspace-infra/src/errors.rs new file mode 100644 index 0000000000..a9a07a99a6 --- /dev/null +++ b/rust-lib/flowy-workspace-infra/src/errors.rs @@ -0,0 +1,77 @@ +use crate::protobuf::ErrorCode as ProtoBufErrorCode; + +use derive_more::Display; +use flowy_derive::ProtoBuf_Enum; +use protobuf::ProtobufEnum; +use std::convert::{TryFrom, TryInto}; + +#[derive(Debug, Clone, ProtoBuf_Enum, Display, PartialEq, Eq)] +pub enum ErrorCode { + #[display(fmt = "Workspace name can not be empty or whitespace")] + WorkspaceNameInvalid = 0, + + #[display(fmt = "Workspace id can not be empty or whitespace")] + WorkspaceIdInvalid = 1, + + #[display(fmt = "Color style of the App is invalid")] + AppColorStyleInvalid = 2, + + #[display(fmt = "Workspace desc is invalid")] + WorkspaceDescTooLong = 3, + + #[display(fmt = "Workspace description too long")] + WorkspaceNameTooLong = 4, + + #[display(fmt = "App id can not be empty or whitespace")] + AppIdInvalid = 10, + + #[display(fmt = "App name can not be empty or whitespace")] + AppNameInvalid = 11, + + #[display(fmt = "View name can not be empty or whitespace")] + ViewNameInvalid = 20, + + #[display(fmt = "Thumbnail of the view is invalid")] + ViewThumbnailInvalid = 21, + + #[display(fmt = "View id can not be empty or whitespace")] + ViewIdInvalid = 22, + + #[display(fmt = "View desc too long")] + ViewDescTooLong = 23, + + #[display(fmt = "View data is invalid")] + ViewDataInvalid = 24, + + #[display(fmt = "View name too long")] + ViewNameTooLong = 25, + + #[display(fmt = "User unauthorized")] + UserUnauthorized = 100, + + #[display(fmt = "Workspace websocket error")] + WsConnectError = 200, + + #[display(fmt = "Server error")] + InternalError = 1000, + #[display(fmt = "Record not found")] + RecordNotFound = 1001, +} + +impl std::default::Default for ErrorCode { + fn default() -> Self { ErrorCode::InternalError } +} + +impl ErrorCode { + pub fn value(&self) -> i32 { + let code: ProtoBufErrorCode = self.clone().try_into().unwrap(); + code.value() + } + + pub fn from_i32(value: i32) -> Self { + match ProtoBufErrorCode::from_i32(value) { + None => ErrorCode::InternalError, + Some(code) => ErrorCode::try_from(&code).unwrap(), + } + } +} diff --git a/rust-lib/flowy-workspace-infra/src/lib.rs b/rust-lib/flowy-workspace-infra/src/lib.rs new file mode 100644 index 0000000000..9c5f32ac8d --- /dev/null +++ b/rust-lib/flowy-workspace-infra/src/lib.rs @@ -0,0 +1,6 @@ +pub mod entities; +pub mod errors; +pub mod parser; +#[macro_use] +mod macros; +pub mod protobuf; diff --git a/rust-lib/flowy-workspace-infra/src/macros.rs b/rust-lib/flowy-workspace-infra/src/macros.rs new file mode 100644 index 0000000000..d18f1959fc --- /dev/null +++ b/rust-lib/flowy-workspace-infra/src/macros.rs @@ -0,0 +1,30 @@ +#[macro_export] +macro_rules! impl_def_and_def_mut { + ($target:ident, $item: ident) => { + impl std::ops::Deref for $target { + type Target = Vec<$item>; + + fn deref(&self) -> &Self::Target { &self.items } + } + impl std::ops::DerefMut for $target { + fn deref_mut(&mut self) -> &mut Self::Target { &mut self.items } + } + + impl $target { + #[allow(dead_code)] + pub fn into_inner(&mut self) -> Vec<$item> { ::std::mem::replace(&mut self.items, vec![]) } + + #[allow(dead_code)] + pub fn push(&mut self, item: $item) { + if self.items.contains(&item) { + log::error!("add duplicate item: {:?}", item); + return; + } + + self.items.push(item); + } + + pub fn first_or_crash(&self) -> &$item { self.items.first().unwrap() } + } + }; +} diff --git a/rust-lib/flowy-workspace/src/entities/app/parser/app_color_style.rs b/rust-lib/flowy-workspace-infra/src/parser/app/app_color_style.rs similarity index 64% rename from rust-lib/flowy-workspace/src/entities/app/parser/app_color_style.rs rename to rust-lib/flowy-workspace-infra/src/parser/app/app_color_style.rs index 23f1e56fdf..3b971f7f87 100644 --- a/rust-lib/flowy-workspace/src/entities/app/parser/app_color_style.rs +++ b/rust-lib/flowy-workspace-infra/src/parser/app/app_color_style.rs @@ -1,10 +1,12 @@ +use crate::errors::ErrorCode; + #[derive(Debug)] pub struct AppColorStyle { pub theme_color: String, } impl AppColorStyle { - pub fn parse(theme_color: String) -> Result { + pub fn parse(theme_color: String) -> Result { // TODO: verify the color style format Ok(AppColorStyle { theme_color }) } diff --git a/rust-lib/flowy-workspace/src/entities/app/parser/app_desc.rs b/rust-lib/flowy-workspace-infra/src/parser/app/app_desc.rs similarity index 100% rename from rust-lib/flowy-workspace/src/entities/app/parser/app_desc.rs rename to rust-lib/flowy-workspace-infra/src/parser/app/app_desc.rs diff --git a/rust-lib/flowy-workspace/src/entities/app/parser/app_id.rs b/rust-lib/flowy-workspace-infra/src/parser/app/app_id.rs similarity index 59% rename from rust-lib/flowy-workspace/src/entities/app/parser/app_id.rs rename to rust-lib/flowy-workspace-infra/src/parser/app/app_id.rs index e7a5fe3a79..4a69ce7a7f 100644 --- a/rust-lib/flowy-workspace/src/entities/app/parser/app_id.rs +++ b/rust-lib/flowy-workspace-infra/src/parser/app/app_id.rs @@ -1,10 +1,12 @@ +use crate::errors::ErrorCode; + #[derive(Debug)] pub struct AppId(pub String); impl AppId { - pub fn parse(s: String) -> Result { + pub fn parse(s: String) -> Result { if s.trim().is_empty() { - return Err(format!("App id can not be empty or whitespace")); + return Err(ErrorCode::AppIdInvalid); } Ok(Self(s)) diff --git a/rust-lib/flowy-workspace/src/entities/app/parser/app_name.rs b/rust-lib/flowy-workspace-infra/src/parser/app/app_name.rs similarity index 59% rename from rust-lib/flowy-workspace/src/entities/app/parser/app_name.rs rename to rust-lib/flowy-workspace-infra/src/parser/app/app_name.rs index 01a50e8444..9b954cb44c 100644 --- a/rust-lib/flowy-workspace/src/entities/app/parser/app_name.rs +++ b/rust-lib/flowy-workspace-infra/src/parser/app/app_name.rs @@ -1,10 +1,12 @@ +use crate::errors::ErrorCode; + #[derive(Debug)] pub struct AppName(pub String); impl AppName { - pub fn parse(s: String) -> Result { + pub fn parse(s: String) -> Result { if s.trim().is_empty() { - return Err(format!("App name can not be empty or whitespace")); + return Err(ErrorCode::AppNameInvalid); } Ok(Self(s)) diff --git a/rust-lib/flowy-workspace/src/entities/app/parser/mod.rs b/rust-lib/flowy-workspace-infra/src/parser/app/mod.rs similarity index 100% rename from rust-lib/flowy-workspace/src/entities/app/parser/mod.rs rename to rust-lib/flowy-workspace-infra/src/parser/app/mod.rs diff --git a/rust-lib/flowy-workspace-infra/src/parser/mod.rs b/rust-lib/flowy-workspace-infra/src/parser/mod.rs new file mode 100644 index 0000000000..3ee0f4b591 --- /dev/null +++ b/rust-lib/flowy-workspace-infra/src/parser/mod.rs @@ -0,0 +1,4 @@ +pub mod app; +pub mod trash; +pub mod view; +pub mod workspace; diff --git a/rust-lib/flowy-workspace/src/entities/trash/parser/mod.rs b/rust-lib/flowy-workspace-infra/src/parser/trash/mod.rs similarity index 100% rename from rust-lib/flowy-workspace/src/entities/trash/parser/mod.rs rename to rust-lib/flowy-workspace-infra/src/parser/trash/mod.rs diff --git a/rust-lib/flowy-workspace/src/entities/trash/parser/trash_id.rs b/rust-lib/flowy-workspace-infra/src/parser/trash/trash_id.rs similarity index 100% rename from rust-lib/flowy-workspace/src/entities/trash/parser/trash_id.rs rename to rust-lib/flowy-workspace-infra/src/parser/trash/trash_id.rs diff --git a/rust-lib/flowy-workspace/src/entities/view/parser/delta_data.rs b/rust-lib/flowy-workspace-infra/src/parser/view/delta_data.rs similarity index 100% rename from rust-lib/flowy-workspace/src/entities/view/parser/delta_data.rs rename to rust-lib/flowy-workspace-infra/src/parser/view/delta_data.rs diff --git a/rust-lib/flowy-workspace/src/entities/view/parser/mod.rs b/rust-lib/flowy-workspace-infra/src/parser/view/mod.rs similarity index 100% rename from rust-lib/flowy-workspace/src/entities/view/parser/mod.rs rename to rust-lib/flowy-workspace-infra/src/parser/view/mod.rs diff --git a/rust-lib/flowy-workspace/src/entities/view/parser/view_desc.rs b/rust-lib/flowy-workspace-infra/src/parser/view/view_desc.rs similarity index 65% rename from rust-lib/flowy-workspace/src/entities/view/parser/view_desc.rs rename to rust-lib/flowy-workspace-infra/src/parser/view/view_desc.rs index b3635bc258..cce4989c9e 100644 --- a/rust-lib/flowy-workspace/src/entities/view/parser/view_desc.rs +++ b/rust-lib/flowy-workspace-infra/src/parser/view/view_desc.rs @@ -1,12 +1,13 @@ +use crate::errors::ErrorCode; use unicode_segmentation::UnicodeSegmentation; #[derive(Debug)] pub struct ViewDesc(pub String); impl ViewDesc { - pub fn parse(s: String) -> Result { + pub fn parse(s: String) -> Result { if s.graphemes(true).count() > 1000 { - return Err(format!("View desc too long")); + return Err(ErrorCode::ViewDescTooLong); } Ok(Self(s)) diff --git a/rust-lib/flowy-workspace/src/entities/view/parser/view_id.rs b/rust-lib/flowy-workspace-infra/src/parser/view/view_id.rs similarity index 59% rename from rust-lib/flowy-workspace/src/entities/view/parser/view_id.rs rename to rust-lib/flowy-workspace-infra/src/parser/view/view_id.rs index e9ed402ef7..6bf81a034f 100644 --- a/rust-lib/flowy-workspace/src/entities/view/parser/view_id.rs +++ b/rust-lib/flowy-workspace-infra/src/parser/view/view_id.rs @@ -1,10 +1,12 @@ +use crate::errors::ErrorCode; + #[derive(Debug)] pub struct ViewId(pub String); impl ViewId { - pub fn parse(s: String) -> Result { + pub fn parse(s: String) -> Result { if s.trim().is_empty() { - return Err(format!("View id can not be empty or whitespace")); + return Err(ErrorCode::ViewIdInvalid); } Ok(Self(s)) diff --git a/rust-lib/flowy-workspace/src/entities/view/parser/view_name.rs b/rust-lib/flowy-workspace-infra/src/parser/view/view_name.rs similarity index 61% rename from rust-lib/flowy-workspace/src/entities/view/parser/view_name.rs rename to rust-lib/flowy-workspace-infra/src/parser/view/view_name.rs index f283b092ca..f7e2545081 100644 --- a/rust-lib/flowy-workspace/src/entities/view/parser/view_name.rs +++ b/rust-lib/flowy-workspace-infra/src/parser/view/view_name.rs @@ -1,16 +1,17 @@ +use crate::errors::ErrorCode; use unicode_segmentation::UnicodeSegmentation; #[derive(Debug)] pub struct ViewName(pub String); impl ViewName { - pub fn parse(s: String) -> Result { + pub fn parse(s: String) -> Result { if s.trim().is_empty() { - return Err(format!("View name can not be empty or whitespace")); + return Err(ErrorCode::ViewNameInvalid); } if s.graphemes(true).count() > 256 { - return Err(format!("View name too long")); + return Err(ErrorCode::ViewNameTooLong); } Ok(Self(s)) diff --git a/rust-lib/flowy-workspace/src/entities/view/parser/view_thumbnail.rs b/rust-lib/flowy-workspace-infra/src/parser/view/view_thumbnail.rs similarity index 79% rename from rust-lib/flowy-workspace/src/entities/view/parser/view_thumbnail.rs rename to rust-lib/flowy-workspace-infra/src/parser/view/view_thumbnail.rs index ce7aba0b15..7f18e0e920 100644 --- a/rust-lib/flowy-workspace/src/entities/view/parser/view_thumbnail.rs +++ b/rust-lib/flowy-workspace-infra/src/parser/view/view_thumbnail.rs @@ -1,8 +1,10 @@ +use crate::errors::ErrorCode; + #[derive(Debug)] pub struct ViewThumbnail(pub String); impl ViewThumbnail { - pub fn parse(s: String) -> Result { + pub fn parse(s: String) -> Result { // if s.trim().is_empty() { // return Err(format!("View thumbnail can not be empty or whitespace")); // } diff --git a/rust-lib/flowy-workspace/src/entities/workspace/parser/mod.rs b/rust-lib/flowy-workspace-infra/src/parser/workspace/mod.rs similarity index 100% rename from rust-lib/flowy-workspace/src/entities/workspace/parser/mod.rs rename to rust-lib/flowy-workspace-infra/src/parser/workspace/mod.rs diff --git a/rust-lib/flowy-workspace/src/entities/workspace/parser/workspace_desc.rs b/rust-lib/flowy-workspace-infra/src/parser/workspace/workspace_desc.rs similarity index 65% rename from rust-lib/flowy-workspace/src/entities/workspace/parser/workspace_desc.rs rename to rust-lib/flowy-workspace-infra/src/parser/workspace/workspace_desc.rs index 0876cde657..71e47ac124 100644 --- a/rust-lib/flowy-workspace/src/entities/workspace/parser/workspace_desc.rs +++ b/rust-lib/flowy-workspace-infra/src/parser/workspace/workspace_desc.rs @@ -1,12 +1,13 @@ +use crate::errors::ErrorCode; use unicode_segmentation::UnicodeSegmentation; #[derive(Debug)] pub struct WorkspaceDesc(pub String); impl WorkspaceDesc { - pub fn parse(s: String) -> Result { + pub fn parse(s: String) -> Result { if s.graphemes(true).count() > 1024 { - return Err(format!("Workspace description too long")); + return Err(ErrorCode::WorkspaceNameTooLong); } Ok(Self(s)) diff --git a/rust-lib/flowy-workspace/src/entities/workspace/parser/workspace_id.rs b/rust-lib/flowy-workspace-infra/src/parser/workspace/workspace_id.rs similarity index 59% rename from rust-lib/flowy-workspace/src/entities/workspace/parser/workspace_id.rs rename to rust-lib/flowy-workspace-infra/src/parser/workspace/workspace_id.rs index 060ea982e6..5ba59d2255 100644 --- a/rust-lib/flowy-workspace/src/entities/workspace/parser/workspace_id.rs +++ b/rust-lib/flowy-workspace-infra/src/parser/workspace/workspace_id.rs @@ -1,10 +1,12 @@ +use crate::errors::ErrorCode; + #[derive(Debug)] pub struct WorkspaceId(pub String); impl WorkspaceId { - pub fn parse(s: String) -> Result { + pub fn parse(s: String) -> Result { if s.trim().is_empty() { - return Err(format!("Workspace id can not be empty or whitespace")); + return Err(ErrorCode::WorkspaceIdInvalid); } Ok(Self(s)) diff --git a/rust-lib/flowy-workspace/src/entities/workspace/parser/workspace_name.rs b/rust-lib/flowy-workspace-infra/src/parser/workspace/workspace_name.rs similarity index 61% rename from rust-lib/flowy-workspace/src/entities/workspace/parser/workspace_name.rs rename to rust-lib/flowy-workspace-infra/src/parser/workspace/workspace_name.rs index e464d553af..3761e5a346 100644 --- a/rust-lib/flowy-workspace/src/entities/workspace/parser/workspace_name.rs +++ b/rust-lib/flowy-workspace-infra/src/parser/workspace/workspace_name.rs @@ -1,16 +1,17 @@ +use crate::errors::ErrorCode; use unicode_segmentation::UnicodeSegmentation; #[derive(Debug)] pub struct WorkspaceName(pub String); impl WorkspaceName { - pub fn parse(s: String) -> Result { + pub fn parse(s: String) -> Result { if s.trim().is_empty() { - return Err(format!("Workspace name can not be empty or whitespace")); + return Err(ErrorCode::WorkspaceNameInvalid); } if s.graphemes(true).count() > 256 { - return Err(format!("Workspace name too long")); + return Err(ErrorCode::WorkspaceNameTooLong); } Ok(Self(s)) diff --git a/rust-lib/flowy-workspace-infra/src/protobuf/mod.rs b/rust-lib/flowy-workspace-infra/src/protobuf/mod.rs new file mode 100644 index 0000000000..2480f62fbe --- /dev/null +++ b/rust-lib/flowy-workspace-infra/src/protobuf/mod.rs @@ -0,0 +1,4 @@ + +mod model; +pub use model::*; + \ No newline at end of file diff --git a/rust-lib/flowy-workspace/src/protobuf/model/app_create.rs b/rust-lib/flowy-workspace-infra/src/protobuf/model/app_create.rs similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/model/app_create.rs rename to rust-lib/flowy-workspace-infra/src/protobuf/model/app_create.rs diff --git a/rust-lib/flowy-workspace/src/protobuf/model/app_query.rs b/rust-lib/flowy-workspace-infra/src/protobuf/model/app_query.rs similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/model/app_query.rs rename to rust-lib/flowy-workspace-infra/src/protobuf/model/app_query.rs diff --git a/rust-lib/flowy-workspace/src/protobuf/model/app_update.rs b/rust-lib/flowy-workspace-infra/src/protobuf/model/app_update.rs similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/model/app_update.rs rename to rust-lib/flowy-workspace-infra/src/protobuf/model/app_update.rs diff --git a/rust-lib/flowy-workspace-infra/src/protobuf/model/errors.rs b/rust-lib/flowy-workspace-infra/src/protobuf/model/errors.rs new file mode 100644 index 0000000000..d72b4f5b95 --- /dev/null +++ b/rust-lib/flowy-workspace-infra/src/protobuf/model/errors.rs @@ -0,0 +1,181 @@ +// This file is generated by rust-protobuf 2.22.1. Do not edit +// @generated + +// https://github.com/rust-lang/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy::all)] + +#![allow(unused_attributes)] +#![cfg_attr(rustfmt, rustfmt::skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unused_imports)] +#![allow(unused_results)] +//! Generated file from `errors.proto` + +/// Generated files are compatible only with the same version +/// of protobuf runtime. +// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1; + +#[derive(Clone,PartialEq,Eq,Debug,Hash)] +pub enum ErrorCode { + WorkspaceNameInvalid = 0, + WorkspaceIdInvalid = 1, + AppColorStyleInvalid = 2, + WorkspaceDescTooLong = 3, + WorkspaceNameTooLong = 4, + AppIdInvalid = 10, + AppNameInvalid = 11, + ViewNameInvalid = 20, + ViewThumbnailInvalid = 21, + ViewIdInvalid = 22, + ViewDescTooLong = 23, + ViewDataInvalid = 24, + ViewNameTooLong = 25, + UserUnauthorized = 100, + WsConnectError = 200, + InternalError = 1000, + RecordNotFound = 1001, +} + +impl ::protobuf::ProtobufEnum for ErrorCode { + fn value(&self) -> i32 { + *self as i32 + } + + fn from_i32(value: i32) -> ::std::option::Option { + match value { + 0 => ::std::option::Option::Some(ErrorCode::WorkspaceNameInvalid), + 1 => ::std::option::Option::Some(ErrorCode::WorkspaceIdInvalid), + 2 => ::std::option::Option::Some(ErrorCode::AppColorStyleInvalid), + 3 => ::std::option::Option::Some(ErrorCode::WorkspaceDescTooLong), + 4 => ::std::option::Option::Some(ErrorCode::WorkspaceNameTooLong), + 10 => ::std::option::Option::Some(ErrorCode::AppIdInvalid), + 11 => ::std::option::Option::Some(ErrorCode::AppNameInvalid), + 20 => ::std::option::Option::Some(ErrorCode::ViewNameInvalid), + 21 => ::std::option::Option::Some(ErrorCode::ViewThumbnailInvalid), + 22 => ::std::option::Option::Some(ErrorCode::ViewIdInvalid), + 23 => ::std::option::Option::Some(ErrorCode::ViewDescTooLong), + 24 => ::std::option::Option::Some(ErrorCode::ViewDataInvalid), + 25 => ::std::option::Option::Some(ErrorCode::ViewNameTooLong), + 100 => ::std::option::Option::Some(ErrorCode::UserUnauthorized), + 200 => ::std::option::Option::Some(ErrorCode::WsConnectError), + 1000 => ::std::option::Option::Some(ErrorCode::InternalError), + 1001 => ::std::option::Option::Some(ErrorCode::RecordNotFound), + _ => ::std::option::Option::None + } + } + + fn values() -> &'static [Self] { + static values: &'static [ErrorCode] = &[ + ErrorCode::WorkspaceNameInvalid, + ErrorCode::WorkspaceIdInvalid, + ErrorCode::AppColorStyleInvalid, + ErrorCode::WorkspaceDescTooLong, + ErrorCode::WorkspaceNameTooLong, + ErrorCode::AppIdInvalid, + ErrorCode::AppNameInvalid, + ErrorCode::ViewNameInvalid, + ErrorCode::ViewThumbnailInvalid, + ErrorCode::ViewIdInvalid, + ErrorCode::ViewDescTooLong, + ErrorCode::ViewDataInvalid, + ErrorCode::ViewNameTooLong, + ErrorCode::UserUnauthorized, + ErrorCode::WsConnectError, + ErrorCode::InternalError, + ErrorCode::RecordNotFound, + ]; + values + } + + 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::("ErrorCode", file_descriptor_proto()) + }) + } +} + +impl ::std::marker::Copy for ErrorCode { +} + +impl ::std::default::Default for ErrorCode { + fn default() -> Self { + ErrorCode::WorkspaceNameInvalid + } +} + +impl ::protobuf::reflect::ProtobufValue for ErrorCode { + 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*\x86\x03\n\tErrorCode\x12\x18\n\x14WorkspaceNameInval\ + id\x10\0\x12\x16\n\x12WorkspaceIdInvalid\x10\x01\x12\x18\n\x14AppColorSt\ + yleInvalid\x10\x02\x12\x18\n\x14WorkspaceDescTooLong\x10\x03\x12\x18\n\ + \x14WorkspaceNameTooLong\x10\x04\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\x0fViewDescTooLong\x10\x17\x12\x13\n\x0fViewDataInvalid\x10\ + \x18\x12\x13\n\x0fViewNameTooLong\x10\x19\x12\x14\n\x10UserUnauthorized\ + \x10d\x12\x13\n\x0eWsConnectError\x10\xc8\x01\x12\x12\n\rInternalError\ + \x10\xe8\x07\x12\x13\n\x0eRecordNotFound\x10\xe9\x07J\xe3\x05\n\x06\x12\ + \x04\0\0\x14\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x05\0\x12\x04\ + \x02\0\x14\x01\n\n\n\x03\x05\0\x01\x12\x03\x02\x05\x0e\n\x0b\n\x04\x05\0\ + \x02\0\x12\x03\x03\x04\x1d\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x03\x04\ + \x18\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x03\x1b\x1c\n\x0b\n\x04\x05\0\ + \x02\x01\x12\x03\x04\x04\x1b\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x04\ + \x04\x16\n\x0c\n\x05\x05\0\x02\x01\x02\x12\x03\x04\x19\x1a\n\x0b\n\x04\ + \x05\0\x02\x02\x12\x03\x05\x04\x1d\n\x0c\n\x05\x05\0\x02\x02\x01\x12\x03\ + \x05\x04\x18\n\x0c\n\x05\x05\0\x02\x02\x02\x12\x03\x05\x1b\x1c\n\x0b\n\ + \x04\x05\0\x02\x03\x12\x03\x06\x04\x1d\n\x0c\n\x05\x05\0\x02\x03\x01\x12\ + \x03\x06\x04\x18\n\x0c\n\x05\x05\0\x02\x03\x02\x12\x03\x06\x1b\x1c\n\x0b\ + \n\x04\x05\0\x02\x04\x12\x03\x07\x04\x1d\n\x0c\n\x05\x05\0\x02\x04\x01\ + \x12\x03\x07\x04\x18\n\x0c\n\x05\x05\0\x02\x04\x02\x12\x03\x07\x1b\x1c\n\ + \x0b\n\x04\x05\0\x02\x05\x12\x03\x08\x04\x16\n\x0c\n\x05\x05\0\x02\x05\ + \x01\x12\x03\x08\x04\x10\n\x0c\n\x05\x05\0\x02\x05\x02\x12\x03\x08\x13\ + \x15\n\x0b\n\x04\x05\0\x02\x06\x12\x03\t\x04\x18\n\x0c\n\x05\x05\0\x02\ + \x06\x01\x12\x03\t\x04\x12\n\x0c\n\x05\x05\0\x02\x06\x02\x12\x03\t\x15\ + \x17\n\x0b\n\x04\x05\0\x02\x07\x12\x03\n\x04\x19\n\x0c\n\x05\x05\0\x02\ + \x07\x01\x12\x03\n\x04\x13\n\x0c\n\x05\x05\0\x02\x07\x02\x12\x03\n\x16\ + \x18\n\x0b\n\x04\x05\0\x02\x08\x12\x03\x0b\x04\x1e\n\x0c\n\x05\x05\0\x02\ + \x08\x01\x12\x03\x0b\x04\x18\n\x0c\n\x05\x05\0\x02\x08\x02\x12\x03\x0b\ + \x1b\x1d\n\x0b\n\x04\x05\0\x02\t\x12\x03\x0c\x04\x17\n\x0c\n\x05\x05\0\ + \x02\t\x01\x12\x03\x0c\x04\x11\n\x0c\n\x05\x05\0\x02\t\x02\x12\x03\x0c\ + \x14\x16\n\x0b\n\x04\x05\0\x02\n\x12\x03\r\x04\x19\n\x0c\n\x05\x05\0\x02\ + \n\x01\x12\x03\r\x04\x13\n\x0c\n\x05\x05\0\x02\n\x02\x12\x03\r\x16\x18\n\ + \x0b\n\x04\x05\0\x02\x0b\x12\x03\x0e\x04\x19\n\x0c\n\x05\x05\0\x02\x0b\ + \x01\x12\x03\x0e\x04\x13\n\x0c\n\x05\x05\0\x02\x0b\x02\x12\x03\x0e\x16\ + \x18\n\x0b\n\x04\x05\0\x02\x0c\x12\x03\x0f\x04\x19\n\x0c\n\x05\x05\0\x02\ + \x0c\x01\x12\x03\x0f\x04\x13\n\x0c\n\x05\x05\0\x02\x0c\x02\x12\x03\x0f\ + \x16\x18\n\x0b\n\x04\x05\0\x02\r\x12\x03\x10\x04\x1b\n\x0c\n\x05\x05\0\ + \x02\r\x01\x12\x03\x10\x04\x14\n\x0c\n\x05\x05\0\x02\r\x02\x12\x03\x10\ + \x17\x1a\n\x0b\n\x04\x05\0\x02\x0e\x12\x03\x11\x04\x19\n\x0c\n\x05\x05\0\ + \x02\x0e\x01\x12\x03\x11\x04\x12\n\x0c\n\x05\x05\0\x02\x0e\x02\x12\x03\ + \x11\x15\x18\n\x0b\n\x04\x05\0\x02\x0f\x12\x03\x12\x04\x19\n\x0c\n\x05\ + \x05\0\x02\x0f\x01\x12\x03\x12\x04\x11\n\x0c\n\x05\x05\0\x02\x0f\x02\x12\ + \x03\x12\x14\x18\n\x0b\n\x04\x05\0\x02\x10\x12\x03\x13\x04\x1a\n\x0c\n\ + \x05\x05\0\x02\x10\x01\x12\x03\x13\x04\x12\n\x0c\n\x05\x05\0\x02\x10\x02\ + \x12\x03\x13\x15\x19b\x06proto3\ +"; + +static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; + +fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { + ::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap() +} + +pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) +} diff --git a/rust-lib/flowy-workspace-infra/src/protobuf/model/mod.rs b/rust-lib/flowy-workspace-infra/src/protobuf/model/mod.rs new file mode 100644 index 0000000000..eabed0d2eb --- /dev/null +++ b/rust-lib/flowy-workspace-infra/src/protobuf/model/mod.rs @@ -0,0 +1,40 @@ +// Auto-generated, do not edit + +mod view_update; +pub use view_update::*; + +mod app_query; +pub use app_query::*; + +mod workspace_delete; +pub use workspace_delete::*; + +mod errors; +pub use errors::*; + +mod workspace_update; +pub use workspace_update::*; + +mod app_create; +pub use app_create::*; + +mod workspace_query; +pub use workspace_query::*; + +mod view_create; +pub use view_create::*; + +mod workspace_user_detail; +pub use workspace_user_detail::*; + +mod workspace_create; +pub use workspace_create::*; + +mod app_update; +pub use app_update::*; + +mod view_query; +pub use view_query::*; + +mod trash_create; +pub use trash_create::*; diff --git a/rust-lib/flowy-workspace/src/protobuf/model/trash_create.rs b/rust-lib/flowy-workspace-infra/src/protobuf/model/trash_create.rs similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/model/trash_create.rs rename to rust-lib/flowy-workspace-infra/src/protobuf/model/trash_create.rs diff --git a/rust-lib/flowy-workspace/src/protobuf/model/view_create.rs b/rust-lib/flowy-workspace-infra/src/protobuf/model/view_create.rs similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/model/view_create.rs rename to rust-lib/flowy-workspace-infra/src/protobuf/model/view_create.rs diff --git a/rust-lib/flowy-workspace/src/protobuf/model/view_query.rs b/rust-lib/flowy-workspace-infra/src/protobuf/model/view_query.rs similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/model/view_query.rs rename to rust-lib/flowy-workspace-infra/src/protobuf/model/view_query.rs diff --git a/rust-lib/flowy-workspace/src/protobuf/model/view_update.rs b/rust-lib/flowy-workspace-infra/src/protobuf/model/view_update.rs similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/model/view_update.rs rename to rust-lib/flowy-workspace-infra/src/protobuf/model/view_update.rs diff --git a/rust-lib/flowy-workspace/src/protobuf/model/workspace_create.rs b/rust-lib/flowy-workspace-infra/src/protobuf/model/workspace_create.rs similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/model/workspace_create.rs rename to rust-lib/flowy-workspace-infra/src/protobuf/model/workspace_create.rs diff --git a/rust-lib/flowy-workspace/src/protobuf/model/workspace_delete.rs b/rust-lib/flowy-workspace-infra/src/protobuf/model/workspace_delete.rs similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/model/workspace_delete.rs rename to rust-lib/flowy-workspace-infra/src/protobuf/model/workspace_delete.rs diff --git a/rust-lib/flowy-workspace/src/protobuf/model/workspace_query.rs b/rust-lib/flowy-workspace-infra/src/protobuf/model/workspace_query.rs similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/model/workspace_query.rs rename to rust-lib/flowy-workspace-infra/src/protobuf/model/workspace_query.rs diff --git a/rust-lib/flowy-workspace/src/protobuf/model/workspace_update.rs b/rust-lib/flowy-workspace-infra/src/protobuf/model/workspace_update.rs similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/model/workspace_update.rs rename to rust-lib/flowy-workspace-infra/src/protobuf/model/workspace_update.rs diff --git a/rust-lib/flowy-workspace/src/protobuf/model/workspace_user_detail.rs b/rust-lib/flowy-workspace-infra/src/protobuf/model/workspace_user_detail.rs similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/model/workspace_user_detail.rs rename to rust-lib/flowy-workspace-infra/src/protobuf/model/workspace_user_detail.rs diff --git a/rust-lib/flowy-workspace/src/protobuf/proto/app_create.proto b/rust-lib/flowy-workspace-infra/src/protobuf/proto/app_create.proto similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/proto/app_create.proto rename to rust-lib/flowy-workspace-infra/src/protobuf/proto/app_create.proto diff --git a/rust-lib/flowy-workspace/src/protobuf/proto/app_query.proto b/rust-lib/flowy-workspace-infra/src/protobuf/proto/app_query.proto similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/proto/app_query.proto rename to rust-lib/flowy-workspace-infra/src/protobuf/proto/app_query.proto diff --git a/rust-lib/flowy-workspace/src/protobuf/proto/app_update.proto b/rust-lib/flowy-workspace-infra/src/protobuf/proto/app_update.proto similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/proto/app_update.proto rename to rust-lib/flowy-workspace-infra/src/protobuf/proto/app_update.proto diff --git a/rust-lib/flowy-workspace-infra/src/protobuf/proto/errors.proto b/rust-lib/flowy-workspace-infra/src/protobuf/proto/errors.proto new file mode 100644 index 0000000000..e536f6b045 --- /dev/null +++ b/rust-lib/flowy-workspace-infra/src/protobuf/proto/errors.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +enum ErrorCode { + WorkspaceNameInvalid = 0; + WorkspaceIdInvalid = 1; + AppColorStyleInvalid = 2; + WorkspaceDescTooLong = 3; + WorkspaceNameTooLong = 4; + AppIdInvalid = 10; + AppNameInvalid = 11; + ViewNameInvalid = 20; + ViewThumbnailInvalid = 21; + ViewIdInvalid = 22; + ViewDescTooLong = 23; + ViewDataInvalid = 24; + ViewNameTooLong = 25; + UserUnauthorized = 100; + WsConnectError = 200; + InternalError = 1000; + RecordNotFound = 1001; +} diff --git a/rust-lib/flowy-workspace/src/protobuf/proto/trash_create.proto b/rust-lib/flowy-workspace-infra/src/protobuf/proto/trash_create.proto similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/proto/trash_create.proto rename to rust-lib/flowy-workspace-infra/src/protobuf/proto/trash_create.proto diff --git a/rust-lib/flowy-workspace/src/protobuf/proto/view_create.proto b/rust-lib/flowy-workspace-infra/src/protobuf/proto/view_create.proto similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/proto/view_create.proto rename to rust-lib/flowy-workspace-infra/src/protobuf/proto/view_create.proto diff --git a/rust-lib/flowy-workspace/src/protobuf/proto/view_query.proto b/rust-lib/flowy-workspace-infra/src/protobuf/proto/view_query.proto similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/proto/view_query.proto rename to rust-lib/flowy-workspace-infra/src/protobuf/proto/view_query.proto diff --git a/rust-lib/flowy-workspace/src/protobuf/proto/view_update.proto b/rust-lib/flowy-workspace-infra/src/protobuf/proto/view_update.proto similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/proto/view_update.proto rename to rust-lib/flowy-workspace-infra/src/protobuf/proto/view_update.proto diff --git a/rust-lib/flowy-workspace/src/protobuf/proto/workspace_create.proto b/rust-lib/flowy-workspace-infra/src/protobuf/proto/workspace_create.proto similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/proto/workspace_create.proto rename to rust-lib/flowy-workspace-infra/src/protobuf/proto/workspace_create.proto diff --git a/rust-lib/flowy-workspace/src/protobuf/proto/workspace_delete.proto b/rust-lib/flowy-workspace-infra/src/protobuf/proto/workspace_delete.proto similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/proto/workspace_delete.proto rename to rust-lib/flowy-workspace-infra/src/protobuf/proto/workspace_delete.proto diff --git a/rust-lib/flowy-workspace/src/protobuf/proto/workspace_query.proto b/rust-lib/flowy-workspace-infra/src/protobuf/proto/workspace_query.proto similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/proto/workspace_query.proto rename to rust-lib/flowy-workspace-infra/src/protobuf/proto/workspace_query.proto diff --git a/rust-lib/flowy-workspace/src/protobuf/proto/workspace_update.proto b/rust-lib/flowy-workspace-infra/src/protobuf/proto/workspace_update.proto similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/proto/workspace_update.proto rename to rust-lib/flowy-workspace-infra/src/protobuf/proto/workspace_update.proto diff --git a/rust-lib/flowy-workspace/src/protobuf/proto/workspace_user_detail.proto b/rust-lib/flowy-workspace-infra/src/protobuf/proto/workspace_user_detail.proto similarity index 100% rename from rust-lib/flowy-workspace/src/protobuf/proto/workspace_user_detail.proto rename to rust-lib/flowy-workspace-infra/src/protobuf/proto/workspace_user_detail.proto diff --git a/rust-lib/flowy-workspace/Cargo.toml b/rust-lib/flowy-workspace/Cargo.toml index 72c59918d0..1016cffc8b 100644 --- a/rust-lib/flowy-workspace/Cargo.toml +++ b/rust-lib/flowy-workspace/Cargo.toml @@ -6,6 +6,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +flowy-workspace-infra = { path = "../flowy-workspace-infra" } flowy-dispatch = { path = "../flowy-dispatch" } flowy-derive = { path = "../flowy-derive" } flowy-database = { path = "../flowy-database" } @@ -23,7 +24,6 @@ diesel = {version = "1.4.7", features = ["sqlite"]} diesel_derives = {version = "1.4.1", features = ["sqlite"]} #diesel = { git = "https://github.com/diesel-rs/diesel.git", branch = "master", features = ["sqlite"] } #diesel_derives = { git = "https://github.com/diesel-rs/diesel.git", branch = "master",features = ["sqlite"] } - futures-core = { version = "0.3", default-features = false } futures = "0.3.15" pin-project = "1.0.0" @@ -34,11 +34,12 @@ lazy_static = "1.4.0" serde = { version = "1.0", features = ["derive"] } derive_more = {version = "0.99", features = ["display"]} bincode = { version = "1.3"} -unicode-segmentation = "1.7.1" tracing = { version = "0.1", features = ["log"] } bytes = { version = "1.0" } crossbeam = "0.8.1" crossbeam-utils = "0.8" + + [dev-dependencies] flowy-test = { path = "../flowy-test" } serial_test = "0.5.1" diff --git a/rust-lib/flowy-workspace/src/entities/app/mod.rs b/rust-lib/flowy-workspace/src/entities/app/mod.rs deleted file mode 100644 index e11d72e49a..0000000000 --- a/rust-lib/flowy-workspace/src/entities/app/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -#[cfg(feature = "flowy_client_sdk")] -mod app_create; -#[cfg(feature = "flowy_client_sdk")] -mod app_query; -#[cfg(feature = "flowy_client_sdk")] -mod app_update; - -#[cfg(feature = "flowy_client_sdk")] -pub use app_create::*; -#[cfg(feature = "flowy_client_sdk")] -pub use app_query::*; -#[cfg(feature = "flowy_client_sdk")] -pub use app_update::*; - -pub mod parser; diff --git a/rust-lib/flowy-workspace/src/entities/mod.rs b/rust-lib/flowy-workspace/src/entities/mod.rs deleted file mode 100644 index 70972f0352..0000000000 --- a/rust-lib/flowy-workspace/src/entities/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -pub mod app; -pub mod trash; -pub mod view; -pub mod workspace; - -pub mod parser { - pub use crate::entities::{app::parser::*, trash::parser::*, view::parser::*, workspace::parser::*}; -} diff --git a/rust-lib/flowy-workspace/src/entities/trash/mod.rs b/rust-lib/flowy-workspace/src/entities/trash/mod.rs deleted file mode 100644 index b6f1a8028b..0000000000 --- a/rust-lib/flowy-workspace/src/entities/trash/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub mod parser; - -#[cfg(feature = "flowy_client_sdk")] -mod trash_create; - -#[cfg(feature = "flowy_client_sdk")] -pub use trash_create::*; diff --git a/rust-lib/flowy-workspace/src/entities/view/mod.rs b/rust-lib/flowy-workspace/src/entities/view/mod.rs deleted file mode 100644 index a0cd9ccfdd..0000000000 --- a/rust-lib/flowy-workspace/src/entities/view/mod.rs +++ /dev/null @@ -1,14 +0,0 @@ -pub mod parser; -#[cfg(feature = "flowy_client_sdk")] -mod view_create; -#[cfg(feature = "flowy_client_sdk")] -mod view_query; -#[cfg(feature = "flowy_client_sdk")] -mod view_update; - -#[cfg(feature = "flowy_client_sdk")] -pub use view_create::*; -#[cfg(feature = "flowy_client_sdk")] -pub use view_query::*; -#[cfg(feature = "flowy_client_sdk")] -pub use view_update::*; diff --git a/rust-lib/flowy-workspace/src/entities/workspace/mod.rs b/rust-lib/flowy-workspace/src/entities/workspace/mod.rs deleted file mode 100644 index 785fcf9353..0000000000 --- a/rust-lib/flowy-workspace/src/entities/workspace/mod.rs +++ /dev/null @@ -1,23 +0,0 @@ -#[cfg(feature = "flowy_client_sdk")] -pub use workspace_create::*; -#[cfg(feature = "flowy_client_sdk")] -pub use workspace_delete::*; -#[cfg(feature = "flowy_client_sdk")] -pub use workspace_query::*; -#[cfg(feature = "flowy_client_sdk")] -pub use workspace_update::*; -#[cfg(feature = "flowy_client_sdk")] -pub use workspace_user_detail::*; - -#[cfg(feature = "flowy_client_sdk")] -mod workspace_create; -#[cfg(feature = "flowy_client_sdk")] -mod workspace_delete; -#[cfg(feature = "flowy_client_sdk")] -mod workspace_query; -#[cfg(feature = "flowy_client_sdk")] -mod workspace_update; -#[cfg(feature = "flowy_client_sdk")] -mod workspace_user_detail; - -pub mod parser; diff --git a/rust-lib/flowy-workspace/src/errors.rs b/rust-lib/flowy-workspace/src/errors.rs index 023a0de2d8..754ddca5c4 100644 --- a/rust-lib/flowy-workspace/src/errors.rs +++ b/rust-lib/flowy-workspace/src/errors.rs @@ -1,9 +1,10 @@ use bytes::Bytes; -use derive_more::Display; -use flowy_derive::{ProtoBuf, ProtoBuf_Enum}; + +use flowy_derive::ProtoBuf; use flowy_dispatch::prelude::{EventResponse, ResponseBuilder}; use flowy_document::errors::DocError; use flowy_net::errors::ErrorCode as ServerErrorCode; +pub use flowy_workspace_infra::errors::ErrorCode; use std::{convert::TryInto, fmt, fmt::Debug}; pub type WorkspaceResult = std::result::Result; @@ -11,28 +12,23 @@ pub type WorkspaceResult = std::result::Result; #[derive(Debug, Default, Clone, ProtoBuf)] pub struct WorkspaceError { #[pb(index = 1)] - pub code: ErrorCode, + pub code: i32, #[pb(index = 2)] pub msg: String, } macro_rules! static_workspace_error { - ($name:ident, $status:expr) => { + ($name:ident, $code:expr) => { #[allow(non_snake_case, missing_docs)] - pub fn $name() -> WorkspaceError { - WorkspaceError { - code: $status, - msg: format!("{}", $status), - } - } + pub fn $name() -> WorkspaceError { $code.into() } }; } impl WorkspaceError { pub fn new(code: ErrorCode, msg: &str) -> Self { Self { - code, + code: code.value(), msg: msg.to_owned(), } } @@ -40,13 +36,13 @@ impl WorkspaceError { static_workspace_error!(workspace_name, ErrorCode::WorkspaceNameInvalid); static_workspace_error!(workspace_id, ErrorCode::WorkspaceIdInvalid); static_workspace_error!(color_style, ErrorCode::AppColorStyleInvalid); - static_workspace_error!(workspace_desc, ErrorCode::WorkspaceDescInvalid); + static_workspace_error!(workspace_desc, ErrorCode::WorkspaceDescTooLong); static_workspace_error!(app_name, ErrorCode::AppNameInvalid); static_workspace_error!(invalid_app_id, ErrorCode::AppIdInvalid); static_workspace_error!(view_name, ErrorCode::ViewNameInvalid); static_workspace_error!(view_thumbnail, ErrorCode::ViewThumbnailInvalid); static_workspace_error!(invalid_view_id, ErrorCode::ViewIdInvalid); - static_workspace_error!(view_desc, ErrorCode::ViewDescInvalid); + static_workspace_error!(view_desc, ErrorCode::ViewDescTooLong); static_workspace_error!(view_data, ErrorCode::ViewDataInvalid); static_workspace_error!(unauthorized, ErrorCode::UserUnauthorized); static_workspace_error!(internal, ErrorCode::InternalError); @@ -59,53 +55,6 @@ impl WorkspaceError { } } -#[derive(Debug, Clone, ProtoBuf_Enum, Display, PartialEq, Eq)] -pub enum ErrorCode { - #[display(fmt = "Workspace name is invalid")] - WorkspaceNameInvalid = 0, - - #[display(fmt = "Workspace id is invalid")] - WorkspaceIdInvalid = 1, - - #[display(fmt = "Color style of the App is invalid")] - AppColorStyleInvalid = 2, - - #[display(fmt = "Workspace desc is invalid")] - WorkspaceDescInvalid = 3, - - #[display(fmt = "Id of the App is invalid")] - AppIdInvalid = 10, - - #[display(fmt = "Name of the App is invalid")] - AppNameInvalid = 11, - - #[display(fmt = "Name of the View is invalid")] - ViewNameInvalid = 20, - - #[display(fmt = "Thumbnail of the view is invalid")] - ViewThumbnailInvalid = 21, - - #[display(fmt = "Id of the View is invalid")] - ViewIdInvalid = 22, - - #[display(fmt = "Description of the View is invalid")] - ViewDescInvalid = 23, - - #[display(fmt = "View data is invalid")] - ViewDataInvalid = 24, - - #[display(fmt = "User unauthorized")] - UserUnauthorized = 100, - - #[display(fmt = "Workspace websocket error")] - WsConnectError = 200, - - #[display(fmt = "Server error")] - InternalError = 1000, - #[display(fmt = "Record not found")] - RecordNotFound = 1001, -} - pub fn internal_error(e: T) -> WorkspaceError where T: std::fmt::Debug, @@ -113,8 +62,13 @@ where WorkspaceError::internal().context(e) } -impl std::default::Default for ErrorCode { - fn default() -> Self { ErrorCode::InternalError } +impl std::convert::From for WorkspaceError { + fn from(code: ErrorCode) -> Self { + WorkspaceError { + code: code.value(), + msg: format!("{}", code), + } + } } impl std::convert::From for WorkspaceError { diff --git a/rust-lib/flowy-workspace/src/lib.rs b/rust-lib/flowy-workspace/src/lib.rs index 3e133634bc..1bff21d47d 100644 --- a/rust-lib/flowy-workspace/src/lib.rs +++ b/rust-lib/flowy-workspace/src/lib.rs @@ -1,5 +1,3 @@ -pub mod entities; - #[cfg(feature = "flowy_client_sdk")] pub mod event; #[cfg(feature = "flowy_client_sdk")] @@ -7,6 +5,8 @@ pub mod module; #[cfg(feature = "flowy_client_sdk")] mod services; +pub use flowy_workspace_infra::entities; + #[macro_use] mod macros; @@ -18,15 +18,6 @@ pub mod protobuf; #[cfg(feature = "flowy_client_sdk")] pub mod prelude { - pub use crate::{ - entities::{app::*, trash::*, view::*, workspace::*}, - errors::*, - module::*, - services::*, - }; -} - -#[cfg(feature = "backend_service")] -pub mod backend_service { - pub use crate::protobuf::*; + pub use crate::{errors::*, module::*, services::*}; + pub use flowy_workspace_infra::entities::{app::*, trash::*, view::*, workspace::*}; } diff --git a/rust-lib/flowy-workspace/src/protobuf/model/app_delete.rs b/rust-lib/flowy-workspace/src/protobuf/model/app_delete.rs deleted file mode 100644 index 4f4e5defc6..0000000000 --- a/rust-lib/flowy-workspace/src/protobuf/model/app_delete.rs +++ /dev/null @@ -1,369 +0,0 @@ -// This file is generated by rust-protobuf 2.22.1. Do not edit -// @generated - -// https://github.com/rust-lang/rust-clippy/issues/702 -#![allow(unknown_lints)] -#![allow(clippy::all)] - -#![allow(unused_attributes)] -#![cfg_attr(rustfmt, rustfmt::skip)] - -#![allow(box_pointers)] -#![allow(dead_code)] -#![allow(missing_docs)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(non_upper_case_globals)] -#![allow(trivial_casts)] -#![allow(unused_imports)] -#![allow(unused_results)] -//! Generated file from `app_delete.proto` - -/// Generated files are compatible only with the same version -/// of protobuf runtime. -// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1; - -#[derive(PartialEq,Clone,Default)] -pub struct DeleteAppRequest { - // message fields - pub app_id: ::std::string::String, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a DeleteAppRequest { - fn default() -> &'a DeleteAppRequest { - ::default_instance() - } -} - -impl DeleteAppRequest { - pub fn new() -> DeleteAppRequest { - ::std::default::Default::default() - } - - // string app_id = 1; - - - pub fn get_app_id(&self) -> &str { - &self.app_id - } - pub fn clear_app_id(&mut self) { - self.app_id.clear(); - } - - // Param is passed by value, moved - pub fn set_app_id(&mut self, v: ::std::string::String) { - self.app_id = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_app_id(&mut self) -> &mut ::std::string::String { - &mut self.app_id - } - - // Take field - pub fn take_app_id(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.app_id, ::std::string::String::new()) - } -} - -impl ::protobuf::Message for DeleteAppRequest { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.app_id)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if !self.app_id.is_empty() { - my_size += ::protobuf::rt::string_size(1, &self.app_id); - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - if !self.app_id.is_empty() { - os.write_string(1, &self.app_id)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &dyn (::std::any::Any) { - self as &dyn (::std::any::Any) - } - fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { - self as &mut dyn (::std::any::Any) - } - fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> DeleteAppRequest { - DeleteAppRequest::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "app_id", - |m: &DeleteAppRequest| { &m.app_id }, - |m: &mut DeleteAppRequest| { &mut m.app_id }, - )); - ::protobuf::reflect::MessageDescriptor::new_pb_name::( - "DeleteAppRequest", - fields, - file_descriptor_proto() - ) - }) - } - - fn default_instance() -> &'static DeleteAppRequest { - static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; - instance.get(DeleteAppRequest::new) - } -} - -impl ::protobuf::Clear for DeleteAppRequest { - fn clear(&mut self) { - self.app_id.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for DeleteAppRequest { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for DeleteAppRequest { - fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { - ::protobuf::reflect::ReflectValueRef::Message(self) - } -} - -#[derive(PartialEq,Clone,Default)] -pub struct DeleteAppParams { - // message fields - pub app_id: ::std::string::String, - // special fields - pub unknown_fields: ::protobuf::UnknownFields, - pub cached_size: ::protobuf::CachedSize, -} - -impl<'a> ::std::default::Default for &'a DeleteAppParams { - fn default() -> &'a DeleteAppParams { - ::default_instance() - } -} - -impl DeleteAppParams { - pub fn new() -> DeleteAppParams { - ::std::default::Default::default() - } - - // string app_id = 1; - - - pub fn get_app_id(&self) -> &str { - &self.app_id - } - pub fn clear_app_id(&mut self) { - self.app_id.clear(); - } - - // Param is passed by value, moved - pub fn set_app_id(&mut self, v: ::std::string::String) { - self.app_id = v; - } - - // Mutable pointer to the field. - // If field is not initialized, it is initialized with default value first. - pub fn mut_app_id(&mut self) -> &mut ::std::string::String { - &mut self.app_id - } - - // Take field - pub fn take_app_id(&mut self) -> ::std::string::String { - ::std::mem::replace(&mut self.app_id, ::std::string::String::new()) - } -} - -impl ::protobuf::Message for DeleteAppParams { - fn is_initialized(&self) -> bool { - true - } - - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { - while !is.eof()? { - let (field_number, wire_type) = is.read_tag_unpack()?; - match field_number { - 1 => { - ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.app_id)?; - }, - _ => { - ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; - }, - }; - } - ::std::result::Result::Ok(()) - } - - // Compute sizes of nested messages - #[allow(unused_variables)] - fn compute_size(&self) -> u32 { - let mut my_size = 0; - if !self.app_id.is_empty() { - my_size += ::protobuf::rt::string_size(1, &self.app_id); - } - my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); - self.cached_size.set(my_size); - my_size - } - - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - if !self.app_id.is_empty() { - os.write_string(1, &self.app_id)?; - } - os.write_unknown_fields(self.get_unknown_fields())?; - ::std::result::Result::Ok(()) - } - - fn get_cached_size(&self) -> u32 { - self.cached_size.get() - } - - fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { - &self.unknown_fields - } - - fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { - &mut self.unknown_fields - } - - fn as_any(&self) -> &dyn (::std::any::Any) { - self as &dyn (::std::any::Any) - } - fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { - self as &mut dyn (::std::any::Any) - } - fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { - self - } - - fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - Self::descriptor_static() - } - - fn new() -> DeleteAppParams { - DeleteAppParams::new() - } - - fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { - static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "app_id", - |m: &DeleteAppParams| { &m.app_id }, - |m: &mut DeleteAppParams| { &mut m.app_id }, - )); - ::protobuf::reflect::MessageDescriptor::new_pb_name::( - "DeleteAppParams", - fields, - file_descriptor_proto() - ) - }) - } - - fn default_instance() -> &'static DeleteAppParams { - static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; - instance.get(DeleteAppParams::new) - } -} - -impl ::protobuf::Clear for DeleteAppParams { - fn clear(&mut self) { - self.app_id.clear(); - self.unknown_fields.clear(); - } -} - -impl ::std::fmt::Debug for DeleteAppParams { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - ::protobuf::text_format::fmt(self, f) - } -} - -impl ::protobuf::reflect::ProtobufValue for DeleteAppParams { - fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { - ::protobuf::reflect::ReflectValueRef::Message(self) - } -} - -static file_descriptor_proto_data: &'static [u8] = b"\ - \n\x10app_delete.proto\")\n\x10DeleteAppRequest\x12\x15\n\x06app_id\x18\ - \x01\x20\x01(\tR\x05appId\"(\n\x0fDeleteAppParams\x12\x15\n\x06app_id\ - \x18\x01\x20\x01(\tR\x05appIdJ\xb0\x01\n\x06\x12\x04\0\0\x07\x01\n\x08\n\ - \x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x04\x01\n\n\n\x03\ - \x04\0\x01\x12\x03\x02\x08\x18\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\ - \x16\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\x03\x04\n\n\x0c\n\x05\x04\0\x02\ - \0\x01\x12\x03\x03\x0b\x11\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x14\ - \x15\n\n\n\x02\x04\x01\x12\x04\x05\0\x07\x01\n\n\n\x03\x04\x01\x01\x12\ - \x03\x05\x08\x17\n\x0b\n\x04\x04\x01\x02\0\x12\x03\x06\x04\x16\n\x0c\n\ - \x05\x04\x01\x02\0\x05\x12\x03\x06\x04\n\n\x0c\n\x05\x04\x01\x02\0\x01\ - \x12\x03\x06\x0b\x11\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03\x06\x14\x15b\ - \x06proto3\ -"; - -static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; - -fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { - ::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap() -} - -pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { - file_descriptor_proto_lazy.get(|| { - parse_descriptor_proto() - }) -} diff --git a/rust-lib/flowy-workspace/src/protobuf/model/errors.rs b/rust-lib/flowy-workspace/src/protobuf/model/errors.rs index 848ded9495..4fd34284af 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: ErrorCode, + pub code: i32, pub msg: ::std::string::String, // special fields pub unknown_fields: ::protobuf::UnknownFields, @@ -44,18 +44,18 @@ impl WorkspaceError { ::std::default::Default::default() } - // .ErrorCode code = 1; + // int32 code = 1; - pub fn get_code(&self) -> ErrorCode { + pub fn get_code(&self) -> i32 { self.code } pub fn clear_code(&mut self) { - self.code = ErrorCode::WorkspaceNameInvalid; + self.code = 0; } // Param is passed by value, moved - pub fn set_code(&mut self, v: ErrorCode) { + pub fn set_code(&mut self, v: i32) { self.code = v; } @@ -96,7 +96,11 @@ impl ::protobuf::Message for WorkspaceError { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { 1 => { - ::protobuf::rt::read_proto3_enum_with_unknown_fields_into(wire_type, is, &mut self.code, 1, &mut self.unknown_fields)? + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_int32()?; + self.code = tmp; }, 2 => { ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.msg)?; @@ -113,8 +117,8 @@ impl ::protobuf::Message for WorkspaceError { #[allow(unused_variables)] fn compute_size(&self) -> u32 { let mut my_size = 0; - if self.code != ErrorCode::WorkspaceNameInvalid { - my_size += ::protobuf::rt::enum_size(1, self.code); + if self.code != 0 { + my_size += ::protobuf::rt::value_size(1, self.code, ::protobuf::wire_format::WireTypeVarint); } if !self.msg.is_empty() { my_size += ::protobuf::rt::string_size(2, &self.msg); @@ -125,8 +129,8 @@ impl ::protobuf::Message for WorkspaceError { } fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { - if self.code != ErrorCode::WorkspaceNameInvalid { - os.write_enum(1, ::protobuf::ProtobufEnum::value(&self.code))?; + if self.code != 0 { + os.write_int32(1, self.code)?; } if !self.msg.is_empty() { os.write_string(2, &self.msg)?; @@ -169,7 +173,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::ProtobufTypeInt32>( "code", |m: &WorkspaceError| { &m.code }, |m: &mut WorkspaceError| { &mut m.code }, @@ -195,7 +199,7 @@ impl ::protobuf::Message for WorkspaceError { impl ::protobuf::Clear for WorkspaceError { fn clear(&mut self) { - self.code = ErrorCode::WorkspaceNameInvalid; + self.code = 0; self.msg.clear(); self.unknown_fields.clear(); } @@ -213,146 +217,17 @@ impl ::protobuf::reflect::ProtobufValue for WorkspaceError { } } -#[derive(Clone,PartialEq,Eq,Debug,Hash)] -pub enum ErrorCode { - WorkspaceNameInvalid = 0, - WorkspaceIdInvalid = 1, - AppColorStyleInvalid = 2, - WorkspaceDescInvalid = 3, - AppIdInvalid = 10, - AppNameInvalid = 11, - ViewNameInvalid = 20, - ViewThumbnailInvalid = 21, - ViewIdInvalid = 22, - ViewDescInvalid = 23, - ViewDataInvalid = 24, - UserUnauthorized = 100, - WsConnectError = 200, - InternalError = 1000, - RecordNotFound = 1001, -} - -impl ::protobuf::ProtobufEnum for ErrorCode { - fn value(&self) -> i32 { - *self as i32 - } - - fn from_i32(value: i32) -> ::std::option::Option { - match value { - 0 => ::std::option::Option::Some(ErrorCode::WorkspaceNameInvalid), - 1 => ::std::option::Option::Some(ErrorCode::WorkspaceIdInvalid), - 2 => ::std::option::Option::Some(ErrorCode::AppColorStyleInvalid), - 3 => ::std::option::Option::Some(ErrorCode::WorkspaceDescInvalid), - 10 => ::std::option::Option::Some(ErrorCode::AppIdInvalid), - 11 => ::std::option::Option::Some(ErrorCode::AppNameInvalid), - 20 => ::std::option::Option::Some(ErrorCode::ViewNameInvalid), - 21 => ::std::option::Option::Some(ErrorCode::ViewThumbnailInvalid), - 22 => ::std::option::Option::Some(ErrorCode::ViewIdInvalid), - 23 => ::std::option::Option::Some(ErrorCode::ViewDescInvalid), - 24 => ::std::option::Option::Some(ErrorCode::ViewDataInvalid), - 100 => ::std::option::Option::Some(ErrorCode::UserUnauthorized), - 200 => ::std::option::Option::Some(ErrorCode::WsConnectError), - 1000 => ::std::option::Option::Some(ErrorCode::InternalError), - 1001 => ::std::option::Option::Some(ErrorCode::RecordNotFound), - _ => ::std::option::Option::None - } - } - - fn values() -> &'static [Self] { - static values: &'static [ErrorCode] = &[ - ErrorCode::WorkspaceNameInvalid, - ErrorCode::WorkspaceIdInvalid, - ErrorCode::AppColorStyleInvalid, - ErrorCode::WorkspaceDescInvalid, - ErrorCode::AppIdInvalid, - ErrorCode::AppNameInvalid, - ErrorCode::ViewNameInvalid, - ErrorCode::ViewThumbnailInvalid, - ErrorCode::ViewIdInvalid, - ErrorCode::ViewDescInvalid, - ErrorCode::ViewDataInvalid, - ErrorCode::UserUnauthorized, - ErrorCode::WsConnectError, - ErrorCode::InternalError, - ErrorCode::RecordNotFound, - ]; - values - } - - 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::("ErrorCode", file_descriptor_proto()) - }) - } -} - -impl ::std::marker::Copy for ErrorCode { -} - -impl ::std::default::Default for ErrorCode { - fn default() -> Self { - ErrorCode::WorkspaceNameInvalid - } -} - -impl ::protobuf::reflect::ProtobufValue for ErrorCode { - 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\"B\n\x0eWorkspaceError\x12\x1e\n\x04code\x18\x01\x20\ - \x01(\x0e2\n.ErrorCodeR\x04code\x12\x10\n\x03msg\x18\x02\x20\x01(\tR\x03\ - msg*\xd7\x02\n\tErrorCode\x12\x18\n\x14WorkspaceNameInvalid\x10\0\x12\ - \x16\n\x12WorkspaceIdInvalid\x10\x01\x12\x18\n\x14AppColorStyleInvalid\ - \x10\x02\x12\x18\n\x14WorkspaceDescInvalid\x10\x03\x12\x10\n\x0cAppIdInv\ - alid\x10\n\x12\x12\n\x0eAppNameInvalid\x10\x0b\x12\x13\n\x0fViewNameInva\ - lid\x10\x14\x12\x18\n\x14ViewThumbnailInvalid\x10\x15\x12\x11\n\rViewIdI\ - nvalid\x10\x16\x12\x13\n\x0fViewDescInvalid\x10\x17\x12\x13\n\x0fViewDat\ - aInvalid\x10\x18\x12\x14\n\x10UserUnauthorized\x10d\x12\x13\n\x0eWsConne\ - ctError\x10\xc8\x01\x12\x12\n\rInternalError\x10\xe8\x07\x12\x13\n\x0eRe\ - cordNotFound\x10\xe9\x07J\x97\x06\n\x06\x12\x04\0\0\x16\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\x16\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\x1d\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x07\ - \x04\x18\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x07\x1b\x1c\n\x0b\n\x04\x05\ - \0\x02\x01\x12\x03\x08\x04\x1b\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x08\ - \x04\x16\n\x0c\n\x05\x05\0\x02\x01\x02\x12\x03\x08\x19\x1a\n\x0b\n\x04\ - \x05\0\x02\x02\x12\x03\t\x04\x1d\n\x0c\n\x05\x05\0\x02\x02\x01\x12\x03\t\ - \x04\x18\n\x0c\n\x05\x05\0\x02\x02\x02\x12\x03\t\x1b\x1c\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\x19\n\x0c\n\x05\x05\0\x02\n\x01\ - \x12\x03\x11\x04\x13\n\x0c\n\x05\x05\0\x02\n\x02\x12\x03\x11\x16\x18\n\ - \x0b\n\x04\x05\0\x02\x0b\x12\x03\x12\x04\x1b\n\x0c\n\x05\x05\0\x02\x0b\ - \x01\x12\x03\x12\x04\x14\n\x0c\n\x05\x05\0\x02\x0b\x02\x12\x03\x12\x17\ - \x1a\n\x0b\n\x04\x05\0\x02\x0c\x12\x03\x13\x04\x19\n\x0c\n\x05\x05\0\x02\ - \x0c\x01\x12\x03\x13\x04\x12\n\x0c\n\x05\x05\0\x02\x0c\x02\x12\x03\x13\ - \x15\x18\n\x0b\n\x04\x05\0\x02\r\x12\x03\x14\x04\x19\n\x0c\n\x05\x05\0\ - \x02\r\x01\x12\x03\x14\x04\x11\n\x0c\n\x05\x05\0\x02\r\x02\x12\x03\x14\ - \x14\x18\n\x0b\n\x04\x05\0\x02\x0e\x12\x03\x15\x04\x1a\n\x0c\n\x05\x05\0\ - \x02\x0e\x01\x12\x03\x15\x04\x12\n\x0c\n\x05\x05\0\x02\x0e\x02\x12\x03\ - \x15\x15\x19b\x06proto3\ + \n\x0cerrors.proto\"6\n\x0eWorkspaceError\x12\x12\n\x04code\x18\x01\x20\ + \x01(\x05R\x04code\x12\x10\n\x03msg\x18\x02\x20\x01(\tR\x03msgJ\x98\x01\ + \n\x06\x12\x04\0\0\x05\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x04\ + \0\x12\x04\x02\0\x05\x01\n\n\n\x03\x04\0\x01\x12\x03\x02\x08\x16\n\x0b\n\ + \x04\x04\0\x02\0\x12\x03\x03\x04\x13\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\ + \x03\x04\t\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\n\x0e\n\x0c\n\x05\x04\ + \0\x02\0\x03\x12\x03\x03\x11\x12\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x04\ + \x04\x13\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x04\x04\n\n\x0c\n\x05\x04\ + \0\x02\x01\x01\x12\x03\x04\x0b\x0e\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\ + \x04\x11\x12b\x06proto3\ "; static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; diff --git a/rust-lib/flowy-workspace/src/protobuf/model/mod.rs b/rust-lib/flowy-workspace/src/protobuf/model/mod.rs index c76475bf7b..35cbf4e069 100644 --- a/rust-lib/flowy-workspace/src/protobuf/model/mod.rs +++ b/rust-lib/flowy-workspace/src/protobuf/model/mod.rs @@ -1,49 +1,10 @@ // Auto-generated, do not edit -mod view_update; -pub use view_update::*; - -mod app_query; -pub use app_query::*; - -mod workspace_delete; -pub use workspace_delete::*; - mod observable; pub use observable::*; mod errors; pub use errors::*; -mod workspace_update; -pub use workspace_update::*; - -mod app_create; -pub use app_create::*; - -mod workspace_query; -pub use workspace_query::*; - mod event; pub use event::*; - -mod view_create; -pub use view_create::*; - -mod workspace_user_detail; -pub use workspace_user_detail::*; - -mod workspace_create; -pub use workspace_create::*; - -mod app_update; -pub use app_update::*; - -mod view_query; -pub use view_query::*; - -mod trash_create; -pub use trash_create::*; - -mod app_delete; -pub use app_delete::*; diff --git a/rust-lib/flowy-workspace/src/protobuf/proto/app_delete.proto b/rust-lib/flowy-workspace/src/protobuf/proto/app_delete.proto deleted file mode 100644 index 1f13f1c55d..0000000000 --- a/rust-lib/flowy-workspace/src/protobuf/proto/app_delete.proto +++ /dev/null @@ -1,8 +0,0 @@ -syntax = "proto3"; - -message DeleteAppRequest { - string app_id = 1; -} -message DeleteAppParams { - string app_id = 1; -} diff --git a/rust-lib/flowy-workspace/src/protobuf/proto/errors.proto b/rust-lib/flowy-workspace/src/protobuf/proto/errors.proto index 81830b8638..b67c663608 100644 --- a/rust-lib/flowy-workspace/src/protobuf/proto/errors.proto +++ b/rust-lib/flowy-workspace/src/protobuf/proto/errors.proto @@ -1,23 +1,6 @@ syntax = "proto3"; message WorkspaceError { - ErrorCode code = 1; + int32 code = 1; string msg = 2; } -enum ErrorCode { - WorkspaceNameInvalid = 0; - WorkspaceIdInvalid = 1; - AppColorStyleInvalid = 2; - WorkspaceDescInvalid = 3; - AppIdInvalid = 10; - AppNameInvalid = 11; - ViewNameInvalid = 20; - ViewThumbnailInvalid = 21; - ViewIdInvalid = 22; - ViewDescInvalid = 23; - ViewDataInvalid = 24; - UserUnauthorized = 100; - WsConnectError = 200; - InternalError = 1000; - RecordNotFound = 1001; -} diff --git a/rust-lib/flowy-workspace/tests/workspace/workspace_test.rs b/rust-lib/flowy-workspace/tests/workspace/workspace_test.rs index d5bef1caf5..0bc08519c2 100644 --- a/rust-lib/flowy-workspace/tests/workspace/workspace_test.rs +++ b/rust-lib/flowy-workspace/tests/workspace/workspace_test.rs @@ -45,7 +45,7 @@ async fn workspace_create_with_invalid_name() { .await .error() .code, - ErrorCode::WorkspaceNameInvalid + ErrorCode::WorkspaceNameInvalid.value() ) } } @@ -66,7 +66,7 @@ async fn workspace_update_with_invalid_name() { .await .error() .code, - ErrorCode::WorkspaceNameInvalid + ErrorCode::WorkspaceNameInvalid.value() ) } }