mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-23 17:26:35 +00:00
refactor(server-api): Replace Rest API interface with Graphql endpoints everywhere they are used
With no implementations yet
This commit is contained in:
parent
522cbbf3d5
commit
daf50e8c92
|
@ -8,8 +8,12 @@ import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/server_settings.g
|
||||||
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/services.graphql.dart';
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/services.graphql.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/users.graphql.dart';
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/users.graphql.dart';
|
||||||
import 'package:selfprivacy/logic/models/auto_upgrade_settings.dart';
|
import 'package:selfprivacy/logic/models/auto_upgrade_settings.dart';
|
||||||
|
import 'package:selfprivacy/logic/models/hive/backblaze_bucket.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/user.dart';
|
import 'package:selfprivacy/logic/models/hive/user.dart';
|
||||||
import 'package:selfprivacy/logic/models/json/api_token.dart';
|
import 'package:selfprivacy/logic/models/json/api_token.dart';
|
||||||
|
import 'package:selfprivacy/logic/models/json/backup.dart';
|
||||||
|
import 'package:selfprivacy/logic/models/json/device_token.dart';
|
||||||
|
import 'package:selfprivacy/logic/models/json/recovery_token_status.dart';
|
||||||
import 'package:selfprivacy/logic/models/json/server_disk_volume.dart';
|
import 'package:selfprivacy/logic/models/json/server_disk_volume.dart';
|
||||||
import 'package:selfprivacy/logic/models/json/server_job.dart';
|
import 'package:selfprivacy/logic/models/json/server_job.dart';
|
||||||
import 'package:selfprivacy/logic/models/service.dart';
|
import 'package:selfprivacy/logic/models/service.dart';
|
||||||
|
@ -35,20 +39,34 @@ class GenericMutationResult {
|
||||||
|
|
||||||
class GenericJobMutationReturn extends GenericMutationResult {
|
class GenericJobMutationReturn extends GenericMutationResult {
|
||||||
GenericJobMutationReturn({
|
GenericJobMutationReturn({
|
||||||
required final super.success,
|
required super.success,
|
||||||
required final super.code,
|
required super.code,
|
||||||
final super.message,
|
super.message,
|
||||||
this.job,
|
this.job,
|
||||||
});
|
});
|
||||||
final ServerJob? job;
|
final ServerJob? job;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ApiResponse<D> {
|
||||||
|
ApiResponse({
|
||||||
|
required this.statusCode,
|
||||||
|
required this.data,
|
||||||
|
this.errorMessage,
|
||||||
|
});
|
||||||
|
final int statusCode;
|
||||||
|
final String? errorMessage;
|
||||||
|
final D data;
|
||||||
|
|
||||||
|
bool get isSuccess => statusCode >= 200 && statusCode < 300;
|
||||||
|
}
|
||||||
|
|
||||||
class ServerApi extends ApiMap
|
class ServerApi extends ApiMap
|
||||||
with VolumeApi, JobsApi, ServerActionsApi, ServicesApi, UsersApi {
|
with VolumeApi, JobsApi, ServerActionsApi, ServicesApi, UsersApi {
|
||||||
ServerApi({
|
ServerApi({
|
||||||
this.hasLogger = false,
|
this.hasLogger = false,
|
||||||
this.isWithToken = true,
|
this.isWithToken = true,
|
||||||
this.customToken = '',
|
this.customToken = '',
|
||||||
|
this.overrideDomain,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -58,7 +76,9 @@ class ServerApi extends ApiMap
|
||||||
@override
|
@override
|
||||||
String customToken;
|
String customToken;
|
||||||
@override
|
@override
|
||||||
String? get rootAddress => getIt<ApiConfigModel>().serverDomain?.domainName;
|
String? get rootAddress =>
|
||||||
|
overrideDomain ?? getIt<ApiConfigModel>().serverDomain?.domainName;
|
||||||
|
String? overrideDomain;
|
||||||
|
|
||||||
Future<String?> getApiVersion() async {
|
Future<String?> getApiVersion() async {
|
||||||
QueryResult response;
|
QueryResult response;
|
||||||
|
@ -193,4 +213,43 @@ class ServerApi extends ApiMap
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<ApiResponse<RecoveryKeyStatus?>> getRecoveryTokenStatus() async {}
|
||||||
|
|
||||||
|
Future<ApiResponse<String>> generateRecoveryToken(
|
||||||
|
final DateTime? expirationDate,
|
||||||
|
final int? numberOfUses,
|
||||||
|
) async {}
|
||||||
|
|
||||||
|
Future<String?> getDkim() async {}
|
||||||
|
|
||||||
|
Future<ApiResponse<List<ApiToken>>> getApiTokens() async {}
|
||||||
|
|
||||||
|
Future<ApiResponse<void>> deleteApiToken(final String name) async {}
|
||||||
|
|
||||||
|
Future<ApiResponse<String>> createDeviceToken() async {}
|
||||||
|
|
||||||
|
Future<BackupStatus> getBackupStatus() async {}
|
||||||
|
|
||||||
|
Future<List<Backup>> getBackups() async {}
|
||||||
|
|
||||||
|
Future<void> uploadBackblazeConfig(final BackblazeBucket bucket) async {}
|
||||||
|
|
||||||
|
Future<void> forceBackupListReload() async {}
|
||||||
|
|
||||||
|
Future<void> startBackup() async {}
|
||||||
|
|
||||||
|
Future<void> restoreBackup(final String backupId) async {}
|
||||||
|
|
||||||
|
Future<bool> isHttpServerWorking() async {}
|
||||||
|
|
||||||
|
Future<ApiResponse<String>> authorizeDevice(final DeviceToken token) async {}
|
||||||
|
|
||||||
|
Future<ApiResponse<String>> useRecoveryToken(final DeviceToken token) async {}
|
||||||
|
|
||||||
|
Future<Map<String, bool>> servicesPowerCheck() async {}
|
||||||
|
|
||||||
|
Future<ApiResponse<List<String>>> getUsersList({
|
||||||
|
required final bool withMainUser,
|
||||||
|
}) async {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import 'dart:async';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:selfprivacy/config/get_it_config.dart';
|
import 'package:selfprivacy/config/get_it_config.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/backblaze.dart';
|
import 'package:selfprivacy/logic/api_maps/rest_maps/backblaze.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/server.dart';
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/models/hive/backblaze_bucket.dart';
|
import 'package:selfprivacy/logic/models/hive/backblaze_bucket.dart';
|
||||||
import 'package:selfprivacy/logic/models/json/backup.dart';
|
import 'package:selfprivacy/logic/models/json/backup.dart';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import 'package:selfprivacy/config/get_it_config.dart';
|
import 'package:selfprivacy/config/get_it_config.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/server.dart';
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server.dart';
|
||||||
import 'package:selfprivacy/logic/common_enum/common_enum.dart';
|
import 'package:selfprivacy/logic/common_enum/common_enum.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/models/json/api_token.dart';
|
import 'package:selfprivacy/logic/models/json/api_token.dart';
|
||||||
|
|
|
@ -6,7 +6,7 @@ import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_depe
|
||||||
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
import 'package:selfprivacy/logic/models/hive/server_domain.dart';
|
||||||
import 'package:selfprivacy/logic/models/json/dns_records.dart';
|
import 'package:selfprivacy/logic/models/json/dns_records.dart';
|
||||||
|
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/server.dart';
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server.dart';
|
||||||
|
|
||||||
part 'dns_records_state.dart';
|
part 'dns_records_state.dart';
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import 'dart:async';
|
||||||
|
|
||||||
import 'package:cubit_form/cubit_form.dart';
|
import 'package:cubit_form/cubit_form.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/server.dart';
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/forms/factories/field_cubit_factory.dart';
|
import 'package:selfprivacy/logic/cubit/forms/factories/field_cubit_factory.dart';
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/server.dart';
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server.dart';
|
||||||
import 'package:selfprivacy/logic/common_enum/common_enum.dart';
|
import 'package:selfprivacy/logic/common_enum/common_enum.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart';
|
||||||
import 'package:selfprivacy/logic/models/json/recovery_token_status.dart';
|
import 'package:selfprivacy/logic/models/json/recovery_token_status.dart';
|
||||||
|
|
|
@ -12,7 +12,7 @@ import 'package:selfprivacy/config/hive_config.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/api_factory_creator.dart';
|
import 'package:selfprivacy/logic/api_maps/rest_maps/api_factory_creator.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/dns_provider.dart';
|
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/dns_provider.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/dns_provider_factory.dart';
|
import 'package:selfprivacy/logic/api_maps/rest_maps/dns_providers/dns_provider_factory.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/server.dart';
|
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/server_provider.dart';
|
import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/server_provider.dart';
|
||||||
import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/server_provider_factory.dart';
|
import 'package:selfprivacy/logic/api_maps/rest_maps/server_providers/server_provider_factory.dart';
|
||||||
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
||||||
|
|
Loading…
Reference in a new issue