mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix some test bugs when dispatcher initialize by multi threads
This commit is contained in:
parent
5d94c63377
commit
ae23a41445
@ -2,34 +2,12 @@
|
||||
|
||||
/// Auto gen code from rust ast, do not edit
|
||||
part of 'dispatch.dart';
|
||||
class UserEventAuthCheck {
|
||||
UserSignInParams params;
|
||||
UserEventAuthCheck(this.params);
|
||||
|
||||
Future<Either<UserSignInResult, FlowyError>> send() {
|
||||
return paramsToBytes(params).fold(
|
||||
(bytes) {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.AuthCheck.toString()
|
||||
..payload = bytes;
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(UserSignInResult.fromBuffer(bytes)),
|
||||
(error) => right(error),
|
||||
));
|
||||
},
|
||||
(err) => Future(() => right(err)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventSignIn {
|
||||
UserSignInParams params;
|
||||
UserEventSignIn(this.params);
|
||||
SignInRequest request;
|
||||
UserEventSignIn(this.request);
|
||||
|
||||
Future<Either<UserSignInResult, FlowyError>> send() {
|
||||
return paramsToBytes(params).fold(
|
||||
Future<Either<SignInResponse, FlowyError>> send() {
|
||||
return requestToBytes(request).fold(
|
||||
(bytes) {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.SignIn.toString()
|
||||
@ -37,7 +15,29 @@ class UserEventSignIn {
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(UserSignInResult.fromBuffer(bytes)),
|
||||
(bytes) => left(SignInResponse.fromBuffer(bytes)),
|
||||
(error) => right(error),
|
||||
));
|
||||
},
|
||||
(err) => Future(() => right(err)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventSignUp {
|
||||
SignUpRequest request;
|
||||
UserEventSignUp(this.request);
|
||||
|
||||
Future<Either<SignUpResponse, FlowyError>> send() {
|
||||
return requestToBytes(request).fold(
|
||||
(bytes) {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.SignUp.toString()
|
||||
..payload = bytes;
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(SignUpResponse.fromBuffer(bytes)),
|
||||
(error) => right(error),
|
||||
));
|
||||
},
|
||||
|
@ -86,7 +86,7 @@ Completer<Uint8List> _sendToRust(FFIRequest request) {
|
||||
return completer;
|
||||
}
|
||||
|
||||
Either<Uint8List, FlowyError> paramsToBytes<T extends GeneratedMessage>(
|
||||
Either<Uint8List, FlowyError> requestToBytes<T extends GeneratedMessage>(
|
||||
T? message) {
|
||||
try {
|
||||
if (message != null) {
|
||||
|
@ -9,15 +9,15 @@ import 'dart:core' as $core;
|
||||
|
||||
import 'package:protobuf/protobuf.dart' as $pb;
|
||||
|
||||
class UserSignInParams extends $pb.GeneratedMessage {
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UserSignInParams', createEmptyInstance: create)
|
||||
class SignInRequest extends $pb.GeneratedMessage {
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'SignInRequest', createEmptyInstance: create)
|
||||
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'email')
|
||||
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'password')
|
||||
..hasRequiredFields = false
|
||||
;
|
||||
|
||||
UserSignInParams._() : super();
|
||||
factory UserSignInParams({
|
||||
SignInRequest._() : super();
|
||||
factory SignInRequest({
|
||||
$core.String? email,
|
||||
$core.String? password,
|
||||
}) {
|
||||
@ -30,26 +30,26 @@ class UserSignInParams extends $pb.GeneratedMessage {
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
factory UserSignInParams.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
|
||||
factory UserSignInParams.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
|
||||
factory SignInRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
|
||||
factory SignInRequest.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')
|
||||
UserSignInParams clone() => UserSignInParams()..mergeFromMessage(this);
|
||||
SignInRequest clone() => SignInRequest()..mergeFromMessage(this);
|
||||
@$core.Deprecated(
|
||||
'Using this can add significant overhead to your binary. '
|
||||
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
|
||||
'Will be removed in next major version')
|
||||
UserSignInParams copyWith(void Function(UserSignInParams) updates) => super.copyWith((message) => updates(message as UserSignInParams)) as UserSignInParams; // ignore: deprecated_member_use
|
||||
SignInRequest copyWith(void Function(SignInRequest) updates) => super.copyWith((message) => updates(message as SignInRequest)) as SignInRequest; // ignore: deprecated_member_use
|
||||
$pb.BuilderInfo get info_ => _i;
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static UserSignInParams create() => UserSignInParams._();
|
||||
UserSignInParams createEmptyInstance() => create();
|
||||
static $pb.PbList<UserSignInParams> createRepeated() => $pb.PbList<UserSignInParams>();
|
||||
static SignInRequest create() => SignInRequest._();
|
||||
SignInRequest createEmptyInstance() => create();
|
||||
static $pb.PbList<SignInRequest> createRepeated() => $pb.PbList<SignInRequest>();
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static UserSignInParams getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<UserSignInParams>(create);
|
||||
static UserSignInParams? _defaultInstance;
|
||||
static SignInRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<SignInRequest>(create);
|
||||
static SignInRequest? _defaultInstance;
|
||||
|
||||
@$pb.TagNumber(1)
|
||||
$core.String get email => $_getSZ(0);
|
||||
@ -70,15 +70,15 @@ class UserSignInParams extends $pb.GeneratedMessage {
|
||||
void clearPassword() => clearField(2);
|
||||
}
|
||||
|
||||
class UserSignInRequest extends $pb.GeneratedMessage {
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UserSignInRequest', createEmptyInstance: create)
|
||||
class SignInParams extends $pb.GeneratedMessage {
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'SignInParams', createEmptyInstance: create)
|
||||
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'email')
|
||||
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'password')
|
||||
..hasRequiredFields = false
|
||||
;
|
||||
|
||||
UserSignInRequest._() : super();
|
||||
factory UserSignInRequest({
|
||||
SignInParams._() : super();
|
||||
factory SignInParams({
|
||||
$core.String? email,
|
||||
$core.String? password,
|
||||
}) {
|
||||
@ -91,26 +91,26 @@ class UserSignInRequest extends $pb.GeneratedMessage {
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
factory UserSignInRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
|
||||
factory UserSignInRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
|
||||
factory SignInParams.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
|
||||
factory SignInParams.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')
|
||||
UserSignInRequest clone() => UserSignInRequest()..mergeFromMessage(this);
|
||||
SignInParams clone() => SignInParams()..mergeFromMessage(this);
|
||||
@$core.Deprecated(
|
||||
'Using this can add significant overhead to your binary. '
|
||||
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
|
||||
'Will be removed in next major version')
|
||||
UserSignInRequest copyWith(void Function(UserSignInRequest) updates) => super.copyWith((message) => updates(message as UserSignInRequest)) as UserSignInRequest; // ignore: deprecated_member_use
|
||||
SignInParams copyWith(void Function(SignInParams) updates) => super.copyWith((message) => updates(message as SignInParams)) as SignInParams; // ignore: deprecated_member_use
|
||||
$pb.BuilderInfo get info_ => _i;
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static UserSignInRequest create() => UserSignInRequest._();
|
||||
UserSignInRequest createEmptyInstance() => create();
|
||||
static $pb.PbList<UserSignInRequest> createRepeated() => $pb.PbList<UserSignInRequest>();
|
||||
static SignInParams create() => SignInParams._();
|
||||
SignInParams createEmptyInstance() => create();
|
||||
static $pb.PbList<SignInParams> createRepeated() => $pb.PbList<SignInParams>();
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static UserSignInRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<UserSignInRequest>(create);
|
||||
static UserSignInRequest? _defaultInstance;
|
||||
static SignInParams getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<SignInParams>(create);
|
||||
static SignInParams? _defaultInstance;
|
||||
|
||||
@$pb.TagNumber(1)
|
||||
$core.String get email => $_getSZ(0);
|
||||
@ -131,14 +131,14 @@ class UserSignInRequest extends $pb.GeneratedMessage {
|
||||
void clearPassword() => clearField(2);
|
||||
}
|
||||
|
||||
class UserSignInResult extends $pb.GeneratedMessage {
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UserSignInResult', createEmptyInstance: create)
|
||||
class SignInResponse extends $pb.GeneratedMessage {
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'SignInResponse', createEmptyInstance: create)
|
||||
..aOB(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'isSuccess')
|
||||
..hasRequiredFields = false
|
||||
;
|
||||
|
||||
UserSignInResult._() : super();
|
||||
factory UserSignInResult({
|
||||
SignInResponse._() : super();
|
||||
factory SignInResponse({
|
||||
$core.bool? isSuccess,
|
||||
}) {
|
||||
final _result = create();
|
||||
@ -147,26 +147,26 @@ class UserSignInResult extends $pb.GeneratedMessage {
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
factory UserSignInResult.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
|
||||
factory UserSignInResult.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
|
||||
factory SignInResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
|
||||
factory SignInResponse.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')
|
||||
UserSignInResult clone() => UserSignInResult()..mergeFromMessage(this);
|
||||
SignInResponse clone() => SignInResponse()..mergeFromMessage(this);
|
||||
@$core.Deprecated(
|
||||
'Using this can add significant overhead to your binary. '
|
||||
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
|
||||
'Will be removed in next major version')
|
||||
UserSignInResult copyWith(void Function(UserSignInResult) updates) => super.copyWith((message) => updates(message as UserSignInResult)) as UserSignInResult; // ignore: deprecated_member_use
|
||||
SignInResponse copyWith(void Function(SignInResponse) updates) => super.copyWith((message) => updates(message as SignInResponse)) as SignInResponse; // ignore: deprecated_member_use
|
||||
$pb.BuilderInfo get info_ => _i;
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static UserSignInResult create() => UserSignInResult._();
|
||||
UserSignInResult createEmptyInstance() => create();
|
||||
static $pb.PbList<UserSignInResult> createRepeated() => $pb.PbList<UserSignInResult>();
|
||||
static SignInResponse create() => SignInResponse._();
|
||||
SignInResponse createEmptyInstance() => create();
|
||||
static $pb.PbList<SignInResponse> createRepeated() => $pb.PbList<SignInResponse>();
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static UserSignInResult getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<UserSignInResult>(create);
|
||||
static UserSignInResult? _defaultInstance;
|
||||
static SignInResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<SignInResponse>(create);
|
||||
static SignInResponse? _defaultInstance;
|
||||
|
||||
@$pb.TagNumber(1)
|
||||
$core.bool get isSuccess => $_getBF(0);
|
||||
|
@ -6,24 +6,24 @@
|
||||
// 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;
|
||||
const UserSignInParams$json = const {
|
||||
'1': 'UserSignInParams',
|
||||
const SignInRequest$json = const {
|
||||
'1': 'SignInRequest',
|
||||
'2': const [
|
||||
const {'1': 'email', '3': 1, '4': 1, '5': 9, '10': 'email'},
|
||||
const {'1': 'password', '3': 2, '4': 1, '5': 9, '10': 'password'},
|
||||
],
|
||||
};
|
||||
|
||||
const UserSignInRequest$json = const {
|
||||
'1': 'UserSignInRequest',
|
||||
const SignInParams$json = const {
|
||||
'1': 'SignInParams',
|
||||
'2': const [
|
||||
const {'1': 'email', '3': 1, '4': 1, '5': 9, '10': 'email'},
|
||||
const {'1': 'password', '3': 2, '4': 1, '5': 9, '10': 'password'},
|
||||
],
|
||||
};
|
||||
|
||||
const UserSignInResult$json = const {
|
||||
'1': 'UserSignInResult',
|
||||
const SignInResponse$json = const {
|
||||
'1': 'SignInResponse',
|
||||
'2': const [
|
||||
const {'1': 'is_success', '3': 1, '4': 1, '5': 8, '10': 'isSuccess'},
|
||||
],
|
||||
|
@ -9,16 +9,16 @@ import 'dart:core' as $core;
|
||||
|
||||
import 'package:protobuf/protobuf.dart' as $pb;
|
||||
|
||||
class UserSignUpParams extends $pb.GeneratedMessage {
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UserSignUpParams', createEmptyInstance: create)
|
||||
class SignUpRequest extends $pb.GeneratedMessage {
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'SignUpRequest', createEmptyInstance: create)
|
||||
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'email')
|
||||
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name')
|
||||
..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'password')
|
||||
..hasRequiredFields = false
|
||||
;
|
||||
|
||||
UserSignUpParams._() : super();
|
||||
factory UserSignUpParams({
|
||||
SignUpRequest._() : super();
|
||||
factory SignUpRequest({
|
||||
$core.String? email,
|
||||
$core.String? name,
|
||||
$core.String? password,
|
||||
@ -35,26 +35,26 @@ class UserSignUpParams extends $pb.GeneratedMessage {
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
factory UserSignUpParams.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
|
||||
factory UserSignUpParams.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
|
||||
factory SignUpRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
|
||||
factory SignUpRequest.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')
|
||||
UserSignUpParams clone() => UserSignUpParams()..mergeFromMessage(this);
|
||||
SignUpRequest clone() => SignUpRequest()..mergeFromMessage(this);
|
||||
@$core.Deprecated(
|
||||
'Using this can add significant overhead to your binary. '
|
||||
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
|
||||
'Will be removed in next major version')
|
||||
UserSignUpParams copyWith(void Function(UserSignUpParams) updates) => super.copyWith((message) => updates(message as UserSignUpParams)) as UserSignUpParams; // ignore: deprecated_member_use
|
||||
SignUpRequest copyWith(void Function(SignUpRequest) updates) => super.copyWith((message) => updates(message as SignUpRequest)) as SignUpRequest; // ignore: deprecated_member_use
|
||||
$pb.BuilderInfo get info_ => _i;
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static UserSignUpParams create() => UserSignUpParams._();
|
||||
UserSignUpParams createEmptyInstance() => create();
|
||||
static $pb.PbList<UserSignUpParams> createRepeated() => $pb.PbList<UserSignUpParams>();
|
||||
static SignUpRequest create() => SignUpRequest._();
|
||||
SignUpRequest createEmptyInstance() => create();
|
||||
static $pb.PbList<SignUpRequest> createRepeated() => $pb.PbList<SignUpRequest>();
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static UserSignUpParams getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<UserSignUpParams>(create);
|
||||
static UserSignUpParams? _defaultInstance;
|
||||
static SignUpRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<SignUpRequest>(create);
|
||||
static SignUpRequest? _defaultInstance;
|
||||
|
||||
@$pb.TagNumber(1)
|
||||
$core.String get email => $_getSZ(0);
|
||||
@ -84,16 +84,16 @@ class UserSignUpParams extends $pb.GeneratedMessage {
|
||||
void clearPassword() => clearField(3);
|
||||
}
|
||||
|
||||
class UserSignUpRequest extends $pb.GeneratedMessage {
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UserSignUpRequest', createEmptyInstance: create)
|
||||
class SignUpParams extends $pb.GeneratedMessage {
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'SignUpParams', createEmptyInstance: create)
|
||||
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'email')
|
||||
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name')
|
||||
..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'password')
|
||||
..hasRequiredFields = false
|
||||
;
|
||||
|
||||
UserSignUpRequest._() : super();
|
||||
factory UserSignUpRequest({
|
||||
SignUpParams._() : super();
|
||||
factory SignUpParams({
|
||||
$core.String? email,
|
||||
$core.String? name,
|
||||
$core.String? password,
|
||||
@ -110,26 +110,26 @@ class UserSignUpRequest extends $pb.GeneratedMessage {
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
factory UserSignUpRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
|
||||
factory UserSignUpRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
|
||||
factory SignUpParams.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
|
||||
factory SignUpParams.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')
|
||||
UserSignUpRequest clone() => UserSignUpRequest()..mergeFromMessage(this);
|
||||
SignUpParams clone() => SignUpParams()..mergeFromMessage(this);
|
||||
@$core.Deprecated(
|
||||
'Using this can add significant overhead to your binary. '
|
||||
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
|
||||
'Will be removed in next major version')
|
||||
UserSignUpRequest copyWith(void Function(UserSignUpRequest) updates) => super.copyWith((message) => updates(message as UserSignUpRequest)) as UserSignUpRequest; // ignore: deprecated_member_use
|
||||
SignUpParams copyWith(void Function(SignUpParams) updates) => super.copyWith((message) => updates(message as SignUpParams)) as SignUpParams; // ignore: deprecated_member_use
|
||||
$pb.BuilderInfo get info_ => _i;
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static UserSignUpRequest create() => UserSignUpRequest._();
|
||||
UserSignUpRequest createEmptyInstance() => create();
|
||||
static $pb.PbList<UserSignUpRequest> createRepeated() => $pb.PbList<UserSignUpRequest>();
|
||||
static SignUpParams create() => SignUpParams._();
|
||||
SignUpParams createEmptyInstance() => create();
|
||||
static $pb.PbList<SignUpParams> createRepeated() => $pb.PbList<SignUpParams>();
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static UserSignUpRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<UserSignUpRequest>(create);
|
||||
static UserSignUpRequest? _defaultInstance;
|
||||
static SignUpParams getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<SignUpParams>(create);
|
||||
static SignUpParams? _defaultInstance;
|
||||
|
||||
@$pb.TagNumber(1)
|
||||
$core.String get email => $_getSZ(0);
|
||||
@ -159,14 +159,14 @@ class UserSignUpRequest extends $pb.GeneratedMessage {
|
||||
void clearPassword() => clearField(3);
|
||||
}
|
||||
|
||||
class UserSignUpResult extends $pb.GeneratedMessage {
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UserSignUpResult', createEmptyInstance: create)
|
||||
class SignUpResponse extends $pb.GeneratedMessage {
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'SignUpResponse', createEmptyInstance: create)
|
||||
..aOB(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'isSuccess')
|
||||
..hasRequiredFields = false
|
||||
;
|
||||
|
||||
UserSignUpResult._() : super();
|
||||
factory UserSignUpResult({
|
||||
SignUpResponse._() : super();
|
||||
factory SignUpResponse({
|
||||
$core.bool? isSuccess,
|
||||
}) {
|
||||
final _result = create();
|
||||
@ -175,26 +175,26 @@ class UserSignUpResult extends $pb.GeneratedMessage {
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
factory UserSignUpResult.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
|
||||
factory UserSignUpResult.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
|
||||
factory SignUpResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
|
||||
factory SignUpResponse.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')
|
||||
UserSignUpResult clone() => UserSignUpResult()..mergeFromMessage(this);
|
||||
SignUpResponse clone() => SignUpResponse()..mergeFromMessage(this);
|
||||
@$core.Deprecated(
|
||||
'Using this can add significant overhead to your binary. '
|
||||
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
|
||||
'Will be removed in next major version')
|
||||
UserSignUpResult copyWith(void Function(UserSignUpResult) updates) => super.copyWith((message) => updates(message as UserSignUpResult)) as UserSignUpResult; // ignore: deprecated_member_use
|
||||
SignUpResponse copyWith(void Function(SignUpResponse) updates) => super.copyWith((message) => updates(message as SignUpResponse)) as SignUpResponse; // ignore: deprecated_member_use
|
||||
$pb.BuilderInfo get info_ => _i;
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static UserSignUpResult create() => UserSignUpResult._();
|
||||
UserSignUpResult createEmptyInstance() => create();
|
||||
static $pb.PbList<UserSignUpResult> createRepeated() => $pb.PbList<UserSignUpResult>();
|
||||
static SignUpResponse create() => SignUpResponse._();
|
||||
SignUpResponse createEmptyInstance() => create();
|
||||
static $pb.PbList<SignUpResponse> createRepeated() => $pb.PbList<SignUpResponse>();
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static UserSignUpResult getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<UserSignUpResult>(create);
|
||||
static UserSignUpResult? _defaultInstance;
|
||||
static SignUpResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<SignUpResponse>(create);
|
||||
static SignUpResponse? _defaultInstance;
|
||||
|
||||
@$pb.TagNumber(1)
|
||||
$core.bool get isSuccess => $_getBF(0);
|
||||
|
@ -6,8 +6,8 @@
|
||||
// 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;
|
||||
const UserSignUpParams$json = const {
|
||||
'1': 'UserSignUpParams',
|
||||
const SignUpRequest$json = const {
|
||||
'1': 'SignUpRequest',
|
||||
'2': const [
|
||||
const {'1': 'email', '3': 1, '4': 1, '5': 9, '10': 'email'},
|
||||
const {'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'},
|
||||
@ -15,8 +15,8 @@ const UserSignUpParams$json = const {
|
||||
],
|
||||
};
|
||||
|
||||
const UserSignUpRequest$json = const {
|
||||
'1': 'UserSignUpRequest',
|
||||
const SignUpParams$json = const {
|
||||
'1': 'SignUpParams',
|
||||
'2': const [
|
||||
const {'1': 'email', '3': 1, '4': 1, '5': 9, '10': 'email'},
|
||||
const {'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'},
|
||||
@ -24,8 +24,8 @@ const UserSignUpRequest$json = const {
|
||||
],
|
||||
};
|
||||
|
||||
const UserSignUpResult$json = const {
|
||||
'1': 'UserSignUpResult',
|
||||
const SignUpResponse$json = const {
|
||||
'1': 'SignUpResponse',
|
||||
'2': const [
|
||||
const {'1': 'is_success', '3': 1, '4': 1, '5': 8, '10': 'isSuccess'},
|
||||
],
|
||||
|
@ -52,6 +52,10 @@ Here are the event flow:
|
||||
|
||||
The event flow will be discussed in two parts: the frontend implemented in flutter and the FlowySDK implemented in Rust.
|
||||
|
||||
#### FlowySDK
|
||||
|
||||
|
||||
|
||||
#### Frontend
|
||||
The Frontend follows the DDD design pattern, you can recap from [**here**](DOMAIN_DRIVEN_DESIGN.md).
|
||||
```
|
||||
@ -66,6 +70,4 @@ The Frontend follows the DDD design pattern, you can recap from [**here**](DOMAI
|
||||
└──────────────┘
|
||||
```
|
||||
|
||||
#### FlowySDK
|
||||
|
||||
|
||||
|
@ -25,6 +25,8 @@ pub extern "C" fn init_sdk(path: *mut c_char) -> i64 {
|
||||
let c_str: &CStr = unsafe { CStr::from_ptr(path) };
|
||||
let path: &str = c_str.to_str().unwrap();
|
||||
FlowySDK::init_log(path);
|
||||
|
||||
log::info!("🔥 FlowySDK start running");
|
||||
FlowySDK::init(path);
|
||||
return 1;
|
||||
}
|
||||
|
@ -135,6 +135,7 @@ impl<'c, T> ASTAttr<'c, T> {
|
||||
}
|
||||
|
||||
pub struct ASTAttrField {
|
||||
#[allow(dead_code)]
|
||||
name: String,
|
||||
pb_index: Option<syn::LitInt>,
|
||||
pb_one_of: bool,
|
||||
|
@ -18,15 +18,14 @@ pub fn category_from_str(type_str: &str) -> TypeCategory {
|
||||
"FFIRequest"
|
||||
| "FFIResponse"
|
||||
| "User"
|
||||
| "UserSignUpParams"
|
||||
| "UserSignUpRequest"
|
||||
| "UserSignUpResult"
|
||||
| "UserSignInParams"
|
||||
| "UserSignInRequest"
|
||||
| "UserSignInResult"
|
||||
| "SignUpRequest"
|
||||
| "SignUpParams"
|
||||
| "SignUpResponse"
|
||||
| "SignInRequest"
|
||||
| "SignInParams"
|
||||
| "SignInResponse"
|
||||
=> TypeCategory::Protobuf,
|
||||
"FFIStatusCode"
|
||||
| "UserEvent"
|
||||
=> TypeCategory::Enum,
|
||||
|
||||
"Option" => TypeCategory::Opt,
|
||||
|
@ -111,7 +111,7 @@ where
|
||||
T: FromBytes,
|
||||
{
|
||||
match payload {
|
||||
Payload::None => Err(format!("Expected payload")),
|
||||
Payload::None => Err(format!("Parse fail, expected payload")),
|
||||
Payload::Bytes(bytes) => match T::parse_from_bytes(&bytes) {
|
||||
Ok(data) => Ok(Data(data)),
|
||||
Err(e) => Err(e),
|
||||
|
@ -35,7 +35,6 @@ impl EventDispatch {
|
||||
module_map,
|
||||
runtime,
|
||||
};
|
||||
|
||||
*(EVENT_DISPATCH.write().unwrap()) = Some(dispatch);
|
||||
}
|
||||
|
||||
@ -65,7 +64,7 @@ impl EventDispatch {
|
||||
DispatchFuture {
|
||||
fut: Box::pin(async move {
|
||||
join_handle.await.unwrap_or_else(|e| {
|
||||
InternalError::new(format!("Dispatch join error: {:?}", e))
|
||||
InternalError::new(format!("EVENT_DISPATCH join error: {:?}", e))
|
||||
.as_response()
|
||||
})
|
||||
}),
|
||||
|
@ -55,7 +55,7 @@ pub type EventServiceFactory = BoxServiceFactory<(), ServiceRequest, ServiceResp
|
||||
|
||||
pub struct Module {
|
||||
pub name: String,
|
||||
data: DataContainer,
|
||||
module_data: DataContainer,
|
||||
service_map: Arc<HashMap<Event, EventServiceFactory>>,
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ impl Module {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
name: "".to_owned(),
|
||||
data: DataContainer::new(),
|
||||
module_data: DataContainer::new(),
|
||||
service_map: Arc::new(HashMap::new()),
|
||||
}
|
||||
}
|
||||
@ -74,7 +74,7 @@ impl Module {
|
||||
}
|
||||
|
||||
pub fn data<D: 'static + Send + Sync>(mut self, data: D) -> Self {
|
||||
self.data.insert(ModuleData::new(data));
|
||||
self.module_data.insert(ModuleData::new(data));
|
||||
self
|
||||
}
|
||||
|
||||
|
@ -4,18 +4,24 @@ use std::{fmt, fmt::Formatter};
|
||||
pub enum PayloadError {}
|
||||
|
||||
// TODO: support stream data
|
||||
#[derive(Clone, Debug, serde::Serialize)]
|
||||
#[derive(Clone, serde::Serialize)]
|
||||
pub enum Payload {
|
||||
None,
|
||||
Bytes(Vec<u8>),
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for Payload {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { format_payload_print(self, f) }
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Payload {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Payload::Bytes(bytes) => f.write_fmt(format_args!("{} bytes", bytes.len())),
|
||||
Payload::None => f.write_str("Empty"),
|
||||
}
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { format_payload_print(self, f) }
|
||||
}
|
||||
|
||||
fn format_payload_print(payload: &Payload, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
match payload {
|
||||
Payload::Bytes(bytes) => f.write_fmt(format_args!("{} bytes", bytes.len())),
|
||||
Payload::None => f.write_str("Empty"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ use crate::{
|
||||
request::{EventRequest, Payload},
|
||||
response::Responder,
|
||||
};
|
||||
use derivative::*;
|
||||
use std::{fmt, fmt::Formatter};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize)]
|
||||
@ -13,8 +14,9 @@ pub enum StatusCode {
|
||||
}
|
||||
|
||||
// serde user guide: https://serde.rs/field-attrs.html
|
||||
#[derive(Debug, Clone, serde::Serialize)]
|
||||
#[derive(Debug, Clone, serde::Serialize, Derivative)]
|
||||
pub struct EventResponse {
|
||||
#[derivative(Debug = "ignore")]
|
||||
pub payload: Payload,
|
||||
pub status_code: StatusCode,
|
||||
pub error: Option<SystemError>,
|
||||
|
@ -14,6 +14,7 @@ thread_local!(
|
||||
);
|
||||
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
pub enum SystemCommand {
|
||||
Exit(i8),
|
||||
}
|
||||
@ -23,6 +24,7 @@ pub struct FlowySystem {
|
||||
}
|
||||
|
||||
impl FlowySystem {
|
||||
#[allow(dead_code)]
|
||||
pub fn construct<F, S>(module_factory: F, sender_factory: S) -> SystemRunner
|
||||
where
|
||||
F: FnOnce() -> Vec<Module>,
|
||||
@ -49,6 +51,7 @@ impl FlowySystem {
|
||||
runner
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn stop(&self) {
|
||||
match self.sys_cmd_tx.send(SystemCommand::Exit(0)) {
|
||||
Ok(_) => {},
|
||||
@ -58,13 +61,14 @@ impl FlowySystem {
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
#[allow(dead_code)]
|
||||
pub fn set_current(sys: FlowySystem) {
|
||||
CURRENT.with(|cell| {
|
||||
*cell.borrow_mut() = Some(Arc::new(sys));
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn current() -> Arc<FlowySystem> {
|
||||
CURRENT.with(|cell| match *cell.borrow() {
|
||||
Some(ref sys) => sys.clone(),
|
||||
@ -102,6 +106,7 @@ pub struct SystemRunner {
|
||||
}
|
||||
|
||||
impl SystemRunner {
|
||||
#[allow(dead_code)]
|
||||
pub fn run(self) -> io::Result<()> {
|
||||
let SystemRunner { rt, stop_rx } = self;
|
||||
match rt.block_on(stop_rx) {
|
||||
@ -119,6 +124,7 @@ impl SystemRunner {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn spawn<F: Future<Output = ()> + 'static>(self, future: F) -> Self {
|
||||
self.rt.spawn(future);
|
||||
self
|
||||
@ -135,6 +141,7 @@ pub struct Runtime {
|
||||
}
|
||||
|
||||
impl Runtime {
|
||||
#[allow(dead_code)]
|
||||
pub fn new() -> io::Result<Runtime> {
|
||||
let rt = tokio_default_runtime()?;
|
||||
Ok(Runtime {
|
||||
@ -143,6 +150,7 @@ impl Runtime {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn spawn<F>(&self, future: F) -> &Self
|
||||
where
|
||||
F: Future<Output = ()> + 'static,
|
||||
@ -151,6 +159,7 @@ impl Runtime {
|
||||
self
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn block_on<F>(&self, f: F) -> F::Output
|
||||
where
|
||||
F: Future + 'static,
|
||||
|
@ -7,7 +7,8 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
flowy-dispatch = { path = "../flowy-dispatch", features = ["use_tracing"]}
|
||||
flowy-log = { path = "../flowy-log", features = ["use_bunyan"] }
|
||||
flowy-log = { path = "../flowy-log" }
|
||||
#flowy-log = { path = "../flowy-log", features = ["use_bunyan"] }
|
||||
flowy-user = { path = "../flowy-user" }
|
||||
tracing = { version = "0.1" }
|
||||
log = "0.4.14"
|
||||
|
@ -9,8 +9,7 @@ impl FlowySDK {
|
||||
pub fn init_log(directory: &str) { flowy_log::init_log("flowy", directory, "Debug").unwrap(); }
|
||||
|
||||
pub fn init(path: &str) {
|
||||
log::info!("🔥 Start running");
|
||||
tracing::info!("🔥 Root path: {}", path);
|
||||
tracing::trace!("🔥 Root path: {}", path);
|
||||
EventDispatch::construct(|| build_modules());
|
||||
}
|
||||
}
|
||||
|
@ -14,4 +14,6 @@ bincode = { version = "1.3"}
|
||||
protobuf = {version = "2.24.1"}
|
||||
claim = "0.5.0"
|
||||
tokio = { version = "1", features = ["full"]}
|
||||
futures-util = "0.3.15"
|
||||
futures-util = "0.3.15"
|
||||
thread-id = "3.3.0"
|
||||
log = "0.4"
|
@ -7,6 +7,7 @@ use std::{
|
||||
hash::Hash,
|
||||
path::PathBuf,
|
||||
sync::Once,
|
||||
thread,
|
||||
};
|
||||
|
||||
pub mod prelude {
|
||||
@ -21,8 +22,8 @@ pub fn init_sdk() {
|
||||
|
||||
INIT.call_once(|| {
|
||||
FlowySDK::init_log(&root_dir);
|
||||
FlowySDK::init(&root_dir);
|
||||
});
|
||||
FlowySDK::init(&root_dir);
|
||||
}
|
||||
|
||||
fn root_dir() -> String {
|
||||
@ -42,7 +43,7 @@ fn root_dir() -> String {
|
||||
}
|
||||
|
||||
pub struct EventTester {
|
||||
request: Option<ModuleRequest>,
|
||||
inner_request: Option<ModuleRequest>,
|
||||
assert_status_code: Option<StatusCode>,
|
||||
response: Option<EventResponse>,
|
||||
}
|
||||
@ -53,22 +54,26 @@ impl EventTester {
|
||||
E: Eq + Hash + Debug + Clone + Display,
|
||||
{
|
||||
init_sdk();
|
||||
let request = ModuleRequest::new(event);
|
||||
log::trace!(
|
||||
"{:?} thread started: thread_id= {}",
|
||||
thread::current(),
|
||||
thread_id::get()
|
||||
);
|
||||
Self {
|
||||
request: Some(request),
|
||||
inner_request: Some(ModuleRequest::new(event)),
|
||||
assert_status_code: None,
|
||||
response: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn payload<P>(mut self, payload: P) -> Self
|
||||
pub fn request<P>(mut self, request: P) -> Self
|
||||
where
|
||||
P: ToBytes,
|
||||
{
|
||||
let mut request = self.request.take().unwrap();
|
||||
let bytes = payload.into_bytes().unwrap();
|
||||
request = request.payload(bytes);
|
||||
self.request = Some(request);
|
||||
let mut inner_request = self.inner_request.take().unwrap();
|
||||
let bytes = request.into_bytes().unwrap();
|
||||
inner_request = inner_request.payload(bytes);
|
||||
self.inner_request = Some(inner_request);
|
||||
self
|
||||
}
|
||||
|
||||
@ -77,26 +82,25 @@ impl EventTester {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn assert_error(mut self) -> Self {
|
||||
self.assert_status_code = Some(StatusCode::Err);
|
||||
self
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub async fn async_send(mut self) -> Self {
|
||||
let resp =
|
||||
EventDispatch::async_send(self.request.take().unwrap(), |_| Box::pin(async {})).await;
|
||||
EventDispatch::async_send(self.inner_request.take().unwrap(), |_| Box::pin(async {}))
|
||||
.await;
|
||||
|
||||
if let Some(ref status_code) = self.assert_status_code {
|
||||
assert_eq!(&resp.status_code, status_code)
|
||||
}
|
||||
dbg!(&resp);
|
||||
check(&resp, &self.assert_status_code);
|
||||
self.response = Some(resp);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn sync_send(mut self) -> Self {
|
||||
let resp = EventDispatch::sync_send(self.request.take().unwrap());
|
||||
|
||||
if let Some(ref status_code) = self.assert_status_code {
|
||||
assert_eq!(&resp.status_code, status_code)
|
||||
}
|
||||
dbg!(&resp);
|
||||
let resp = EventDispatch::sync_send(self.inner_request.take().unwrap());
|
||||
check(&resp, &self.assert_status_code);
|
||||
self.response = Some(resp);
|
||||
self
|
||||
}
|
||||
@ -109,3 +113,12 @@ impl EventTester {
|
||||
<Data<R>>::try_from(response.payload).unwrap().into_inner()
|
||||
}
|
||||
}
|
||||
|
||||
fn check(response: &EventResponse, status_code: &Option<StatusCode>) {
|
||||
if let Some(ref status_code) = status_code {
|
||||
if &response.status_code != status_code {
|
||||
eprintln!("{:#?}", response);
|
||||
}
|
||||
assert_eq!(&response.status_code, status_code)
|
||||
}
|
||||
}
|
||||
|
@ -26,4 +26,6 @@ quickcheck = "0.9.2"
|
||||
quickcheck_macros = "0.9.1"
|
||||
fake = "~2.3.0"
|
||||
claim = "0.4.0"
|
||||
flowy-test = { path = "../flowy-test" }
|
||||
flowy-test = { path = "../flowy-test" }
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
futures = "0.3.15"
|
@ -1,3 +1,3 @@
|
||||
|
||||
proto_crates = ["src/domain"]
|
||||
event_files = ["src/domain/event.rs"]
|
||||
event_files = ["src/event.rs"]
|
@ -1,4 +1,3 @@
|
||||
pub mod event;
|
||||
pub mod user;
|
||||
|
||||
pub use user::*;
|
||||
|
||||
pub mod user;
|
||||
|
@ -3,7 +3,7 @@ use flowy_derive::ProtoBuf;
|
||||
use std::convert::TryInto;
|
||||
|
||||
#[derive(ProtoBuf, Default)]
|
||||
pub struct UserSignInParams {
|
||||
pub struct SignInRequest {
|
||||
#[pb(index = 1)]
|
||||
pub email: String,
|
||||
|
||||
@ -12,7 +12,7 @@ pub struct UserSignInParams {
|
||||
}
|
||||
|
||||
#[derive(Default, ProtoBuf)]
|
||||
pub struct UserSignInRequest {
|
||||
pub struct SignInParams {
|
||||
#[pb(index = 1)]
|
||||
pub email: String,
|
||||
|
||||
@ -20,14 +20,14 @@ pub struct UserSignInRequest {
|
||||
pub password: String,
|
||||
}
|
||||
|
||||
impl TryInto<UserSignInRequest> for UserSignInParams {
|
||||
impl TryInto<SignInParams> for SignInRequest {
|
||||
type Error = String;
|
||||
|
||||
fn try_into(self) -> Result<UserSignInRequest, Self::Error> {
|
||||
fn try_into(self) -> Result<SignInParams, Self::Error> {
|
||||
let email = UserEmail::parse(self.email)?;
|
||||
let password = UserPassword::parse(self.password)?;
|
||||
|
||||
Ok(UserSignInRequest {
|
||||
Ok(SignInParams {
|
||||
email: email.0,
|
||||
password: password.0,
|
||||
})
|
||||
@ -35,11 +35,11 @@ impl TryInto<UserSignInRequest> for UserSignInParams {
|
||||
}
|
||||
|
||||
#[derive(ProtoBuf, Default, Debug)]
|
||||
pub struct UserSignInResult {
|
||||
pub struct SignInResponse {
|
||||
#[pb(index = 1)]
|
||||
pub is_success: bool,
|
||||
}
|
||||
|
||||
impl UserSignInResult {
|
||||
impl SignInResponse {
|
||||
pub fn new(is_success: bool) -> Self { Self { is_success } }
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ use flowy_derive::ProtoBuf;
|
||||
use std::convert::TryInto;
|
||||
|
||||
#[derive(ProtoBuf, Default)]
|
||||
pub struct UserSignUpParams {
|
||||
pub struct SignUpRequest {
|
||||
#[pb(index = 1)]
|
||||
pub email: String,
|
||||
|
||||
@ -13,14 +13,14 @@ pub struct UserSignUpParams {
|
||||
#[pb(index = 3)]
|
||||
pub password: String,
|
||||
}
|
||||
impl TryInto<UserSignUpRequest> for UserSignUpParams {
|
||||
impl TryInto<SignUpParams> for SignUpRequest {
|
||||
type Error = String;
|
||||
|
||||
fn try_into(self) -> Result<UserSignUpRequest, Self::Error> {
|
||||
fn try_into(self) -> Result<SignUpParams, Self::Error> {
|
||||
let email = UserEmail::parse(self.email)?;
|
||||
let name = UserName::parse(self.name)?;
|
||||
let password = UserPassword::parse(self.password)?;
|
||||
Ok(UserSignUpRequest {
|
||||
Ok(SignUpParams {
|
||||
email: email.0,
|
||||
name: name.0,
|
||||
password: password.0,
|
||||
@ -29,7 +29,7 @@ impl TryInto<UserSignUpRequest> for UserSignUpParams {
|
||||
}
|
||||
|
||||
#[derive(ProtoBuf, Default)]
|
||||
pub struct UserSignUpRequest {
|
||||
pub struct SignUpParams {
|
||||
#[pb(index = 1)]
|
||||
pub email: String,
|
||||
|
||||
@ -40,12 +40,12 @@ pub struct UserSignUpRequest {
|
||||
pub password: String,
|
||||
}
|
||||
|
||||
#[derive(ProtoBuf, Default)]
|
||||
pub struct UserSignUpResult {
|
||||
#[derive(ProtoBuf, Debug, Default)]
|
||||
pub struct SignUpResponse {
|
||||
#[pb(index = 1)]
|
||||
pub is_success: bool,
|
||||
}
|
||||
|
||||
impl UserSignUpResult {
|
||||
impl SignUpResponse {
|
||||
pub fn new(is_success: bool) -> Self { Self { is_success } }
|
||||
}
|
||||
|
@ -4,12 +4,12 @@ use flowy_derive::{Flowy_Event, ProtoBuf_Enum};
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
|
||||
pub enum UserEvent {
|
||||
#[display(fmt = "AuthCheck")]
|
||||
#[event(input = "UserSignInParams", output = "UserSignInResult")]
|
||||
AuthCheck = 0,
|
||||
#[event(input = "UserSignInParams", output = "UserSignInResult")]
|
||||
#[display(fmt = "SignIn")]
|
||||
#[event(input = "SignInRequest", output = "SignInResponse")]
|
||||
SignIn = 1,
|
||||
#[display(fmt = "SignUp")]
|
||||
#[event(input = "SignUpRequest", output = "SignUpResponse")]
|
||||
SignUp = 2,
|
||||
#[display(fmt = "SignOut")]
|
||||
SignOut = 3,
|
@ -10,12 +10,10 @@ use std::convert::TryInto;
|
||||
email = %data.email,
|
||||
)
|
||||
)]
|
||||
pub async fn user_sign_in(
|
||||
data: Data<UserSignInParams>,
|
||||
) -> ResponseResult<UserSignInResult, String> {
|
||||
let _request: UserSignInRequest = data.into_inner().try_into()?;
|
||||
|
||||
let response = UserSignInResult::new(true);
|
||||
pub async fn user_sign_in(data: Data<SignInRequest>) -> ResponseResult<SignInResponse, String> {
|
||||
let _params: SignInParams = data.into_inner().try_into()?;
|
||||
// TODO: user sign in
|
||||
let response = SignInResponse::new(true);
|
||||
response_ok(response)
|
||||
}
|
||||
|
||||
@ -26,11 +24,10 @@ pub async fn user_sign_in(
|
||||
email = %data.email,
|
||||
)
|
||||
)]
|
||||
pub async fn user_sign_up(
|
||||
data: Data<UserSignUpParams>,
|
||||
) -> ResponseResult<UserSignUpResult, String> {
|
||||
let _request: UserSignUpRequest = data.into_inner().try_into()?;
|
||||
pub async fn user_sign_up(data: Data<SignUpRequest>) -> ResponseResult<SignUpResponse, String> {
|
||||
let _params: SignUpParams = data.into_inner().try_into()?;
|
||||
// TODO: user sign up
|
||||
|
||||
let response = UserSignUpResult::new(true);
|
||||
response_ok(response)
|
||||
let fake_resp = SignUpResponse::new(true);
|
||||
response_ok(fake_resp)
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
mod domain;
|
||||
mod error;
|
||||
pub mod event;
|
||||
mod handlers;
|
||||
pub mod module;
|
||||
mod protobuf;
|
||||
|
@ -1,6 +1,7 @@
|
||||
use crate::{domain::event::UserEvent, handlers::*};
|
||||
use flowy_dispatch::prelude::*;
|
||||
|
||||
use crate::{event::UserEvent, handlers::*};
|
||||
|
||||
pub fn create() -> Module {
|
||||
Module::new()
|
||||
.name("Flowy-User")
|
||||
|
@ -24,7 +24,7 @@
|
||||
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1;
|
||||
|
||||
#[derive(PartialEq,Clone,Default)]
|
||||
pub struct UserSignInParams {
|
||||
pub struct SignInRequest {
|
||||
// message fields
|
||||
pub email: ::std::string::String,
|
||||
pub password: ::std::string::String,
|
||||
@ -33,14 +33,14 @@ pub struct UserSignInParams {
|
||||
pub cached_size: ::protobuf::CachedSize,
|
||||
}
|
||||
|
||||
impl<'a> ::std::default::Default for &'a UserSignInParams {
|
||||
fn default() -> &'a UserSignInParams {
|
||||
<UserSignInParams as ::protobuf::Message>::default_instance()
|
||||
impl<'a> ::std::default::Default for &'a SignInRequest {
|
||||
fn default() -> &'a SignInRequest {
|
||||
<SignInRequest as ::protobuf::Message>::default_instance()
|
||||
}
|
||||
}
|
||||
|
||||
impl UserSignInParams {
|
||||
pub fn new() -> UserSignInParams {
|
||||
impl SignInRequest {
|
||||
pub fn new() -> SignInRequest {
|
||||
::std::default::Default::default()
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ impl UserSignInParams {
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Message for UserSignInParams {
|
||||
impl ::protobuf::Message for SignInRequest {
|
||||
fn is_initialized(&self) -> bool {
|
||||
true
|
||||
}
|
||||
@ -172,8 +172,8 @@ impl ::protobuf::Message for UserSignInParams {
|
||||
Self::descriptor_static()
|
||||
}
|
||||
|
||||
fn new() -> UserSignInParams {
|
||||
UserSignInParams::new()
|
||||
fn new() -> SignInRequest {
|
||||
SignInRequest::new()
|
||||
}
|
||||
|
||||
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
|
||||
@ -182,29 +182,29 @@ impl ::protobuf::Message for UserSignInParams {
|
||||
let mut fields = ::std::vec::Vec::new();
|
||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
||||
"email",
|
||||
|m: &UserSignInParams| { &m.email },
|
||||
|m: &mut UserSignInParams| { &mut m.email },
|
||||
|m: &SignInRequest| { &m.email },
|
||||
|m: &mut SignInRequest| { &mut m.email },
|
||||
));
|
||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
||||
"password",
|
||||
|m: &UserSignInParams| { &m.password },
|
||||
|m: &mut UserSignInParams| { &mut m.password },
|
||||
|m: &SignInRequest| { &m.password },
|
||||
|m: &mut SignInRequest| { &mut m.password },
|
||||
));
|
||||
::protobuf::reflect::MessageDescriptor::new_pb_name::<UserSignInParams>(
|
||||
"UserSignInParams",
|
||||
::protobuf::reflect::MessageDescriptor::new_pb_name::<SignInRequest>(
|
||||
"SignInRequest",
|
||||
fields,
|
||||
file_descriptor_proto()
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
fn default_instance() -> &'static UserSignInParams {
|
||||
static instance: ::protobuf::rt::LazyV2<UserSignInParams> = ::protobuf::rt::LazyV2::INIT;
|
||||
instance.get(UserSignInParams::new)
|
||||
fn default_instance() -> &'static SignInRequest {
|
||||
static instance: ::protobuf::rt::LazyV2<SignInRequest> = ::protobuf::rt::LazyV2::INIT;
|
||||
instance.get(SignInRequest::new)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Clear for UserSignInParams {
|
||||
impl ::protobuf::Clear for SignInRequest {
|
||||
fn clear(&mut self) {
|
||||
self.email.clear();
|
||||
self.password.clear();
|
||||
@ -212,20 +212,20 @@ impl ::protobuf::Clear for UserSignInParams {
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::fmt::Debug for UserSignInParams {
|
||||
impl ::std::fmt::Debug for SignInRequest {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||
::protobuf::text_format::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::reflect::ProtobufValue for UserSignInParams {
|
||||
impl ::protobuf::reflect::ProtobufValue for SignInRequest {
|
||||
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
|
||||
::protobuf::reflect::ReflectValueRef::Message(self)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq,Clone,Default)]
|
||||
pub struct UserSignInRequest {
|
||||
pub struct SignInParams {
|
||||
// message fields
|
||||
pub email: ::std::string::String,
|
||||
pub password: ::std::string::String,
|
||||
@ -234,14 +234,14 @@ pub struct UserSignInRequest {
|
||||
pub cached_size: ::protobuf::CachedSize,
|
||||
}
|
||||
|
||||
impl<'a> ::std::default::Default for &'a UserSignInRequest {
|
||||
fn default() -> &'a UserSignInRequest {
|
||||
<UserSignInRequest as ::protobuf::Message>::default_instance()
|
||||
impl<'a> ::std::default::Default for &'a SignInParams {
|
||||
fn default() -> &'a SignInParams {
|
||||
<SignInParams as ::protobuf::Message>::default_instance()
|
||||
}
|
||||
}
|
||||
|
||||
impl UserSignInRequest {
|
||||
pub fn new() -> UserSignInRequest {
|
||||
impl SignInParams {
|
||||
pub fn new() -> SignInParams {
|
||||
::std::default::Default::default()
|
||||
}
|
||||
|
||||
@ -298,7 +298,7 @@ impl UserSignInRequest {
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Message for UserSignInRequest {
|
||||
impl ::protobuf::Message for SignInParams {
|
||||
fn is_initialized(&self) -> bool {
|
||||
true
|
||||
}
|
||||
@ -373,8 +373,8 @@ impl ::protobuf::Message for UserSignInRequest {
|
||||
Self::descriptor_static()
|
||||
}
|
||||
|
||||
fn new() -> UserSignInRequest {
|
||||
UserSignInRequest::new()
|
||||
fn new() -> SignInParams {
|
||||
SignInParams::new()
|
||||
}
|
||||
|
||||
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
|
||||
@ -383,29 +383,29 @@ impl ::protobuf::Message for UserSignInRequest {
|
||||
let mut fields = ::std::vec::Vec::new();
|
||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
||||
"email",
|
||||
|m: &UserSignInRequest| { &m.email },
|
||||
|m: &mut UserSignInRequest| { &mut m.email },
|
||||
|m: &SignInParams| { &m.email },
|
||||
|m: &mut SignInParams| { &mut m.email },
|
||||
));
|
||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
||||
"password",
|
||||
|m: &UserSignInRequest| { &m.password },
|
||||
|m: &mut UserSignInRequest| { &mut m.password },
|
||||
|m: &SignInParams| { &m.password },
|
||||
|m: &mut SignInParams| { &mut m.password },
|
||||
));
|
||||
::protobuf::reflect::MessageDescriptor::new_pb_name::<UserSignInRequest>(
|
||||
"UserSignInRequest",
|
||||
::protobuf::reflect::MessageDescriptor::new_pb_name::<SignInParams>(
|
||||
"SignInParams",
|
||||
fields,
|
||||
file_descriptor_proto()
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
fn default_instance() -> &'static UserSignInRequest {
|
||||
static instance: ::protobuf::rt::LazyV2<UserSignInRequest> = ::protobuf::rt::LazyV2::INIT;
|
||||
instance.get(UserSignInRequest::new)
|
||||
fn default_instance() -> &'static SignInParams {
|
||||
static instance: ::protobuf::rt::LazyV2<SignInParams> = ::protobuf::rt::LazyV2::INIT;
|
||||
instance.get(SignInParams::new)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Clear for UserSignInRequest {
|
||||
impl ::protobuf::Clear for SignInParams {
|
||||
fn clear(&mut self) {
|
||||
self.email.clear();
|
||||
self.password.clear();
|
||||
@ -413,20 +413,20 @@ impl ::protobuf::Clear for UserSignInRequest {
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::fmt::Debug for UserSignInRequest {
|
||||
impl ::std::fmt::Debug for SignInParams {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||
::protobuf::text_format::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::reflect::ProtobufValue for UserSignInRequest {
|
||||
impl ::protobuf::reflect::ProtobufValue for SignInParams {
|
||||
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
|
||||
::protobuf::reflect::ReflectValueRef::Message(self)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq,Clone,Default)]
|
||||
pub struct UserSignInResult {
|
||||
pub struct SignInResponse {
|
||||
// message fields
|
||||
pub is_success: bool,
|
||||
// special fields
|
||||
@ -434,14 +434,14 @@ pub struct UserSignInResult {
|
||||
pub cached_size: ::protobuf::CachedSize,
|
||||
}
|
||||
|
||||
impl<'a> ::std::default::Default for &'a UserSignInResult {
|
||||
fn default() -> &'a UserSignInResult {
|
||||
<UserSignInResult as ::protobuf::Message>::default_instance()
|
||||
impl<'a> ::std::default::Default for &'a SignInResponse {
|
||||
fn default() -> &'a SignInResponse {
|
||||
<SignInResponse as ::protobuf::Message>::default_instance()
|
||||
}
|
||||
}
|
||||
|
||||
impl UserSignInResult {
|
||||
pub fn new() -> UserSignInResult {
|
||||
impl SignInResponse {
|
||||
pub fn new() -> SignInResponse {
|
||||
::std::default::Default::default()
|
||||
}
|
||||
|
||||
@ -461,7 +461,7 @@ impl UserSignInResult {
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Message for UserSignInResult {
|
||||
impl ::protobuf::Message for SignInResponse {
|
||||
fn is_initialized(&self) -> bool {
|
||||
true
|
||||
}
|
||||
@ -531,8 +531,8 @@ impl ::protobuf::Message for UserSignInResult {
|
||||
Self::descriptor_static()
|
||||
}
|
||||
|
||||
fn new() -> UserSignInResult {
|
||||
UserSignInResult::new()
|
||||
fn new() -> SignInResponse {
|
||||
SignInResponse::new()
|
||||
}
|
||||
|
||||
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
|
||||
@ -541,66 +541,66 @@ impl ::protobuf::Message for UserSignInResult {
|
||||
let mut fields = ::std::vec::Vec::new();
|
||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBool>(
|
||||
"is_success",
|
||||
|m: &UserSignInResult| { &m.is_success },
|
||||
|m: &mut UserSignInResult| { &mut m.is_success },
|
||||
|m: &SignInResponse| { &m.is_success },
|
||||
|m: &mut SignInResponse| { &mut m.is_success },
|
||||
));
|
||||
::protobuf::reflect::MessageDescriptor::new_pb_name::<UserSignInResult>(
|
||||
"UserSignInResult",
|
||||
::protobuf::reflect::MessageDescriptor::new_pb_name::<SignInResponse>(
|
||||
"SignInResponse",
|
||||
fields,
|
||||
file_descriptor_proto()
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
fn default_instance() -> &'static UserSignInResult {
|
||||
static instance: ::protobuf::rt::LazyV2<UserSignInResult> = ::protobuf::rt::LazyV2::INIT;
|
||||
instance.get(UserSignInResult::new)
|
||||
fn default_instance() -> &'static SignInResponse {
|
||||
static instance: ::protobuf::rt::LazyV2<SignInResponse> = ::protobuf::rt::LazyV2::INIT;
|
||||
instance.get(SignInResponse::new)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Clear for UserSignInResult {
|
||||
impl ::protobuf::Clear for SignInResponse {
|
||||
fn clear(&mut self) {
|
||||
self.is_success = false;
|
||||
self.unknown_fields.clear();
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::fmt::Debug for UserSignInResult {
|
||||
impl ::std::fmt::Debug for SignInResponse {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||
::protobuf::text_format::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::reflect::ProtobufValue for UserSignInResult {
|
||||
impl ::protobuf::reflect::ProtobufValue for SignInResponse {
|
||||
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
|
||||
::protobuf::reflect::ReflectValueRef::Message(self)
|
||||
}
|
||||
}
|
||||
|
||||
static file_descriptor_proto_data: &'static [u8] = b"\
|
||||
\n\rsign_in.proto\"D\n\x10UserSignInParams\x12\x14\n\x05email\x18\x01\
|
||||
\x20\x01(\tR\x05email\x12\x1a\n\x08password\x18\x02\x20\x01(\tR\x08passw\
|
||||
ord\"E\n\x11UserSignInRequest\x12\x14\n\x05email\x18\x01\x20\x01(\tR\x05\
|
||||
email\x12\x1a\n\x08password\x18\x02\x20\x01(\tR\x08password\"1\n\x10User\
|
||||
SignInResult\x12\x1d\n\nis_success\x18\x01\x20\x01(\x08R\tisSuccessJ\xed\
|
||||
\x02\n\x06\x12\x04\0\0\x0c\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\x18\n\
|
||||
\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x15\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\x10\n\x0c\
|
||||
\n\x05\x04\0\x02\0\x03\x12\x03\x03\x13\x14\n\x0b\n\x04\x04\0\x02\x01\x12\
|
||||
\x03\x04\x04\x18\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\x13\n\x0c\n\x05\x04\0\x02\x01\x03\
|
||||
\x12\x03\x04\x16\x17\n\n\n\x02\x04\x01\x12\x04\x06\0\t\x01\n\n\n\x03\x04\
|
||||
\x01\x01\x12\x03\x06\x08\x19\n\x0b\n\x04\x04\x01\x02\0\x12\x03\x07\x04\
|
||||
\x15\n\x0c\n\x05\x04\x01\x02\0\x05\x12\x03\x07\x04\n\n\x0c\n\x05\x04\x01\
|
||||
\x02\0\x01\x12\x03\x07\x0b\x10\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03\x07\
|
||||
\x13\x14\n\x0b\n\x04\x04\x01\x02\x01\x12\x03\x08\x04\x18\n\x0c\n\x05\x04\
|
||||
\x01\x02\x01\x05\x12\x03\x08\x04\n\n\x0c\n\x05\x04\x01\x02\x01\x01\x12\
|
||||
\x03\x08\x0b\x13\n\x0c\n\x05\x04\x01\x02\x01\x03\x12\x03\x08\x16\x17\n\n\
|
||||
\n\x02\x04\x02\x12\x04\n\0\x0c\x01\n\n\n\x03\x04\x02\x01\x12\x03\n\x08\
|
||||
\x18\n\x0b\n\x04\x04\x02\x02\0\x12\x03\x0b\x04\x18\n\x0c\n\x05\x04\x02\
|
||||
\x02\0\x05\x12\x03\x0b\x04\x08\n\x0c\n\x05\x04\x02\x02\0\x01\x12\x03\x0b\
|
||||
\t\x13\n\x0c\n\x05\x04\x02\x02\0\x03\x12\x03\x0b\x16\x17b\x06proto3\
|
||||
\n\rsign_in.proto\"A\n\rSignInRequest\x12\x14\n\x05email\x18\x01\x20\x01\
|
||||
(\tR\x05email\x12\x1a\n\x08password\x18\x02\x20\x01(\tR\x08password\"@\n\
|
||||
\x0cSignInParams\x12\x14\n\x05email\x18\x01\x20\x01(\tR\x05email\x12\x1a\
|
||||
\n\x08password\x18\x02\x20\x01(\tR\x08password\"/\n\x0eSignInResponse\
|
||||
\x12\x1d\n\nis_success\x18\x01\x20\x01(\x08R\tisSuccessJ\xed\x02\n\x06\
|
||||
\x12\x04\0\0\x0c\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\x15\n\x0b\n\x04\
|
||||
\x04\0\x02\0\x12\x03\x03\x04\x15\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\x10\n\x0c\n\x05\x04\0\
|
||||
\x02\0\x03\x12\x03\x03\x13\x14\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x04\x04\
|
||||
\x18\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\x13\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\
|
||||
\x04\x16\x17\n\n\n\x02\x04\x01\x12\x04\x06\0\t\x01\n\n\n\x03\x04\x01\x01\
|
||||
\x12\x03\x06\x08\x14\n\x0b\n\x04\x04\x01\x02\0\x12\x03\x07\x04\x15\n\x0c\
|
||||
\n\x05\x04\x01\x02\0\x05\x12\x03\x07\x04\n\n\x0c\n\x05\x04\x01\x02\0\x01\
|
||||
\x12\x03\x07\x0b\x10\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03\x07\x13\x14\n\
|
||||
\x0b\n\x04\x04\x01\x02\x01\x12\x03\x08\x04\x18\n\x0c\n\x05\x04\x01\x02\
|
||||
\x01\x05\x12\x03\x08\x04\n\n\x0c\n\x05\x04\x01\x02\x01\x01\x12\x03\x08\
|
||||
\x0b\x13\n\x0c\n\x05\x04\x01\x02\x01\x03\x12\x03\x08\x16\x17\n\n\n\x02\
|
||||
\x04\x02\x12\x04\n\0\x0c\x01\n\n\n\x03\x04\x02\x01\x12\x03\n\x08\x16\n\
|
||||
\x0b\n\x04\x04\x02\x02\0\x12\x03\x0b\x04\x18\n\x0c\n\x05\x04\x02\x02\0\
|
||||
\x05\x12\x03\x0b\x04\x08\n\x0c\n\x05\x04\x02\x02\0\x01\x12\x03\x0b\t\x13\
|
||||
\n\x0c\n\x05\x04\x02\x02\0\x03\x12\x03\x0b\x16\x17b\x06proto3\
|
||||
";
|
||||
|
||||
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
|
||||
|
@ -24,7 +24,7 @@
|
||||
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1;
|
||||
|
||||
#[derive(PartialEq,Clone,Default)]
|
||||
pub struct UserSignUpParams {
|
||||
pub struct SignUpRequest {
|
||||
// message fields
|
||||
pub email: ::std::string::String,
|
||||
pub name: ::std::string::String,
|
||||
@ -34,14 +34,14 @@ pub struct UserSignUpParams {
|
||||
pub cached_size: ::protobuf::CachedSize,
|
||||
}
|
||||
|
||||
impl<'a> ::std::default::Default for &'a UserSignUpParams {
|
||||
fn default() -> &'a UserSignUpParams {
|
||||
<UserSignUpParams as ::protobuf::Message>::default_instance()
|
||||
impl<'a> ::std::default::Default for &'a SignUpRequest {
|
||||
fn default() -> &'a SignUpRequest {
|
||||
<SignUpRequest as ::protobuf::Message>::default_instance()
|
||||
}
|
||||
}
|
||||
|
||||
impl UserSignUpParams {
|
||||
pub fn new() -> UserSignUpParams {
|
||||
impl SignUpRequest {
|
||||
pub fn new() -> SignUpRequest {
|
||||
::std::default::Default::default()
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ impl UserSignUpParams {
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Message for UserSignUpParams {
|
||||
impl ::protobuf::Message for SignUpRequest {
|
||||
fn is_initialized(&self) -> bool {
|
||||
true
|
||||
}
|
||||
@ -208,8 +208,8 @@ impl ::protobuf::Message for UserSignUpParams {
|
||||
Self::descriptor_static()
|
||||
}
|
||||
|
||||
fn new() -> UserSignUpParams {
|
||||
UserSignUpParams::new()
|
||||
fn new() -> SignUpRequest {
|
||||
SignUpRequest::new()
|
||||
}
|
||||
|
||||
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
|
||||
@ -218,34 +218,34 @@ impl ::protobuf::Message for UserSignUpParams {
|
||||
let mut fields = ::std::vec::Vec::new();
|
||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
||||
"email",
|
||||
|m: &UserSignUpParams| { &m.email },
|
||||
|m: &mut UserSignUpParams| { &mut m.email },
|
||||
|m: &SignUpRequest| { &m.email },
|
||||
|m: &mut SignUpRequest| { &mut m.email },
|
||||
));
|
||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
||||
"name",
|
||||
|m: &UserSignUpParams| { &m.name },
|
||||
|m: &mut UserSignUpParams| { &mut m.name },
|
||||
|m: &SignUpRequest| { &m.name },
|
||||
|m: &mut SignUpRequest| { &mut m.name },
|
||||
));
|
||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
||||
"password",
|
||||
|m: &UserSignUpParams| { &m.password },
|
||||
|m: &mut UserSignUpParams| { &mut m.password },
|
||||
|m: &SignUpRequest| { &m.password },
|
||||
|m: &mut SignUpRequest| { &mut m.password },
|
||||
));
|
||||
::protobuf::reflect::MessageDescriptor::new_pb_name::<UserSignUpParams>(
|
||||
"UserSignUpParams",
|
||||
::protobuf::reflect::MessageDescriptor::new_pb_name::<SignUpRequest>(
|
||||
"SignUpRequest",
|
||||
fields,
|
||||
file_descriptor_proto()
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
fn default_instance() -> &'static UserSignUpParams {
|
||||
static instance: ::protobuf::rt::LazyV2<UserSignUpParams> = ::protobuf::rt::LazyV2::INIT;
|
||||
instance.get(UserSignUpParams::new)
|
||||
fn default_instance() -> &'static SignUpRequest {
|
||||
static instance: ::protobuf::rt::LazyV2<SignUpRequest> = ::protobuf::rt::LazyV2::INIT;
|
||||
instance.get(SignUpRequest::new)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Clear for UserSignUpParams {
|
||||
impl ::protobuf::Clear for SignUpRequest {
|
||||
fn clear(&mut self) {
|
||||
self.email.clear();
|
||||
self.name.clear();
|
||||
@ -254,20 +254,20 @@ impl ::protobuf::Clear for UserSignUpParams {
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::fmt::Debug for UserSignUpParams {
|
||||
impl ::std::fmt::Debug for SignUpRequest {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||
::protobuf::text_format::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::reflect::ProtobufValue for UserSignUpParams {
|
||||
impl ::protobuf::reflect::ProtobufValue for SignUpRequest {
|
||||
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
|
||||
::protobuf::reflect::ReflectValueRef::Message(self)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq,Clone,Default)]
|
||||
pub struct UserSignUpRequest {
|
||||
pub struct SignUpParams {
|
||||
// message fields
|
||||
pub email: ::std::string::String,
|
||||
pub name: ::std::string::String,
|
||||
@ -277,14 +277,14 @@ pub struct UserSignUpRequest {
|
||||
pub cached_size: ::protobuf::CachedSize,
|
||||
}
|
||||
|
||||
impl<'a> ::std::default::Default for &'a UserSignUpRequest {
|
||||
fn default() -> &'a UserSignUpRequest {
|
||||
<UserSignUpRequest as ::protobuf::Message>::default_instance()
|
||||
impl<'a> ::std::default::Default for &'a SignUpParams {
|
||||
fn default() -> &'a SignUpParams {
|
||||
<SignUpParams as ::protobuf::Message>::default_instance()
|
||||
}
|
||||
}
|
||||
|
||||
impl UserSignUpRequest {
|
||||
pub fn new() -> UserSignUpRequest {
|
||||
impl SignUpParams {
|
||||
pub fn new() -> SignUpParams {
|
||||
::std::default::Default::default()
|
||||
}
|
||||
|
||||
@ -367,7 +367,7 @@ impl UserSignUpRequest {
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Message for UserSignUpRequest {
|
||||
impl ::protobuf::Message for SignUpParams {
|
||||
fn is_initialized(&self) -> bool {
|
||||
true
|
||||
}
|
||||
@ -451,8 +451,8 @@ impl ::protobuf::Message for UserSignUpRequest {
|
||||
Self::descriptor_static()
|
||||
}
|
||||
|
||||
fn new() -> UserSignUpRequest {
|
||||
UserSignUpRequest::new()
|
||||
fn new() -> SignUpParams {
|
||||
SignUpParams::new()
|
||||
}
|
||||
|
||||
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
|
||||
@ -461,34 +461,34 @@ impl ::protobuf::Message for UserSignUpRequest {
|
||||
let mut fields = ::std::vec::Vec::new();
|
||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
||||
"email",
|
||||
|m: &UserSignUpRequest| { &m.email },
|
||||
|m: &mut UserSignUpRequest| { &mut m.email },
|
||||
|m: &SignUpParams| { &m.email },
|
||||
|m: &mut SignUpParams| { &mut m.email },
|
||||
));
|
||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
||||
"name",
|
||||
|m: &UserSignUpRequest| { &m.name },
|
||||
|m: &mut UserSignUpRequest| { &mut m.name },
|
||||
|m: &SignUpParams| { &m.name },
|
||||
|m: &mut SignUpParams| { &mut m.name },
|
||||
));
|
||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
|
||||
"password",
|
||||
|m: &UserSignUpRequest| { &m.password },
|
||||
|m: &mut UserSignUpRequest| { &mut m.password },
|
||||
|m: &SignUpParams| { &m.password },
|
||||
|m: &mut SignUpParams| { &mut m.password },
|
||||
));
|
||||
::protobuf::reflect::MessageDescriptor::new_pb_name::<UserSignUpRequest>(
|
||||
"UserSignUpRequest",
|
||||
::protobuf::reflect::MessageDescriptor::new_pb_name::<SignUpParams>(
|
||||
"SignUpParams",
|
||||
fields,
|
||||
file_descriptor_proto()
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
fn default_instance() -> &'static UserSignUpRequest {
|
||||
static instance: ::protobuf::rt::LazyV2<UserSignUpRequest> = ::protobuf::rt::LazyV2::INIT;
|
||||
instance.get(UserSignUpRequest::new)
|
||||
fn default_instance() -> &'static SignUpParams {
|
||||
static instance: ::protobuf::rt::LazyV2<SignUpParams> = ::protobuf::rt::LazyV2::INIT;
|
||||
instance.get(SignUpParams::new)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Clear for UserSignUpRequest {
|
||||
impl ::protobuf::Clear for SignUpParams {
|
||||
fn clear(&mut self) {
|
||||
self.email.clear();
|
||||
self.name.clear();
|
||||
@ -497,20 +497,20 @@ impl ::protobuf::Clear for UserSignUpRequest {
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::fmt::Debug for UserSignUpRequest {
|
||||
impl ::std::fmt::Debug for SignUpParams {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||
::protobuf::text_format::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::reflect::ProtobufValue for UserSignUpRequest {
|
||||
impl ::protobuf::reflect::ProtobufValue for SignUpParams {
|
||||
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
|
||||
::protobuf::reflect::ReflectValueRef::Message(self)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq,Clone,Default)]
|
||||
pub struct UserSignUpResult {
|
||||
pub struct SignUpResponse {
|
||||
// message fields
|
||||
pub is_success: bool,
|
||||
// special fields
|
||||
@ -518,14 +518,14 @@ pub struct UserSignUpResult {
|
||||
pub cached_size: ::protobuf::CachedSize,
|
||||
}
|
||||
|
||||
impl<'a> ::std::default::Default for &'a UserSignUpResult {
|
||||
fn default() -> &'a UserSignUpResult {
|
||||
<UserSignUpResult as ::protobuf::Message>::default_instance()
|
||||
impl<'a> ::std::default::Default for &'a SignUpResponse {
|
||||
fn default() -> &'a SignUpResponse {
|
||||
<SignUpResponse as ::protobuf::Message>::default_instance()
|
||||
}
|
||||
}
|
||||
|
||||
impl UserSignUpResult {
|
||||
pub fn new() -> UserSignUpResult {
|
||||
impl SignUpResponse {
|
||||
pub fn new() -> SignUpResponse {
|
||||
::std::default::Default::default()
|
||||
}
|
||||
|
||||
@ -545,7 +545,7 @@ impl UserSignUpResult {
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Message for UserSignUpResult {
|
||||
impl ::protobuf::Message for SignUpResponse {
|
||||
fn is_initialized(&self) -> bool {
|
||||
true
|
||||
}
|
||||
@ -615,8 +615,8 @@ impl ::protobuf::Message for UserSignUpResult {
|
||||
Self::descriptor_static()
|
||||
}
|
||||
|
||||
fn new() -> UserSignUpResult {
|
||||
UserSignUpResult::new()
|
||||
fn new() -> SignUpResponse {
|
||||
SignUpResponse::new()
|
||||
}
|
||||
|
||||
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
|
||||
@ -625,73 +625,73 @@ impl ::protobuf::Message for UserSignUpResult {
|
||||
let mut fields = ::std::vec::Vec::new();
|
||||
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBool>(
|
||||
"is_success",
|
||||
|m: &UserSignUpResult| { &m.is_success },
|
||||
|m: &mut UserSignUpResult| { &mut m.is_success },
|
||||
|m: &SignUpResponse| { &m.is_success },
|
||||
|m: &mut SignUpResponse| { &mut m.is_success },
|
||||
));
|
||||
::protobuf::reflect::MessageDescriptor::new_pb_name::<UserSignUpResult>(
|
||||
"UserSignUpResult",
|
||||
::protobuf::reflect::MessageDescriptor::new_pb_name::<SignUpResponse>(
|
||||
"SignUpResponse",
|
||||
fields,
|
||||
file_descriptor_proto()
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
fn default_instance() -> &'static UserSignUpResult {
|
||||
static instance: ::protobuf::rt::LazyV2<UserSignUpResult> = ::protobuf::rt::LazyV2::INIT;
|
||||
instance.get(UserSignUpResult::new)
|
||||
fn default_instance() -> &'static SignUpResponse {
|
||||
static instance: ::protobuf::rt::LazyV2<SignUpResponse> = ::protobuf::rt::LazyV2::INIT;
|
||||
instance.get(SignUpResponse::new)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Clear for UserSignUpResult {
|
||||
impl ::protobuf::Clear for SignUpResponse {
|
||||
fn clear(&mut self) {
|
||||
self.is_success = false;
|
||||
self.unknown_fields.clear();
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::fmt::Debug for UserSignUpResult {
|
||||
impl ::std::fmt::Debug for SignUpResponse {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||
::protobuf::text_format::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::reflect::ProtobufValue for UserSignUpResult {
|
||||
impl ::protobuf::reflect::ProtobufValue for SignUpResponse {
|
||||
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
|
||||
::protobuf::reflect::ReflectValueRef::Message(self)
|
||||
}
|
||||
}
|
||||
|
||||
static file_descriptor_proto_data: &'static [u8] = b"\
|
||||
\n\rsign_up.proto\"X\n\x10UserSignUpParams\x12\x14\n\x05email\x18\x01\
|
||||
\x20\x01(\tR\x05email\x12\x12\n\x04name\x18\x02\x20\x01(\tR\x04name\x12\
|
||||
\x1a\n\x08password\x18\x03\x20\x01(\tR\x08password\"Y\n\x11UserSignUpReq\
|
||||
uest\x12\x14\n\x05email\x18\x01\x20\x01(\tR\x05email\x12\x12\n\x04name\
|
||||
\x18\x02\x20\x01(\tR\x04name\x12\x1a\n\x08password\x18\x03\x20\x01(\tR\
|
||||
\x08password\"1\n\x10UserSignUpResult\x12\x1d\n\nis_success\x18\x01\x20\
|
||||
\x01(\x08R\tisSuccessJ\xdb\x03\n\x06\x12\x04\0\0\x0e\x01\n\x08\n\x01\x0c\
|
||||
\x12\x03\0\0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x06\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\x15\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\x10\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x13\x14\n\
|
||||
\x0b\n\x04\x04\0\x02\x01\x12\x03\x04\x04\x14\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\x0f\
|
||||
\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x04\x12\x13\n\x0b\n\x04\x04\0\x02\
|
||||
\x02\x12\x03\x05\x04\x18\n\x0c\n\x05\x04\0\x02\x02\x05\x12\x03\x05\x04\n\
|
||||
\n\x0c\n\x05\x04\0\x02\x02\x01\x12\x03\x05\x0b\x13\n\x0c\n\x05\x04\0\x02\
|
||||
\x02\x03\x12\x03\x05\x16\x17\n\n\n\x02\x04\x01\x12\x04\x07\0\x0b\x01\n\n\
|
||||
\n\x03\x04\x01\x01\x12\x03\x07\x08\x19\n\x0b\n\x04\x04\x01\x02\0\x12\x03\
|
||||
\x08\x04\x15\n\x0c\n\x05\x04\x01\x02\0\x05\x12\x03\x08\x04\n\n\x0c\n\x05\
|
||||
\x04\x01\x02\0\x01\x12\x03\x08\x0b\x10\n\x0c\n\x05\x04\x01\x02\0\x03\x12\
|
||||
\x03\x08\x13\x14\n\x0b\n\x04\x04\x01\x02\x01\x12\x03\t\x04\x14\n\x0c\n\
|
||||
\x05\x04\x01\x02\x01\x05\x12\x03\t\x04\n\n\x0c\n\x05\x04\x01\x02\x01\x01\
|
||||
\x12\x03\t\x0b\x0f\n\x0c\n\x05\x04\x01\x02\x01\x03\x12\x03\t\x12\x13\n\
|
||||
\x0b\n\x04\x04\x01\x02\x02\x12\x03\n\x04\x18\n\x0c\n\x05\x04\x01\x02\x02\
|
||||
\x05\x12\x03\n\x04\n\n\x0c\n\x05\x04\x01\x02\x02\x01\x12\x03\n\x0b\x13\n\
|
||||
\x0c\n\x05\x04\x01\x02\x02\x03\x12\x03\n\x16\x17\n\n\n\x02\x04\x02\x12\
|
||||
\x04\x0c\0\x0e\x01\n\n\n\x03\x04\x02\x01\x12\x03\x0c\x08\x18\n\x0b\n\x04\
|
||||
\x04\x02\x02\0\x12\x03\r\x04\x18\n\x0c\n\x05\x04\x02\x02\0\x05\x12\x03\r\
|
||||
\x04\x08\n\x0c\n\x05\x04\x02\x02\0\x01\x12\x03\r\t\x13\n\x0c\n\x05\x04\
|
||||
\x02\x02\0\x03\x12\x03\r\x16\x17b\x06proto3\
|
||||
\n\rsign_up.proto\"U\n\rSignUpRequest\x12\x14\n\x05email\x18\x01\x20\x01\
|
||||
(\tR\x05email\x12\x12\n\x04name\x18\x02\x20\x01(\tR\x04name\x12\x1a\n\
|
||||
\x08password\x18\x03\x20\x01(\tR\x08password\"T\n\x0cSignUpParams\x12\
|
||||
\x14\n\x05email\x18\x01\x20\x01(\tR\x05email\x12\x12\n\x04name\x18\x02\
|
||||
\x20\x01(\tR\x04name\x12\x1a\n\x08password\x18\x03\x20\x01(\tR\x08passwo\
|
||||
rd\"/\n\x0eSignUpResponse\x12\x1d\n\nis_success\x18\x01\x20\x01(\x08R\ti\
|
||||
sSuccessJ\xdb\x03\n\x06\x12\x04\0\0\x0e\x01\n\x08\n\x01\x0c\x12\x03\0\0\
|
||||
\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x06\x01\n\n\n\x03\x04\0\x01\x12\x03\
|
||||
\x02\x08\x15\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x15\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\x10\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x13\x14\n\x0b\n\x04\x04\
|
||||
\0\x02\x01\x12\x03\x04\x04\x14\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\x0f\n\x0c\n\x05\x04\
|
||||
\0\x02\x01\x03\x12\x03\x04\x12\x13\n\x0b\n\x04\x04\0\x02\x02\x12\x03\x05\
|
||||
\x04\x18\n\x0c\n\x05\x04\0\x02\x02\x05\x12\x03\x05\x04\n\n\x0c\n\x05\x04\
|
||||
\0\x02\x02\x01\x12\x03\x05\x0b\x13\n\x0c\n\x05\x04\0\x02\x02\x03\x12\x03\
|
||||
\x05\x16\x17\n\n\n\x02\x04\x01\x12\x04\x07\0\x0b\x01\n\n\n\x03\x04\x01\
|
||||
\x01\x12\x03\x07\x08\x14\n\x0b\n\x04\x04\x01\x02\0\x12\x03\x08\x04\x15\n\
|
||||
\x0c\n\x05\x04\x01\x02\0\x05\x12\x03\x08\x04\n\n\x0c\n\x05\x04\x01\x02\0\
|
||||
\x01\x12\x03\x08\x0b\x10\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03\x08\x13\
|
||||
\x14\n\x0b\n\x04\x04\x01\x02\x01\x12\x03\t\x04\x14\n\x0c\n\x05\x04\x01\
|
||||
\x02\x01\x05\x12\x03\t\x04\n\n\x0c\n\x05\x04\x01\x02\x01\x01\x12\x03\t\
|
||||
\x0b\x0f\n\x0c\n\x05\x04\x01\x02\x01\x03\x12\x03\t\x12\x13\n\x0b\n\x04\
|
||||
\x04\x01\x02\x02\x12\x03\n\x04\x18\n\x0c\n\x05\x04\x01\x02\x02\x05\x12\
|
||||
\x03\n\x04\n\n\x0c\n\x05\x04\x01\x02\x02\x01\x12\x03\n\x0b\x13\n\x0c\n\
|
||||
\x05\x04\x01\x02\x02\x03\x12\x03\n\x16\x17\n\n\n\x02\x04\x02\x12\x04\x0c\
|
||||
\0\x0e\x01\n\n\n\x03\x04\x02\x01\x12\x03\x0c\x08\x16\n\x0b\n\x04\x04\x02\
|
||||
\x02\0\x12\x03\r\x04\x18\n\x0c\n\x05\x04\x02\x02\0\x05\x12\x03\r\x04\x08\
|
||||
\n\x0c\n\x05\x04\x02\x02\0\x01\x12\x03\r\t\x13\n\x0c\n\x05\x04\x02\x02\0\
|
||||
\x03\x12\x03\r\x16\x17b\x06proto3\
|
||||
";
|
||||
|
||||
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
|
||||
|
@ -1,13 +1,13 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message UserSignInParams {
|
||||
message SignInRequest {
|
||||
string email = 1;
|
||||
string password = 2;
|
||||
}
|
||||
message UserSignInRequest {
|
||||
message SignInParams {
|
||||
string email = 1;
|
||||
string password = 2;
|
||||
}
|
||||
message UserSignInResult {
|
||||
message SignInResponse {
|
||||
bool is_success = 1;
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message UserSignUpParams {
|
||||
message SignUpRequest {
|
||||
string email = 1;
|
||||
string name = 2;
|
||||
string password = 3;
|
||||
}
|
||||
message UserSignUpRequest {
|
||||
message SignUpParams {
|
||||
string email = 1;
|
||||
string name = 2;
|
||||
string password = 3;
|
||||
}
|
||||
message UserSignUpResult {
|
||||
message SignUpResponse {
|
||||
bool is_success = 1;
|
||||
}
|
||||
|
132
rust-lib/flowy-user/tests/auth.rs
Normal file
132
rust-lib/flowy-user/tests/auth.rs
Normal file
@ -0,0 +1,132 @@
|
||||
use flowy_test::prelude::*;
|
||||
use flowy_user::{event::UserEvent::*, prelude::*};
|
||||
|
||||
#[test]
|
||||
fn sign_up_success() {
|
||||
let request = SignUpRequest {
|
||||
email: valid_email(),
|
||||
name: valid_name(),
|
||||
password: valid_password(),
|
||||
};
|
||||
|
||||
let response = EventTester::new(SignUp)
|
||||
.request(request)
|
||||
.sync_send()
|
||||
.parse::<SignUpResponse>();
|
||||
dbg!(&response);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sign_in_success() {
|
||||
let request = SignInRequest {
|
||||
email: valid_email(),
|
||||
password: valid_password(),
|
||||
};
|
||||
|
||||
let response = EventTester::new(SignIn)
|
||||
.request(request)
|
||||
.sync_send()
|
||||
.parse::<SignInResponse>();
|
||||
dbg!(&response);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sign_up_with_invalid_email() {
|
||||
for email in invalid_email_test_case() {
|
||||
let request = SignUpRequest {
|
||||
email: email.to_string(),
|
||||
name: valid_name(),
|
||||
password: valid_password(),
|
||||
};
|
||||
|
||||
let _ = EventTester::new(SignUp)
|
||||
.request(request)
|
||||
.assert_error()
|
||||
.sync_send();
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn sign_up_with_invalid_password() {
|
||||
for password in invalid_password_test_case() {
|
||||
let request = SignUpRequest {
|
||||
email: valid_email(),
|
||||
name: valid_name(),
|
||||
password,
|
||||
};
|
||||
|
||||
let _ = EventTester::new(SignUp)
|
||||
.request(request)
|
||||
.assert_error()
|
||||
.sync_send();
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn sign_in_with_invalid_email() {
|
||||
for email in invalid_email_test_case() {
|
||||
let request = SignInRequest {
|
||||
email: email.to_string(),
|
||||
password: valid_password(),
|
||||
};
|
||||
|
||||
let _ = EventTester::new(SignIn)
|
||||
.request(request)
|
||||
.assert_error()
|
||||
.sync_send();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sign_in_with_invalid_password() {
|
||||
for password in invalid_password_test_case() {
|
||||
let request = SignInRequest {
|
||||
email: valid_email(),
|
||||
password,
|
||||
};
|
||||
|
||||
let _ = EventTester::new(SignIn)
|
||||
.request(request)
|
||||
.assert_error()
|
||||
.sync_send();
|
||||
}
|
||||
}
|
||||
|
||||
fn invalid_email_test_case() -> Vec<String> {
|
||||
// https://gist.github.com/cjaoude/fd9910626629b53c4d25
|
||||
vec![
|
||||
"",
|
||||
"annie@",
|
||||
"annie@gmail@",
|
||||
"#@%^%#$@#$@#.com",
|
||||
"@example.com",
|
||||
"Joe Smith <email@example.com>",
|
||||
"email.example.com",
|
||||
"email@example@example.com",
|
||||
"email@-example.com",
|
||||
"email@example..com",
|
||||
"あいうえお@example.com",
|
||||
/* The following email is valid according to the validate_email function return
|
||||
* ".email@example.com",
|
||||
* "email.@example.com",
|
||||
* "email..email@example.com",
|
||||
* "email@example",
|
||||
* "email@example.web",
|
||||
* "email@111.222.333.44444",
|
||||
* "Abc..123@example.com", */
|
||||
]
|
||||
.iter()
|
||||
.map(|s| s.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
fn invalid_password_test_case() -> Vec<String> {
|
||||
vec!["", "123456", "1234".repeat(100).as_str()]
|
||||
.iter()
|
||||
.map(|s| s.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
fn valid_email() -> String { "annie@appflowy.io".to_string() }
|
||||
|
||||
fn valid_password() -> String { "HelloWorld!123".to_string() }
|
||||
|
||||
fn valid_name() -> String { "AppFlowy".to_string() }
|
@ -1 +1 @@
|
||||
mod sign_in;
|
||||
mod auth;
|
||||
|
@ -1,53 +0,0 @@
|
||||
use flowy_test::prelude::*;
|
||||
use flowy_user::prelude::{event::UserEvent::*, *};
|
||||
|
||||
#[test]
|
||||
fn sign_in_with_invalid_email() {
|
||||
let test_cases = vec!["", "annie@", "annie@gmail@"];
|
||||
let password = "Appflowy!123".to_string();
|
||||
|
||||
for email in test_cases {
|
||||
let params = UserSignInParams {
|
||||
email: email.to_string(),
|
||||
password: password.clone(),
|
||||
};
|
||||
|
||||
let _ = EventTester::new(SignIn)
|
||||
.payload(params)
|
||||
.assert_status_code(StatusCode::Err)
|
||||
.sync_send();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sign_in_with_invalid_password() {
|
||||
let test_cases = vec!["".to_string(), "123456".to_owned(), "1234".repeat(100)];
|
||||
let email = "annie@appflowy.io".to_string();
|
||||
|
||||
for password in test_cases {
|
||||
let params = UserSignInParams {
|
||||
email: email.clone(),
|
||||
password,
|
||||
};
|
||||
|
||||
let _ = EventTester::new(SignIn)
|
||||
.payload(params)
|
||||
.assert_status_code(StatusCode::Err)
|
||||
.sync_send();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sign_in_success() {
|
||||
let params = UserSignInParams {
|
||||
email: "annie@appflowy.io".to_string(),
|
||||
password: "HelloWorld!123".to_string(),
|
||||
};
|
||||
|
||||
let result = EventTester::new(SignIn)
|
||||
.payload(params)
|
||||
.assert_status_code(StatusCode::Ok)
|
||||
.sync_send()
|
||||
.parse::<UserSignInResult>();
|
||||
dbg!(&result);
|
||||
}
|
@ -3,11 +3,11 @@
|
||||
{%- endif -%}
|
||||
|
||||
class {{ event_class }} {
|
||||
{{ input_deserializer }} params;
|
||||
{{ event_class }}(this.params);
|
||||
{{ input_deserializer }} request;
|
||||
{{ event_class }}(this.request);
|
||||
|
||||
Future<Either<{{ output_deserializer }}, FlowyError>> send() {
|
||||
return paramsToBytes(params).fold(
|
||||
return requestToBytes(request).fold(
|
||||
(bytes) {
|
||||
final request = FFIRequest.create()
|
||||
..event = {{ event }}.toString()
|
||||
|
Loading…
Reference in New Issue
Block a user