From 7ead9a29ea9ec615cee6577f7b2de7f084e79c65 Mon Sep 17 00:00:00 2001 From: NaiJi Date: Mon, 25 Jul 2022 17:06:55 +0300 Subject: [PATCH] Implement basic graphql api map structure --- assets/translations/en.json | 3 +- assets/translations/ru.json | 3 +- build.yaml | 2 +- lib/logic/api_maps/graphql_maps/api_map.dart | 25 + .../schema/get_api_tokens.graphql.dart | 474 ++++++++++++++++++ .../schema/get_api_tokens.graphql.g.dart | 23 + .../schema/get_api_version.graphql.dart | 301 +++++++++++ .../schema/get_api_version.graphql.g.dart | 14 + .../graphql_maps/schema/schema.graphql.dart | 274 ++++++++++ .../graphql_maps/schema/schema.graphql.g.dart | 21 + .../api_maps/graphql_maps/schema/server.dart | 39 ++ lib/logic/api_maps/rest_maps/server.dart | 5 +- lib/logic/models/json/api_token.g.dart | 6 + lib/logic/models/json/backup.g.dart | 12 + lib/logic/models/json/device_token.g.dart | 6 + .../models/json/hetzner_server_info.g.dart | 49 ++ .../models/json/recovery_token_status.g.dart | 9 + lib/ui/pages/more/info/info.dart | 25 +- pubspec.lock | 82 +-- pubspec.yaml | 18 +- .../flutter/generated_plugin_registrant.cc | 3 + windows/flutter/generated_plugins.cmake | 1 + 22 files changed, 1321 insertions(+), 74 deletions(-) create mode 100644 lib/logic/api_maps/graphql_maps/api_map.dart create mode 100644 lib/logic/api_maps/graphql_maps/schema/get_api_tokens.graphql.dart create mode 100644 lib/logic/api_maps/graphql_maps/schema/get_api_version.graphql.dart create mode 100644 lib/logic/api_maps/graphql_maps/schema/schema.graphql.dart create mode 100644 lib/logic/api_maps/graphql_maps/schema/server.dart diff --git a/assets/translations/en.json b/assets/translations/en.json index c0e95639..4fdb0626 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -52,7 +52,8 @@ "copied_ssh": "SSH copied to clipboard", "delete_ssh_text": "Delete SSH key?", "about_app_page": { - "text": "Application version v.{}" + "application_version_text": "Application version v.{}", + "api_version_text": "Server API version v.{}" }, "settings": { "title": "Application settings", diff --git a/assets/translations/ru.json b/assets/translations/ru.json index e2048024..a93e122a 100644 --- a/assets/translations/ru.json +++ b/assets/translations/ru.json @@ -52,7 +52,8 @@ "copied_ssh": "SSH ключ cкопирован в буфер", "delete_ssh_text": "Удалить SSH ключ?", "about_app_page": { - "text": "Версия приложения: v.{}" + "application_version_text": "Версия приложения v.{}", + "api_version_text": "Версия API сервера v.{}" }, "settings": { "title": "Настройки приложения", diff --git a/build.yaml b/build.yaml index 2fb31704..993e8dd4 100644 --- a/build.yaml +++ b/build.yaml @@ -14,4 +14,4 @@ targets: json_serializable: options: create_factory: true - create_to_json: false + create_to_json: true diff --git a/lib/logic/api_maps/graphql_maps/api_map.dart b/lib/logic/api_maps/graphql_maps/api_map.dart new file mode 100644 index 00000000..90d6a349 --- /dev/null +++ b/lib/logic/api_maps/graphql_maps/api_map.dart @@ -0,0 +1,25 @@ +import 'package:graphql_flutter/graphql_flutter.dart'; + +abstract class ApiMap { + Future getClient() async { + final httpLink = HttpLink( + 'https://api.$rootAddress/graphql', + ); + + final Link graphQLLink = isWithToken + ? AuthLink( + getToken: () async => authToken, + ).concat(httpLink) + : httpLink; + + return GraphQLClient( + cache: GraphQLCache(), + link: graphQLLink, + ); + } + + abstract final String? rootAddress; + abstract final bool hasLogger; + abstract final bool isWithToken; + abstract final String authToken; +} diff --git a/lib/logic/api_maps/graphql_maps/schema/get_api_tokens.graphql.dart b/lib/logic/api_maps/graphql_maps/schema/get_api_tokens.graphql.dart new file mode 100644 index 00000000..763ffcc4 --- /dev/null +++ b/lib/logic/api_maps/graphql_maps/schema/get_api_tokens.graphql.dart @@ -0,0 +1,474 @@ +import 'package:gql/ast.dart'; +import 'package:graphql/client.dart' as graphql; +import 'package:json_annotation/json_annotation.dart'; +import 'package:selfprivacy/utils/scalars.dart'; +part 'get_api_tokens.graphql.g.dart'; + +@JsonSerializable(explicitToJson: true) +class Query$GetApiTokensQuery { + Query$GetApiTokensQuery({required this.api, required this.$__typename}); + + @override + factory Query$GetApiTokensQuery.fromJson(Map json) => + _$Query$GetApiTokensQueryFromJson(json); + + final Query$GetApiTokensQuery$api api; + + @JsonKey(name: '__typename') + final String $__typename; + + Map toJson() => _$Query$GetApiTokensQueryToJson(this); + int get hashCode { + final l$api = api; + final l$$__typename = $__typename; + return Object.hashAll([l$api, l$$__typename]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (!(other is Query$GetApiTokensQuery) || runtimeType != other.runtimeType) + return false; + final l$api = api; + final lOther$api = other.api; + if (l$api != lOther$api) return false; + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) return false; + return true; + } +} + +extension UtilityExtension$Query$GetApiTokensQuery on Query$GetApiTokensQuery { + CopyWith$Query$GetApiTokensQuery get copyWith => + CopyWith$Query$GetApiTokensQuery(this, (i) => i); +} + +abstract class CopyWith$Query$GetApiTokensQuery { + factory CopyWith$Query$GetApiTokensQuery(Query$GetApiTokensQuery instance, + TRes Function(Query$GetApiTokensQuery) then) = + _CopyWithImpl$Query$GetApiTokensQuery; + + factory CopyWith$Query$GetApiTokensQuery.stub(TRes res) = + _CopyWithStubImpl$Query$GetApiTokensQuery; + + TRes call({Query$GetApiTokensQuery$api? api, String? $__typename}); + CopyWith$Query$GetApiTokensQuery$api get api; +} + +class _CopyWithImpl$Query$GetApiTokensQuery + implements CopyWith$Query$GetApiTokensQuery { + _CopyWithImpl$Query$GetApiTokensQuery(this._instance, this._then); + + final Query$GetApiTokensQuery _instance; + + final TRes Function(Query$GetApiTokensQuery) _then; + + static const _undefined = {}; + + TRes call({Object? api = _undefined, Object? $__typename = _undefined}) => + _then(Query$GetApiTokensQuery( + api: api == _undefined || api == null + ? _instance.api + : (api as Query$GetApiTokensQuery$api), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String))); + CopyWith$Query$GetApiTokensQuery$api get api { + final local$api = _instance.api; + return CopyWith$Query$GetApiTokensQuery$api(local$api, (e) => call(api: e)); + } +} + +class _CopyWithStubImpl$Query$GetApiTokensQuery + implements CopyWith$Query$GetApiTokensQuery { + _CopyWithStubImpl$Query$GetApiTokensQuery(this._res); + + TRes _res; + + call({Query$GetApiTokensQuery$api? api, String? $__typename}) => _res; + CopyWith$Query$GetApiTokensQuery$api get api => + CopyWith$Query$GetApiTokensQuery$api.stub(_res); +} + +const documentNodeQueryGetApiTokensQuery = DocumentNode(definitions: [ + OperationDefinitionNode( + type: OperationType.query, + name: NameNode(value: 'GetApiTokensQuery'), + variableDefinitions: [], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'api'), + alias: null, + arguments: [], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'devices'), + alias: null, + arguments: [], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'creationDate'), + alias: null, + arguments: [], + directives: [], + selectionSet: null), + FieldNode( + name: NameNode(value: 'isCaller'), + alias: null, + arguments: [], + directives: [], + selectionSet: null), + FieldNode( + name: NameNode(value: 'name'), + alias: null, + arguments: [], + directives: [], + selectionSet: null), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null) + ])), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null) + ])), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null) + ])), +]); +Query$GetApiTokensQuery _parserFn$Query$GetApiTokensQuery( + Map data) => + Query$GetApiTokensQuery.fromJson(data); + +class Options$Query$GetApiTokensQuery + extends graphql.QueryOptions { + Options$Query$GetApiTokensQuery( + {String? operationName, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + Duration? pollInterval, + graphql.Context? context}) + : super( + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult, + pollInterval: pollInterval, + context: context, + document: documentNodeQueryGetApiTokensQuery, + parserFn: _parserFn$Query$GetApiTokensQuery); +} + +class WatchOptions$Query$GetApiTokensQuery + extends graphql.WatchQueryOptions { + WatchOptions$Query$GetApiTokensQuery( + {String? operationName, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + graphql.Context? context, + Duration? pollInterval, + bool? eagerlyFetchResults, + bool carryForwardDataOnException = true, + bool fetchResults = false}) + : super( + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult, + context: context, + document: documentNodeQueryGetApiTokensQuery, + pollInterval: pollInterval, + eagerlyFetchResults: eagerlyFetchResults, + carryForwardDataOnException: carryForwardDataOnException, + fetchResults: fetchResults, + parserFn: _parserFn$Query$GetApiTokensQuery); +} + +class FetchMoreOptions$Query$GetApiTokensQuery + extends graphql.FetchMoreOptions { + FetchMoreOptions$Query$GetApiTokensQuery( + {required graphql.UpdateQuery updateQuery}) + : super( + updateQuery: updateQuery, + document: documentNodeQueryGetApiTokensQuery); +} + +extension ClientExtension$Query$GetApiTokensQuery on graphql.GraphQLClient { + Future> query$GetApiTokensQuery( + [Options$Query$GetApiTokensQuery? options]) async => + await this.query(options ?? Options$Query$GetApiTokensQuery()); + graphql.ObservableQuery watchQuery$GetApiTokensQuery( + [WatchOptions$Query$GetApiTokensQuery? options]) => + this.watchQuery(options ?? WatchOptions$Query$GetApiTokensQuery()); + void writeQuery$GetApiTokensQuery( + {required Query$GetApiTokensQuery data, bool broadcast = true}) => + this.writeQuery( + graphql.Request( + operation: graphql.Operation( + document: documentNodeQueryGetApiTokensQuery)), + data: data.toJson(), + broadcast: broadcast); + Query$GetApiTokensQuery? readQuery$GetApiTokensQuery( + {bool optimistic = true}) { + final result = this.readQuery( + graphql.Request( + operation: graphql.Operation( + document: documentNodeQueryGetApiTokensQuery)), + optimistic: optimistic); + return result == null ? null : Query$GetApiTokensQuery.fromJson(result); + } +} + +@JsonSerializable(explicitToJson: true) +class Query$GetApiTokensQuery$api { + Query$GetApiTokensQuery$api( + {required this.devices, required this.$__typename}); + + @override + factory Query$GetApiTokensQuery$api.fromJson(Map json) => + _$Query$GetApiTokensQuery$apiFromJson(json); + + final List devices; + + @JsonKey(name: '__typename') + final String $__typename; + + Map toJson() => _$Query$GetApiTokensQuery$apiToJson(this); + int get hashCode { + final l$devices = devices; + final l$$__typename = $__typename; + return Object.hashAll( + [Object.hashAll(l$devices.map((v) => v)), l$$__typename]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (!(other is Query$GetApiTokensQuery$api) || + runtimeType != other.runtimeType) return false; + final l$devices = devices; + final lOther$devices = other.devices; + if (l$devices.length != lOther$devices.length) return false; + for (int i = 0; i < l$devices.length; i++) { + final l$devices$entry = l$devices[i]; + final lOther$devices$entry = lOther$devices[i]; + if (l$devices$entry != lOther$devices$entry) return false; + } + + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) return false; + return true; + } +} + +extension UtilityExtension$Query$GetApiTokensQuery$api + on Query$GetApiTokensQuery$api { + CopyWith$Query$GetApiTokensQuery$api + get copyWith => CopyWith$Query$GetApiTokensQuery$api(this, (i) => i); +} + +abstract class CopyWith$Query$GetApiTokensQuery$api { + factory CopyWith$Query$GetApiTokensQuery$api( + Query$GetApiTokensQuery$api instance, + TRes Function(Query$GetApiTokensQuery$api) then) = + _CopyWithImpl$Query$GetApiTokensQuery$api; + + factory CopyWith$Query$GetApiTokensQuery$api.stub(TRes res) = + _CopyWithStubImpl$Query$GetApiTokensQuery$api; + + TRes call( + {List? devices, + String? $__typename}); + TRes devices( + Iterable Function( + Iterable< + CopyWith$Query$GetApiTokensQuery$api$devices< + Query$GetApiTokensQuery$api$devices>>) + _fn); +} + +class _CopyWithImpl$Query$GetApiTokensQuery$api + implements CopyWith$Query$GetApiTokensQuery$api { + _CopyWithImpl$Query$GetApiTokensQuery$api(this._instance, this._then); + + final Query$GetApiTokensQuery$api _instance; + + final TRes Function(Query$GetApiTokensQuery$api) _then; + + static const _undefined = {}; + + TRes call({Object? devices = _undefined, Object? $__typename = _undefined}) => + _then(Query$GetApiTokensQuery$api( + devices: devices == _undefined || devices == null + ? _instance.devices + : (devices as List), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String))); + TRes devices( + Iterable Function( + Iterable< + CopyWith$Query$GetApiTokensQuery$api$devices< + Query$GetApiTokensQuery$api$devices>>) + _fn) => + call( + devices: _fn(_instance.devices.map((e) => + CopyWith$Query$GetApiTokensQuery$api$devices(e, (i) => i))) + .toList()); +} + +class _CopyWithStubImpl$Query$GetApiTokensQuery$api + implements CopyWith$Query$GetApiTokensQuery$api { + _CopyWithStubImpl$Query$GetApiTokensQuery$api(this._res); + + TRes _res; + + call( + {List? devices, + String? $__typename}) => + _res; + devices(_fn) => _res; +} + +@JsonSerializable(explicitToJson: true) +class Query$GetApiTokensQuery$api$devices { + Query$GetApiTokensQuery$api$devices( + {required this.creationDate, + required this.isCaller, + required this.name, + required this.$__typename}); + + @override + factory Query$GetApiTokensQuery$api$devices.fromJson( + Map json) => + _$Query$GetApiTokensQuery$api$devicesFromJson(json); + + @JsonKey(fromJson: dateTimeFromJson, toJson: dateTimeToJson) + final DateTime creationDate; + + final bool isCaller; + + final String name; + + @JsonKey(name: '__typename') + final String $__typename; + + Map toJson() => + _$Query$GetApiTokensQuery$api$devicesToJson(this); + int get hashCode { + final l$creationDate = creationDate; + final l$isCaller = isCaller; + final l$name = name; + final l$$__typename = $__typename; + return Object.hashAll([l$creationDate, l$isCaller, l$name, l$$__typename]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (!(other is Query$GetApiTokensQuery$api$devices) || + runtimeType != other.runtimeType) return false; + final l$creationDate = creationDate; + final lOther$creationDate = other.creationDate; + if (l$creationDate != lOther$creationDate) return false; + final l$isCaller = isCaller; + final lOther$isCaller = other.isCaller; + if (l$isCaller != lOther$isCaller) return false; + final l$name = name; + final lOther$name = other.name; + if (l$name != lOther$name) return false; + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) return false; + return true; + } +} + +extension UtilityExtension$Query$GetApiTokensQuery$api$devices + on Query$GetApiTokensQuery$api$devices { + CopyWith$Query$GetApiTokensQuery$api$devices< + Query$GetApiTokensQuery$api$devices> + get copyWith => + CopyWith$Query$GetApiTokensQuery$api$devices(this, (i) => i); +} + +abstract class CopyWith$Query$GetApiTokensQuery$api$devices { + factory CopyWith$Query$GetApiTokensQuery$api$devices( + Query$GetApiTokensQuery$api$devices instance, + TRes Function(Query$GetApiTokensQuery$api$devices) then) = + _CopyWithImpl$Query$GetApiTokensQuery$api$devices; + + factory CopyWith$Query$GetApiTokensQuery$api$devices.stub(TRes res) = + _CopyWithStubImpl$Query$GetApiTokensQuery$api$devices; + + TRes call( + {DateTime? creationDate, + bool? isCaller, + String? name, + String? $__typename}); +} + +class _CopyWithImpl$Query$GetApiTokensQuery$api$devices + implements CopyWith$Query$GetApiTokensQuery$api$devices { + _CopyWithImpl$Query$GetApiTokensQuery$api$devices(this._instance, this._then); + + final Query$GetApiTokensQuery$api$devices _instance; + + final TRes Function(Query$GetApiTokensQuery$api$devices) _then; + + static const _undefined = {}; + + TRes call( + {Object? creationDate = _undefined, + Object? isCaller = _undefined, + Object? name = _undefined, + Object? $__typename = _undefined}) => + _then(Query$GetApiTokensQuery$api$devices( + creationDate: creationDate == _undefined || creationDate == null + ? _instance.creationDate + : (creationDate as DateTime), + isCaller: isCaller == _undefined || isCaller == null + ? _instance.isCaller + : (isCaller as bool), + name: name == _undefined || name == null + ? _instance.name + : (name as String), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String))); +} + +class _CopyWithStubImpl$Query$GetApiTokensQuery$api$devices + implements CopyWith$Query$GetApiTokensQuery$api$devices { + _CopyWithStubImpl$Query$GetApiTokensQuery$api$devices(this._res); + + TRes _res; + + call( + {DateTime? creationDate, + bool? isCaller, + String? name, + String? $__typename}) => + _res; +} diff --git a/lib/logic/api_maps/graphql_maps/schema/get_api_tokens.graphql.g.dart b/lib/logic/api_maps/graphql_maps/schema/get_api_tokens.graphql.g.dart index 508d8010..bb5e5bae 100644 --- a/lib/logic/api_maps/graphql_maps/schema/get_api_tokens.graphql.g.dart +++ b/lib/logic/api_maps/graphql_maps/schema/get_api_tokens.graphql.g.dart @@ -14,6 +14,13 @@ Query$GetApiTokensQuery _$Query$GetApiTokensQueryFromJson( $__typename: json['__typename'] as String, ); +Map _$Query$GetApiTokensQueryToJson( + Query$GetApiTokensQuery instance) => + { + 'api': instance.api.toJson(), + '__typename': instance.$__typename, + }; + Query$GetApiTokensQuery$api _$Query$GetApiTokensQuery$apiFromJson( Map json) => Query$GetApiTokensQuery$api( @@ -24,6 +31,13 @@ Query$GetApiTokensQuery$api _$Query$GetApiTokensQuery$apiFromJson( $__typename: json['__typename'] as String, ); +Map _$Query$GetApiTokensQuery$apiToJson( + Query$GetApiTokensQuery$api instance) => + { + 'devices': instance.devices.map((e) => e.toJson()).toList(), + '__typename': instance.$__typename, + }; + Query$GetApiTokensQuery$api$devices _$Query$GetApiTokensQuery$api$devicesFromJson(Map json) => Query$GetApiTokensQuery$api$devices( @@ -32,3 +46,12 @@ Query$GetApiTokensQuery$api$devices name: json['name'] as String, $__typename: json['__typename'] as String, ); + +Map _$Query$GetApiTokensQuery$api$devicesToJson( + Query$GetApiTokensQuery$api$devices instance) => + { + 'creationDate': dateTimeToJson(instance.creationDate), + 'isCaller': instance.isCaller, + 'name': instance.name, + '__typename': instance.$__typename, + }; diff --git a/lib/logic/api_maps/graphql_maps/schema/get_api_version.graphql.dart b/lib/logic/api_maps/graphql_maps/schema/get_api_version.graphql.dart new file mode 100644 index 00000000..8d255fe6 --- /dev/null +++ b/lib/logic/api_maps/graphql_maps/schema/get_api_version.graphql.dart @@ -0,0 +1,301 @@ +import 'package:gql/ast.dart'; +import 'package:graphql/client.dart' as graphql; +import 'package:json_annotation/json_annotation.dart'; +part 'get_api_version.graphql.g.dart'; + +@JsonSerializable(explicitToJson: true) +class Query$GetApiVersionQuery { + Query$GetApiVersionQuery({required this.api, required this.$__typename}); + + @override + factory Query$GetApiVersionQuery.fromJson(Map json) => + _$Query$GetApiVersionQueryFromJson(json); + + final Query$GetApiVersionQuery$api api; + + @JsonKey(name: '__typename') + final String $__typename; + + Map toJson() => _$Query$GetApiVersionQueryToJson(this); + int get hashCode { + final l$api = api; + final l$$__typename = $__typename; + return Object.hashAll([l$api, l$$__typename]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (!(other is Query$GetApiVersionQuery) || + runtimeType != other.runtimeType) return false; + final l$api = api; + final lOther$api = other.api; + if (l$api != lOther$api) return false; + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) return false; + return true; + } +} + +extension UtilityExtension$Query$GetApiVersionQuery + on Query$GetApiVersionQuery { + CopyWith$Query$GetApiVersionQuery get copyWith => + CopyWith$Query$GetApiVersionQuery(this, (i) => i); +} + +abstract class CopyWith$Query$GetApiVersionQuery { + factory CopyWith$Query$GetApiVersionQuery(Query$GetApiVersionQuery instance, + TRes Function(Query$GetApiVersionQuery) then) = + _CopyWithImpl$Query$GetApiVersionQuery; + + factory CopyWith$Query$GetApiVersionQuery.stub(TRes res) = + _CopyWithStubImpl$Query$GetApiVersionQuery; + + TRes call({Query$GetApiVersionQuery$api? api, String? $__typename}); + CopyWith$Query$GetApiVersionQuery$api get api; +} + +class _CopyWithImpl$Query$GetApiVersionQuery + implements CopyWith$Query$GetApiVersionQuery { + _CopyWithImpl$Query$GetApiVersionQuery(this._instance, this._then); + + final Query$GetApiVersionQuery _instance; + + final TRes Function(Query$GetApiVersionQuery) _then; + + static const _undefined = {}; + + TRes call({Object? api = _undefined, Object? $__typename = _undefined}) => + _then(Query$GetApiVersionQuery( + api: api == _undefined || api == null + ? _instance.api + : (api as Query$GetApiVersionQuery$api), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String))); + CopyWith$Query$GetApiVersionQuery$api get api { + final local$api = _instance.api; + return CopyWith$Query$GetApiVersionQuery$api( + local$api, (e) => call(api: e)); + } +} + +class _CopyWithStubImpl$Query$GetApiVersionQuery + implements CopyWith$Query$GetApiVersionQuery { + _CopyWithStubImpl$Query$GetApiVersionQuery(this._res); + + TRes _res; + + call({Query$GetApiVersionQuery$api? api, String? $__typename}) => _res; + CopyWith$Query$GetApiVersionQuery$api get api => + CopyWith$Query$GetApiVersionQuery$api.stub(_res); +} + +const documentNodeQueryGetApiVersionQuery = DocumentNode(definitions: [ + OperationDefinitionNode( + type: OperationType.query, + name: NameNode(value: 'GetApiVersionQuery'), + variableDefinitions: [], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'api'), + alias: null, + arguments: [], + directives: [], + selectionSet: SelectionSetNode(selections: [ + FieldNode( + name: NameNode(value: 'version'), + alias: null, + arguments: [], + directives: [], + selectionSet: null), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null) + ])), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null) + ])), +]); +Query$GetApiVersionQuery _parserFn$Query$GetApiVersionQuery( + Map data) => + Query$GetApiVersionQuery.fromJson(data); + +class Options$Query$GetApiVersionQuery + extends graphql.QueryOptions { + Options$Query$GetApiVersionQuery( + {String? operationName, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + Duration? pollInterval, + graphql.Context? context}) + : super( + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult, + pollInterval: pollInterval, + context: context, + document: documentNodeQueryGetApiVersionQuery, + parserFn: _parserFn$Query$GetApiVersionQuery); +} + +class WatchOptions$Query$GetApiVersionQuery + extends graphql.WatchQueryOptions { + WatchOptions$Query$GetApiVersionQuery( + {String? operationName, + graphql.FetchPolicy? fetchPolicy, + graphql.ErrorPolicy? errorPolicy, + graphql.CacheRereadPolicy? cacheRereadPolicy, + Object? optimisticResult, + graphql.Context? context, + Duration? pollInterval, + bool? eagerlyFetchResults, + bool carryForwardDataOnException = true, + bool fetchResults = false}) + : super( + operationName: operationName, + fetchPolicy: fetchPolicy, + errorPolicy: errorPolicy, + cacheRereadPolicy: cacheRereadPolicy, + optimisticResult: optimisticResult, + context: context, + document: documentNodeQueryGetApiVersionQuery, + pollInterval: pollInterval, + eagerlyFetchResults: eagerlyFetchResults, + carryForwardDataOnException: carryForwardDataOnException, + fetchResults: fetchResults, + parserFn: _parserFn$Query$GetApiVersionQuery); +} + +class FetchMoreOptions$Query$GetApiVersionQuery + extends graphql.FetchMoreOptions { + FetchMoreOptions$Query$GetApiVersionQuery( + {required graphql.UpdateQuery updateQuery}) + : super( + updateQuery: updateQuery, + document: documentNodeQueryGetApiVersionQuery); +} + +extension ClientExtension$Query$GetApiVersionQuery on graphql.GraphQLClient { + Future> + query$GetApiVersionQuery( + [Options$Query$GetApiVersionQuery? options]) async => + await this.query(options ?? Options$Query$GetApiVersionQuery()); + graphql.ObservableQuery + watchQuery$GetApiVersionQuery( + [WatchOptions$Query$GetApiVersionQuery? options]) => + this.watchQuery(options ?? WatchOptions$Query$GetApiVersionQuery()); + void writeQuery$GetApiVersionQuery( + {required Query$GetApiVersionQuery data, bool broadcast = true}) => + this.writeQuery( + graphql.Request( + operation: graphql.Operation( + document: documentNodeQueryGetApiVersionQuery)), + data: data.toJson(), + broadcast: broadcast); + Query$GetApiVersionQuery? readQuery$GetApiVersionQuery( + {bool optimistic = true}) { + final result = this.readQuery( + graphql.Request( + operation: graphql.Operation( + document: documentNodeQueryGetApiVersionQuery)), + optimistic: optimistic); + return result == null ? null : Query$GetApiVersionQuery.fromJson(result); + } +} + +@JsonSerializable(explicitToJson: true) +class Query$GetApiVersionQuery$api { + Query$GetApiVersionQuery$api( + {required this.version, required this.$__typename}); + + @override + factory Query$GetApiVersionQuery$api.fromJson(Map json) => + _$Query$GetApiVersionQuery$apiFromJson(json); + + final String version; + + @JsonKey(name: '__typename') + final String $__typename; + + Map toJson() => _$Query$GetApiVersionQuery$apiToJson(this); + int get hashCode { + final l$version = version; + final l$$__typename = $__typename; + return Object.hashAll([l$version, l$$__typename]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (!(other is Query$GetApiVersionQuery$api) || + runtimeType != other.runtimeType) return false; + final l$version = version; + final lOther$version = other.version; + if (l$version != lOther$version) return false; + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) return false; + return true; + } +} + +extension UtilityExtension$Query$GetApiVersionQuery$api + on Query$GetApiVersionQuery$api { + CopyWith$Query$GetApiVersionQuery$api + get copyWith => CopyWith$Query$GetApiVersionQuery$api(this, (i) => i); +} + +abstract class CopyWith$Query$GetApiVersionQuery$api { + factory CopyWith$Query$GetApiVersionQuery$api( + Query$GetApiVersionQuery$api instance, + TRes Function(Query$GetApiVersionQuery$api) then) = + _CopyWithImpl$Query$GetApiVersionQuery$api; + + factory CopyWith$Query$GetApiVersionQuery$api.stub(TRes res) = + _CopyWithStubImpl$Query$GetApiVersionQuery$api; + + TRes call({String? version, String? $__typename}); +} + +class _CopyWithImpl$Query$GetApiVersionQuery$api + implements CopyWith$Query$GetApiVersionQuery$api { + _CopyWithImpl$Query$GetApiVersionQuery$api(this._instance, this._then); + + final Query$GetApiVersionQuery$api _instance; + + final TRes Function(Query$GetApiVersionQuery$api) _then; + + static const _undefined = {}; + + TRes call({Object? version = _undefined, Object? $__typename = _undefined}) => + _then(Query$GetApiVersionQuery$api( + version: version == _undefined || version == null + ? _instance.version + : (version as String), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String))); +} + +class _CopyWithStubImpl$Query$GetApiVersionQuery$api + implements CopyWith$Query$GetApiVersionQuery$api { + _CopyWithStubImpl$Query$GetApiVersionQuery$api(this._res); + + TRes _res; + + call({String? version, String? $__typename}) => _res; +} diff --git a/lib/logic/api_maps/graphql_maps/schema/get_api_version.graphql.g.dart b/lib/logic/api_maps/graphql_maps/schema/get_api_version.graphql.g.dart index c0b5a378..0c051786 100644 --- a/lib/logic/api_maps/graphql_maps/schema/get_api_version.graphql.g.dart +++ b/lib/logic/api_maps/graphql_maps/schema/get_api_version.graphql.g.dart @@ -14,9 +14,23 @@ Query$GetApiVersionQuery _$Query$GetApiVersionQueryFromJson( $__typename: json['__typename'] as String, ); +Map _$Query$GetApiVersionQueryToJson( + Query$GetApiVersionQuery instance) => + { + 'api': instance.api.toJson(), + '__typename': instance.$__typename, + }; + Query$GetApiVersionQuery$api _$Query$GetApiVersionQuery$apiFromJson( Map json) => Query$GetApiVersionQuery$api( version: json['version'] as String, $__typename: json['__typename'] as String, ); + +Map _$Query$GetApiVersionQuery$apiToJson( + Query$GetApiVersionQuery$api instance) => + { + 'version': instance.version, + '__typename': instance.$__typename, + }; diff --git a/lib/logic/api_maps/graphql_maps/schema/schema.graphql.dart b/lib/logic/api_maps/graphql_maps/schema/schema.graphql.dart new file mode 100644 index 00000000..27f902e2 --- /dev/null +++ b/lib/logic/api_maps/graphql_maps/schema/schema.graphql.dart @@ -0,0 +1,274 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:selfprivacy/utils/scalars.dart'; +part 'schema.graphql.g.dart'; + +@JsonSerializable(explicitToJson: true) +class Input$RecoveryKeyLimitsInput { + Input$RecoveryKeyLimitsInput({this.expirationDate, this.uses}); + + @override + factory Input$RecoveryKeyLimitsInput.fromJson(Map json) => + _$Input$RecoveryKeyLimitsInputFromJson(json); + + @JsonKey( + fromJson: _nullable$dateTimeFromJson, toJson: _nullable$dateTimeToJson) + final DateTime? expirationDate; + + final int? uses; + + Map toJson() => _$Input$RecoveryKeyLimitsInputToJson(this); + int get hashCode { + final l$expirationDate = expirationDate; + final l$uses = uses; + return Object.hashAll([l$expirationDate, l$uses]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (!(other is Input$RecoveryKeyLimitsInput) || + runtimeType != other.runtimeType) return false; + final l$expirationDate = expirationDate; + final lOther$expirationDate = other.expirationDate; + if (l$expirationDate != lOther$expirationDate) return false; + final l$uses = uses; + final lOther$uses = other.uses; + if (l$uses != lOther$uses) return false; + return true; + } + + CopyWith$Input$RecoveryKeyLimitsInput + get copyWith => CopyWith$Input$RecoveryKeyLimitsInput(this, (i) => i); +} + +abstract class CopyWith$Input$RecoveryKeyLimitsInput { + factory CopyWith$Input$RecoveryKeyLimitsInput( + Input$RecoveryKeyLimitsInput instance, + TRes Function(Input$RecoveryKeyLimitsInput) then) = + _CopyWithImpl$Input$RecoveryKeyLimitsInput; + + factory CopyWith$Input$RecoveryKeyLimitsInput.stub(TRes res) = + _CopyWithStubImpl$Input$RecoveryKeyLimitsInput; + + TRes call({DateTime? expirationDate, int? uses}); +} + +class _CopyWithImpl$Input$RecoveryKeyLimitsInput + implements CopyWith$Input$RecoveryKeyLimitsInput { + _CopyWithImpl$Input$RecoveryKeyLimitsInput(this._instance, this._then); + + final Input$RecoveryKeyLimitsInput _instance; + + final TRes Function(Input$RecoveryKeyLimitsInput) _then; + + static const _undefined = {}; + + TRes call({Object? expirationDate = _undefined, Object? uses = _undefined}) => + _then(Input$RecoveryKeyLimitsInput( + expirationDate: expirationDate == _undefined + ? _instance.expirationDate + : (expirationDate as DateTime?), + uses: uses == _undefined ? _instance.uses : (uses as int?))); +} + +class _CopyWithStubImpl$Input$RecoveryKeyLimitsInput + implements CopyWith$Input$RecoveryKeyLimitsInput { + _CopyWithStubImpl$Input$RecoveryKeyLimitsInput(this._res); + + TRes _res; + + call({DateTime? expirationDate, int? uses}) => _res; +} + +@JsonSerializable(explicitToJson: true) +class Input$UseNewDeviceKeyInput { + Input$UseNewDeviceKeyInput({required this.key, required this.deviceName}); + + @override + factory Input$UseNewDeviceKeyInput.fromJson(Map json) => + _$Input$UseNewDeviceKeyInputFromJson(json); + + final String key; + + final String deviceName; + + Map toJson() => _$Input$UseNewDeviceKeyInputToJson(this); + int get hashCode { + final l$key = key; + final l$deviceName = deviceName; + return Object.hashAll([l$key, l$deviceName]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (!(other is Input$UseNewDeviceKeyInput) || + runtimeType != other.runtimeType) return false; + final l$key = key; + final lOther$key = other.key; + if (l$key != lOther$key) return false; + final l$deviceName = deviceName; + final lOther$deviceName = other.deviceName; + if (l$deviceName != lOther$deviceName) return false; + return true; + } + + CopyWith$Input$UseNewDeviceKeyInput + get copyWith => CopyWith$Input$UseNewDeviceKeyInput(this, (i) => i); +} + +abstract class CopyWith$Input$UseNewDeviceKeyInput { + factory CopyWith$Input$UseNewDeviceKeyInput( + Input$UseNewDeviceKeyInput instance, + TRes Function(Input$UseNewDeviceKeyInput) then) = + _CopyWithImpl$Input$UseNewDeviceKeyInput; + + factory CopyWith$Input$UseNewDeviceKeyInput.stub(TRes res) = + _CopyWithStubImpl$Input$UseNewDeviceKeyInput; + + TRes call({String? key, String? deviceName}); +} + +class _CopyWithImpl$Input$UseNewDeviceKeyInput + implements CopyWith$Input$UseNewDeviceKeyInput { + _CopyWithImpl$Input$UseNewDeviceKeyInput(this._instance, this._then); + + final Input$UseNewDeviceKeyInput _instance; + + final TRes Function(Input$UseNewDeviceKeyInput) _then; + + static const _undefined = {}; + + TRes call({Object? key = _undefined, Object? deviceName = _undefined}) => + _then(Input$UseNewDeviceKeyInput( + key: key == _undefined || key == null + ? _instance.key + : (key as String), + deviceName: deviceName == _undefined || deviceName == null + ? _instance.deviceName + : (deviceName as String))); +} + +class _CopyWithStubImpl$Input$UseNewDeviceKeyInput + implements CopyWith$Input$UseNewDeviceKeyInput { + _CopyWithStubImpl$Input$UseNewDeviceKeyInput(this._res); + + TRes _res; + + call({String? key, String? deviceName}) => _res; +} + +@JsonSerializable(explicitToJson: true) +class Input$UseRecoveryKeyInput { + Input$UseRecoveryKeyInput({required this.key, required this.deviceName}); + + @override + factory Input$UseRecoveryKeyInput.fromJson(Map json) => + _$Input$UseRecoveryKeyInputFromJson(json); + + final String key; + + final String deviceName; + + Map toJson() => _$Input$UseRecoveryKeyInputToJson(this); + int get hashCode { + final l$key = key; + final l$deviceName = deviceName; + return Object.hashAll([l$key, l$deviceName]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (!(other is Input$UseRecoveryKeyInput) || + runtimeType != other.runtimeType) return false; + final l$key = key; + final lOther$key = other.key; + if (l$key != lOther$key) return false; + final l$deviceName = deviceName; + final lOther$deviceName = other.deviceName; + if (l$deviceName != lOther$deviceName) return false; + return true; + } + + CopyWith$Input$UseRecoveryKeyInput get copyWith => + CopyWith$Input$UseRecoveryKeyInput(this, (i) => i); +} + +abstract class CopyWith$Input$UseRecoveryKeyInput { + factory CopyWith$Input$UseRecoveryKeyInput(Input$UseRecoveryKeyInput instance, + TRes Function(Input$UseRecoveryKeyInput) then) = + _CopyWithImpl$Input$UseRecoveryKeyInput; + + factory CopyWith$Input$UseRecoveryKeyInput.stub(TRes res) = + _CopyWithStubImpl$Input$UseRecoveryKeyInput; + + TRes call({String? key, String? deviceName}); +} + +class _CopyWithImpl$Input$UseRecoveryKeyInput + implements CopyWith$Input$UseRecoveryKeyInput { + _CopyWithImpl$Input$UseRecoveryKeyInput(this._instance, this._then); + + final Input$UseRecoveryKeyInput _instance; + + final TRes Function(Input$UseRecoveryKeyInput) _then; + + static const _undefined = {}; + + TRes call({Object? key = _undefined, Object? deviceName = _undefined}) => + _then(Input$UseRecoveryKeyInput( + key: key == _undefined || key == null + ? _instance.key + : (key as String), + deviceName: deviceName == _undefined || deviceName == null + ? _instance.deviceName + : (deviceName as String))); +} + +class _CopyWithStubImpl$Input$UseRecoveryKeyInput + implements CopyWith$Input$UseRecoveryKeyInput { + _CopyWithStubImpl$Input$UseRecoveryKeyInput(this._res); + + TRes _res; + + call({String? key, String? deviceName}) => _res; +} + +enum Enum$DnsProvider { + @JsonValue('CLOUDFLARE') + CLOUDFLARE, + $unknown +} + +enum Enum$ServerProvider { + @JsonValue('HETZNER') + HETZNER, + $unknown +} + +enum Enum$Severity { + @JsonValue('INFO') + INFO, + @JsonValue('WARNING') + WARNING, + @JsonValue('ERROR') + ERROR, + @JsonValue('CRITICAL') + CRITICAL, + @JsonValue('SUCCESS') + SUCCESS, + $unknown +} + +const possibleTypesMap = { + 'MutationReturnInterface': { + 'ApiKeyMutationReturn', + 'DeviceApiTokenMutationReturn', + 'GenericMutationReturn' + } +}; +DateTime? _nullable$dateTimeFromJson(dynamic data) => + data == null ? null : dateTimeFromJson(data); +dynamic _nullable$dateTimeToJson(DateTime? data) => + data == null ? null : dateTimeToJson(data); diff --git a/lib/logic/api_maps/graphql_maps/schema/schema.graphql.g.dart b/lib/logic/api_maps/graphql_maps/schema/schema.graphql.g.dart index 84a4c38f..9002a8e1 100644 --- a/lib/logic/api_maps/graphql_maps/schema/schema.graphql.g.dart +++ b/lib/logic/api_maps/graphql_maps/schema/schema.graphql.g.dart @@ -13,6 +13,13 @@ Input$RecoveryKeyLimitsInput _$Input$RecoveryKeyLimitsInputFromJson( uses: json['uses'] as int?, ); +Map _$Input$RecoveryKeyLimitsInputToJson( + Input$RecoveryKeyLimitsInput instance) => + { + 'expirationDate': _nullable$dateTimeToJson(instance.expirationDate), + 'uses': instance.uses, + }; + Input$UseNewDeviceKeyInput _$Input$UseNewDeviceKeyInputFromJson( Map json) => Input$UseNewDeviceKeyInput( @@ -20,9 +27,23 @@ Input$UseNewDeviceKeyInput _$Input$UseNewDeviceKeyInputFromJson( deviceName: json['deviceName'] as String, ); +Map _$Input$UseNewDeviceKeyInputToJson( + Input$UseNewDeviceKeyInput instance) => + { + 'key': instance.key, + 'deviceName': instance.deviceName, + }; + Input$UseRecoveryKeyInput _$Input$UseRecoveryKeyInputFromJson( Map json) => Input$UseRecoveryKeyInput( key: json['key'] as String, deviceName: json['deviceName'] as String, ); + +Map _$Input$UseRecoveryKeyInputToJson( + Input$UseRecoveryKeyInput instance) => + { + 'key': instance.key, + 'deviceName': instance.deviceName, + }; diff --git a/lib/logic/api_maps/graphql_maps/schema/server.dart b/lib/logic/api_maps/graphql_maps/schema/server.dart new file mode 100644 index 00000000..cc0a6c38 --- /dev/null +++ b/lib/logic/api_maps/graphql_maps/schema/server.dart @@ -0,0 +1,39 @@ +import 'package:graphql/client.dart'; +import 'package:selfprivacy/config/get_it_config.dart'; +import 'package:selfprivacy/logic/api_maps/graphql_maps/api_map.dart'; +import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/get_api_version.graphql.dart'; +import 'package:selfprivacy/logic/models/hive/server_domain.dart'; + +class ServerApi extends ApiMap { + ServerApi({ + this.hasLogger = false, + this.isWithToken = true, + this.authToken = '', + }) { + final ServerDomain? serverDomain = getIt().serverDomain; + rootAddress = serverDomain?.domainName ?? ''; + } + @override + bool hasLogger; + @override + bool isWithToken; + @override + String authToken; + @override + String? rootAddress; + + Future getApiVersion() async { + QueryResult response; + + final GraphQLClient client = await getClient(); + String? apiVersion; + + try { + response = await client.query$GetApiVersionQuery(); + apiVersion = response.data!['api']['version']; + } catch (e) { + print(e); + } + return apiVersion; + } +} diff --git a/lib/logic/api_maps/rest_maps/server.dart b/lib/logic/api_maps/rest_maps/server.dart index 3cb2ed73..4139d3e2 100644 --- a/lib/logic/api_maps/rest_maps/server.dart +++ b/lib/logic/api_maps/rest_maps/server.dart @@ -49,9 +49,8 @@ class ServerApi extends ApiMap { BaseOptions options = BaseOptions(); if (isWithToken) { - final ServerDomain? cloudFlareDomain = - getIt().serverDomain; - final String domainName = cloudFlareDomain!.domainName; + final ServerDomain? serverDomain = getIt().serverDomain; + final String domainName = serverDomain!.domainName; final String? apiToken = getIt().serverDetails?.apiToken; options = BaseOptions( diff --git a/lib/logic/models/json/api_token.g.dart b/lib/logic/models/json/api_token.g.dart index b6c8b8db..7f7af88c 100644 --- a/lib/logic/models/json/api_token.g.dart +++ b/lib/logic/models/json/api_token.g.dart @@ -11,3 +11,9 @@ ApiToken _$ApiTokenFromJson(Map json) => ApiToken( date: DateTime.parse(json['date'] as String), isCaller: json['is_caller'] as bool, ); + +Map _$ApiTokenToJson(ApiToken instance) => { + 'name': instance.name, + 'date': instance.date.toIso8601String(), + 'is_caller': instance.isCaller, + }; diff --git a/lib/logic/models/json/backup.g.dart b/lib/logic/models/json/backup.g.dart index c784abe1..dea4847d 100644 --- a/lib/logic/models/json/backup.g.dart +++ b/lib/logic/models/json/backup.g.dart @@ -11,12 +11,24 @@ Backup _$BackupFromJson(Map json) => Backup( id: json['short_id'] as String, ); +Map _$BackupToJson(Backup instance) => { + 'time': instance.time.toIso8601String(), + 'short_id': instance.id, + }; + BackupStatus _$BackupStatusFromJson(Map json) => BackupStatus( status: $enumDecode(_$BackupStatusEnumEnumMap, json['status']), progress: (json['progress'] as num).toDouble(), errorMessage: json['error_message'] as String?, ); +Map _$BackupStatusToJson(BackupStatus instance) => + { + 'status': _$BackupStatusEnumEnumMap[instance.status]!, + 'progress': instance.progress, + 'error_message': instance.errorMessage, + }; + const _$BackupStatusEnumEnumMap = { BackupStatusEnum.noKey: 'NO_KEY', BackupStatusEnum.notInitialized: 'NOT_INITIALIZED', diff --git a/lib/logic/models/json/device_token.g.dart b/lib/logic/models/json/device_token.g.dart index efe976c5..406530df 100644 --- a/lib/logic/models/json/device_token.g.dart +++ b/lib/logic/models/json/device_token.g.dart @@ -10,3 +10,9 @@ DeviceToken _$DeviceTokenFromJson(Map json) => DeviceToken( device: json['device'] as String, token: json['token'] as String, ); + +Map _$DeviceTokenToJson(DeviceToken instance) => + { + 'device': instance.device, + 'token': instance.token, + }; diff --git a/lib/logic/models/json/hetzner_server_info.g.dart b/lib/logic/models/json/hetzner_server_info.g.dart index e8c21917..6c178ea4 100644 --- a/lib/logic/models/json/hetzner_server_info.g.dart +++ b/lib/logic/models/json/hetzner_server_info.g.dart @@ -19,6 +19,18 @@ HetznerServerInfo _$HetznerServerInfoFromJson(Map json) => (json['volumes'] as List).map((e) => e as int).toList(), ); +Map _$HetznerServerInfoToJson(HetznerServerInfo instance) => + { + 'id': instance.id, + 'name': instance.name, + 'status': _$ServerStatusEnumMap[instance.status]!, + 'created': instance.created.toIso8601String(), + 'volumes': instance.volumes, + 'server_type': instance.serverType, + 'datacenter': instance.location, + 'public_net': instance.publicNet, + }; + const _$ServerStatusEnumMap = { ServerStatus.running: 'running', ServerStatus.initializing: 'initializing', @@ -37,6 +49,12 @@ HetznerPublicNetInfo _$HetznerPublicNetInfoFromJson( HetznerIp4.fromJson(json['ipv4'] as Map), ); +Map _$HetznerPublicNetInfoToJson( + HetznerPublicNetInfo instance) => + { + 'ipv4': instance.ipv4, + }; + HetznerIp4 _$HetznerIp4FromJson(Map json) => HetznerIp4( json['id'] as int, json['ip'] as String, @@ -44,6 +62,14 @@ HetznerIp4 _$HetznerIp4FromJson(Map json) => HetznerIp4( json['dns_ptr'] as String, ); +Map _$HetznerIp4ToJson(HetznerIp4 instance) => + { + 'blocked': instance.blocked, + 'dns_ptr': instance.reverseDns, + 'id': instance.id, + 'ip': instance.ip, + }; + HetznerServerTypeInfo _$HetznerServerTypeInfoFromJson( Map json) => HetznerServerTypeInfo( @@ -55,12 +81,27 @@ HetznerServerTypeInfo _$HetznerServerTypeInfoFromJson( .toList(), ); +Map _$HetznerServerTypeInfoToJson( + HetznerServerTypeInfo instance) => + { + 'cores': instance.cores, + 'memory': instance.memory, + 'disk': instance.disk, + 'prices': instance.prices, + }; + HetznerPriceInfo _$HetznerPriceInfoFromJson(Map json) => HetznerPriceInfo( HetznerPriceInfo.getPrice(json['price_hourly'] as Map), HetznerPriceInfo.getPrice(json['price_monthly'] as Map), ); +Map _$HetznerPriceInfoToJson(HetznerPriceInfo instance) => + { + 'price_hourly': instance.hourly, + 'price_monthly': instance.monthly, + }; + HetznerLocation _$HetznerLocationFromJson(Map json) => HetznerLocation( json['country'] as String, @@ -68,3 +109,11 @@ HetznerLocation _$HetznerLocationFromJson(Map json) => json['description'] as String, json['network_zone'] as String, ); + +Map _$HetznerLocationToJson(HetznerLocation instance) => + { + 'country': instance.country, + 'city': instance.city, + 'description': instance.description, + 'network_zone': instance.zone, + }; diff --git a/lib/logic/models/json/recovery_token_status.g.dart b/lib/logic/models/json/recovery_token_status.g.dart index cef9abbd..9fb6d6cd 100644 --- a/lib/logic/models/json/recovery_token_status.g.dart +++ b/lib/logic/models/json/recovery_token_status.g.dart @@ -17,3 +17,12 @@ RecoveryKeyStatus _$RecoveryKeyStatusFromJson(Map json) => : DateTime.parse(json['expiration'] as String), usesLeft: json['uses_left'] as int?, ); + +Map _$RecoveryKeyStatusToJson(RecoveryKeyStatus instance) => + { + 'exists': instance.exists, + 'date': instance.date?.toIso8601String(), + 'expiration': instance.expiration?.toIso8601String(), + 'uses_left': instance.usesLeft, + 'valid': instance.valid, + }; diff --git a/lib/ui/pages/more/info/info.dart b/lib/ui/pages/more/info/info.dart index d4c4863b..0860ca80 100644 --- a/lib/ui/pages/more/info/info.dart +++ b/lib/ui/pages/more/info/info.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:selfprivacy/config/brand_theme.dart'; +import 'package:selfprivacy/logic/api_maps/graphql_maps/schema/server.dart'; import 'package:selfprivacy/ui/components/brand_divider/brand_divider.dart'; import 'package:selfprivacy/ui/components/brand_header/brand_header.dart'; import 'package:selfprivacy/ui/components/brand_text/brand_text.dart'; @@ -23,9 +24,16 @@ class InfoPage extends StatelessWidget { const BrandDivider(), const SizedBox(height: 10), FutureBuilder( - future: _version(), + future: _packageVersion(), builder: (final context, final snapshot) => BrandText.body1( - 'more.about_app_page.text' + 'more.about_app_page.application_version_text' + .tr(args: [snapshot.data.toString()]), + ), + ), + FutureBuilder( + future: _apiVersion(), + builder: (final context, final snapshot) => BrandText.body1( + 'more.about_app_page.api_version_text' .tr(args: [snapshot.data.toString()]), ), ), @@ -34,7 +42,7 @@ class InfoPage extends StatelessWidget { ), ); - Future _version() async { + Future _packageVersion() async { String packageVersion = 'unknown'; try { final PackageInfo packageInfo = await PackageInfo.fromPlatform(); @@ -45,4 +53,15 @@ class InfoPage extends StatelessWidget { return packageVersion; } + + Future _apiVersion() async { + String apiVersion = 'unknown'; + try { + apiVersion = await ServerApi().getApiVersion() ?? apiVersion; + } catch (e) { + print(e); + } + + return apiVersion; + } } diff --git a/pubspec.lock b/pubspec.lock index cb308ae6..e40f6b5c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -29,13 +29,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.3.1" - asn1lib: - dependency: transitive - description: - name: asn1lib - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" async: dependency: transitive description: @@ -84,7 +77,7 @@ packages: name: build_config url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.0" build_daemon: dependency: transitive description: @@ -105,7 +98,7 @@ packages: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "2.1.11" + version: "2.2.0" build_runner_core: dependency: transitive description: @@ -175,14 +168,14 @@ packages: name: connectivity_plus url: "https://pub.dartlang.org" source: hosted - version: "2.3.5" + version: "2.1.0" connectivity_plus_linux: dependency: transitive description: name: connectivity_plus_linux url: "https://pub.dartlang.org" source: hosted - version: "1.3.1" + version: "1.1.0" connectivity_plus_macos: dependency: transitive description: @@ -203,7 +196,7 @@ packages: name: connectivity_plus_web url: "https://pub.dartlang.org" source: hosted - version: "1.2.2" + version: "1.2.3" connectivity_plus_windows: dependency: transitive description: @@ -246,13 +239,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.1" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.4" dart_style: dependency: transitive description: @@ -266,14 +252,14 @@ packages: name: dbus url: "https://pub.dartlang.org" source: hosted - version: "0.7.3" + version: "0.5.4" device_info_plus: dependency: "direct main" description: name: device_info_plus url: "https://pub.dartlang.org" source: hosted - version: "3.2.3" + version: "4.0.1" device_info_plus_linux: dependency: transitive description: @@ -308,7 +294,7 @@ packages: name: device_info_plus_windows url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "3.0.1" dio: dependency: "direct main" description: @@ -322,7 +308,7 @@ packages: name: dynamic_color url: "https://pub.dartlang.org" source: hosted - version: "1.2.2" + version: "1.4.0" easy_localization: dependency: "direct main" description: @@ -371,7 +357,7 @@ packages: name: ffi url: "https://pub.dartlang.org" source: hosted - version: "1.2.1" + version: "2.0.1" file: dependency: transitive description: @@ -587,7 +573,7 @@ packages: name: graphql_codegen url: "https://pub.dartlang.org" source: hosted - version: "0.9.0" + version: "0.10.2" graphql_codegen_config: dependency: transitive description: @@ -622,7 +608,7 @@ packages: name: hive url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.2.3" hive_flutter: dependency: "direct main" description: @@ -636,7 +622,7 @@ packages: name: hive_generator url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.1.3" http: dependency: transitive description: @@ -699,14 +685,14 @@ packages: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "4.5.0" + version: "4.6.0" json_serializable: dependency: "direct dev" description: name: json_serializable url: "https://pub.dartlang.org" source: hosted - version: "6.2.0" + version: "6.3.1" lints: dependency: transitive description: @@ -818,7 +804,7 @@ packages: name: nm url: "https://pub.dartlang.org" source: hosted - version: "0.5.0" + version: "0.3.0" node_preamble: dependency: transitive description: @@ -881,7 +867,7 @@ packages: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "2.1.6" + version: "2.1.7" path_provider_macos: dependency: transitive description: @@ -902,7 +888,14 @@ packages: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "2.0.6" + version: "2.1.0" + pedantic: + dependency: transitive + description: + name: pedantic + url: "https://pub.dartlang.org" + source: hosted + version: "1.11.1" petitparser: dependency: transitive description: @@ -973,13 +966,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.0" recase: dependency: transitive description: @@ -993,7 +979,7 @@ packages: name: rxdart url: "https://pub.dartlang.org" source: hosted - version: "0.27.4" + version: "0.27.5" share_plus: dependency: "direct main" description: @@ -1160,13 +1146,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.2" - ssh_key: - dependency: "direct main" - description: - name: ssh_key - url: "https://pub.dartlang.org" - source: hosted - version: "0.7.1" stack_trace: dependency: transitive description: @@ -1251,13 +1230,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.0" - tuple: - dependency: transitive - description: - name: tuple - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" typed_data: dependency: transitive description: @@ -1404,7 +1376,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.6.1" + version: "2.7.0" xdg_directories: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index f5367d99..114723f1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,10 +12,9 @@ dependencies: basic_utils: ^4.2.0 crypt: ^4.2.1 cubit_form: ^2.0.1 - cupertino_icons: ^1.0.4 - device_info_plus: ^3.2.3 + device_info_plus: ^4.0.1 dio: ^4.0.4 - dynamic_color: ^1.2.2 + dynamic_color: ^1.4.0 easy_localization: ^3.0.0 either_option: ^2.0.1-dev.1 equatable: ^2.0.3 @@ -28,14 +27,14 @@ dependencies: get_it: ^7.2.0 gql: ^0.13.1 graphql: ^5.1.1 - graphql_codegen: ^0.9.0 + graphql_codegen: ^0.10.2 graphql_flutter: ^5.1.0 gtk_theme_fl: ^0.0.1 - hive: ^2.0.5 + hive: ^2.2.3 hive_flutter: ^1.1.0 intl: ^0.17.0 ionicons: ^0.1.2 - json_annotation: ^4.4.0 + json_annotation: ^4.6.0 local_auth: ^2.0.2 modal_bottom_sheet: ^2.0.1 nanoid: ^1.0.0 @@ -44,7 +43,6 @@ dependencies: provider: ^6.0.2 pub_semver: ^2.1.1 share_plus: ^4.0.4 - ssh_key: ^0.7.1 system_theme: ^2.0.0 timezone: ^0.8.0 url_launcher: ^6.0.20 @@ -53,10 +51,10 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - build_runner: ^2.1.1 + build_runner: ^2.2.0 flutter_launcher_icons: ^0.9.2 - hive_generator: ^1.0.0 - json_serializable: ^6.1.4 + hive_generator: ^1.1.3 + json_serializable: ^6.3.1 flutter_lints: ^2.0.1 flutter_icons: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 070eb3b5..1feb1b08 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -7,6 +7,7 @@ #include "generated_plugin_registrant.h" #include +#include #include #include #include @@ -14,6 +15,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { ConnectivityPlusWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); + DynamicColorPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("DynamicColorPluginCApi")); FlutterSecureStorageWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin")); SystemThemePluginRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index a26e37b0..fa5d72de 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -4,6 +4,7 @@ list(APPEND FLUTTER_PLUGIN_LIST connectivity_plus_windows + dynamic_color flutter_secure_storage_windows system_theme url_launcher_windows