rename flowy-editor to flowy-document

This commit is contained in:
appflowy 2021-07-31 10:50:56 +08:00
parent 033ea89bde
commit 55de7f69a4
89 changed files with 456 additions and 446 deletions

View File

@ -1,7 +1,7 @@
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:app_flowy/workspace/domain/i_doc.dart'; import 'package:app_flowy/workspace/domain/i_doc.dart';
import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:flowy_sdk/protobuf/flowy-editor/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-document/errors.pb.dart';
part 'doc_watch_bloc.freezed.dart'; part 'doc_watch_bloc.freezed.dart';
class DocWatchBloc extends Bloc<DocWatchEvent, DocWatchState> { class DocWatchBloc extends Bloc<DocWatchEvent, DocWatchState> {
@ -38,5 +38,5 @@ class DocWatchEvent with _$DocWatchEvent {
class DocWatchState with _$DocWatchState { class DocWatchState with _$DocWatchState {
const factory DocWatchState.loading() = Loading; const factory DocWatchState.loading() = Loading;
const factory DocWatchState.loadDoc(Doc doc) = LoadDoc; const factory DocWatchState.loadDoc(Doc doc) = LoadDoc;
const factory DocWatchState.loadFail(EditorError error) = LoadFail; const factory DocWatchState.loadFail(DocError error) = LoadFail;
} }

View File

@ -160,7 +160,7 @@ class _$DocWatchStateTearOff {
); );
} }
LoadFail loadFail(EditorError error) { LoadFail loadFail(DocError error) {
return LoadFail( return LoadFail(
error, error,
); );
@ -176,14 +176,14 @@ mixin _$DocWatchState {
TResult when<TResult extends Object?>({ TResult when<TResult extends Object?>({
required TResult Function() loading, required TResult Function() loading,
required TResult Function(Doc doc) loadDoc, required TResult Function(Doc doc) loadDoc,
required TResult Function(EditorError error) loadFail, required TResult Function(DocError error) loadFail,
}) => }) =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
@optionalTypeArgs @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({ TResult maybeWhen<TResult extends Object?>({
TResult Function()? loading, TResult Function()? loading,
TResult Function(Doc doc)? loadDoc, TResult Function(Doc doc)? loadDoc,
TResult Function(EditorError error)? loadFail, TResult Function(DocError error)? loadFail,
required TResult orElse(), required TResult orElse(),
}) => }) =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
@ -260,7 +260,7 @@ class _$Loading implements Loading {
TResult when<TResult extends Object?>({ TResult when<TResult extends Object?>({
required TResult Function() loading, required TResult Function() loading,
required TResult Function(Doc doc) loadDoc, required TResult Function(Doc doc) loadDoc,
required TResult Function(EditorError error) loadFail, required TResult Function(DocError error) loadFail,
}) { }) {
return loading(); return loading();
} }
@ -270,7 +270,7 @@ class _$Loading implements Loading {
TResult maybeWhen<TResult extends Object?>({ TResult maybeWhen<TResult extends Object?>({
TResult Function()? loading, TResult Function()? loading,
TResult Function(Doc doc)? loadDoc, TResult Function(Doc doc)? loadDoc,
TResult Function(EditorError error)? loadFail, TResult Function(DocError error)? loadFail,
required TResult orElse(), required TResult orElse(),
}) { }) {
if (loading != null) { if (loading != null) {
@ -372,7 +372,7 @@ class _$LoadDoc implements LoadDoc {
TResult when<TResult extends Object?>({ TResult when<TResult extends Object?>({
required TResult Function() loading, required TResult Function() loading,
required TResult Function(Doc doc) loadDoc, required TResult Function(Doc doc) loadDoc,
required TResult Function(EditorError error) loadFail, required TResult Function(DocError error) loadFail,
}) { }) {
return loadDoc(doc); return loadDoc(doc);
} }
@ -382,7 +382,7 @@ class _$LoadDoc implements LoadDoc {
TResult maybeWhen<TResult extends Object?>({ TResult maybeWhen<TResult extends Object?>({
TResult Function()? loading, TResult Function()? loading,
TResult Function(Doc doc)? loadDoc, TResult Function(Doc doc)? loadDoc,
TResult Function(EditorError error)? loadFail, TResult Function(DocError error)? loadFail,
required TResult orElse(), required TResult orElse(),
}) { }) {
if (loadDoc != null) { if (loadDoc != null) {
@ -428,7 +428,7 @@ abstract class LoadDoc implements DocWatchState {
abstract class $LoadFailCopyWith<$Res> { abstract class $LoadFailCopyWith<$Res> {
factory $LoadFailCopyWith(LoadFail value, $Res Function(LoadFail) then) = factory $LoadFailCopyWith(LoadFail value, $Res Function(LoadFail) then) =
_$LoadFailCopyWithImpl<$Res>; _$LoadFailCopyWithImpl<$Res>;
$Res call({EditorError error}); $Res call({DocError error});
} }
/// @nodoc /// @nodoc
@ -448,7 +448,7 @@ class _$LoadFailCopyWithImpl<$Res> extends _$DocWatchStateCopyWithImpl<$Res>
error == freezed error == freezed
? _value.error ? _value.error
: error // ignore: cast_nullable_to_non_nullable : error // ignore: cast_nullable_to_non_nullable
as EditorError, as DocError,
)); ));
} }
} }
@ -459,7 +459,7 @@ class _$LoadFail implements LoadFail {
const _$LoadFail(this.error); const _$LoadFail(this.error);
@override @override
final EditorError error; final DocError error;
@override @override
String toString() { String toString() {
@ -488,7 +488,7 @@ class _$LoadFail implements LoadFail {
TResult when<TResult extends Object?>({ TResult when<TResult extends Object?>({
required TResult Function() loading, required TResult Function() loading,
required TResult Function(Doc doc) loadDoc, required TResult Function(Doc doc) loadDoc,
required TResult Function(EditorError error) loadFail, required TResult Function(DocError error) loadFail,
}) { }) {
return loadFail(error); return loadFail(error);
} }
@ -498,7 +498,7 @@ class _$LoadFail implements LoadFail {
TResult maybeWhen<TResult extends Object?>({ TResult maybeWhen<TResult extends Object?>({
TResult Function()? loading, TResult Function()? loading,
TResult Function(Doc doc)? loadDoc, TResult Function(Doc doc)? loadDoc,
TResult Function(EditorError error)? loadFail, TResult Function(DocError error)? loadFail,
required TResult orElse(), required TResult orElse(),
}) { }) {
if (loadFail != null) { if (loadFail != null) {
@ -533,9 +533,9 @@ class _$LoadFail implements LoadFail {
} }
abstract class LoadFail implements DocWatchState { abstract class LoadFail implements DocWatchState {
const factory LoadFail(EditorError error) = _$LoadFail; const factory LoadFail(DocError error) = _$LoadFail;
EditorError get error => throw _privateConstructorUsedError; DocError get error => throw _privateConstructorUsedError;
@JsonKey(ignore: true) @JsonKey(ignore: true)
$LoadFailCopyWith<LoadFail> get copyWith => $LoadFailCopyWith<LoadFail> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;

View File

@ -1,7 +1,7 @@
import 'package:flowy_editor/flowy_editor.dart'; import 'package:flowy_editor/flowy_editor.dart';
import 'package:flowy_sdk/protobuf/flowy-editor/doc_create.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-document/doc_create.pb.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/protobuf/flowy-editor/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-document/errors.pb.dart';
class Doc { class Doc {
final DocInfo info; final DocInfo info;
@ -11,8 +11,8 @@ class Doc {
} }
abstract class IDoc { abstract class IDoc {
Future<Either<Doc, EditorError>> readDoc(); Future<Either<Doc, DocError>> readDoc();
Future<Either<Unit, EditorError>> updateDoc( Future<Either<Unit, DocError>> updateDoc(
{String? name, String? desc, String? text}); {String? name, String? desc, String? text});
Future<Either<Unit, EditorError>> closeDoc(); Future<Either<Unit, DocError>> closeDoc();
} }

View File

@ -2,7 +2,7 @@ import 'dart:convert';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
import 'package:flowy_editor/flowy_editor.dart'; import 'package:flowy_editor/flowy_editor.dart';
import 'package:flowy_sdk/protobuf/flowy-editor/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-document/errors.pb.dart';
import 'package:app_flowy/workspace/domain/i_doc.dart'; import 'package:app_flowy/workspace/domain/i_doc.dart';
import 'package:app_flowy/workspace/infrastructure/repos/doc_repo.dart'; import 'package:app_flowy/workspace/infrastructure/repos/doc_repo.dart';
@ -13,12 +13,12 @@ class IDocImpl extends IDoc {
IDocImpl({required this.repo}); IDocImpl({required this.repo});
@override @override
Future<Either<Unit, EditorError>> closeDoc() { Future<Either<Unit, DocError>> closeDoc() {
return repo.closeDoc(); return repo.closeDoc();
} }
@override @override
Future<Either<Doc, EditorError>> readDoc() async { Future<Either<Doc, DocError>> readDoc() async {
final docInfoOrFail = await repo.readDoc(); final docInfoOrFail = await repo.readDoc();
return docInfoOrFail.fold( return docInfoOrFail.fold(
(info) => _loadDocument(info.path).then((result) => result.fold( (info) => _loadDocument(info.path).then((result) => result.fold(
@ -29,13 +29,13 @@ class IDocImpl extends IDoc {
} }
@override @override
Future<Either<Unit, EditorError>> updateDoc( Future<Either<Unit, DocError>> updateDoc(
{String? name, String? desc, String? text}) { {String? name, String? desc, String? text}) {
final json = jsonEncode(text ?? ""); final json = jsonEncode(text ?? "");
return repo.updateDoc(name: name, desc: desc, text: json); return repo.updateDoc(name: name, desc: desc, text: json);
} }
Future<Either<Document, EditorError>> _loadDocument(String path) { Future<Either<Document, DocError>> _loadDocument(String path) {
return repo.readDocData(path).then((docDataOrFail) { return repo.readDocData(path).then((docDataOrFail) {
return docDataOrFail.fold( return docDataOrFail.fold(
(docData) => left(_decodeToDocument(docData.text)), (docData) => left(_decodeToDocument(docData.text)),

View File

@ -1,9 +1,9 @@
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
import 'package:flowy_sdk/dispatch/dispatch.dart'; import 'package:flowy_sdk/dispatch/dispatch.dart';
import 'package:flowy_sdk/protobuf/flowy-editor/doc_create.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-document/doc_create.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-editor/doc_modify.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-document/doc_modify.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-editor/doc_query.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-document/doc_query.pb.dart';
import 'package:flowy_sdk/protobuf/flowy-editor/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-document/errors.pb.dart';
class DocRepository { class DocRepository {
final String docId; final String docId;
@ -11,7 +11,7 @@ class DocRepository {
required this.docId, required this.docId,
}); });
Future<Either<DocInfo, EditorError>> createDoc( Future<Either<DocInfo, DocError>> createDoc(
{required String name, String? desc, String? text}) { {required String name, String? desc, String? text}) {
final request = final request =
CreateDocRequest(id: docId, name: name, desc: desc, text: text); CreateDocRequest(id: docId, name: name, desc: desc, text: text);
@ -19,26 +19,26 @@ class DocRepository {
return EditorEventCreateDoc(request).send(); return EditorEventCreateDoc(request).send();
} }
Future<Either<DocInfo, EditorError>> readDoc() { Future<Either<DocInfo, DocError>> readDoc() {
final request = QueryDocRequest.create()..docId = docId; final request = QueryDocRequest.create()..docId = docId;
return EditorEventReadDocInfo(request).send(); return EditorEventReadDocInfo(request).send();
} }
Future<Either<DocData, EditorError>> readDocData(String path) { Future<Either<DocData, DocError>> readDocData(String path) {
final request = QueryDocDataRequest.create() final request = QueryDocDataRequest.create()
..docId = docId ..docId = docId
..path = path; ..path = path;
return EditorEventReadDocData(request).send(); return EditorEventReadDocData(request).send();
} }
Future<Either<Unit, EditorError>> updateDoc( Future<Either<Unit, DocError>> updateDoc(
{String? name, String? desc, String? text}) { {String? name, String? desc, String? text}) {
final request = UpdateDocRequest(id: docId, name: name, text: text); final request = UpdateDocRequest(id: docId, name: name, text: text);
return EditorEventUpdateDoc(request).send(); return EditorEventUpdateDoc(request).send();
} }
Future<Either<Unit, EditorError>> closeDoc( Future<Either<Unit, DocError>> closeDoc(
{String? name, String? desc, String? text}) { {String? name, String? desc, String? text}) {
throw UnimplementedError(); throw UnimplementedError();
} }

View File

@ -2,74 +2,6 @@
/// Auto gen code from rust ast, do not edit /// Auto gen code from rust ast, do not edit
part of 'dispatch.dart'; part of 'dispatch.dart';
class EditorEventCreateDoc {
CreateDocRequest request;
EditorEventCreateDoc(this.request);
Future<Either<DocInfo, EditorError>> send() {
final request = FFIRequest.create()
..event = EditorEvent.CreateDoc.toString()
..payload = requestToBytes(this.request);
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(DocInfo.fromBuffer(okBytes)),
(errBytes) => right(EditorError.fromBuffer(errBytes)),
));
}
}
class EditorEventUpdateDoc {
UpdateDocRequest request;
EditorEventUpdateDoc(this.request);
Future<Either<Unit, EditorError>> send() {
final request = FFIRequest.create()
..event = EditorEvent.UpdateDoc.toString()
..payload = requestToBytes(this.request);
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(bytes) => left(unit),
(errBytes) => right(EditorError.fromBuffer(errBytes)),
));
}
}
class EditorEventReadDocInfo {
QueryDocRequest request;
EditorEventReadDocInfo(this.request);
Future<Either<DocInfo, EditorError>> send() {
final request = FFIRequest.create()
..event = EditorEvent.ReadDocInfo.toString()
..payload = requestToBytes(this.request);
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(DocInfo.fromBuffer(okBytes)),
(errBytes) => right(EditorError.fromBuffer(errBytes)),
));
}
}
class EditorEventReadDocData {
QueryDocDataRequest request;
EditorEventReadDocData(this.request);
Future<Either<DocData, EditorError>> send() {
final request = FFIRequest.create()
..event = EditorEvent.ReadDocData.toString()
..payload = requestToBytes(this.request);
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(DocData.fromBuffer(okBytes)),
(errBytes) => right(EditorError.fromBuffer(errBytes)),
));
}
}
class WorkspaceEventCreateWorkspace { class WorkspaceEventCreateWorkspace {
CreateWorkspaceRequest request; CreateWorkspaceRequest request;
WorkspaceEventCreateWorkspace(this.request); WorkspaceEventCreateWorkspace(this.request);
@ -285,6 +217,74 @@ class WorkspaceEventDeleteView {
} }
} }
class EditorEventCreateDoc {
CreateDocRequest request;
EditorEventCreateDoc(this.request);
Future<Either<DocInfo, DocError>> send() {
final request = FFIRequest.create()
..event = EditorEvent.CreateDoc.toString()
..payload = requestToBytes(this.request);
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(DocInfo.fromBuffer(okBytes)),
(errBytes) => right(DocError.fromBuffer(errBytes)),
));
}
}
class EditorEventUpdateDoc {
UpdateDocRequest request;
EditorEventUpdateDoc(this.request);
Future<Either<Unit, DocError>> send() {
final request = FFIRequest.create()
..event = EditorEvent.UpdateDoc.toString()
..payload = requestToBytes(this.request);
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(bytes) => left(unit),
(errBytes) => right(DocError.fromBuffer(errBytes)),
));
}
}
class EditorEventReadDocInfo {
QueryDocRequest request;
EditorEventReadDocInfo(this.request);
Future<Either<DocInfo, DocError>> send() {
final request = FFIRequest.create()
..event = EditorEvent.ReadDocInfo.toString()
..payload = requestToBytes(this.request);
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(DocInfo.fromBuffer(okBytes)),
(errBytes) => right(DocError.fromBuffer(errBytes)),
));
}
}
class EditorEventReadDocData {
QueryDocDataRequest request;
EditorEventReadDocData(this.request);
Future<Either<DocData, DocError>> send() {
final request = FFIRequest.create()
..event = EditorEvent.ReadDocData.toString()
..payload = requestToBytes(this.request);
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(DocData.fromBuffer(okBytes)),
(errBytes) => right(DocError.fromBuffer(errBytes)),
));
}
}
class UserEventGetStatus { class UserEventGetStatus {
UserEventGetStatus(); UserEventGetStatus();

View File

@ -13,7 +13,7 @@ import 'package:flowy_sdk/ffi.dart' as ffi;
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart'; import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
import 'package:flowy_sdk/protobuf/dart-ffi/protobuf.dart'; import 'package:flowy_sdk/protobuf/dart-ffi/protobuf.dart';
import 'package:flowy_sdk/protobuf/flowy-workspace/protobuf.dart'; import 'package:flowy_sdk/protobuf/flowy-workspace/protobuf.dart';
import 'package:flowy_sdk/protobuf/flowy-editor/protobuf.dart'; import 'package:flowy_sdk/protobuf/flowy-document/protobuf.dart';
// ignore: unused_import // ignore: unused_import
import 'package:flowy_sdk/protobuf/flowy-infra/protobuf.dart'; import 'package:flowy_sdk/protobuf/flowy-infra/protobuf.dart';
import 'package:protobuf/protobuf.dart'; import 'package:protobuf/protobuf.dart';

View File

@ -13,16 +13,16 @@ import 'errors.pbenum.dart';
export 'errors.pbenum.dart'; export 'errors.pbenum.dart';
class EditorError extends $pb.GeneratedMessage { class DocError extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'EditorError', createEmptyInstance: create) static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'DocError', createEmptyInstance: create)
..e<EditorErrorCode>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'code', $pb.PbFieldType.OE, defaultOrMaker: EditorErrorCode.Unknown, valueOf: EditorErrorCode.valueOf, enumValues: EditorErrorCode.values) ..e<DocErrorCode>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'code', $pb.PbFieldType.OE, defaultOrMaker: DocErrorCode.Unknown, valueOf: DocErrorCode.valueOf, enumValues: DocErrorCode.values)
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'msg') ..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'msg')
..hasRequiredFields = false ..hasRequiredFields = false
; ;
EditorError._() : super(); DocError._() : super();
factory EditorError({ factory DocError({
EditorErrorCode? code, DocErrorCode? code,
$core.String? msg, $core.String? msg,
}) { }) {
final _result = create(); final _result = create();
@ -34,31 +34,31 @@ class EditorError extends $pb.GeneratedMessage {
} }
return _result; return _result;
} }
factory EditorError.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); factory DocError.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory EditorError.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); factory DocError.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
@$core.Deprecated( @$core.Deprecated(
'Using this can add significant overhead to your binary. ' 'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version') 'Will be removed in next major version')
EditorError clone() => EditorError()..mergeFromMessage(this); DocError clone() => DocError()..mergeFromMessage(this);
@$core.Deprecated( @$core.Deprecated(
'Using this can add significant overhead to your binary. ' 'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version') 'Will be removed in next major version')
EditorError copyWith(void Function(EditorError) updates) => super.copyWith((message) => updates(message as EditorError)) as EditorError; // ignore: deprecated_member_use DocError copyWith(void Function(DocError) updates) => super.copyWith((message) => updates(message as DocError)) as DocError; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i; $pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline') @$core.pragma('dart2js:noInline')
static EditorError create() => EditorError._(); static DocError create() => DocError._();
EditorError createEmptyInstance() => create(); DocError createEmptyInstance() => create();
static $pb.PbList<EditorError> createRepeated() => $pb.PbList<EditorError>(); static $pb.PbList<DocError> createRepeated() => $pb.PbList<DocError>();
@$core.pragma('dart2js:noInline') @$core.pragma('dart2js:noInline')
static EditorError getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<EditorError>(create); static DocError getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<DocError>(create);
static EditorError? _defaultInstance; static DocError? _defaultInstance;
@$pb.TagNumber(1) @$pb.TagNumber(1)
EditorErrorCode get code => $_getN(0); DocErrorCode get code => $_getN(0);
@$pb.TagNumber(1) @$pb.TagNumber(1)
set code(EditorErrorCode v) { setField(1, v); } set code(DocErrorCode v) { setField(1, v); }
@$pb.TagNumber(1) @$pb.TagNumber(1)
$core.bool hasCode() => $_has(0); $core.bool hasCode() => $_has(0);
@$pb.TagNumber(1) @$pb.TagNumber(1)

View File

@ -0,0 +1,40 @@
///
// 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 DocErrorCode extends $pb.ProtobufEnum {
static const DocErrorCode Unknown = DocErrorCode._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'Unknown');
static const DocErrorCode EditorDBInternalError = DocErrorCode._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'EditorDBInternalError');
static const DocErrorCode EditorDBConnFailed = DocErrorCode._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'EditorDBConnFailed');
static const DocErrorCode DocNameInvalid = DocErrorCode._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DocNameInvalid');
static const DocErrorCode DocViewIdInvalid = DocErrorCode._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DocViewIdInvalid');
static const DocErrorCode DocDescTooLong = DocErrorCode._(12, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DocDescTooLong');
static const DocErrorCode DocOpenFileError = DocErrorCode._(13, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DocOpenFileError');
static const DocErrorCode DocFilePathInvalid = DocErrorCode._(14, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DocFilePathInvalid');
static const DocErrorCode EditorUserNotLoginYet = DocErrorCode._(100, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'EditorUserNotLoginYet');
static const $core.List<DocErrorCode> values = <DocErrorCode> [
Unknown,
EditorDBInternalError,
EditorDBConnFailed,
DocNameInvalid,
DocViewIdInvalid,
DocDescTooLong,
DocOpenFileError,
DocFilePathInvalid,
EditorUserNotLoginYet,
];
static final $core.Map<$core.int, DocErrorCode> _byValue = $pb.ProtobufEnum.initByValue(values);
static DocErrorCode? valueOf($core.int value) => _byValue[value];
const DocErrorCode._($core.int v, $core.String n) : super(v, n);
}

View File

@ -0,0 +1,39 @@
///
// 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 docErrorCodeDescriptor instead')
const DocErrorCode$json = const {
'1': 'DocErrorCode',
'2': const [
const {'1': 'Unknown', '2': 0},
const {'1': 'EditorDBInternalError', '2': 1},
const {'1': 'EditorDBConnFailed', '2': 2},
const {'1': 'DocNameInvalid', '2': 10},
const {'1': 'DocViewIdInvalid', '2': 11},
const {'1': 'DocDescTooLong', '2': 12},
const {'1': 'DocOpenFileError', '2': 13},
const {'1': 'DocFilePathInvalid', '2': 14},
const {'1': 'EditorUserNotLoginYet', '2': 100},
],
};
/// Descriptor for `DocErrorCode`. Decode as a `google.protobuf.EnumDescriptorProto`.
final $typed_data.Uint8List docErrorCodeDescriptor = $convert.base64Decode('CgxEb2NFcnJvckNvZGUSCwoHVW5rbm93bhAAEhkKFUVkaXRvckRCSW50ZXJuYWxFcnJvchABEhYKEkVkaXRvckRCQ29ubkZhaWxlZBACEhIKDkRvY05hbWVJbnZhbGlkEAoSFAoQRG9jVmlld0lkSW52YWxpZBALEhIKDkRvY0Rlc2NUb29Mb25nEAwSFAoQRG9jT3BlbkZpbGVFcnJvchANEhYKEkRvY0ZpbGVQYXRoSW52YWxpZBAOEhkKFUVkaXRvclVzZXJOb3RMb2dpbllldBBk');
@$core.Deprecated('Use docErrorDescriptor instead')
const DocError$json = const {
'1': 'DocError',
'2': const [
const {'1': 'code', '3': 1, '4': 1, '5': 14, '6': '.DocErrorCode', '10': 'code'},
const {'1': 'msg', '3': 2, '4': 1, '5': 9, '10': 'msg'},
],
};
/// Descriptor for `DocError`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List docErrorDescriptor = $convert.base64Decode('CghEb2NFcnJvchIhCgRjb2RlGAEgASgOMg0uRG9jRXJyb3JDb2RlUgRjb2RlEhAKA21zZxgCIAEoCVIDbXNn');

View File

@ -1,40 +0,0 @@
///
// Generated code. Do not modify.
// source: errors.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
// ignore_for_file: UNDEFINED_SHOWN_NAME
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
class EditorErrorCode extends $pb.ProtobufEnum {
static const EditorErrorCode Unknown = EditorErrorCode._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'Unknown');
static const EditorErrorCode EditorDBInternalError = EditorErrorCode._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'EditorDBInternalError');
static const EditorErrorCode EditorDBConnFailed = EditorErrorCode._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'EditorDBConnFailed');
static const EditorErrorCode DocNameInvalid = EditorErrorCode._(10, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DocNameInvalid');
static const EditorErrorCode DocViewIdInvalid = EditorErrorCode._(11, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DocViewIdInvalid');
static const EditorErrorCode DocDescTooLong = EditorErrorCode._(12, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DocDescTooLong');
static const EditorErrorCode DocOpenFileError = EditorErrorCode._(13, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DocOpenFileError');
static const EditorErrorCode DocFilePathInvalid = EditorErrorCode._(14, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DocFilePathInvalid');
static const EditorErrorCode EditorUserNotLoginYet = EditorErrorCode._(100, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'EditorUserNotLoginYet');
static const $core.List<EditorErrorCode> values = <EditorErrorCode> [
Unknown,
EditorDBInternalError,
EditorDBConnFailed,
DocNameInvalid,
DocViewIdInvalid,
DocDescTooLong,
DocOpenFileError,
DocFilePathInvalid,
EditorUserNotLoginYet,
];
static final $core.Map<$core.int, EditorErrorCode> _byValue = $pb.ProtobufEnum.initByValue(values);
static EditorErrorCode? valueOf($core.int value) => _byValue[value];
const EditorErrorCode._($core.int v, $core.String n) : super(v, n);
}

View File

@ -1,39 +0,0 @@
///
// Generated code. Do not modify.
// source: errors.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
import 'dart:core' as $core;
import 'dart:convert' as $convert;
import 'dart:typed_data' as $typed_data;
@$core.Deprecated('Use editorErrorCodeDescriptor instead')
const EditorErrorCode$json = const {
'1': 'EditorErrorCode',
'2': const [
const {'1': 'Unknown', '2': 0},
const {'1': 'EditorDBInternalError', '2': 1},
const {'1': 'EditorDBConnFailed', '2': 2},
const {'1': 'DocNameInvalid', '2': 10},
const {'1': 'DocViewIdInvalid', '2': 11},
const {'1': 'DocDescTooLong', '2': 12},
const {'1': 'DocOpenFileError', '2': 13},
const {'1': 'DocFilePathInvalid', '2': 14},
const {'1': 'EditorUserNotLoginYet', '2': 100},
],
};
/// Descriptor for `EditorErrorCode`. Decode as a `google.protobuf.EnumDescriptorProto`.
final $typed_data.Uint8List editorErrorCodeDescriptor = $convert.base64Decode('Cg9FZGl0b3JFcnJvckNvZGUSCwoHVW5rbm93bhAAEhkKFUVkaXRvckRCSW50ZXJuYWxFcnJvchABEhYKEkVkaXRvckRCQ29ubkZhaWxlZBACEhIKDkRvY05hbWVJbnZhbGlkEAoSFAoQRG9jVmlld0lkSW52YWxpZBALEhIKDkRvY0Rlc2NUb29Mb25nEAwSFAoQRG9jT3BlbkZpbGVFcnJvchANEhYKEkRvY0ZpbGVQYXRoSW52YWxpZBAOEhkKFUVkaXRvclVzZXJOb3RMb2dpbllldBBk');
@$core.Deprecated('Use editorErrorDescriptor instead')
const EditorError$json = const {
'1': 'EditorError',
'2': const [
const {'1': 'code', '3': 1, '4': 1, '5': 14, '6': '.EditorErrorCode', '10': 'code'},
const {'1': 'msg', '3': 2, '4': 1, '5': 9, '10': 'msg'},
],
};
/// Descriptor for `EditorError`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List editorErrorDescriptor = $convert.base64Decode('CgtFZGl0b3JFcnJvchIkCgRjb2RlGAEgASgOMhAuRWRpdG9yRXJyb3JDb2RlUgRjb2RlEhAKA21zZxgCIAEoCVIDbXNn');

View File

@ -13,6 +13,7 @@ members = [
"flowy-infra", "flowy-infra",
"flowy-workspace", "flowy-workspace",
"flowy-observable", "flowy-observable",
"flowy-document",
"flowy-editor", "flowy-editor",
] ]

View File

@ -17,13 +17,6 @@ pub fn category_from_str(type_str: &str) -> TypeCategory {
"String" => TypeCategory::Str, "String" => TypeCategory::Str,
"ObservableSubject" "ObservableSubject"
| "KeyValue" | "KeyValue"
| "CreateDocRequest"
| "DocInfo"
| "DocData"
| "QueryDocRequest"
| "QueryDocDataRequest"
| "UpdateDocRequest"
| "EditorError"
| "QueryAppRequest" | "QueryAppRequest"
| "CreateAppRequest" | "CreateAppRequest"
| "ColorStyle" | "ColorStyle"
@ -45,6 +38,13 @@ pub fn category_from_str(type_str: &str) -> TypeCategory {
| "View" | "View"
| "RepeatedView" | "RepeatedView"
| "WorkspaceError" | "WorkspaceError"
| "CreateDocRequest"
| "DocInfo"
| "DocData"
| "QueryDocRequest"
| "QueryDocDataRequest"
| "UpdateDocRequest"
| "DocError"
| "FFIRequest" | "FFIRequest"
| "FFIResponse" | "FFIResponse"
| "UserDetail" | "UserDetail"
@ -56,12 +56,12 @@ pub fn category_from_str(type_str: &str) -> TypeCategory {
| "SignInParams" | "SignInParams"
| "UserError" | "UserError"
=> TypeCategory::Protobuf, => TypeCategory::Protobuf,
"EditorEvent" "ViewType"
| "EditorErrorCode"
| "ViewType"
| "WorkspaceEvent" | "WorkspaceEvent"
| "WsErrCode" | "WsErrCode"
| "WorkspaceObservable" | "WorkspaceObservable"
| "EditorEvent"
| "DocErrorCode"
| "FFIStatusCode" | "FFIStatusCode"
| "UserStatus" | "UserStatus"
| "UserEvent" | "UserEvent"

View File

@ -67,9 +67,9 @@ impl Responder for EventResponse {
fn respond_to(self, _: &EventRequest) -> EventResponse { self } fn respond_to(self, _: &EventRequest) -> EventResponse { self }
} }
pub type ResponseResult<T, E> = std::result::Result<Data<T>, E>; pub type DataResult<T, E> = std::result::Result<Data<T>, E>;
pub fn response_ok<T, E>(data: T) -> Result<Data<T>, E> pub fn data_result<T, E>(data: T) -> Result<Data<T>, E>
where where
E: Into<DispatchError>, E: Into<DispatchError>,
{ {

View File

@ -0,0 +1,25 @@
[package]
name = "flowy-document"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
derive_more = {version = "0.99", features = ["display"]}
flowy-dispatch = { path = "../flowy-dispatch" }
flowy-log = { path = "../flowy-log" }
flowy-derive = { path = "../flowy-derive" }
flowy-database = { path = "../flowy-database" }
flowy-infra = { path = "../flowy-infra" }
diesel = {version = "1.4.7", features = ["sqlite"]}
diesel_derives = {version = "1.4.1", features = ["sqlite"]}
protobuf = {version = "2.18.0"}
unicode-segmentation = "1.7.1"
lazy_static = "1.4.0"
log = "0.4.14"
tokio = {version = "1.6.0", features = ["sync"]}
tracing = { version = "0.1", features = ["log"] }
[dev-dependencies]
flowy-test = { path = "../flowy-test" }

View File

@ -28,12 +28,12 @@ pub struct CreateDocParams {
} }
impl TryInto<CreateDocParams> for CreateDocRequest { impl TryInto<CreateDocParams> for CreateDocRequest {
type Error = EditorError; type Error = DocError;
fn try_into(self) -> Result<CreateDocParams, Self::Error> { fn try_into(self) -> Result<CreateDocParams, Self::Error> {
let name = DocName::parse(self.name) let name = DocName::parse(self.name)
.map_err(|e| { .map_err(|e| {
ErrorBuilder::new(EditorErrorCode::DocNameInvalid) ErrorBuilder::new(DocErrorCode::DocNameInvalid)
.msg(e) .msg(e)
.build() .build()
})? })?
@ -41,7 +41,7 @@ impl TryInto<CreateDocParams> for CreateDocRequest {
let id = DocViewId::parse(self.id) let id = DocViewId::parse(self.id)
.map_err(|e| { .map_err(|e| {
ErrorBuilder::new(EditorErrorCode::DocViewIdInvalid) ErrorBuilder::new(DocErrorCode::DocViewIdInvalid)
.msg(e) .msg(e)
.build() .build()
})? })?

View File

@ -25,12 +25,12 @@ pub(crate) struct UpdateDocParams {
} }
impl TryInto<UpdateDocParams> for UpdateDocRequest { impl TryInto<UpdateDocParams> for UpdateDocRequest {
type Error = EditorError; type Error = DocError;
fn try_into(self) -> Result<UpdateDocParams, Self::Error> { fn try_into(self) -> Result<UpdateDocParams, Self::Error> {
let id = DocId::parse(self.id) let id = DocId::parse(self.id)
.map_err(|e| { .map_err(|e| {
ErrorBuilder::new(EditorErrorCode::DocViewIdInvalid) ErrorBuilder::new(DocErrorCode::DocViewIdInvalid)
.msg(e) .msg(e)
.build() .build()
})? })?
@ -41,7 +41,7 @@ impl TryInto<UpdateDocParams> for UpdateDocRequest {
Some(name) => Some( Some(name) => Some(
DocName::parse(name) DocName::parse(name)
.map_err(|e| { .map_err(|e| {
ErrorBuilder::new(EditorErrorCode::DocNameInvalid) ErrorBuilder::new(DocErrorCode::DocNameInvalid)
.msg(e) .msg(e)
.build() .build()
})? })?
@ -54,7 +54,7 @@ impl TryInto<UpdateDocParams> for UpdateDocRequest {
Some(desc) => Some( Some(desc) => Some(
DocDesc::parse(desc) DocDesc::parse(desc)
.map_err(|e| { .map_err(|e| {
ErrorBuilder::new(EditorErrorCode::DocDescTooLong) ErrorBuilder::new(DocErrorCode::DocDescTooLong)
.msg(e) .msg(e)
.build() .build()
})? })?

View File

@ -16,12 +16,12 @@ pub(crate) struct QueryDocParams {
} }
impl TryInto<QueryDocParams> for QueryDocRequest { impl TryInto<QueryDocParams> for QueryDocRequest {
type Error = EditorError; type Error = DocError;
fn try_into(self) -> Result<QueryDocParams, Self::Error> { fn try_into(self) -> Result<QueryDocParams, Self::Error> {
let doc_id = DocId::parse(self.doc_id) let doc_id = DocId::parse(self.doc_id)
.map_err(|e| { .map_err(|e| {
ErrorBuilder::new(EditorErrorCode::DocViewIdInvalid) ErrorBuilder::new(DocErrorCode::DocViewIdInvalid)
.msg(e) .msg(e)
.build() .build()
})? })?
@ -46,12 +46,12 @@ pub(crate) struct QueryDocDataParams {
} }
impl TryInto<QueryDocDataParams> for QueryDocDataRequest { impl TryInto<QueryDocDataParams> for QueryDocDataRequest {
type Error = EditorError; type Error = DocError;
fn try_into(self) -> Result<QueryDocDataParams, Self::Error> { fn try_into(self) -> Result<QueryDocDataParams, Self::Error> {
let doc_id = DocId::parse(self.doc_id) let doc_id = DocId::parse(self.doc_id)
.map_err(|e| { .map_err(|e| {
ErrorBuilder::new(EditorErrorCode::DocViewIdInvalid) ErrorBuilder::new(DocErrorCode::DocViewIdInvalid)
.msg(e) .msg(e)
.build() .build()
})? })?
@ -59,7 +59,7 @@ impl TryInto<QueryDocDataParams> for QueryDocDataRequest {
let path = DocPath::parse(self.path) let path = DocPath::parse(self.path)
.map_err(|e| { .map_err(|e| {
ErrorBuilder::new(EditorErrorCode::DocFilePathInvalid) ErrorBuilder::new(DocErrorCode::DocFilePathInvalid)
.msg(e) .msg(e)
.build() .build()
})? })?

View File

@ -5,16 +5,16 @@ use flowy_dispatch::prelude::{EventResponse, ResponseBuilder};
use std::convert::TryInto; use std::convert::TryInto;
#[derive(Debug, Default, Clone, ProtoBuf)] #[derive(Debug, Default, Clone, ProtoBuf)]
pub struct EditorError { pub struct DocError {
#[pb(index = 1)] #[pb(index = 1)]
pub code: EditorErrorCode, pub code: DocErrorCode,
#[pb(index = 2)] #[pb(index = 2)]
pub msg: String, pub msg: String,
} }
impl EditorError { impl DocError {
fn new(code: EditorErrorCode, msg: &str) -> Self { fn new(code: DocErrorCode, msg: &str) -> Self {
Self { Self {
code, code,
msg: msg.to_owned(), msg: msg.to_owned(),
@ -23,7 +23,7 @@ impl EditorError {
} }
#[derive(Debug, Clone, ProtoBuf_Enum, Display, PartialEq, Eq)] #[derive(Debug, Clone, ProtoBuf_Enum, Display, PartialEq, Eq)]
pub enum EditorErrorCode { pub enum DocErrorCode {
#[display(fmt = "Unknown")] #[display(fmt = "Unknown")]
Unknown = 0, Unknown = 0,
@ -52,27 +52,27 @@ pub enum EditorErrorCode {
EditorUserNotLoginYet = 100, EditorUserNotLoginYet = 100,
} }
impl std::default::Default for EditorErrorCode { impl std::default::Default for DocErrorCode {
fn default() -> Self { EditorErrorCode::Unknown } fn default() -> Self { DocErrorCode::Unknown }
} }
impl std::convert::From<flowy_database::result::Error> for EditorError { impl std::convert::From<flowy_database::result::Error> for DocError {
fn from(error: flowy_database::result::Error) -> Self { fn from(error: flowy_database::result::Error) -> Self {
ErrorBuilder::new(EditorErrorCode::EditorDBInternalError) ErrorBuilder::new(DocErrorCode::EditorDBInternalError)
.error(error) .error(error)
.build() .build()
} }
} }
impl std::convert::From<FileError> for EditorError { impl std::convert::From<FileError> for DocError {
fn from(error: FileError) -> Self { fn from(error: FileError) -> Self {
ErrorBuilder::new(EditorErrorCode::DocOpenFileError) ErrorBuilder::new(DocErrorCode::DocOpenFileError)
.error(error) .error(error)
.build() .build()
} }
} }
impl flowy_dispatch::Error for EditorError { impl flowy_dispatch::Error for DocError {
fn as_response(&self) -> EventResponse { fn as_response(&self) -> EventResponse {
let bytes: Vec<u8> = self.clone().try_into().unwrap(); let bytes: Vec<u8> = self.clone().try_into().unwrap();
ResponseBuilder::Err().data(bytes).build() ResponseBuilder::Err().data(bytes).build()
@ -80,12 +80,12 @@ impl flowy_dispatch::Error for EditorError {
} }
pub struct ErrorBuilder { pub struct ErrorBuilder {
pub code: EditorErrorCode, pub code: DocErrorCode,
pub msg: Option<String>, pub msg: Option<String>,
} }
impl ErrorBuilder { impl ErrorBuilder {
pub fn new(code: EditorErrorCode) -> Self { ErrorBuilder { code, msg: None } } pub fn new(code: DocErrorCode) -> Self { ErrorBuilder { code, msg: None } }
pub fn msg<T>(mut self, msg: T) -> Self pub fn msg<T>(mut self, msg: T) -> Self
where where
@ -103,7 +103,7 @@ impl ErrorBuilder {
self self
} }
pub fn build(mut self) -> EditorError { pub fn build(mut self) -> DocError {
EditorError::new(self.code, &self.msg.take().unwrap_or("".to_owned())) DocError::new(self.code, &self.msg.take().unwrap_or("".to_owned()))
} }
} }

View File

@ -2,7 +2,7 @@ use derive_more::Display;
use flowy_derive::{Flowy_Event, ProtoBuf_Enum}; use flowy_derive::{Flowy_Event, ProtoBuf_Enum};
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)] #[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
#[event_err = "EditorError"] #[event_err = "DocError"]
pub enum EditorEvent { pub enum EditorEvent {
#[display(fmt = "CreateDoc")] #[display(fmt = "CreateDoc")]
#[event(input = "CreateDocRequest", output = "DocInfo")] #[event(input = "CreateDocRequest", output = "DocInfo")]

View File

@ -1,6 +1,6 @@
use crate::{ use crate::{
entities::doc::*, entities::doc::*,
errors::EditorError, errors::DocError,
services::{doc_controller::DocController, file_manager::FileManager}, services::{doc_controller::DocController, file_manager::FileManager},
}; };
use flowy_dispatch::prelude::*; use flowy_dispatch::prelude::*;
@ -12,7 +12,7 @@ pub async fn create_doc(
data: Data<CreateDocRequest>, data: Data<CreateDocRequest>,
controller: Unit<DocController>, controller: Unit<DocController>,
manager: Unit<RwLock<FileManager>>, manager: Unit<RwLock<FileManager>>,
) -> ResponseResult<DocInfo, EditorError> { ) -> DataResult<DocInfo, DocError> {
let params: CreateDocParams = data.into_inner().try_into()?; let params: CreateDocParams = data.into_inner().try_into()?;
let dir = manager.read().await.user.user_doc_dir()?; let dir = manager.read().await.user.user_doc_dir()?;
let path = manager let path = manager
@ -22,7 +22,7 @@ pub async fn create_doc(
let doc_desc = controller let doc_desc = controller
.create_doc(params, path.to_str().unwrap()) .create_doc(params, path.to_str().unwrap())
.await?; .await?;
response_ok(doc_desc) data_result(doc_desc)
} }
#[tracing::instrument(name = "read_doc", skip(data, controller, manager))] #[tracing::instrument(name = "read_doc", skip(data, controller, manager))]
@ -30,7 +30,7 @@ pub async fn read_doc(
data: Data<QueryDocRequest>, data: Data<QueryDocRequest>,
controller: Unit<DocController>, controller: Unit<DocController>,
manager: Unit<RwLock<FileManager>>, manager: Unit<RwLock<FileManager>>,
) -> ResponseResult<DocInfo, EditorError> { ) -> DataResult<DocInfo, DocError> {
let params: QueryDocParams = data.into_inner().try_into()?; let params: QueryDocParams = data.into_inner().try_into()?;
let doc_info = controller.read_doc(&params.doc_id).await?; let doc_info = controller.read_doc(&params.doc_id).await?;
let _ = manager let _ = manager
@ -38,28 +38,28 @@ pub async fn read_doc(
.await .await
.open(Path::new(&doc_info.path), doc_info.id.clone())?; .open(Path::new(&doc_info.path), doc_info.id.clone())?;
response_ok(doc_info) data_result(doc_info)
} }
#[tracing::instrument(name = "read_doc_data", skip(data, manager))] #[tracing::instrument(name = "read_doc_data", skip(data, manager))]
pub async fn read_doc_data( pub async fn read_doc_data(
data: Data<QueryDocDataRequest>, data: Data<QueryDocDataRequest>,
manager: Unit<RwLock<FileManager>>, manager: Unit<RwLock<FileManager>>,
) -> ResponseResult<DocData, EditorError> { ) -> DataResult<DocData, DocError> {
let params: QueryDocDataParams = data.into_inner().try_into()?; let params: QueryDocDataParams = data.into_inner().try_into()?;
let text = manager let text = manager
.write() .write()
.await .await
.open(Path::new(&params.path), params.doc_id)?; .open(Path::new(&params.path), params.doc_id)?;
response_ok(DocData { text }) data_result(DocData { text })
} }
pub async fn update_doc( pub async fn update_doc(
data: Data<UpdateDocRequest>, data: Data<UpdateDocRequest>,
controller: Unit<DocController>, controller: Unit<DocController>,
manager: Unit<RwLock<FileManager>>, manager: Unit<RwLock<FileManager>>,
) -> Result<(), EditorError> { ) -> Result<(), DocError> {
let mut params: UpdateDocParams = data.into_inner().try_into()?; let mut params: UpdateDocParams = data.into_inner().try_into()?;
if let Some(s) = params.text.take() { if let Some(s) = params.text.take() {

View File

@ -0,0 +1,15 @@
pub mod entities;
pub mod errors;
pub mod event;
mod handlers;
pub mod module;
mod protobuf;
mod services;
mod sql_tables;
#[macro_use]
extern crate flowy_database;
pub mod prelude {
pub use crate::module::*;
}

View File

@ -1,5 +1,5 @@
use crate::{ use crate::{
errors::EditorError, errors::DocError,
event::EditorEvent, event::EditorEvent,
handlers::*, handlers::*,
services::{doc_controller::DocController, file_manager::FileManager}, services::{doc_controller::DocController, file_manager::FileManager},
@ -9,20 +9,20 @@ use flowy_dispatch::prelude::*;
use std::sync::Arc; use std::sync::Arc;
use tokio::sync::RwLock; use tokio::sync::RwLock;
pub trait EditorDatabase: Send + Sync { pub trait DocumentDatabase: Send + Sync {
fn db_connection(&self) -> Result<DBConnection, EditorError>; fn db_connection(&self) -> Result<DBConnection, DocError>;
} }
pub trait EditorUser: Send + Sync { pub trait DocumentUser: Send + Sync {
fn user_doc_dir(&self) -> Result<String, EditorError>; fn user_doc_dir(&self) -> Result<String, DocError>;
} }
pub fn create(database: Arc<dyn EditorDatabase>, user: Arc<dyn EditorUser>) -> Module { pub fn create(database: Arc<dyn DocumentDatabase>, user: Arc<dyn DocumentUser>) -> Module {
let file_manager = RwLock::new(FileManager::new(user.clone())); let file_manager = RwLock::new(FileManager::new(user.clone()));
let doc_controller = DocController::new(database); let doc_controller = DocController::new(database);
Module::new() Module::new()
.name("Flowy-Editor") .name("flowy-document")
.data(file_manager) .data(file_manager)
.data(doc_controller) .data(doc_controller)
.event(EditorEvent::CreateDoc, create_doc) .event(EditorEvent::CreateDoc, create_doc)

View File

@ -24,38 +24,38 @@
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1; // const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1;
#[derive(PartialEq,Clone,Default)] #[derive(PartialEq,Clone,Default)]
pub struct EditorError { pub struct DocError {
// message fields // message fields
pub code: EditorErrorCode, pub code: DocErrorCode,
pub msg: ::std::string::String, pub msg: ::std::string::String,
// special fields // special fields
pub unknown_fields: ::protobuf::UnknownFields, pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize, pub cached_size: ::protobuf::CachedSize,
} }
impl<'a> ::std::default::Default for &'a EditorError { impl<'a> ::std::default::Default for &'a DocError {
fn default() -> &'a EditorError { fn default() -> &'a DocError {
<EditorError as ::protobuf::Message>::default_instance() <DocError as ::protobuf::Message>::default_instance()
} }
} }
impl EditorError { impl DocError {
pub fn new() -> EditorError { pub fn new() -> DocError {
::std::default::Default::default() ::std::default::Default::default()
} }
// .EditorErrorCode code = 1; // .DocErrorCode code = 1;
pub fn get_code(&self) -> EditorErrorCode { pub fn get_code(&self) -> DocErrorCode {
self.code self.code
} }
pub fn clear_code(&mut self) { pub fn clear_code(&mut self) {
self.code = EditorErrorCode::Unknown; self.code = DocErrorCode::Unknown;
} }
// Param is passed by value, moved // Param is passed by value, moved
pub fn set_code(&mut self, v: EditorErrorCode) { pub fn set_code(&mut self, v: DocErrorCode) {
self.code = v; self.code = v;
} }
@ -86,7 +86,7 @@ impl EditorError {
} }
} }
impl ::protobuf::Message for EditorError { impl ::protobuf::Message for DocError {
fn is_initialized(&self) -> bool { fn is_initialized(&self) -> bool {
true true
} }
@ -113,7 +113,7 @@ impl ::protobuf::Message for EditorError {
#[allow(unused_variables)] #[allow(unused_variables)]
fn compute_size(&self) -> u32 { fn compute_size(&self) -> u32 {
let mut my_size = 0; let mut my_size = 0;
if self.code != EditorErrorCode::Unknown { if self.code != DocErrorCode::Unknown {
my_size += ::protobuf::rt::enum_size(1, self.code); my_size += ::protobuf::rt::enum_size(1, self.code);
} }
if !self.msg.is_empty() { if !self.msg.is_empty() {
@ -125,7 +125,7 @@ impl ::protobuf::Message for EditorError {
} }
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
if self.code != EditorErrorCode::Unknown { if self.code != DocErrorCode::Unknown {
os.write_enum(1, ::protobuf::ProtobufEnum::value(&self.code))?; os.write_enum(1, ::protobuf::ProtobufEnum::value(&self.code))?;
} }
if !self.msg.is_empty() { if !self.msg.is_empty() {
@ -161,60 +161,60 @@ impl ::protobuf::Message for EditorError {
Self::descriptor_static() Self::descriptor_static()
} }
fn new() -> EditorError { fn new() -> DocError {
EditorError::new() DocError::new()
} }
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT;
descriptor.get(|| { descriptor.get(|| {
let mut fields = ::std::vec::Vec::new(); let mut fields = ::std::vec::Vec::new();
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeEnum<EditorErrorCode>>( fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeEnum<DocErrorCode>>(
"code", "code",
|m: &EditorError| { &m.code }, |m: &DocError| { &m.code },
|m: &mut EditorError| { &mut m.code }, |m: &mut DocError| { &mut m.code },
)); ));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"msg", "msg",
|m: &EditorError| { &m.msg }, |m: &DocError| { &m.msg },
|m: &mut EditorError| { &mut m.msg }, |m: &mut DocError| { &mut m.msg },
)); ));
::protobuf::reflect::MessageDescriptor::new_pb_name::<EditorError>( ::protobuf::reflect::MessageDescriptor::new_pb_name::<DocError>(
"EditorError", "DocError",
fields, fields,
file_descriptor_proto() file_descriptor_proto()
) )
}) })
} }
fn default_instance() -> &'static EditorError { fn default_instance() -> &'static DocError {
static instance: ::protobuf::rt::LazyV2<EditorError> = ::protobuf::rt::LazyV2::INIT; static instance: ::protobuf::rt::LazyV2<DocError> = ::protobuf::rt::LazyV2::INIT;
instance.get(EditorError::new) instance.get(DocError::new)
} }
} }
impl ::protobuf::Clear for EditorError { impl ::protobuf::Clear for DocError {
fn clear(&mut self) { fn clear(&mut self) {
self.code = EditorErrorCode::Unknown; self.code = DocErrorCode::Unknown;
self.msg.clear(); self.msg.clear();
self.unknown_fields.clear(); self.unknown_fields.clear();
} }
} }
impl ::std::fmt::Debug for EditorError { impl ::std::fmt::Debug for DocError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f) ::protobuf::text_format::fmt(self, f)
} }
} }
impl ::protobuf::reflect::ProtobufValue for EditorError { impl ::protobuf::reflect::ProtobufValue for DocError {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
::protobuf::reflect::ReflectValueRef::Message(self) ::protobuf::reflect::ReflectValueRef::Message(self)
} }
} }
#[derive(Clone,PartialEq,Eq,Debug,Hash)] #[derive(Clone,PartialEq,Eq,Debug,Hash)]
pub enum EditorErrorCode { pub enum DocErrorCode {
Unknown = 0, Unknown = 0,
EditorDBInternalError = 1, EditorDBInternalError = 1,
EditorDBConnFailed = 2, EditorDBConnFailed = 2,
@ -226,37 +226,37 @@ pub enum EditorErrorCode {
EditorUserNotLoginYet = 100, EditorUserNotLoginYet = 100,
} }
impl ::protobuf::ProtobufEnum for EditorErrorCode { impl ::protobuf::ProtobufEnum for DocErrorCode {
fn value(&self) -> i32 { fn value(&self) -> i32 {
*self as i32 *self as i32
} }
fn from_i32(value: i32) -> ::std::option::Option<EditorErrorCode> { fn from_i32(value: i32) -> ::std::option::Option<DocErrorCode> {
match value { match value {
0 => ::std::option::Option::Some(EditorErrorCode::Unknown), 0 => ::std::option::Option::Some(DocErrorCode::Unknown),
1 => ::std::option::Option::Some(EditorErrorCode::EditorDBInternalError), 1 => ::std::option::Option::Some(DocErrorCode::EditorDBInternalError),
2 => ::std::option::Option::Some(EditorErrorCode::EditorDBConnFailed), 2 => ::std::option::Option::Some(DocErrorCode::EditorDBConnFailed),
10 => ::std::option::Option::Some(EditorErrorCode::DocNameInvalid), 10 => ::std::option::Option::Some(DocErrorCode::DocNameInvalid),
11 => ::std::option::Option::Some(EditorErrorCode::DocViewIdInvalid), 11 => ::std::option::Option::Some(DocErrorCode::DocViewIdInvalid),
12 => ::std::option::Option::Some(EditorErrorCode::DocDescTooLong), 12 => ::std::option::Option::Some(DocErrorCode::DocDescTooLong),
13 => ::std::option::Option::Some(EditorErrorCode::DocOpenFileError), 13 => ::std::option::Option::Some(DocErrorCode::DocOpenFileError),
14 => ::std::option::Option::Some(EditorErrorCode::DocFilePathInvalid), 14 => ::std::option::Option::Some(DocErrorCode::DocFilePathInvalid),
100 => ::std::option::Option::Some(EditorErrorCode::EditorUserNotLoginYet), 100 => ::std::option::Option::Some(DocErrorCode::EditorUserNotLoginYet),
_ => ::std::option::Option::None _ => ::std::option::Option::None
} }
} }
fn values() -> &'static [Self] { fn values() -> &'static [Self] {
static values: &'static [EditorErrorCode] = &[ static values: &'static [DocErrorCode] = &[
EditorErrorCode::Unknown, DocErrorCode::Unknown,
EditorErrorCode::EditorDBInternalError, DocErrorCode::EditorDBInternalError,
EditorErrorCode::EditorDBConnFailed, DocErrorCode::EditorDBConnFailed,
EditorErrorCode::DocNameInvalid, DocErrorCode::DocNameInvalid,
EditorErrorCode::DocViewIdInvalid, DocErrorCode::DocViewIdInvalid,
EditorErrorCode::DocDescTooLong, DocErrorCode::DocDescTooLong,
EditorErrorCode::DocOpenFileError, DocErrorCode::DocOpenFileError,
EditorErrorCode::DocFilePathInvalid, DocErrorCode::DocFilePathInvalid,
EditorErrorCode::EditorUserNotLoginYet, DocErrorCode::EditorUserNotLoginYet,
]; ];
values values
} }
@ -264,61 +264,61 @@ impl ::protobuf::ProtobufEnum for EditorErrorCode {
fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor { fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor {
static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::LazyV2::INIT; static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::LazyV2::INIT;
descriptor.get(|| { descriptor.get(|| {
::protobuf::reflect::EnumDescriptor::new_pb_name::<EditorErrorCode>("EditorErrorCode", file_descriptor_proto()) ::protobuf::reflect::EnumDescriptor::new_pb_name::<DocErrorCode>("DocErrorCode", file_descriptor_proto())
}) })
} }
} }
impl ::std::marker::Copy for EditorErrorCode { impl ::std::marker::Copy for DocErrorCode {
} }
impl ::std::default::Default for EditorErrorCode { impl ::std::default::Default for DocErrorCode {
fn default() -> Self { fn default() -> Self {
EditorErrorCode::Unknown DocErrorCode::Unknown
} }
} }
impl ::protobuf::reflect::ProtobufValue for EditorErrorCode { impl ::protobuf::reflect::ProtobufValue for DocErrorCode {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
::protobuf::reflect::ReflectValueRef::Enum(::protobuf::ProtobufEnum::descriptor(self)) ::protobuf::reflect::ReflectValueRef::Enum(::protobuf::ProtobufEnum::descriptor(self))
} }
} }
static file_descriptor_proto_data: &'static [u8] = b"\ static file_descriptor_proto_data: &'static [u8] = b"\
\n\x0cerrors.proto\"E\n\x0bEditorError\x12$\n\x04code\x18\x01\x20\x01(\ \n\x0cerrors.proto\"?\n\x08DocError\x12!\n\x04code\x18\x01\x20\x01(\x0e2\
\x0e2\x10.EditorErrorCodeR\x04code\x12\x10\n\x03msg\x18\x02\x20\x01(\tR\ \r.DocErrorCodeR\x04code\x12\x10\n\x03msg\x18\x02\x20\x01(\tR\x03msg*\
\x03msg*\xd8\x01\n\x0fEditorErrorCode\x12\x0b\n\x07Unknown\x10\0\x12\x19\ \xd5\x01\n\x0cDocErrorCode\x12\x0b\n\x07Unknown\x10\0\x12\x19\n\x15Edito\
\n\x15EditorDBInternalError\x10\x01\x12\x16\n\x12EditorDBConnFailed\x10\ rDBInternalError\x10\x01\x12\x16\n\x12EditorDBConnFailed\x10\x02\x12\x12\
\x02\x12\x12\n\x0eDocNameInvalid\x10\n\x12\x14\n\x10DocViewIdInvalid\x10\ \n\x0eDocNameInvalid\x10\n\x12\x14\n\x10DocViewIdInvalid\x10\x0b\x12\x12\
\x0b\x12\x12\n\x0eDocDescTooLong\x10\x0c\x12\x14\n\x10DocOpenFileError\ \n\x0eDocDescTooLong\x10\x0c\x12\x14\n\x10DocOpenFileError\x10\r\x12\x16\
\x10\r\x12\x16\n\x12DocFilePathInvalid\x10\x0e\x12\x19\n\x15EditorUserNo\ \n\x12DocFilePathInvalid\x10\x0e\x12\x19\n\x15EditorUserNotLoginYet\x10d\
tLoginYet\x10dJ\xa1\x04\n\x06\x12\x04\0\0\x10\x01\n\x08\n\x01\x0c\x12\ J\xa1\x04\n\x06\x12\x04\0\0\x10\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\
\x03\0\0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x05\x01\n\n\n\x03\x04\0\x01\ \n\x02\x04\0\x12\x04\x02\0\x05\x01\n\n\n\x03\x04\0\x01\x12\x03\x02\x08\
\x12\x03\x02\x08\x13\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x1d\n\x0c\n\ \x10\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x1a\n\x0c\n\x05\x04\0\x02\0\
\x05\x04\0\x02\0\x06\x12\x03\x03\x04\x13\n\x0c\n\x05\x04\0\x02\0\x01\x12\ \x06\x12\x03\x03\x04\x10\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\x11\x15\
\x03\x03\x14\x18\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x1b\x1c\n\x0b\n\ \n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x18\x19\n\x0b\n\x04\x04\0\x02\
\x04\x04\0\x02\x01\x12\x03\x04\x04\x13\n\x0c\n\x05\x04\0\x02\x01\x05\x12\ \x01\x12\x03\x04\x04\x13\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x04\x04\n\
\x03\x04\x04\n\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x04\x0b\x0e\n\x0c\n\ \n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x04\x0b\x0e\n\x0c\n\x05\x04\0\x02\
\x05\x04\0\x02\x01\x03\x12\x03\x04\x11\x12\n\n\n\x02\x05\0\x12\x04\x06\0\ \x01\x03\x12\x03\x04\x11\x12\n\n\n\x02\x05\0\x12\x04\x06\0\x10\x01\n\n\n\
\x10\x01\n\n\n\x03\x05\0\x01\x12\x03\x06\x05\x14\n\x0b\n\x04\x05\0\x02\0\ \x03\x05\0\x01\x12\x03\x06\x05\x11\n\x0b\n\x04\x05\0\x02\0\x12\x03\x07\
\x12\x03\x07\x04\x10\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x07\x04\x0b\n\ \x04\x10\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x07\x04\x0b\n\x0c\n\x05\x05\
\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x07\x0e\x0f\n\x0b\n\x04\x05\0\x02\x01\ \0\x02\0\x02\x12\x03\x07\x0e\x0f\n\x0b\n\x04\x05\0\x02\x01\x12\x03\x08\
\x12\x03\x08\x04\x1e\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x08\x04\x19\n\ \x04\x1e\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x08\x04\x19\n\x0c\n\x05\
\x0c\n\x05\x05\0\x02\x01\x02\x12\x03\x08\x1c\x1d\n\x0b\n\x04\x05\0\x02\ \x05\0\x02\x01\x02\x12\x03\x08\x1c\x1d\n\x0b\n\x04\x05\0\x02\x02\x12\x03\
\x02\x12\x03\t\x04\x1b\n\x0c\n\x05\x05\0\x02\x02\x01\x12\x03\t\x04\x16\n\ \t\x04\x1b\n\x0c\n\x05\x05\0\x02\x02\x01\x12\x03\t\x04\x16\n\x0c\n\x05\
\x0c\n\x05\x05\0\x02\x02\x02\x12\x03\t\x19\x1a\n\x0b\n\x04\x05\0\x02\x03\ \x05\0\x02\x02\x02\x12\x03\t\x19\x1a\n\x0b\n\x04\x05\0\x02\x03\x12\x03\n\
\x12\x03\n\x04\x18\n\x0c\n\x05\x05\0\x02\x03\x01\x12\x03\n\x04\x12\n\x0c\ \x04\x18\n\x0c\n\x05\x05\0\x02\x03\x01\x12\x03\n\x04\x12\n\x0c\n\x05\x05\
\n\x05\x05\0\x02\x03\x02\x12\x03\n\x15\x17\n\x0b\n\x04\x05\0\x02\x04\x12\ \0\x02\x03\x02\x12\x03\n\x15\x17\n\x0b\n\x04\x05\0\x02\x04\x12\x03\x0b\
\x03\x0b\x04\x1a\n\x0c\n\x05\x05\0\x02\x04\x01\x12\x03\x0b\x04\x14\n\x0c\ \x04\x1a\n\x0c\n\x05\x05\0\x02\x04\x01\x12\x03\x0b\x04\x14\n\x0c\n\x05\
\n\x05\x05\0\x02\x04\x02\x12\x03\x0b\x17\x19\n\x0b\n\x04\x05\0\x02\x05\ \x05\0\x02\x04\x02\x12\x03\x0b\x17\x19\n\x0b\n\x04\x05\0\x02\x05\x12\x03\
\x12\x03\x0c\x04\x18\n\x0c\n\x05\x05\0\x02\x05\x01\x12\x03\x0c\x04\x12\n\ \x0c\x04\x18\n\x0c\n\x05\x05\0\x02\x05\x01\x12\x03\x0c\x04\x12\n\x0c\n\
\x0c\n\x05\x05\0\x02\x05\x02\x12\x03\x0c\x15\x17\n\x0b\n\x04\x05\0\x02\ \x05\x05\0\x02\x05\x02\x12\x03\x0c\x15\x17\n\x0b\n\x04\x05\0\x02\x06\x12\
\x06\x12\x03\r\x04\x1a\n\x0c\n\x05\x05\0\x02\x06\x01\x12\x03\r\x04\x14\n\ \x03\r\x04\x1a\n\x0c\n\x05\x05\0\x02\x06\x01\x12\x03\r\x04\x14\n\x0c\n\
\x0c\n\x05\x05\0\x02\x06\x02\x12\x03\r\x17\x19\n\x0b\n\x04\x05\0\x02\x07\ \x05\x05\0\x02\x06\x02\x12\x03\r\x17\x19\n\x0b\n\x04\x05\0\x02\x07\x12\
\x12\x03\x0e\x04\x1c\n\x0c\n\x05\x05\0\x02\x07\x01\x12\x03\x0e\x04\x16\n\ \x03\x0e\x04\x1c\n\x0c\n\x05\x05\0\x02\x07\x01\x12\x03\x0e\x04\x16\n\x0c\
\x0c\n\x05\x05\0\x02\x07\x02\x12\x03\x0e\x19\x1b\n\x0b\n\x04\x05\0\x02\ \n\x05\x05\0\x02\x07\x02\x12\x03\x0e\x19\x1b\n\x0b\n\x04\x05\0\x02\x08\
\x08\x12\x03\x0f\x04\x20\n\x0c\n\x05\x05\0\x02\x08\x01\x12\x03\x0f\x04\ \x12\x03\x0f\x04\x20\n\x0c\n\x05\x05\0\x02\x08\x01\x12\x03\x0f\x04\x19\n\
\x19\n\x0c\n\x05\x05\0\x02\x08\x02\x12\x03\x0f\x1c\x1fb\x06proto3\ \x0c\n\x05\x05\0\x02\x08\x02\x12\x03\x0f\x1c\x1fb\x06proto3\
"; ";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;

View File

@ -1,10 +1,10 @@
syntax = "proto3"; syntax = "proto3";
message EditorError { message DocError {
EditorErrorCode code = 1; DocErrorCode code = 1;
string msg = 2; string msg = 2;
} }
enum EditorErrorCode { enum DocErrorCode {
Unknown = 0; Unknown = 0;
EditorDBInternalError = 1; EditorDBInternalError = 1;
EditorDBConnFailed = 2; EditorDBConnFailed = 2;

View File

@ -1,7 +1,7 @@
use crate::{ use crate::{
entities::doc::{CreateDocParams, DocInfo, UpdateDocParams}, entities::doc::{CreateDocParams, DocInfo, UpdateDocParams},
errors::EditorError, errors::DocError,
module::EditorDatabase, module::DocumentDatabase,
sql_tables::doc::{DocTable, DocTableChangeset, DocTableSql}, sql_tables::doc::{DocTable, DocTableChangeset, DocTableSql},
}; };
use std::sync::Arc; use std::sync::Arc;
@ -11,7 +11,7 @@ pub struct DocController {
} }
impl DocController { impl DocController {
pub(crate) fn new(database: Arc<dyn EditorDatabase>) -> Self { pub(crate) fn new(database: Arc<dyn DocumentDatabase>) -> Self {
let sql = Arc::new(DocTableSql { database }); let sql = Arc::new(DocTableSql { database });
Self { sql } Self { sql }
} }
@ -20,7 +20,7 @@ impl DocController {
&self, &self,
params: CreateDocParams, params: CreateDocParams,
path: &str, path: &str,
) -> Result<DocInfo, EditorError> { ) -> Result<DocInfo, DocError> {
let doc_table = DocTable::new(params, path); let doc_table = DocTable::new(params, path);
let doc: DocInfo = doc_table.clone().into(); let doc: DocInfo = doc_table.clone().into();
let _ = self.sql.create_doc_table(doc_table)?; let _ = self.sql.create_doc_table(doc_table)?;
@ -28,13 +28,13 @@ impl DocController {
Ok(doc) Ok(doc)
} }
pub(crate) async fn update_doc(&self, params: UpdateDocParams) -> Result<(), EditorError> { pub(crate) async fn update_doc(&self, params: UpdateDocParams) -> Result<(), DocError> {
let changeset = DocTableChangeset::new(params); let changeset = DocTableChangeset::new(params);
let _ = self.sql.update_doc_table(changeset)?; let _ = self.sql.update_doc_table(changeset)?;
Ok(()) Ok(())
} }
pub(crate) async fn read_doc(&self, doc_id: &str) -> Result<DocInfo, EditorError> { pub(crate) async fn read_doc(&self, doc_id: &str) -> Result<DocInfo, DocError> {
let doc_table = self.sql.read_doc_table(doc_id)?; let doc_table = self.sql.read_doc_table(doc_id)?;
let doc_desc: DocInfo = doc_table.into(); let doc_desc: DocInfo = doc_table.into();
Ok(doc_desc) Ok(doc_desc)

View File

@ -1,4 +1,4 @@
use crate::{module::EditorUser, services::file_manager::*}; use crate::{module::DocumentUser, services::file_manager::*};
use std::{ use std::{
collections::HashMap, collections::HashMap,
path::{Path, PathBuf}, path::{Path, PathBuf},
@ -6,13 +6,13 @@ use std::{
}; };
pub struct FileManager { pub struct FileManager {
pub user: Arc<dyn EditorUser>, pub user: Arc<dyn DocumentUser>,
open_files: HashMap<PathBuf, FileId>, open_files: HashMap<PathBuf, FileId>,
file_info: HashMap<FileId, FileInfo>, file_info: HashMap<FileId, FileInfo>,
} }
impl FileManager { impl FileManager {
pub(crate) fn new(user: Arc<dyn EditorUser>) -> Self { pub(crate) fn new(user: Arc<dyn DocumentUser>) -> Self {
Self { Self {
user, user,
open_files: HashMap::new(), open_files: HashMap::new(),

View File

@ -1,6 +1,6 @@
use crate::{ use crate::{
errors::EditorError, errors::DocError,
module::EditorDatabase, module::DocumentDatabase,
sql_tables::doc::{DocTable, DocTableChangeset}, sql_tables::doc::{DocTable, DocTableChangeset},
}; };
use flowy_database::{ use flowy_database::{
@ -10,11 +10,11 @@ use flowy_database::{
use std::sync::Arc; use std::sync::Arc;
pub struct DocTableSql { pub struct DocTableSql {
pub database: Arc<dyn EditorDatabase>, pub database: Arc<dyn DocumentDatabase>,
} }
impl DocTableSql { impl DocTableSql {
pub(crate) fn create_doc_table(&self, doc_table: DocTable) -> Result<(), EditorError> { pub(crate) fn create_doc_table(&self, doc_table: DocTable) -> Result<(), DocError> {
let conn = self.database.db_connection()?; let conn = self.database.db_connection()?;
let _ = diesel::insert_into(doc_table::table) let _ = diesel::insert_into(doc_table::table)
.values(doc_table) .values(doc_table)
@ -22,13 +22,13 @@ impl DocTableSql {
Ok(()) Ok(())
} }
pub(crate) fn update_doc_table(&self, changeset: DocTableChangeset) -> Result<(), EditorError> { pub(crate) fn update_doc_table(&self, changeset: DocTableChangeset) -> Result<(), DocError> {
let conn = self.database.db_connection()?; let conn = self.database.db_connection()?;
diesel_update_table!(doc_table, changeset, conn); diesel_update_table!(doc_table, changeset, conn);
Ok(()) Ok(())
} }
pub(crate) fn read_doc_table(&self, doc_id: &str) -> Result<DocTable, EditorError> { pub(crate) fn read_doc_table(&self, doc_id: &str) -> Result<DocTable, DocError> {
let doc_table = dsl::doc_table let doc_table = dsl::doc_table
.filter(doc_table::id.eq(doc_id)) .filter(doc_table::id.eq(doc_id))
.first::<DocTable>(&*(self.database.db_connection()?))?; .first::<DocTable>(&*(self.database.db_connection()?))?;
@ -36,5 +36,5 @@ impl DocTableSql {
Ok(doc_table) Ok(doc_table)
} }
pub(crate) fn delete_doc(&self, _view_id: &str) -> Result<(), EditorError> { unimplemented!() } pub(crate) fn delete_doc(&self, _view_id: &str) -> Result<(), DocError> { unimplemented!() }
} }

View File

@ -6,20 +6,3 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
derive_more = {version = "0.99", features = ["display"]}
flowy-dispatch = { path = "../flowy-dispatch" }
flowy-log = { path = "../flowy-log" }
flowy-derive = { path = "../flowy-derive" }
flowy-database = { path = "../flowy-database" }
flowy-infra = { path = "../flowy-infra" }
diesel = {version = "1.4.7", features = ["sqlite"]}
diesel_derives = {version = "1.4.1", features = ["sqlite"]}
protobuf = {version = "2.18.0"}
unicode-segmentation = "1.7.1"
lazy_static = "1.4.0"
log = "0.4.14"
tokio = {version = "1.6.0", features = ["sync"]}
tracing = { version = "0.1", features = ["log"] }
[dev-dependencies]
flowy-test = { path = "../flowy-test" }

View File

@ -1,15 +1,7 @@
pub mod entities; #[cfg(test)]
pub mod errors; mod tests {
pub mod event; #[test]
mod handlers; fn it_works() {
pub mod module; assert_eq!(2 + 2, 4);
mod protobuf; }
mod services;
mod sql_tables;
#[macro_use]
extern crate flowy_database;
pub mod prelude {
pub use crate::module::*;
} }

View File

@ -13,7 +13,7 @@ flowy-user = { path = "../flowy-user" }
flowy-infra = { path = "../flowy-infra" } flowy-infra = { path = "../flowy-infra" }
flowy-workspace = { path = "../flowy-workspace" } flowy-workspace = { path = "../flowy-workspace" }
flowy-database = { path = "../flowy-database" } flowy-database = { path = "../flowy-database" }
flowy-editor = { path = "../flowy-editor" } flowy-document = { path = "../flowy-document" }
tracing = { version = "0.1" } tracing = { version = "0.1" }
log = "0.4.14" log = "0.4.14"
futures-core = { version = "0.3", default-features = false } futures-core = { version = "0.3", default-features = false }

View File

@ -1,7 +1,7 @@
use flowy_database::DBConnection; use flowy_database::DBConnection;
use flowy_editor::{ use flowy_document::{
errors::{EditorError, EditorErrorCode, ErrorBuilder}, errors::{DocError, DocErrorCode, ErrorBuilder},
module::{EditorDatabase, EditorUser}, module::{DocumentDatabase, DocumentUser},
}; };
use flowy_user::prelude::UserSession; use flowy_user::prelude::UserSession;
use std::{path::Path, sync::Arc}; use std::{path::Path, sync::Arc};
@ -10,10 +10,10 @@ pub struct EditorDatabaseImpl {
pub(crate) user_session: Arc<UserSession>, pub(crate) user_session: Arc<UserSession>,
} }
impl EditorDatabase for EditorDatabaseImpl { impl DocumentDatabase for EditorDatabaseImpl {
fn db_connection(&self) -> Result<DBConnection, EditorError> { fn db_connection(&self) -> Result<DBConnection, DocError> {
self.user_session.get_db_connection().map_err(|e| { self.user_session.get_db_connection().map_err(|e| {
ErrorBuilder::new(EditorErrorCode::EditorDBConnFailed) ErrorBuilder::new(DocErrorCode::EditorDBConnFailed)
.error(e) .error(e)
.build() .build()
}) })
@ -24,10 +24,10 @@ pub struct EditorUserImpl {
pub(crate) user_session: Arc<UserSession>, pub(crate) user_session: Arc<UserSession>,
} }
impl EditorUser for EditorUserImpl { impl DocumentUser for EditorUserImpl {
fn user_doc_dir(&self) -> Result<String, EditorError> { fn user_doc_dir(&self) -> Result<String, DocError> {
let dir = self.user_session.get_user_dir().map_err(|e| { let dir = self.user_session.get_user_dir().map_err(|e| {
ErrorBuilder::new(EditorErrorCode::EditorUserNotLoginYet) ErrorBuilder::new(DocErrorCode::EditorUserNotLoginYet)
.error(e) .error(e)
.build() .build()
})?; })?;

View File

@ -40,6 +40,6 @@ pub fn build_modules(config: ModuleConfig, _server: ArcFlowyServer) -> Vec<Modul
vec![ vec![
flowy_user::module::create(user_session), flowy_user::module::create(user_session),
flowy_workspace::module::create(workspace_user_impl, workspace_db), flowy_workspace::module::create(workspace_user_impl, workspace_db),
flowy_editor::module::create(editor_db, editor_user), flowy_document::module::create(editor_db, editor_user),
] ]
} }

View File

@ -7,11 +7,11 @@ use std::{convert::TryInto, sync::Arc};
pub async fn sign_in( pub async fn sign_in(
data: Data<SignInRequest>, data: Data<SignInRequest>,
session: Unit<Arc<UserSession>>, session: Unit<Arc<UserSession>>,
) -> ResponseResult<UserDetail, UserError> { ) -> DataResult<UserDetail, UserError> {
let params: SignInParams = data.into_inner().try_into()?; let params: SignInParams = data.into_inner().try_into()?;
let user = session.sign_in(params).await?; let user = session.sign_in(params).await?;
let user_detail = UserDetail::from(user); let user_detail = UserDetail::from(user);
response_ok(user_detail) data_result(user_detail)
} }
#[tracing::instrument( #[tracing::instrument(
@ -25,9 +25,9 @@ pub async fn sign_in(
pub async fn sign_up( pub async fn sign_up(
data: Data<SignUpRequest>, data: Data<SignUpRequest>,
session: Unit<Arc<UserSession>>, session: Unit<Arc<UserSession>>,
) -> ResponseResult<UserDetail, UserError> { ) -> DataResult<UserDetail, UserError> {
let params: SignUpParams = data.into_inner().try_into()?; let params: SignUpParams = data.into_inner().try_into()?;
let user = session.sign_up(params).await?; let user = session.sign_up(params).await?;
let user_detail = UserDetail::from(user); let user_detail = UserDetail::from(user);
response_ok(user_detail) data_result(user_detail)
} }

View File

@ -3,11 +3,9 @@ use flowy_dispatch::prelude::*;
use std::{convert::TryInto, sync::Arc}; use std::{convert::TryInto, sync::Arc};
#[tracing::instrument(name = "get_user_status", skip(session))] #[tracing::instrument(name = "get_user_status", skip(session))]
pub async fn get_user_status( pub async fn get_user_status(session: Unit<Arc<UserSession>>) -> DataResult<UserDetail, UserError> {
session: Unit<Arc<UserSession>>,
) -> ResponseResult<UserDetail, UserError> {
let user_detail = session.user_detail()?; let user_detail = session.user_detail()?;
response_ok(user_detail) data_result(user_detail)
} }
#[tracing::instrument(name = "sign_out", skip(session))] #[tracing::instrument(name = "sign_out", skip(session))]
@ -20,8 +18,8 @@ pub async fn sign_out(session: Unit<Arc<UserSession>>) -> Result<(), UserError>
pub async fn update_user( pub async fn update_user(
data: Data<UpdateUserRequest>, data: Data<UpdateUserRequest>,
session: Unit<Arc<UserSession>>, session: Unit<Arc<UserSession>>,
) -> ResponseResult<UserDetail, UserError> { ) -> DataResult<UserDetail, UserError> {
let params: UpdateUserParams = data.into_inner().try_into()?; let params: UpdateUserParams = data.into_inner().try_into()?;
let user_detail = session.update_user(params)?; let user_detail = session.update_user(params)?;
response_ok(user_detail) data_result(user_detail)
} }

View File

@ -16,17 +16,17 @@ use crate::{
errors::WorkspaceError, errors::WorkspaceError,
services::{AppController, ViewController}, services::{AppController, ViewController},
}; };
use flowy_dispatch::prelude::{response_ok, Data, ResponseResult, Unit}; use flowy_dispatch::prelude::{data_result, Data, DataResult, Unit};
use std::{convert::TryInto, sync::Arc}; use std::{convert::TryInto, sync::Arc};
#[tracing::instrument(name = "create_app", skip(data, controller))] #[tracing::instrument(name = "create_app", skip(data, controller))]
pub async fn create_app( pub async fn create_app(
data: Data<CreateAppRequest>, data: Data<CreateAppRequest>,
controller: Unit<Arc<AppController>>, controller: Unit<Arc<AppController>>,
) -> ResponseResult<App, WorkspaceError> { ) -> DataResult<App, WorkspaceError> {
let params: CreateAppParams = data.into_inner().try_into()?; let params: CreateAppParams = data.into_inner().try_into()?;
let detail = controller.create_app(params)?; let detail = controller.create_app(params)?;
response_ok(detail) data_result(detail)
} }
#[tracing::instrument(name = "delete_app", skip(data, controller))] #[tracing::instrument(name = "delete_app", skip(data, controller))]
@ -54,15 +54,17 @@ pub async fn read_app(
data: Data<QueryAppRequest>, data: Data<QueryAppRequest>,
app_controller: Unit<Arc<AppController>>, app_controller: Unit<Arc<AppController>>,
view_controller: Unit<Arc<ViewController>>, view_controller: Unit<Arc<ViewController>>,
) -> ResponseResult<App, WorkspaceError> { ) -> DataResult<App, WorkspaceError> {
let params: QueryAppParams = data.into_inner().try_into()?; let params: QueryAppParams = data.into_inner().try_into()?;
let mut app = app_controller let mut app = app_controller
.read_app(&params.app_id, params.is_trash) .read_app(&params.app_id, params.is_trash)
.await?; .await?;
// The View's belonging is the view indexed by the belong_to_id for now
if params.read_belongings { if params.read_belongings {
let views = view_controller.read_views_belong_to(&params.app_id).await?; let views = view_controller.read_views_belong_to(&params.app_id).await?;
app.belongings = RepeatedView { items: views }; app.belongings = RepeatedView { items: views };
} }
response_ok(app) data_result(app)
} }

View File

@ -14,24 +14,24 @@ use crate::{
errors::WorkspaceError, errors::WorkspaceError,
services::ViewController, services::ViewController,
}; };
use flowy_dispatch::prelude::{response_ok, Data, ResponseResult, Unit}; use flowy_dispatch::prelude::{data_result, Data, DataResult, Unit};
use std::{convert::TryInto, sync::Arc}; use std::{convert::TryInto, sync::Arc};
#[tracing::instrument(name = "create_view", skip(data, controller))] #[tracing::instrument(name = "create_view", skip(data, controller))]
pub async fn create_view( pub async fn create_view(
data: Data<CreateViewRequest>, data: Data<CreateViewRequest>,
controller: Unit<Arc<ViewController>>, controller: Unit<Arc<ViewController>>,
) -> ResponseResult<View, WorkspaceError> { ) -> DataResult<View, WorkspaceError> {
let params: CreateViewParams = data.into_inner().try_into()?; let params: CreateViewParams = data.into_inner().try_into()?;
let view = controller.create_view(params).await?; let view = controller.create_view(params).await?;
response_ok(view) data_result(view)
} }
#[tracing::instrument(name = "read_view", skip(data, controller))] #[tracing::instrument(name = "read_view", skip(data, controller))]
pub async fn read_view( pub async fn read_view(
data: Data<QueryViewRequest>, data: Data<QueryViewRequest>,
controller: Unit<Arc<ViewController>>, controller: Unit<Arc<ViewController>>,
) -> ResponseResult<View, WorkspaceError> { ) -> DataResult<View, WorkspaceError> {
let params: QueryViewParams = data.into_inner().try_into()?; let params: QueryViewParams = data.into_inner().try_into()?;
let mut view = controller let mut view = controller
.read_view(&params.view_id, params.is_trash) .read_view(&params.view_id, params.is_trash)
@ -42,7 +42,7 @@ pub async fn read_view(
view.belongings = RepeatedView { items: views } view.belongings = RepeatedView { items: views }
} }
response_ok(view) data_result(view)
} }
#[tracing::instrument(name = "update_view", skip(data, controller))] #[tracing::instrument(name = "update_view", skip(data, controller))]

View File

@ -3,33 +3,33 @@ use crate::{
errors::WorkspaceError, errors::WorkspaceError,
services::WorkspaceController, services::WorkspaceController,
}; };
use flowy_dispatch::prelude::{response_ok, Data, ResponseResult, Unit}; use flowy_dispatch::prelude::{data_result, Data, DataResult, Unit};
use std::{convert::TryInto, sync::Arc}; use std::{convert::TryInto, sync::Arc};
#[tracing::instrument(name = "create_workspace", skip(data, controller))] #[tracing::instrument(name = "create_workspace", skip(data, controller))]
pub async fn create_workspace( pub async fn create_workspace(
data: Data<CreateWorkspaceRequest>, data: Data<CreateWorkspaceRequest>,
controller: Unit<Arc<WorkspaceController>>, controller: Unit<Arc<WorkspaceController>>,
) -> ResponseResult<Workspace, WorkspaceError> { ) -> DataResult<Workspace, WorkspaceError> {
let controller = controller.get_ref().clone(); let controller = controller.get_ref().clone();
let params: CreateWorkspaceParams = data.into_inner().try_into()?; let params: CreateWorkspaceParams = data.into_inner().try_into()?;
let detail = controller.create_workspace(params).await?; let detail = controller.create_workspace(params).await?;
response_ok(detail) data_result(detail)
} }
#[tracing::instrument(name = "read_cur_workspace", skip(controller))] #[tracing::instrument(name = "read_cur_workspace", skip(controller))]
pub async fn read_cur_workspace( pub async fn read_cur_workspace(
controller: Unit<Arc<WorkspaceController>>, controller: Unit<Arc<WorkspaceController>>,
) -> ResponseResult<Workspace, WorkspaceError> { ) -> DataResult<Workspace, WorkspaceError> {
let workspace = controller.read_cur_workspace().await?; let workspace = controller.read_cur_workspace().await?;
response_ok(workspace) data_result(workspace)
} }
#[tracing::instrument(name = "read_workspace", skip(data, controller))] #[tracing::instrument(name = "read_workspace", skip(data, controller))]
pub async fn read_workspace( pub async fn read_workspace(
data: Data<QueryWorkspaceRequest>, data: Data<QueryWorkspaceRequest>,
controller: Unit<Arc<WorkspaceController>>, controller: Unit<Arc<WorkspaceController>>,
) -> ResponseResult<Workspace, WorkspaceError> { ) -> DataResult<Workspace, WorkspaceError> {
let params: QueryWorkspaceParams = data.into_inner().try_into()?; let params: QueryWorkspaceParams = data.into_inner().try_into()?;
let mut workspace = controller.read_workspace(&params.workspace_id).await?; let mut workspace = controller.read_workspace(&params.workspace_id).await?;
@ -38,14 +38,14 @@ pub async fn read_workspace(
workspace.apps = RepeatedApp { items: apps }; workspace.apps = RepeatedApp { items: apps };
} }
response_ok(workspace) data_result(workspace)
} }
#[tracing::instrument(name = "get_all_workspaces", skip(controller))] #[tracing::instrument(name = "get_all_workspaces", skip(controller))]
pub async fn read_all_workspaces( pub async fn read_all_workspaces(
controller: Unit<Arc<WorkspaceController>>, controller: Unit<Arc<WorkspaceController>>,
) -> ResponseResult<Workspaces, WorkspaceError> { ) -> DataResult<Workspaces, WorkspaceError> {
let workspaces = controller.read_workspaces_belong_to_user().await?; let workspaces = controller.read_workspaces_belong_to_user().await?;
response_ok(Workspaces { items: workspaces }) data_result(Workspaces { items: workspaces })
} }

View File

@ -1,8 +1,5 @@
use crate::{ use crate::{
entities::{ entities::app::{App, CreateAppParams, *},
app::{App, CreateAppParams, *},
view::View,
},
errors::*, errors::*,
module::{WorkspaceDatabase, WorkspaceUser}, module::{WorkspaceDatabase, WorkspaceUser},
observable::*, observable::*,

View File

@ -1,10 +1,7 @@
use crate::{ use crate::{
errors::WorkspaceError, errors::WorkspaceError,
module::WorkspaceDatabase, module::WorkspaceDatabase,
sql_tables::{ sql_tables::app::{AppTable, AppTableChangeset},
app::{AppTable, AppTableChangeset},
view::ViewTable,
},
}; };
use flowy_database::{ use flowy_database::{
prelude::*, prelude::*,

View File

@ -1,7 +1,7 @@
use crate::helper::*; use crate::helper::*;
use flowy_workspace::entities::{ use flowy_workspace::entities::{
app::{QueryAppRequest, UpdateAppParams, UpdateAppRequest}, app::{QueryAppRequest, UpdateAppRequest},
view::*, view::*,
}; };