feat: migrate user data to cloud (#3078)

* refactor: weak passed-in params in handler

* refactor: rename struct

* chore: update tables

* chore: update schema

* chore: add permission

* chore: update tables

* chore: support transaction mode

* chore: workspace database id

* chore: add user workspace

* feat: return list of workspaces

* chore: add user to workspace

* feat: separate database row table

* refactor: update schema

* chore: partition table

* chore: use transaction

* refactor: dir

* refactor: collab db ref

* fix: collab db lock

* chore: rename files

* chore: add tables descriptions

* chore: update readme

* docs: update documentation

* chore: rename crate

* chore: update ref

* chore: update tests

* chore: update tests

* refactor: crate deps

* chore: update crate ref

* chore: remove unused deps

* chore: remove unused deps

* chore: update collab crate refs

* chore: replace client with transaction in pooler

* refactor: return error type

* refactor: use anyhow error in deps

* feat: supabase postgrest user signin (wip)

* fix: Cargo.toml source git deps, changed Error to anyhow::Error

* fix: uuid serialization

* chore: fix conflict

* chore: extend the response

* feat: add implementation place holders

* feat: impl get_user_workspaces

* feat: impl get_user_profile

* test: create workspace

* fix: postgrest: field names and alias

* chore: implement folder restful api

* chore: implement collab storate with restful api

* feat: added placeholders for impl: update_user_profile, check_user

* feat: impl: update_user_profile

* feat: impl: check_user

* fix: use UidResponse, add more debug info for serde serialization error

* fix: get_user_profile: use Optional<UserProfileResponse>

* chore: imple init sync

* chore: support soft delete

* feat: postgresql: add migration test

* feat: postgresql migration test: added UID display and colored output

* feat: postgresql migration test: workspace role

* feat: postgresql migration test: create shared common utils

* feat: postgresql migration test: fixed shebang

* chore: add flush_collab_update pg function

* chore: implement datbaase and document restful api

* chore: migrate to use restful api

* chore: update table schema

* chore: fix tests

* chore: remove unused code

* chore: format code

* chore: remove unused env

* fix: tauri build

* fix: tauri build

---------

Co-authored-by: Fu Zi Xiang <speed2exe@live.com.sg>
This commit is contained in:
Nathan.fooo
2023-07-29 09:46:24 +08:00
committed by GitHub
parent a885170869
commit 2cd88594e8
179 changed files with 4999 additions and 5314 deletions

View File

@ -4,7 +4,6 @@ import 'package:appflowy_backend/log.dart';
// ignore: unnecessary_import
import 'package:appflowy_backend/protobuf/dart-ffi/ffi_response.pb.dart';
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
import 'package:appflowy_backend/protobuf/flowy-net/network_state.pb.dart';
import 'package:isolates/isolates.dart';
import 'package:isolates/ports.dart';
import 'package:ffi/ffi.dart';
@ -23,11 +22,9 @@ import 'package:protobuf/protobuf.dart';
import 'dart:convert' show utf8;
import '../protobuf/flowy-config/entities.pb.dart';
import '../protobuf/flowy-config/event_map.pb.dart';
import '../protobuf/flowy-net/event_map.pb.dart';
import 'error.dart';
part 'dart_event/flowy-folder2/dart_event.dart';
part 'dart_event/flowy-net/dart_event.dart';
part 'dart_event/flowy-user/dart_event.dart';
part 'dart_event/flowy-database2/dart_event.dart';
part 'dart_event/flowy-document2/dart_event.dart';

View File

@ -26,16 +26,14 @@ class SupabaseConfiguration {
/// Indicates whether the sync feature is enabled.
final bool enable_sync;
final String url;
final String key;
final String anon_key;
final String jwt_secret;
final PostgresConfiguration postgres_config;
SupabaseConfiguration({
this.enable_sync = true,
required this.url,
required this.key,
required this.anon_key,
required this.jwt_secret,
required this.postgres_config,
});
factory SupabaseConfiguration.fromJson(Map<String, dynamic> json) =>
@ -43,23 +41,3 @@ class SupabaseConfiguration {
Map<String, dynamic> toJson() => _$SupabaseConfigurationToJson(this);
}
@JsonSerializable()
class PostgresConfiguration {
final String url;
final String user_name;
final String password;
final int port;
PostgresConfiguration({
required this.url,
required this.user_name,
required this.password,
required this.port,
});
factory PostgresConfiguration.fromJson(Map<String, dynamic> json) =>
_$PostgresConfigurationFromJson(json);
Map<String, dynamic> toJson() => _$PostgresConfigurationToJson(this);
}

View File

@ -21,10 +21,8 @@ SupabaseConfiguration _$SupabaseConfigurationFromJson(
SupabaseConfiguration(
enable_sync: json['enable_sync'] as bool? ?? true,
url: json['url'] as String,
key: json['key'] as String,
anon_key: json['anon_key'] as String,
jwt_secret: json['jwt_secret'] as String,
postgres_config: PostgresConfiguration.fromJson(
json['postgres_config'] as Map<String, dynamic>),
);
Map<String, dynamic> _$SupabaseConfigurationToJson(
@ -32,25 +30,6 @@ Map<String, dynamic> _$SupabaseConfigurationToJson(
<String, dynamic>{
'enable_sync': instance.enable_sync,
'url': instance.url,
'key': instance.key,
'anon_key': instance.anon_key,
'jwt_secret': instance.jwt_secret,
'postgres_config': instance.postgres_config,
};
PostgresConfiguration _$PostgresConfigurationFromJson(
Map<String, dynamic> json) =>
PostgresConfiguration(
url: json['url'] as String,
user_name: json['user_name'] as String,
password: json['password'] as String,
port: json['port'] as int,
);
Map<String, dynamic> _$PostgresConfigurationToJson(
PostgresConfiguration instance) =>
<String, dynamic>{
'url': instance.url,
'user_name': instance.user_name,
'password': instance.password,
'port': instance.port,
};