add workspace and app

This commit is contained in:
appflowy 2021-07-13 17:19:39 +08:00
parent bf198783e1
commit 5de69abb36
59 changed files with 2678 additions and 13 deletions

View File

@ -0,0 +1,149 @@
///
// Generated code. Do not modify.
// source: app_create.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
class CreateAppRequest extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CreateAppRequest', createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'workspaceId')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name')
..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'desc')
..aOM<ColorStyle>(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'colorStyle', subBuilder: ColorStyle.create)
..hasRequiredFields = false
;
CreateAppRequest._() : super();
factory CreateAppRequest({
$core.String? workspaceId,
$core.String? name,
$core.String? desc,
ColorStyle? colorStyle,
}) {
final _result = create();
if (workspaceId != null) {
_result.workspaceId = workspaceId;
}
if (name != null) {
_result.name = name;
}
if (desc != null) {
_result.desc = desc;
}
if (colorStyle != null) {
_result.colorStyle = colorStyle;
}
return _result;
}
factory CreateAppRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory CreateAppRequest.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')
CreateAppRequest clone() => CreateAppRequest()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
CreateAppRequest copyWith(void Function(CreateAppRequest) updates) => super.copyWith((message) => updates(message as CreateAppRequest)) as CreateAppRequest; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static CreateAppRequest create() => CreateAppRequest._();
CreateAppRequest createEmptyInstance() => create();
static $pb.PbList<CreateAppRequest> createRepeated() => $pb.PbList<CreateAppRequest>();
@$core.pragma('dart2js:noInline')
static CreateAppRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<CreateAppRequest>(create);
static CreateAppRequest? _defaultInstance;
@$pb.TagNumber(1)
$core.String get workspaceId => $_getSZ(0);
@$pb.TagNumber(1)
set workspaceId($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasWorkspaceId() => $_has(0);
@$pb.TagNumber(1)
void clearWorkspaceId() => clearField(1);
@$pb.TagNumber(2)
$core.String get name => $_getSZ(1);
@$pb.TagNumber(2)
set name($core.String v) { $_setString(1, v); }
@$pb.TagNumber(2)
$core.bool hasName() => $_has(1);
@$pb.TagNumber(2)
void clearName() => clearField(2);
@$pb.TagNumber(3)
$core.String get desc => $_getSZ(2);
@$pb.TagNumber(3)
set desc($core.String v) { $_setString(2, v); }
@$pb.TagNumber(3)
$core.bool hasDesc() => $_has(2);
@$pb.TagNumber(3)
void clearDesc() => clearField(3);
@$pb.TagNumber(4)
ColorStyle get colorStyle => $_getN(3);
@$pb.TagNumber(4)
set colorStyle(ColorStyle v) { setField(4, v); }
@$pb.TagNumber(4)
$core.bool hasColorStyle() => $_has(3);
@$pb.TagNumber(4)
void clearColorStyle() => clearField(4);
@$pb.TagNumber(4)
ColorStyle ensureColorStyle() => $_ensure(3);
}
class ColorStyle extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ColorStyle', createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'themeColor')
..hasRequiredFields = false
;
ColorStyle._() : super();
factory ColorStyle({
$core.String? themeColor,
}) {
final _result = create();
if (themeColor != null) {
_result.themeColor = themeColor;
}
return _result;
}
factory ColorStyle.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory ColorStyle.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')
ColorStyle clone() => ColorStyle()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
ColorStyle copyWith(void Function(ColorStyle) updates) => super.copyWith((message) => updates(message as ColorStyle)) as ColorStyle; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static ColorStyle create() => ColorStyle._();
ColorStyle createEmptyInstance() => create();
static $pb.PbList<ColorStyle> createRepeated() => $pb.PbList<ColorStyle>();
@$core.pragma('dart2js:noInline')
static ColorStyle getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<ColorStyle>(create);
static ColorStyle? _defaultInstance;
@$pb.TagNumber(1)
$core.String get themeColor => $_getSZ(0);
@$pb.TagNumber(1)
set themeColor($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasThemeColor() => $_has(0);
@$pb.TagNumber(1)
void clearThemeColor() => clearField(1);
}

View File

@ -0,0 +1,7 @@
///
// Generated code. Do not modify.
// source: app_create.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

View File

@ -0,0 +1,25 @@
///
// Generated code. Do not modify.
// source: app_create.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
import 'dart:core' as $core;
const CreateAppRequest$json = const {
'1': 'CreateAppRequest',
'2': const [
const {'1': 'workspace_id', '3': 1, '4': 1, '5': 9, '10': 'workspaceId'},
const {'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'},
const {'1': 'desc', '3': 3, '4': 1, '5': 9, '10': 'desc'},
const {'1': 'color_style', '3': 4, '4': 1, '5': 11, '6': '.ColorStyle', '10': 'colorStyle'},
],
};
const ColorStyle$json = const {
'1': 'ColorStyle',
'2': const [
const {'1': 'theme_color', '3': 1, '4': 1, '5': 9, '10': 'themeColor'},
],
};

View File

@ -0,0 +1,9 @@
///
// Generated code. Do not modify.
// source: app_create.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
export 'app_create.pb.dart';

View File

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

View File

@ -0,0 +1,32 @@
///
// 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 WorkspaceErrorCode extends $pb.ProtobufEnum {
static const WorkspaceErrorCode Unknown = WorkspaceErrorCode._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'Unknown');
static const WorkspaceErrorCode WorkspaceNameInvalid = WorkspaceErrorCode._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceNameInvalid');
static const WorkspaceErrorCode WorkspaceIdInvalid = WorkspaceErrorCode._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'WorkspaceIdInvalid');
static const WorkspaceErrorCode AppColorStyleInvalid = WorkspaceErrorCode._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'AppColorStyleInvalid');
static const WorkspaceErrorCode DatabaseInternalError = WorkspaceErrorCode._(5, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'DatabaseInternalError');
static const $core.List<WorkspaceErrorCode> values = <WorkspaceErrorCode> [
Unknown,
WorkspaceNameInvalid,
WorkspaceIdInvalid,
AppColorStyleInvalid,
DatabaseInternalError,
];
static final $core.Map<$core.int, WorkspaceErrorCode> _byValue = $pb.ProtobufEnum.initByValue(values);
static WorkspaceErrorCode? valueOf($core.int value) => _byValue[value];
const WorkspaceErrorCode._($core.int v, $core.String n) : super(v, n);
}

View File

@ -0,0 +1,27 @@
///
// 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
import 'dart:core' as $core;
const WorkspaceErrorCode$json = const {
'1': 'WorkspaceErrorCode',
'2': const [
const {'1': 'Unknown', '2': 0},
const {'1': 'WorkspaceNameInvalid', '2': 1},
const {'1': 'WorkspaceIdInvalid', '2': 2},
const {'1': 'AppColorStyleInvalid', '2': 3},
const {'1': 'DatabaseInternalError', '2': 5},
],
};
const WorkspaceError$json = const {
'1': 'WorkspaceError',
'2': const [
const {'1': 'code', '3': 1, '4': 1, '5': 14, '6': '.WorkspaceErrorCode', '10': 'code'},
const {'1': 'msg', '3': 2, '4': 1, '5': 9, '10': 'msg'},
],
};

View File

@ -0,0 +1,9 @@
///
// 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
export 'errors.pb.dart';

View File

@ -1 +1,5 @@
// Auto-generated, do not edit
export './errors.pb.dart';
export './workspace_update.pb.dart';
export './app_create.pb.dart';
export './workspace_create.pb.dart';

View File

@ -0,0 +1,72 @@
///
// Generated code. Do not modify.
// source: workspace_create.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
class CreateWorkspaceRequest extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CreateWorkspaceRequest', createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'desc')
..hasRequiredFields = false
;
CreateWorkspaceRequest._() : super();
factory CreateWorkspaceRequest({
$core.String? name,
$core.String? desc,
}) {
final _result = create();
if (name != null) {
_result.name = name;
}
if (desc != null) {
_result.desc = desc;
}
return _result;
}
factory CreateWorkspaceRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory CreateWorkspaceRequest.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')
CreateWorkspaceRequest clone() => CreateWorkspaceRequest()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
CreateWorkspaceRequest copyWith(void Function(CreateWorkspaceRequest) updates) => super.copyWith((message) => updates(message as CreateWorkspaceRequest)) as CreateWorkspaceRequest; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static CreateWorkspaceRequest create() => CreateWorkspaceRequest._();
CreateWorkspaceRequest createEmptyInstance() => create();
static $pb.PbList<CreateWorkspaceRequest> createRepeated() => $pb.PbList<CreateWorkspaceRequest>();
@$core.pragma('dart2js:noInline')
static CreateWorkspaceRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<CreateWorkspaceRequest>(create);
static CreateWorkspaceRequest? _defaultInstance;
@$pb.TagNumber(1)
$core.String get name => $_getSZ(0);
@$pb.TagNumber(1)
set name($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasName() => $_has(0);
@$pb.TagNumber(1)
void clearName() => clearField(1);
@$pb.TagNumber(2)
$core.String get desc => $_getSZ(1);
@$pb.TagNumber(2)
set desc($core.String v) { $_setString(1, v); }
@$pb.TagNumber(2)
$core.bool hasDesc() => $_has(1);
@$pb.TagNumber(2)
void clearDesc() => clearField(2);
}

View File

@ -0,0 +1,7 @@
///
// Generated code. Do not modify.
// source: workspace_create.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

View File

@ -0,0 +1,16 @@
///
// Generated code. Do not modify.
// source: workspace_create.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
import 'dart:core' as $core;
const CreateWorkspaceRequest$json = const {
'1': 'CreateWorkspaceRequest',
'2': const [
const {'1': 'name', '3': 1, '4': 1, '5': 9, '10': 'name'},
const {'1': 'desc', '3': 2, '4': 1, '5': 9, '10': 'desc'},
],
};

View File

@ -0,0 +1,9 @@
///
// Generated code. Do not modify.
// source: workspace_create.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
export 'workspace_create.pb.dart';

View File

@ -0,0 +1,86 @@
///
// Generated code. Do not modify.
// source: workspace_update.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
class UpdateWorkspaceRequest extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'UpdateWorkspaceRequest', createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'id')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'name')
..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'desc')
..hasRequiredFields = false
;
UpdateWorkspaceRequest._() : super();
factory UpdateWorkspaceRequest({
$core.String? id,
$core.String? name,
$core.String? desc,
}) {
final _result = create();
if (id != null) {
_result.id = id;
}
if (name != null) {
_result.name = name;
}
if (desc != null) {
_result.desc = desc;
}
return _result;
}
factory UpdateWorkspaceRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory UpdateWorkspaceRequest.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')
UpdateWorkspaceRequest clone() => UpdateWorkspaceRequest()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
UpdateWorkspaceRequest copyWith(void Function(UpdateWorkspaceRequest) updates) => super.copyWith((message) => updates(message as UpdateWorkspaceRequest)) as UpdateWorkspaceRequest; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static UpdateWorkspaceRequest create() => UpdateWorkspaceRequest._();
UpdateWorkspaceRequest createEmptyInstance() => create();
static $pb.PbList<UpdateWorkspaceRequest> createRepeated() => $pb.PbList<UpdateWorkspaceRequest>();
@$core.pragma('dart2js:noInline')
static UpdateWorkspaceRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<UpdateWorkspaceRequest>(create);
static UpdateWorkspaceRequest? _defaultInstance;
@$pb.TagNumber(1)
$core.String get id => $_getSZ(0);
@$pb.TagNumber(1)
set id($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasId() => $_has(0);
@$pb.TagNumber(1)
void clearId() => clearField(1);
@$pb.TagNumber(2)
$core.String get name => $_getSZ(1);
@$pb.TagNumber(2)
set name($core.String v) { $_setString(1, v); }
@$pb.TagNumber(2)
$core.bool hasName() => $_has(1);
@$pb.TagNumber(2)
void clearName() => clearField(2);
@$pb.TagNumber(3)
$core.String get desc => $_getSZ(2);
@$pb.TagNumber(3)
set desc($core.String v) { $_setString(2, v); }
@$pb.TagNumber(3)
$core.bool hasDesc() => $_has(2);
@$pb.TagNumber(3)
void clearDesc() => clearField(3);
}

View File

@ -0,0 +1,7 @@
///
// Generated code. Do not modify.
// source: workspace_update.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

View File

@ -0,0 +1,17 @@
///
// Generated code. Do not modify.
// source: workspace_update.proto
//
// @dart = 2.12
// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
import 'dart:core' as $core;
const UpdateWorkspaceRequest$json = const {
'1': 'UpdateWorkspaceRequest',
'2': const [
const {'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'},
const {'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'},
const {'1': 'desc', '3': 3, '4': 1, '5': 9, '10': 'desc'},
],
};

View File

@ -0,0 +1,9 @@
///
// Generated code. Do not modify.
// source: workspace_update.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
export 'workspace_update.pb.dart';

View File

@ -0,0 +1,4 @@
-- This file should undo anything in `up.sql`
DROP TABLE workspace_table;
DROP TABLE app_table;
DROP TABLE view_table;

View File

@ -0,0 +1,34 @@
-- Your SQL goes here
CREATE TABLE workspace_table (
id TEXT NOT NULL PRIMARY KEY,
name TEXT NOT NULL DEFAULT '',
desc TEXT NOT NULL DEFAULT '',
modified_time BIGINT NOT NULL DEFAULT 0,
create_time BIGINT NOT NULL DEFAULT 0,
user_id TEXT NOT NULL DEFAULT '',
version BIGINT NOT NULL DEFAULT 0
);
CREATE TABLE app_table (
id TEXT NOT NULL PRIMARY KEY,
workspace_id TEXT NOT NULL DEFAULT '',
name TEXT NOT NULL DEFAULT '',
desc TEXT NOT NULL DEFAULT '',
color_style BLOB NOT NULL DEFAULT (x''),
last_view_id TEXT DEFAULT '',
modified_time BIGINT NOT NULL DEFAULT 0,
create_time BIGINT NOT NULL DEFAULT 0,
version BIGINT NOT NULL DEFAULT 0
);
CREATE TABLE view_table (
id TEXT NOT NULL PRIMARY KEY,
app_id TEXT NOT NULL DEFAULT '',
name TEXT NOT NULL DEFAULT '',
desc TEXT NOT NULL DEFAULT '',
modified_time BIGINT NOT NULL DEFAULT 0,
create_time BIGINT NOT NULL DEFAULT 0,
thumbnail TEXT NOT NULL DEFAULT '',
view_type INTEGER NOT NULL DEFAULT 0,
version BIGINT NOT NULL DEFAULT 0
);

View File

@ -1,3 +1,17 @@
table! {
app_table (id) {
id -> Text,
workspace_id -> Text,
name -> Text,
desc -> Text,
color_style -> Binary,
last_view_id -> Nullable<Text>,
modified_time -> BigInt,
create_time -> BigInt,
version -> BigInt,
}
}
table! {
user_table (id) {
id -> Text,
@ -6,3 +20,36 @@ table! {
email -> Text,
}
}
table! {
view_table (id) {
id -> Text,
app_id -> Text,
name -> Text,
desc -> Text,
modified_time -> BigInt,
create_time -> BigInt,
thumbnail -> Text,
view_type -> Integer,
version -> BigInt,
}
}
table! {
workspace_table (id) {
id -> Text,
name -> Text,
desc -> Text,
modified_time -> BigInt,
create_time -> BigInt,
user_id -> Text,
version -> BigInt,
}
}
allow_tables_to_appear_in_same_query!(
app_table,
user_table,
view_table,
workspace_table,
);

View File

@ -16,6 +16,11 @@ pub fn category_from_str(type_str: &str) -> TypeCategory {
"u8" => TypeCategory::Bytes,
"String" => TypeCategory::Str,
"KeyValue"
| "CreateAppRequest"
| "ColorStyle"
| "UpdateWorkspaceRequest"
| "CreateWorkspaceRequest"
| "WorkspaceError"
| "FFIRequest"
| "FFIResponse"
| "UserDetail"
@ -26,7 +31,8 @@ pub fn category_from_str(type_str: &str) -> TypeCategory {
| "SignInParams"
| "UserError"
=> TypeCategory::Protobuf,
"FFIStatusCode"
"WorkspaceErrorCode"
| "FFIStatusCode"
| "UserStatus"
| "UserEvent"
| "UserErrorCode"

View File

@ -15,3 +15,4 @@ flowy-sqlite = { path = "../flowy-sqlite"}
lazy_static = "1.4.0"
protobuf = {version = "2.18.0"}
log = "0.4.14"
chrono = "0.4.19"

View File

@ -11,3 +11,4 @@ pub mod kv;
mod protobuf;
pub fn uuid() -> String { uuid::Uuid::new_v4().to_string() }
pub fn timestamp() -> i64 { chrono::Utc::now().timestamp() }

View File

@ -1,6 +1,6 @@
use crate::{
entities::{UserEmail, UserPassword},
errors::{UserError, *},
errors::*,
};
use flowy_derive::ProtoBuf;
use std::convert::TryInto;

View File

@ -1,3 +1,3 @@
pub mod auth;
pub mod auth_handler;
pub use auth::*;
pub use auth_handler::*;

View File

@ -11,5 +11,5 @@ pub mod sql_tables;
extern crate flowy_database;
pub mod prelude {
pub use crate::{entities::*, handlers::auth::*, services::user_session::*};
pub use crate::{entities::*, handlers::auth_handler::*, services::user_session::*};
}

View File

@ -12,8 +12,12 @@ flowy-derive = { path = "../flowy-derive" }
flowy-database = { path = "../flowy-database" }
flowy-sqlite = { path = "../flowy-sqlite" }
flowy-infra = { path = "../flowy-infra" }
protobuf = {version = "2.18.0"}
log = "0.4.14"
diesel = {version = "1.4.7", features = ["sqlite"]}
diesel_derives = {version = "1.4.1", features = ["sqlite"]}
lazy_static = "1.4.0"
serde = { version = "1.0", features = ["derive"] }
derive_more = {version = "0.99", features = ["display"]}
bincode = { version = "1.3"}

View File

@ -1,6 +1,3 @@
#proto_crates = ["src/entities", "src/event.rs", "src/errors.rs"]
#event_files = ["src/event.rs"]
proto_crates = []
event_files = []
proto_crates = ["src/entities", "src/event.rs", "src/errors.rs"]
event_files = ["src/event.rs"]

View File

@ -0,0 +1,15 @@
use crate::entities::app::ColorStyle;
#[derive(Debug)]
pub struct AppColorStyle(pub ColorStyle);
impl AppColorStyle {
pub fn parse(color_style: ColorStyle) -> Result<AppColorStyle, String> {
// TODO: verify the color style format
Ok(Self(color_style))
}
}
impl AsRef<ColorStyle> for AppColorStyle {
fn as_ref(&self) -> &ColorStyle { &self.0 }
}

View File

@ -0,0 +1,68 @@
use crate::{
entities::{
app::{app_color_style::AppColorStyle, app_name::AppName},
workspace::WorkspaceId,
},
errors::*,
};
use flowy_derive::ProtoBuf;
use std::convert::TryInto;
#[derive(ProtoBuf, Default)]
pub struct CreateAppRequest {
#[pb(index = 1)]
pub workspace_id: String,
#[pb(index = 2)]
pub name: String,
#[pb(index = 3)]
pub desc: String,
#[pb(index = 4)]
pub color_style: ColorStyle,
}
#[derive(ProtoBuf, Default, Debug)]
pub struct ColorStyle {
#[pb(index = 1)]
pub theme_color: String,
}
pub struct CreateAppParams {
pub workspace_id: String,
pub name: String,
pub desc: String,
pub color_style: ColorStyle,
}
impl TryInto<CreateAppParams> for CreateAppRequest {
type Error = WorkspaceError;
fn try_into(self) -> Result<CreateAppParams, Self::Error> {
let name = AppName::parse(self.name).map_err(|e| {
ErrorBuilder::new(WorkspaceErrorCode::WorkspaceNameInvalid)
.msg(e)
.build()
})?;
let id = WorkspaceId::parse(self.workspace_id).map_err(|e| {
ErrorBuilder::new(WorkspaceErrorCode::WorkspaceIdInvalid)
.msg(e)
.build()
})?;
let color_style = AppColorStyle::parse(self.color_style).map_err(|e| {
ErrorBuilder::new(WorkspaceErrorCode::AppColorStyleInvalid)
.msg(e)
.build()
})?;
Ok(CreateAppParams {
workspace_id: id.0,
name: name.0,
desc: self.desc,
color_style: color_style.0,
})
}
}

View File

@ -0,0 +1,16 @@
#[derive(Debug)]
pub struct AppName(pub String);
impl AppName {
pub fn parse(s: String) -> Result<AppName, String> {
if s.trim().is_empty() {
return Err(format!("Workspace can not be empty or whitespace"));
}
Ok(Self(s))
}
}
impl AsRef<str> for AppName {
fn as_ref(&self) -> &str { &self.0 }
}

View File

@ -0,0 +1,5 @@
mod app_color_style;
mod app_create;
mod app_name;
pub use app_create::*;

View File

@ -0,0 +1,2 @@
pub mod app;
pub mod workspace;

View File

@ -0,0 +1,11 @@
mod workspace_create;
mod workspace_id;
mod workspace_name;
mod workspace_query;
mod workspace_update;
pub use workspace_create::*;
pub use workspace_id::*;
pub use workspace_name::*;
pub use workspace_query::*;
pub use workspace_update::*;

View File

@ -0,0 +1,34 @@
use crate::{entities::workspace::workspace_name::WorkspaceName, errors::*};
use flowy_derive::ProtoBuf;
use std::convert::TryInto;
#[derive(ProtoBuf, Default)]
pub struct CreateWorkspaceRequest {
#[pb(index = 1)]
name: String,
#[pb(index = 2)]
desc: String,
}
pub struct CreateWorkspaceParams {
pub name: String,
pub desc: String,
}
impl TryInto<CreateWorkspaceParams> for CreateWorkspaceRequest {
type Error = WorkspaceError;
fn try_into(self) -> Result<CreateWorkspaceParams, Self::Error> {
let name = WorkspaceName::parse(self.name).map_err(|e| {
ErrorBuilder::new(WorkspaceErrorCode::WorkspaceNameInvalid)
.msg(e)
.build()
})?;
Ok(CreateWorkspaceParams {
name: name.0,
desc: self.desc,
})
}
}

View File

@ -0,0 +1,16 @@
#[derive(Debug)]
pub struct WorkspaceId(pub String);
impl WorkspaceId {
pub fn parse(s: String) -> Result<WorkspaceId, String> {
if s.trim().is_empty() {
return Err(format!("Workspace id can not be empty or whitespace"));
}
Ok(Self(s))
}
}
impl AsRef<str> for WorkspaceId {
fn as_ref(&self) -> &str { &self.0 }
}

View File

@ -0,0 +1,16 @@
#[derive(Debug)]
pub struct WorkspaceName(pub String);
impl WorkspaceName {
pub fn parse(s: String) -> Result<WorkspaceName, String> {
if s.trim().is_empty() {
return Err(format!("Workspace can not be empty or whitespace"));
}
Ok(Self(s))
}
}
impl AsRef<str> for WorkspaceName {
fn as_ref(&self) -> &str { &self.0 }
}

View File

@ -0,0 +1,51 @@
// use crate::sql_tables::workspace::Workspace;
//
// #[derive(Default, Debug, ProtoBuf)]
// pub struct WorkspaceDetail {
// #[pb(index = 1)]
// pub workspace: Workspace,
//
// #[pb(index = 2)]
// pub apps: Vec<App>,
// }
// use crate::entities::{RepeatedApp, Workspace};
// use flowy_derive::ProtoBuf;
// use flowy_traits::cqrs::Identifiable;
//
// #[derive(ProtoBuf, Default, Debug)]
// pub struct WorkspaceQuery {
// #[pb(index = 1)]
// pub workspace_id: String,
//
// #[pb(index = 2)]
// pub read_apps: bool,
// }
//
// impl WorkspaceQuery {
// pub fn read_workspace(workspace_id: &str) -> Self {
// WorkspaceQuery {
// workspace_id: workspace_id.to_string(),
// read_apps: false,
// }
// }
//
// pub fn read_apps(workspace_id: &str) -> Self {
// WorkspaceQuery {
// workspace_id: workspace_id.to_string(),
// read_apps: true,
// }
// }
// }
//
// #[derive(Default, Debug, ProtoBuf)]
// pub struct WorkspaceQueryResult {
// #[pb(index = 1, oneof)]
// pub workspace: Option<Workspace>,
//
// #[pb(index = 2, oneof)]
// pub apps: Option<RepeatedApp>,
//
// #[pb(index = 100)]
// pub error: String,
// }

View File

@ -0,0 +1,48 @@
use crate::{
entities::workspace::{workspace_id::WorkspaceId, workspace_name::WorkspaceName},
errors::*,
};
use flowy_derive::ProtoBuf;
use std::convert::TryInto;
#[derive(ProtoBuf, Default)]
pub struct UpdateWorkspaceRequest {
#[pb(index = 1)]
id: String,
#[pb(index = 2)]
name: String,
#[pb(index = 3)]
desc: String,
}
pub struct UpdateWorkspaceParams {
pub id: String,
pub name: String,
pub desc: String,
}
impl TryInto<UpdateWorkspaceParams> for UpdateWorkspaceRequest {
type Error = WorkspaceError;
fn try_into(self) -> Result<UpdateWorkspaceParams, Self::Error> {
let name = WorkspaceName::parse(self.name).map_err(|e| {
ErrorBuilder::new(WorkspaceErrorCode::WorkspaceNameInvalid)
.msg(e)
.build()
})?;
let id = WorkspaceId::parse(self.id).map_err(|e| {
ErrorBuilder::new(WorkspaceErrorCode::WorkspaceIdInvalid)
.msg(e)
.build()
})?;
Ok(UpdateWorkspaceParams {
id: id.0,
name: name.0,
desc: self.desc,
})
}
}

View File

@ -0,0 +1,96 @@
use derive_more::Display;
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
use flowy_dispatch::prelude::{EventResponse, ResponseBuilder};
use std::convert::TryInto;
#[derive(Debug, Default, Clone, ProtoBuf)]
pub struct WorkspaceError {
#[pb(index = 1)]
pub code: WorkspaceErrorCode,
#[pb(index = 2)]
pub msg: String,
}
impl WorkspaceError {
fn new(code: WorkspaceErrorCode, msg: &str) -> Self {
Self {
code,
msg: msg.to_owned(),
}
}
}
#[derive(Debug, Clone, ProtoBuf_Enum, Display, PartialEq, Eq)]
pub enum WorkspaceErrorCode {
#[display(fmt = "Unknown")]
Unknown = 0,
#[display(fmt = "Workspace name is invalid")]
WorkspaceNameInvalid = 1,
#[display(fmt = "Workspace id is invalid")]
WorkspaceIdInvalid = 2,
#[display(fmt = "App color style format error")]
AppColorStyleInvalid = 3,
#[display(fmt = "Database internal error")]
DatabaseInternalError = 5,
}
impl std::default::Default for WorkspaceErrorCode {
fn default() -> Self { WorkspaceErrorCode::Unknown }
}
impl std::convert::From<flowy_database::result::Error> for WorkspaceError {
fn from(error: flowy_database::result::Error) -> Self {
ErrorBuilder::new(WorkspaceErrorCode::DatabaseInternalError)
.error(error)
.build()
}
}
impl std::convert::From<flowy_sqlite::Error> for WorkspaceError {
fn from(error: flowy_sqlite::Error) -> Self {
ErrorBuilder::new(WorkspaceErrorCode::DatabaseInternalError)
.error(error)
.build()
}
}
impl flowy_dispatch::Error for WorkspaceError {
fn as_response(&self) -> EventResponse {
let bytes: Vec<u8> = self.clone().try_into().unwrap();
ResponseBuilder::Err().data(bytes).build()
}
}
pub struct ErrorBuilder {
pub code: WorkspaceErrorCode,
pub msg: Option<String>,
}
impl ErrorBuilder {
pub fn new(code: WorkspaceErrorCode) -> Self { ErrorBuilder { code, msg: None } }
pub fn msg<T>(mut self, msg: T) -> Self
where
T: Into<String>,
{
self.msg = Some(msg.into());
self
}
pub fn error<T>(mut self, msg: T) -> Self
where
T: std::fmt::Debug,
{
self.msg = Some(format!("{:?}", msg));
self
}
pub fn build(mut self) -> WorkspaceError {
WorkspaceError::new(self.code, &self.msg.take().unwrap_or("".to_owned()))
}
}

View File

@ -0,0 +1,3 @@
mod workspace_handler;
pub use workspace_handler::*;

View File

@ -0,0 +1 @@

View File

@ -1,5 +1,13 @@
pub mod entities;
pub mod errors;
pub mod event;
mod handlers;
pub mod module;
mod sql_tables;
#[macro_use]
mod macros;
mod protobuf;
#[macro_use]
extern crate flowy_database;

View File

@ -0,0 +1,66 @@
#[macro_export]
macro_rules! impl_sql_binary_expression {
($target:ident) => {
impl diesel::serialize::ToSql<diesel::sql_types::Binary, diesel::sqlite::Sqlite>
for $target
{
fn to_sql<W: std::io::Write>(
&self,
out: &mut diesel::serialize::Output<W, diesel::sqlite::Sqlite>,
) -> diesel::serialize::Result {
let bytes: Vec<u8> = self.try_into().map_err(|e| format!("{:?}", e))?;
diesel::serialize::ToSql::<
diesel::sql_types::Binary,
diesel::sqlite::Sqlite,
>::to_sql(&bytes, out)
// match self.try_into() {
// Ok(bytes) => diesel::serialize::ToSql::<
// diesel::sql_types::Binary,
// diesel::sqlite::Sqlite,
// >::to_sql(&bytes, out),
// Err(e) => {
// log::error!(
// "{:?} serialize to bytes fail. {:?}",
// std::any::type_name::<$target>(),
// e
// );
// panic!();
// },
// }
}
}
// https://docs.diesel.rs/src/diesel/sqlite/types/mod.rs.html#30-33
// impl FromSql<sql_types::Binary, Sqlite> for *const [u8] {
// fn from_sql(bytes: Option<&SqliteValue>) -> deserialize::Result<Self> {
// let bytes = not_none!(bytes).read_blob();
// Ok(bytes as *const _)
// }
// }
impl<DB> diesel::deserialize::FromSql<diesel::sql_types::Binary, DB> for $target
where
DB: diesel::backend::Backend,
*const [u8]: diesel::deserialize::FromSql<diesel::sql_types::Binary, DB>,
{
fn from_sql(bytes: Option<&DB::RawValue>) -> diesel::deserialize::Result<Self> {
let slice_ptr = <*const [u8] as diesel::deserialize::FromSql<
diesel::sql_types::Binary,
DB,
>>::from_sql(bytes)?;
let bytes = unsafe { &*slice_ptr };
match $target::try_from(bytes) {
Ok(object) => Ok(object),
Err(e) => {
log::error!(
"{:?} deserialize from bytes fail. {:?}",
std::any::type_name::<$target>(),
e
);
panic!();
},
}
}
}
};
}

View File

@ -0,0 +1,520 @@
// This file is generated by rust-protobuf 2.22.1. Do not edit
// @generated
// https://github.com/rust-lang/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]
#![allow(unused_attributes)]
#![cfg_attr(rustfmt, rustfmt::skip)]
#![allow(box_pointers)]
#![allow(dead_code)]
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(trivial_casts)]
#![allow(unused_imports)]
#![allow(unused_results)]
//! Generated file from `app_create.proto`
/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1;
#[derive(PartialEq,Clone,Default)]
pub struct CreateAppRequest {
// message fields
pub workspace_id: ::std::string::String,
pub name: ::std::string::String,
pub desc: ::std::string::String,
pub color_style: ::protobuf::SingularPtrField<ColorStyle>,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
}
impl<'a> ::std::default::Default for &'a CreateAppRequest {
fn default() -> &'a CreateAppRequest {
<CreateAppRequest as ::protobuf::Message>::default_instance()
}
}
impl CreateAppRequest {
pub fn new() -> CreateAppRequest {
::std::default::Default::default()
}
// string workspace_id = 1;
pub fn get_workspace_id(&self) -> &str {
&self.workspace_id
}
pub fn clear_workspace_id(&mut self) {
self.workspace_id.clear();
}
// Param is passed by value, moved
pub fn set_workspace_id(&mut self, v: ::std::string::String) {
self.workspace_id = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_workspace_id(&mut self) -> &mut ::std::string::String {
&mut self.workspace_id
}
// Take field
pub fn take_workspace_id(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.workspace_id, ::std::string::String::new())
}
// string name = 2;
pub fn get_name(&self) -> &str {
&self.name
}
pub fn clear_name(&mut self) {
self.name.clear();
}
// Param is passed by value, moved
pub fn set_name(&mut self, v: ::std::string::String) {
self.name = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_name(&mut self) -> &mut ::std::string::String {
&mut self.name
}
// Take field
pub fn take_name(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.name, ::std::string::String::new())
}
// string desc = 3;
pub fn get_desc(&self) -> &str {
&self.desc
}
pub fn clear_desc(&mut self) {
self.desc.clear();
}
// Param is passed by value, moved
pub fn set_desc(&mut self, v: ::std::string::String) {
self.desc = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_desc(&mut self) -> &mut ::std::string::String {
&mut self.desc
}
// Take field
pub fn take_desc(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.desc, ::std::string::String::new())
}
// .ColorStyle color_style = 4;
pub fn get_color_style(&self) -> &ColorStyle {
self.color_style.as_ref().unwrap_or_else(|| <ColorStyle as ::protobuf::Message>::default_instance())
}
pub fn clear_color_style(&mut self) {
self.color_style.clear();
}
pub fn has_color_style(&self) -> bool {
self.color_style.is_some()
}
// Param is passed by value, moved
pub fn set_color_style(&mut self, v: ColorStyle) {
self.color_style = ::protobuf::SingularPtrField::some(v);
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_color_style(&mut self) -> &mut ColorStyle {
if self.color_style.is_none() {
self.color_style.set_default();
}
self.color_style.as_mut().unwrap()
}
// Take field
pub fn take_color_style(&mut self) -> ColorStyle {
self.color_style.take().unwrap_or_else(|| ColorStyle::new())
}
}
impl ::protobuf::Message for CreateAppRequest {
fn is_initialized(&self) -> bool {
for v in &self.color_style {
if !v.is_initialized() {
return false;
}
};
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> {
while !is.eof()? {
let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number {
1 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.workspace_id)?;
},
2 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.name)?;
},
3 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.desc)?;
},
4 => {
::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.color_style)?;
},
_ => {
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u32 {
let mut my_size = 0;
if !self.workspace_id.is_empty() {
my_size += ::protobuf::rt::string_size(1, &self.workspace_id);
}
if !self.name.is_empty() {
my_size += ::protobuf::rt::string_size(2, &self.name);
}
if !self.desc.is_empty() {
my_size += ::protobuf::rt::string_size(3, &self.desc);
}
if let Some(ref v) = self.color_style.as_ref() {
let len = v.compute_size();
my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len;
}
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
if !self.workspace_id.is_empty() {
os.write_string(1, &self.workspace_id)?;
}
if !self.name.is_empty() {
os.write_string(2, &self.name)?;
}
if !self.desc.is_empty() {
os.write_string(3, &self.desc)?;
}
if let Some(ref v) = self.color_style.as_ref() {
os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?;
os.write_raw_varint32(v.get_cached_size())?;
v.write_to_with_cached_sizes(os)?;
}
os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(())
}
fn get_cached_size(&self) -> u32 {
self.cached_size.get()
}
fn get_unknown_fields(&self) -> &::protobuf::UnknownFields {
&self.unknown_fields
}
fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields {
&mut self.unknown_fields
}
fn as_any(&self) -> &dyn (::std::any::Any) {
self as &dyn (::std::any::Any)
}
fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
self as &mut dyn (::std::any::Any)
}
fn into_any(self: ::std::boxed::Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
self
}
fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor {
Self::descriptor_static()
}
fn new() -> CreateAppRequest {
CreateAppRequest::new()
}
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT;
descriptor.get(|| {
let mut fields = ::std::vec::Vec::new();
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"workspace_id",
|m: &CreateAppRequest| { &m.workspace_id },
|m: &mut CreateAppRequest| { &mut m.workspace_id },
));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"name",
|m: &CreateAppRequest| { &m.name },
|m: &mut CreateAppRequest| { &mut m.name },
));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"desc",
|m: &CreateAppRequest| { &m.desc },
|m: &mut CreateAppRequest| { &mut m.desc },
));
fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage<ColorStyle>>(
"color_style",
|m: &CreateAppRequest| { &m.color_style },
|m: &mut CreateAppRequest| { &mut m.color_style },
));
::protobuf::reflect::MessageDescriptor::new_pb_name::<CreateAppRequest>(
"CreateAppRequest",
fields,
file_descriptor_proto()
)
})
}
fn default_instance() -> &'static CreateAppRequest {
static instance: ::protobuf::rt::LazyV2<CreateAppRequest> = ::protobuf::rt::LazyV2::INIT;
instance.get(CreateAppRequest::new)
}
}
impl ::protobuf::Clear for CreateAppRequest {
fn clear(&mut self) {
self.workspace_id.clear();
self.name.clear();
self.desc.clear();
self.color_style.clear();
self.unknown_fields.clear();
}
}
impl ::std::fmt::Debug for CreateAppRequest {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for CreateAppRequest {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
::protobuf::reflect::ReflectValueRef::Message(self)
}
}
#[derive(PartialEq,Clone,Default)]
pub struct ColorStyle {
// message fields
pub theme_color: ::std::string::String,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
}
impl<'a> ::std::default::Default for &'a ColorStyle {
fn default() -> &'a ColorStyle {
<ColorStyle as ::protobuf::Message>::default_instance()
}
}
impl ColorStyle {
pub fn new() -> ColorStyle {
::std::default::Default::default()
}
// string theme_color = 1;
pub fn get_theme_color(&self) -> &str {
&self.theme_color
}
pub fn clear_theme_color(&mut self) {
self.theme_color.clear();
}
// Param is passed by value, moved
pub fn set_theme_color(&mut self, v: ::std::string::String) {
self.theme_color = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_theme_color(&mut self) -> &mut ::std::string::String {
&mut self.theme_color
}
// Take field
pub fn take_theme_color(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.theme_color, ::std::string::String::new())
}
}
impl ::protobuf::Message for ColorStyle {
fn is_initialized(&self) -> bool {
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> {
while !is.eof()? {
let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number {
1 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.theme_color)?;
},
_ => {
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u32 {
let mut my_size = 0;
if !self.theme_color.is_empty() {
my_size += ::protobuf::rt::string_size(1, &self.theme_color);
}
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
if !self.theme_color.is_empty() {
os.write_string(1, &self.theme_color)?;
}
os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(())
}
fn get_cached_size(&self) -> u32 {
self.cached_size.get()
}
fn get_unknown_fields(&self) -> &::protobuf::UnknownFields {
&self.unknown_fields
}
fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields {
&mut self.unknown_fields
}
fn as_any(&self) -> &dyn (::std::any::Any) {
self as &dyn (::std::any::Any)
}
fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
self as &mut dyn (::std::any::Any)
}
fn into_any(self: ::std::boxed::Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
self
}
fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor {
Self::descriptor_static()
}
fn new() -> ColorStyle {
ColorStyle::new()
}
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT;
descriptor.get(|| {
let mut fields = ::std::vec::Vec::new();
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"theme_color",
|m: &ColorStyle| { &m.theme_color },
|m: &mut ColorStyle| { &mut m.theme_color },
));
::protobuf::reflect::MessageDescriptor::new_pb_name::<ColorStyle>(
"ColorStyle",
fields,
file_descriptor_proto()
)
})
}
fn default_instance() -> &'static ColorStyle {
static instance: ::protobuf::rt::LazyV2<ColorStyle> = ::protobuf::rt::LazyV2::INIT;
instance.get(ColorStyle::new)
}
}
impl ::protobuf::Clear for ColorStyle {
fn clear(&mut self) {
self.theme_color.clear();
self.unknown_fields.clear();
}
}
impl ::std::fmt::Debug for ColorStyle {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for ColorStyle {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
::protobuf::reflect::ReflectValueRef::Message(self)
}
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x10app_create.proto\"\x8b\x01\n\x10CreateAppRequest\x12!\n\x0cworkspa\
ce_id\x18\x01\x20\x01(\tR\x0bworkspaceId\x12\x12\n\x04name\x18\x02\x20\
\x01(\tR\x04name\x12\x12\n\x04desc\x18\x03\x20\x01(\tR\x04desc\x12,\n\
\x0bcolor_style\x18\x04\x20\x01(\x0b2\x0b.ColorStyleR\ncolorStyle\"-\n\n\
ColorStyle\x12\x1f\n\x0btheme_color\x18\x01\x20\x01(\tR\nthemeColorJ\xd5\
\x02\n\x06\x12\x04\0\0\n\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\
\x04\0\x12\x04\x02\0\x07\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\x1c\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\x17\n\x0c\
\n\x05\x04\0\x02\0\x03\x12\x03\x03\x1a\x1b\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\x14\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\x0f\n\x0c\n\x05\x04\0\x02\x02\x03\x12\x03\x05\x12\x13\n\
\x0b\n\x04\x04\0\x02\x03\x12\x03\x06\x04\x1f\n\x0c\n\x05\x04\0\x02\x03\
\x06\x12\x03\x06\x04\x0e\n\x0c\n\x05\x04\0\x02\x03\x01\x12\x03\x06\x0f\
\x1a\n\x0c\n\x05\x04\0\x02\x03\x03\x12\x03\x06\x1d\x1e\n\n\n\x02\x04\x01\
\x12\x04\x08\0\n\x01\n\n\n\x03\x04\x01\x01\x12\x03\x08\x08\x12\n\x0b\n\
\x04\x04\x01\x02\0\x12\x03\t\x04\x1b\n\x0c\n\x05\x04\x01\x02\0\x05\x12\
\x03\t\x04\n\n\x0c\n\x05\x04\x01\x02\0\x01\x12\x03\t\x0b\x16\n\x0c\n\x05\
\x04\x01\x02\0\x03\x12\x03\t\x19\x1ab\x06proto3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto {
::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap()
}
pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto {
file_descriptor_proto_lazy.get(|| {
parse_descriptor_proto()
})
}

View File

@ -0,0 +1,312 @@
// This file is generated by rust-protobuf 2.22.1. Do not edit
// @generated
// https://github.com/rust-lang/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]
#![allow(unused_attributes)]
#![cfg_attr(rustfmt, rustfmt::skip)]
#![allow(box_pointers)]
#![allow(dead_code)]
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(trivial_casts)]
#![allow(unused_imports)]
#![allow(unused_results)]
//! Generated file from `errors.proto`
/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1;
#[derive(PartialEq,Clone,Default)]
pub struct WorkspaceError {
// message fields
pub code: WorkspaceErrorCode,
pub msg: ::std::string::String,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
}
impl<'a> ::std::default::Default for &'a WorkspaceError {
fn default() -> &'a WorkspaceError {
<WorkspaceError as ::protobuf::Message>::default_instance()
}
}
impl WorkspaceError {
pub fn new() -> WorkspaceError {
::std::default::Default::default()
}
// .WorkspaceErrorCode code = 1;
pub fn get_code(&self) -> WorkspaceErrorCode {
self.code
}
pub fn clear_code(&mut self) {
self.code = WorkspaceErrorCode::Unknown;
}
// Param is passed by value, moved
pub fn set_code(&mut self, v: WorkspaceErrorCode) {
self.code = v;
}
// string msg = 2;
pub fn get_msg(&self) -> &str {
&self.msg
}
pub fn clear_msg(&mut self) {
self.msg.clear();
}
// Param is passed by value, moved
pub fn set_msg(&mut self, v: ::std::string::String) {
self.msg = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_msg(&mut self) -> &mut ::std::string::String {
&mut self.msg
}
// Take field
pub fn take_msg(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.msg, ::std::string::String::new())
}
}
impl ::protobuf::Message for WorkspaceError {
fn is_initialized(&self) -> bool {
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> {
while !is.eof()? {
let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number {
1 => {
::protobuf::rt::read_proto3_enum_with_unknown_fields_into(wire_type, is, &mut self.code, 1, &mut self.unknown_fields)?
},
2 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.msg)?;
},
_ => {
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u32 {
let mut my_size = 0;
if self.code != WorkspaceErrorCode::Unknown {
my_size += ::protobuf::rt::enum_size(1, self.code);
}
if !self.msg.is_empty() {
my_size += ::protobuf::rt::string_size(2, &self.msg);
}
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
if self.code != WorkspaceErrorCode::Unknown {
os.write_enum(1, ::protobuf::ProtobufEnum::value(&self.code))?;
}
if !self.msg.is_empty() {
os.write_string(2, &self.msg)?;
}
os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(())
}
fn get_cached_size(&self) -> u32 {
self.cached_size.get()
}
fn get_unknown_fields(&self) -> &::protobuf::UnknownFields {
&self.unknown_fields
}
fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields {
&mut self.unknown_fields
}
fn as_any(&self) -> &dyn (::std::any::Any) {
self as &dyn (::std::any::Any)
}
fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
self as &mut dyn (::std::any::Any)
}
fn into_any(self: ::std::boxed::Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
self
}
fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor {
Self::descriptor_static()
}
fn new() -> WorkspaceError {
WorkspaceError::new()
}
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT;
descriptor.get(|| {
let mut fields = ::std::vec::Vec::new();
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeEnum<WorkspaceErrorCode>>(
"code",
|m: &WorkspaceError| { &m.code },
|m: &mut WorkspaceError| { &mut m.code },
));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"msg",
|m: &WorkspaceError| { &m.msg },
|m: &mut WorkspaceError| { &mut m.msg },
));
::protobuf::reflect::MessageDescriptor::new_pb_name::<WorkspaceError>(
"WorkspaceError",
fields,
file_descriptor_proto()
)
})
}
fn default_instance() -> &'static WorkspaceError {
static instance: ::protobuf::rt::LazyV2<WorkspaceError> = ::protobuf::rt::LazyV2::INIT;
instance.get(WorkspaceError::new)
}
}
impl ::protobuf::Clear for WorkspaceError {
fn clear(&mut self) {
self.code = WorkspaceErrorCode::Unknown;
self.msg.clear();
self.unknown_fields.clear();
}
}
impl ::std::fmt::Debug for WorkspaceError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for WorkspaceError {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
::protobuf::reflect::ReflectValueRef::Message(self)
}
}
#[derive(Clone,PartialEq,Eq,Debug,Hash)]
pub enum WorkspaceErrorCode {
Unknown = 0,
WorkspaceNameInvalid = 1,
WorkspaceIdInvalid = 2,
AppColorStyleInvalid = 3,
DatabaseInternalError = 5,
}
impl ::protobuf::ProtobufEnum for WorkspaceErrorCode {
fn value(&self) -> i32 {
*self as i32
}
fn from_i32(value: i32) -> ::std::option::Option<WorkspaceErrorCode> {
match value {
0 => ::std::option::Option::Some(WorkspaceErrorCode::Unknown),
1 => ::std::option::Option::Some(WorkspaceErrorCode::WorkspaceNameInvalid),
2 => ::std::option::Option::Some(WorkspaceErrorCode::WorkspaceIdInvalid),
3 => ::std::option::Option::Some(WorkspaceErrorCode::AppColorStyleInvalid),
5 => ::std::option::Option::Some(WorkspaceErrorCode::DatabaseInternalError),
_ => ::std::option::Option::None
}
}
fn values() -> &'static [Self] {
static values: &'static [WorkspaceErrorCode] = &[
WorkspaceErrorCode::Unknown,
WorkspaceErrorCode::WorkspaceNameInvalid,
WorkspaceErrorCode::WorkspaceIdInvalid,
WorkspaceErrorCode::AppColorStyleInvalid,
WorkspaceErrorCode::DatabaseInternalError,
];
values
}
fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor {
static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::LazyV2::INIT;
descriptor.get(|| {
::protobuf::reflect::EnumDescriptor::new_pb_name::<WorkspaceErrorCode>("WorkspaceErrorCode", file_descriptor_proto())
})
}
}
impl ::std::marker::Copy for WorkspaceErrorCode {
}
impl ::std::default::Default for WorkspaceErrorCode {
fn default() -> Self {
WorkspaceErrorCode::Unknown
}
}
impl ::protobuf::reflect::ProtobufValue for WorkspaceErrorCode {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
::protobuf::reflect::ReflectValueRef::Enum(::protobuf::ProtobufEnum::descriptor(self))
}
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x0cerrors.proto\"K\n\x0eWorkspaceError\x12'\n\x04code\x18\x01\x20\x01\
(\x0e2\x13.WorkspaceErrorCodeR\x04code\x12\x10\n\x03msg\x18\x02\x20\x01(\
\tR\x03msg*\x88\x01\n\x12WorkspaceErrorCode\x12\x0b\n\x07Unknown\x10\0\
\x12\x18\n\x14WorkspaceNameInvalid\x10\x01\x12\x16\n\x12WorkspaceIdInval\
id\x10\x02\x12\x18\n\x14AppColorStyleInvalid\x10\x03\x12\x19\n\x15Databa\
seInternalError\x10\x05J\xfd\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\x16\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x20\n\
\x0c\n\x05\x04\0\x02\0\x06\x12\x03\x03\x04\x16\n\x0c\n\x05\x04\0\x02\0\
\x01\x12\x03\x03\x17\x1b\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x1e\x1f\
\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x04\x04\x13\n\x0c\n\x05\x04\0\x02\x01\
\x05\x12\x03\x04\x04\n\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x04\x0b\x0e\
\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x04\x11\x12\n\n\n\x02\x05\0\x12\
\x04\x06\0\x0c\x01\n\n\n\x03\x05\0\x01\x12\x03\x06\x05\x17\n\x0b\n\x04\
\x05\0\x02\0\x12\x03\x07\x04\x10\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x07\
\x04\x0b\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x07\x0e\x0f\n\x0b\n\x04\x05\
\0\x02\x01\x12\x03\x08\x04\x1d\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x08\
\x04\x18\n\x0c\n\x05\x05\0\x02\x01\x02\x12\x03\x08\x1b\x1c\n\x0b\n\x04\
\x05\0\x02\x02\x12\x03\t\x04\x1b\n\x0c\n\x05\x05\0\x02\x02\x01\x12\x03\t\
\x04\x16\n\x0c\n\x05\x05\0\x02\x02\x02\x12\x03\t\x19\x1a\n\x0b\n\x04\x05\
\0\x02\x03\x12\x03\n\x04\x1d\n\x0c\n\x05\x05\0\x02\x03\x01\x12\x03\n\x04\
\x18\n\x0c\n\x05\x05\0\x02\x03\x02\x12\x03\n\x1b\x1c\n\x0b\n\x04\x05\0\
\x02\x04\x12\x03\x0b\x04\x1e\n\x0c\n\x05\x05\0\x02\x04\x01\x12\x03\x0b\
\x04\x19\n\x0c\n\x05\x05\0\x02\x04\x02\x12\x03\x0b\x1c\x1db\x06proto3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto {
::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap()
}
pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto {
file_descriptor_proto_lazy.get(|| {
parse_descriptor_proto()
})
}

View File

@ -1 +1,13 @@
// Auto-generated, do not edit
mod errors;
pub use errors::*;
mod workspace_update;
pub use workspace_update::*;
mod app_create;
pub use app_create::*;
mod workspace_create;
pub use workspace_create::*;

View File

@ -0,0 +1,250 @@
// This file is generated by rust-protobuf 2.22.1. Do not edit
// @generated
// https://github.com/rust-lang/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]
#![allow(unused_attributes)]
#![cfg_attr(rustfmt, rustfmt::skip)]
#![allow(box_pointers)]
#![allow(dead_code)]
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(trivial_casts)]
#![allow(unused_imports)]
#![allow(unused_results)]
//! Generated file from `workspace_create.proto`
/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1;
#[derive(PartialEq,Clone,Default)]
pub struct CreateWorkspaceRequest {
// message fields
pub name: ::std::string::String,
pub desc: ::std::string::String,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
}
impl<'a> ::std::default::Default for &'a CreateWorkspaceRequest {
fn default() -> &'a CreateWorkspaceRequest {
<CreateWorkspaceRequest as ::protobuf::Message>::default_instance()
}
}
impl CreateWorkspaceRequest {
pub fn new() -> CreateWorkspaceRequest {
::std::default::Default::default()
}
// string name = 1;
pub fn get_name(&self) -> &str {
&self.name
}
pub fn clear_name(&mut self) {
self.name.clear();
}
// Param is passed by value, moved
pub fn set_name(&mut self, v: ::std::string::String) {
self.name = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_name(&mut self) -> &mut ::std::string::String {
&mut self.name
}
// Take field
pub fn take_name(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.name, ::std::string::String::new())
}
// string desc = 2;
pub fn get_desc(&self) -> &str {
&self.desc
}
pub fn clear_desc(&mut self) {
self.desc.clear();
}
// Param is passed by value, moved
pub fn set_desc(&mut self, v: ::std::string::String) {
self.desc = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_desc(&mut self) -> &mut ::std::string::String {
&mut self.desc
}
// Take field
pub fn take_desc(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.desc, ::std::string::String::new())
}
}
impl ::protobuf::Message for CreateWorkspaceRequest {
fn is_initialized(&self) -> bool {
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> {
while !is.eof()? {
let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number {
1 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.name)?;
},
2 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.desc)?;
},
_ => {
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u32 {
let mut my_size = 0;
if !self.name.is_empty() {
my_size += ::protobuf::rt::string_size(1, &self.name);
}
if !self.desc.is_empty() {
my_size += ::protobuf::rt::string_size(2, &self.desc);
}
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
if !self.name.is_empty() {
os.write_string(1, &self.name)?;
}
if !self.desc.is_empty() {
os.write_string(2, &self.desc)?;
}
os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(())
}
fn get_cached_size(&self) -> u32 {
self.cached_size.get()
}
fn get_unknown_fields(&self) -> &::protobuf::UnknownFields {
&self.unknown_fields
}
fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields {
&mut self.unknown_fields
}
fn as_any(&self) -> &dyn (::std::any::Any) {
self as &dyn (::std::any::Any)
}
fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
self as &mut dyn (::std::any::Any)
}
fn into_any(self: ::std::boxed::Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
self
}
fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor {
Self::descriptor_static()
}
fn new() -> CreateWorkspaceRequest {
CreateWorkspaceRequest::new()
}
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT;
descriptor.get(|| {
let mut fields = ::std::vec::Vec::new();
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"name",
|m: &CreateWorkspaceRequest| { &m.name },
|m: &mut CreateWorkspaceRequest| { &mut m.name },
));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"desc",
|m: &CreateWorkspaceRequest| { &m.desc },
|m: &mut CreateWorkspaceRequest| { &mut m.desc },
));
::protobuf::reflect::MessageDescriptor::new_pb_name::<CreateWorkspaceRequest>(
"CreateWorkspaceRequest",
fields,
file_descriptor_proto()
)
})
}
fn default_instance() -> &'static CreateWorkspaceRequest {
static instance: ::protobuf::rt::LazyV2<CreateWorkspaceRequest> = ::protobuf::rt::LazyV2::INIT;
instance.get(CreateWorkspaceRequest::new)
}
}
impl ::protobuf::Clear for CreateWorkspaceRequest {
fn clear(&mut self) {
self.name.clear();
self.desc.clear();
self.unknown_fields.clear();
}
}
impl ::std::fmt::Debug for CreateWorkspaceRequest {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for CreateWorkspaceRequest {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
::protobuf::reflect::ReflectValueRef::Message(self)
}
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x16workspace_create.proto\"@\n\x16CreateWorkspaceRequest\x12\x12\n\
\x04name\x18\x01\x20\x01(\tR\x04name\x12\x12\n\x04desc\x18\x02\x20\x01(\
\tR\x04descJ\x98\x01\n\x06\x12\x04\0\0\x05\x01\n\x08\n\x01\x0c\x12\x03\0\
\0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x05\x01\n\n\n\x03\x04\0\x01\x12\x03\
\x02\x08\x1e\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x04\x14\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\x0f\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\x12\x13\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\x13b\x06proto3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto {
::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap()
}
pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto {
file_descriptor_proto_lazy.get(|| {
parse_descriptor_proto()
})
}

View File

@ -0,0 +1,296 @@
// This file is generated by rust-protobuf 2.22.1. Do not edit
// @generated
// https://github.com/rust-lang/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]
#![allow(unused_attributes)]
#![cfg_attr(rustfmt, rustfmt::skip)]
#![allow(box_pointers)]
#![allow(dead_code)]
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(trivial_casts)]
#![allow(unused_imports)]
#![allow(unused_results)]
//! Generated file from `workspace_update.proto`
/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_22_1;
#[derive(PartialEq,Clone,Default)]
pub struct UpdateWorkspaceRequest {
// message fields
pub id: ::std::string::String,
pub name: ::std::string::String,
pub desc: ::std::string::String,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
}
impl<'a> ::std::default::Default for &'a UpdateWorkspaceRequest {
fn default() -> &'a UpdateWorkspaceRequest {
<UpdateWorkspaceRequest as ::protobuf::Message>::default_instance()
}
}
impl UpdateWorkspaceRequest {
pub fn new() -> UpdateWorkspaceRequest {
::std::default::Default::default()
}
// string id = 1;
pub fn get_id(&self) -> &str {
&self.id
}
pub fn clear_id(&mut self) {
self.id.clear();
}
// Param is passed by value, moved
pub fn set_id(&mut self, v: ::std::string::String) {
self.id = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_id(&mut self) -> &mut ::std::string::String {
&mut self.id
}
// Take field
pub fn take_id(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.id, ::std::string::String::new())
}
// string name = 2;
pub fn get_name(&self) -> &str {
&self.name
}
pub fn clear_name(&mut self) {
self.name.clear();
}
// Param is passed by value, moved
pub fn set_name(&mut self, v: ::std::string::String) {
self.name = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_name(&mut self) -> &mut ::std::string::String {
&mut self.name
}
// Take field
pub fn take_name(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.name, ::std::string::String::new())
}
// string desc = 3;
pub fn get_desc(&self) -> &str {
&self.desc
}
pub fn clear_desc(&mut self) {
self.desc.clear();
}
// Param is passed by value, moved
pub fn set_desc(&mut self, v: ::std::string::String) {
self.desc = v;
}
// Mutable pointer to the field.
// If field is not initialized, it is initialized with default value first.
pub fn mut_desc(&mut self) -> &mut ::std::string::String {
&mut self.desc
}
// Take field
pub fn take_desc(&mut self) -> ::std::string::String {
::std::mem::replace(&mut self.desc, ::std::string::String::new())
}
}
impl ::protobuf::Message for UpdateWorkspaceRequest {
fn is_initialized(&self) -> bool {
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> {
while !is.eof()? {
let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number {
1 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.id)?;
},
2 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.name)?;
},
3 => {
::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.desc)?;
},
_ => {
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u32 {
let mut my_size = 0;
if !self.id.is_empty() {
my_size += ::protobuf::rt::string_size(1, &self.id);
}
if !self.name.is_empty() {
my_size += ::protobuf::rt::string_size(2, &self.name);
}
if !self.desc.is_empty() {
my_size += ::protobuf::rt::string_size(3, &self.desc);
}
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
if !self.id.is_empty() {
os.write_string(1, &self.id)?;
}
if !self.name.is_empty() {
os.write_string(2, &self.name)?;
}
if !self.desc.is_empty() {
os.write_string(3, &self.desc)?;
}
os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(())
}
fn get_cached_size(&self) -> u32 {
self.cached_size.get()
}
fn get_unknown_fields(&self) -> &::protobuf::UnknownFields {
&self.unknown_fields
}
fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields {
&mut self.unknown_fields
}
fn as_any(&self) -> &dyn (::std::any::Any) {
self as &dyn (::std::any::Any)
}
fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
self as &mut dyn (::std::any::Any)
}
fn into_any(self: ::std::boxed::Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
self
}
fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor {
Self::descriptor_static()
}
fn new() -> UpdateWorkspaceRequest {
UpdateWorkspaceRequest::new()
}
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT;
descriptor.get(|| {
let mut fields = ::std::vec::Vec::new();
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"id",
|m: &UpdateWorkspaceRequest| { &m.id },
|m: &mut UpdateWorkspaceRequest| { &mut m.id },
));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"name",
|m: &UpdateWorkspaceRequest| { &m.name },
|m: &mut UpdateWorkspaceRequest| { &mut m.name },
));
fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>(
"desc",
|m: &UpdateWorkspaceRequest| { &m.desc },
|m: &mut UpdateWorkspaceRequest| { &mut m.desc },
));
::protobuf::reflect::MessageDescriptor::new_pb_name::<UpdateWorkspaceRequest>(
"UpdateWorkspaceRequest",
fields,
file_descriptor_proto()
)
})
}
fn default_instance() -> &'static UpdateWorkspaceRequest {
static instance: ::protobuf::rt::LazyV2<UpdateWorkspaceRequest> = ::protobuf::rt::LazyV2::INIT;
instance.get(UpdateWorkspaceRequest::new)
}
}
impl ::protobuf::Clear for UpdateWorkspaceRequest {
fn clear(&mut self) {
self.id.clear();
self.name.clear();
self.desc.clear();
self.unknown_fields.clear();
}
}
impl ::std::fmt::Debug for UpdateWorkspaceRequest {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for UpdateWorkspaceRequest {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
::protobuf::reflect::ReflectValueRef::Message(self)
}
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x16workspace_update.proto\"P\n\x16UpdateWorkspaceRequest\x12\x0e\n\
\x02id\x18\x01\x20\x01(\tR\x02id\x12\x12\n\x04name\x18\x02\x20\x01(\tR\
\x04name\x12\x12\n\x04desc\x18\x03\x20\x01(\tR\x04descJ\xcf\x01\n\x06\
\x12\x04\0\0\x06\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\x1e\n\x0b\n\x04\
\x04\0\x02\0\x12\x03\x03\x04\x12\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\r\n\x0c\n\x05\x04\0\
\x02\0\x03\x12\x03\x03\x10\x11\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\x14\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\x0f\n\x0c\n\x05\x04\0\x02\x02\x03\x12\x03\x05\x12\x13b\x06p\
roto3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto {
::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap()
}
pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto {
file_descriptor_proto_lazy.get(|| {
parse_descriptor_proto()
})
}

View File

@ -0,0 +1,11 @@
syntax = "proto3";
message CreateAppRequest {
string workspace_id = 1;
string name = 2;
string desc = 3;
ColorStyle color_style = 4;
}
message ColorStyle {
string theme_color = 1;
}

View File

@ -0,0 +1,13 @@
syntax = "proto3";
message WorkspaceError {
WorkspaceErrorCode code = 1;
string msg = 2;
}
enum WorkspaceErrorCode {
Unknown = 0;
WorkspaceNameInvalid = 1;
WorkspaceIdInvalid = 2;
AppColorStyleInvalid = 3;
DatabaseInternalError = 5;
}

View File

@ -0,0 +1,6 @@
syntax = "proto3";
message CreateWorkspaceRequest {
string name = 1;
string desc = 2;
}

View File

@ -0,0 +1,7 @@
syntax = "proto3";
message UpdateWorkspaceRequest {
string id = 1;
string name = 2;
string desc = 3;
}

View File

@ -0,0 +1,56 @@
use crate::{impl_sql_binary_expression, sql_tables::workspace::Workspace};
use diesel::sql_types::Binary;
use flowy_database::schema::{app_table, app_table::dsl};
use flowy_infra::{timestamp, uuid};
use serde::{Deserialize, Serialize, __private::TryFrom};
use std::convert::TryInto;
#[derive(
PartialEq,
Serialize,
Deserialize,
Clone,
Debug,
Queryable,
Identifiable,
Insertable,
Associations,
)]
#[belongs_to(Workspace, foreign_key = "workspace_id")]
#[table_name = "app_table"]
#[serde(tag = "type")]
pub(crate) struct App {
pub id: String,
pub workspace_id: String, // equal to #[belongs_to(Workspace, foreign_key = "workspace_id")].
pub name: String,
pub desc: String,
pub color_style: ColorStyleCol,
pub last_view_id: Option<String>,
pub modified_time: i64,
pub create_time: i64,
pub version: i64,
}
#[derive(Clone, PartialEq, Serialize, Deserialize, Debug, Default, FromSqlRow, AsExpression)]
#[sql_type = "Binary"]
pub(crate) struct ColorStyleCol {
pub(crate) theme_color: String,
}
impl std::convert::TryInto<Vec<u8>> for &ColorStyleCol {
type Error = String;
fn try_into(self) -> Result<Vec<u8>, Self::Error> {
bincode::serialize(self).map_err(|e| format!("{:?}", e))
}
}
impl std::convert::TryFrom<&[u8]> for ColorStyleCol {
type Error = String;
fn try_from(value: &[u8]) -> Result<Self, Self::Error> {
bincode::deserialize(value).map_err(|e| format!("{:?}", e))
}
}
impl_sql_binary_expression!(ColorStyleCol);

View File

@ -0,0 +1,3 @@
mod app;
pub use app::*;

View File

@ -0,0 +1,2 @@
pub mod app;
pub mod workspace;

View File

@ -0,0 +1,3 @@
mod workspace;
pub use workspace::*;

View File

@ -0,0 +1,63 @@
use crate::{
entities::workspace::{CreateWorkspaceParams, UpdateWorkspaceParams},
sql_tables::app::App,
};
use flowy_database::schema::{workspace_table, workspace_table::dsl};
use flowy_infra::{timestamp, uuid};
use serde::{Deserialize, Serialize};
#[derive(PartialEq, Clone, Serialize, Deserialize, Debug, Queryable, Identifiable, Insertable)]
#[table_name = "workspace_table"]
#[serde(tag = "type")]
pub struct Workspace {
pub id: String,
pub name: String,
pub desc: String,
pub modified_time: i64,
pub create_time: i64,
pub user_id: String,
pub version: i64,
}
impl Workspace {
#[allow(dead_code)]
pub fn new(params: CreateWorkspaceParams) -> Self {
let mut workspace = Workspace::default();
workspace.name = params.name;
workspace.desc = params.desc;
workspace
}
}
impl std::default::Default for Workspace {
fn default() -> Self {
let time = timestamp();
Workspace {
id: uuid(),
name: String::default(),
desc: String::default(),
modified_time: time,
create_time: time,
user_id: String::default(),
version: 0,
}
}
}
#[derive(AsChangeset, Identifiable, Clone, Default, Debug)]
#[table_name = "workspace_table"]
pub struct WorkspaceChangeset {
pub id: String,
pub name: Option<String>,
pub desc: Option<String>,
}
impl WorkspaceChangeset {
pub fn new(params: UpdateWorkspaceParams) -> Self {
WorkspaceChangeset {
id: params.id,
name: Some(params.name),
desc: Some(params.desc),
}
}
}