mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-18 22:46:57 +00:00
38 lines
1.2 KiB
Dart
38 lines
1.2 KiB
Dart
import 'package:dartz/dartz.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-editor/doc_modify.pb.dart';
|
|
import 'package:flowy_sdk/protobuf/flowy-editor/doc_query.pb.dart';
|
|
import 'package:flowy_sdk/protobuf/flowy-editor/errors.pb.dart';
|
|
|
|
class DocRepository {
|
|
final String docId;
|
|
DocRepository({
|
|
required this.docId,
|
|
});
|
|
|
|
Future<Either<DocDescription, EditorError>> createDoc(
|
|
{required String name, String? desc}) {
|
|
final request = CreateDocRequest(id: docId, name: name, desc: desc);
|
|
|
|
return EditorEventCreateDoc(request).send();
|
|
}
|
|
|
|
Future<Either<Doc, EditorError>> readDoc() {
|
|
final request = QueryDocRequest.create()..docId = docId;
|
|
return EditorEventReadDoc(request).send();
|
|
}
|
|
|
|
Future<Either<Unit, EditorError>> updateDoc(
|
|
{String? name, String? desc, String? text}) {
|
|
final request = UpdateDocRequest(id: docId, name: name, text: text);
|
|
|
|
return EditorEventUpdateDoc(request).send();
|
|
}
|
|
|
|
Future<Either<Unit, EditorError>> closeDoc(
|
|
{String? name, String? desc, String? text}) {
|
|
throw UnimplementedError();
|
|
}
|
|
}
|