diff --git a/lib/misskey_dart.dart b/lib/misskey_dart.dart index 83ce89d4..b644a8b2 100644 --- a/lib/misskey_dart.dart +++ b/lib/misskey_dart.dart @@ -107,8 +107,12 @@ export 'src/data/i/i_update_request.dart'; export 'src/data/i/i_read_announcement_request.dart'; export 'src/data/i/registry/i_registry_get_all_request.dart'; export 'src/data/i/registry/i_registry_get_detail_request.dart'; +export 'src/data/i/registry/i_registry_get_detail_response.dart'; export 'src/data/i/registry/i_registry_get_request.dart'; +export 'src/data/i/registry/i_registry_keys_request.dart'; +export 'src/data/i/registry/i_registry_keys_with_type_request.dart'; export 'src/data/i/registry/i_registry_remove_request.dart'; +export 'src/data/i/registry/i_registry_scopes_with_domain_response.dart'; export 'src/data/i/registry/i_registry_set_request.dart'; export 'src/data/notes/notes_clips_request.dart'; export 'src/data/notes/notes_timeline_request.dart'; diff --git a/lib/src/data/i/registry/i_registry_get_all_request.dart b/lib/src/data/i/registry/i_registry_get_all_request.dart index a6cd3a23..c252b9f3 100644 --- a/lib/src/data/i/registry/i_registry_get_all_request.dart +++ b/lib/src/data/i/registry/i_registry_get_all_request.dart @@ -7,7 +7,7 @@ part 'i_registry_get_all_request.g.dart'; class IRegistryGetAllRequest with _$IRegistryGetAllRequest { const factory IRegistryGetAllRequest({ required List scope, - required String? domain, + String? domain, }) = _IRegistryGetAllRequest; factory IRegistryGetAllRequest.fromJson(Map json) => diff --git a/lib/src/data/i/registry/i_registry_get_all_request.freezed.dart b/lib/src/data/i/registry/i_registry_get_all_request.freezed.dart index db0e94d4..98a225e8 100644 --- a/lib/src/data/i/registry/i_registry_get_all_request.freezed.dart +++ b/lib/src/data/i/registry/i_registry_get_all_request.freezed.dart @@ -114,7 +114,7 @@ class __$$IRegistryGetAllRequestImplCopyWithImpl<$Res> @JsonSerializable() class _$IRegistryGetAllRequestImpl implements _IRegistryGetAllRequest { const _$IRegistryGetAllRequestImpl( - {required final List scope, required this.domain}) + {required final List scope, this.domain}) : _scope = scope; factory _$IRegistryGetAllRequestImpl.fromJson(Map json) => @@ -168,7 +168,7 @@ class _$IRegistryGetAllRequestImpl implements _IRegistryGetAllRequest { abstract class _IRegistryGetAllRequest implements IRegistryGetAllRequest { const factory _IRegistryGetAllRequest( {required final List scope, - required final String? domain}) = _$IRegistryGetAllRequestImpl; + final String? domain}) = _$IRegistryGetAllRequestImpl; factory _IRegistryGetAllRequest.fromJson(Map json) = _$IRegistryGetAllRequestImpl.fromJson; diff --git a/lib/src/data/i/registry/i_registry_get_detail_response.dart b/lib/src/data/i/registry/i_registry_get_detail_response.dart new file mode 100644 index 00000000..4298b884 --- /dev/null +++ b/lib/src/data/i/registry/i_registry_get_detail_response.dart @@ -0,0 +1,15 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'i_registry_get_detail_response.freezed.dart'; +part 'i_registry_get_detail_response.g.dart'; + +@freezed +class IRegistryGetDetailResponse with _$IRegistryGetDetailResponse { + const factory IRegistryGetDetailResponse({ + required DateTime updatedAt, + required dynamic value, + }) = _IRegistryGetDetailResponse; + + factory IRegistryGetDetailResponse.fromJson(Map json) => + _$IRegistryGetDetailResponseFromJson(json); +} diff --git a/lib/src/data/i/registry/i_registry_get_detail_response.freezed.dart b/lib/src/data/i/registry/i_registry_get_detail_response.freezed.dart new file mode 100644 index 00000000..7e597d04 --- /dev/null +++ b/lib/src/data/i/registry/i_registry_get_detail_response.freezed.dart @@ -0,0 +1,181 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'i_registry_get_detail_response.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +IRegistryGetDetailResponse _$IRegistryGetDetailResponseFromJson( + Map json) { + return _IRegistryGetDetailResponse.fromJson(json); +} + +/// @nodoc +mixin _$IRegistryGetDetailResponse { + DateTime get updatedAt => throw _privateConstructorUsedError; + dynamic get value => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $IRegistryGetDetailResponseCopyWith + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $IRegistryGetDetailResponseCopyWith<$Res> { + factory $IRegistryGetDetailResponseCopyWith(IRegistryGetDetailResponse value, + $Res Function(IRegistryGetDetailResponse) then) = + _$IRegistryGetDetailResponseCopyWithImpl<$Res, + IRegistryGetDetailResponse>; + @useResult + $Res call({DateTime updatedAt, dynamic value}); +} + +/// @nodoc +class _$IRegistryGetDetailResponseCopyWithImpl<$Res, + $Val extends IRegistryGetDetailResponse> + implements $IRegistryGetDetailResponseCopyWith<$Res> { + _$IRegistryGetDetailResponseCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? updatedAt = null, + Object? value = freezed, + }) { + return _then(_value.copyWith( + updatedAt: null == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as DateTime, + value: freezed == value + ? _value.value + : value // ignore: cast_nullable_to_non_nullable + as dynamic, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$IRegistryGetDetailResponseImplCopyWith<$Res> + implements $IRegistryGetDetailResponseCopyWith<$Res> { + factory _$$IRegistryGetDetailResponseImplCopyWith( + _$IRegistryGetDetailResponseImpl value, + $Res Function(_$IRegistryGetDetailResponseImpl) then) = + __$$IRegistryGetDetailResponseImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({DateTime updatedAt, dynamic value}); +} + +/// @nodoc +class __$$IRegistryGetDetailResponseImplCopyWithImpl<$Res> + extends _$IRegistryGetDetailResponseCopyWithImpl<$Res, + _$IRegistryGetDetailResponseImpl> + implements _$$IRegistryGetDetailResponseImplCopyWith<$Res> { + __$$IRegistryGetDetailResponseImplCopyWithImpl( + _$IRegistryGetDetailResponseImpl _value, + $Res Function(_$IRegistryGetDetailResponseImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? updatedAt = null, + Object? value = freezed, + }) { + return _then(_$IRegistryGetDetailResponseImpl( + updatedAt: null == updatedAt + ? _value.updatedAt + : updatedAt // ignore: cast_nullable_to_non_nullable + as DateTime, + value: freezed == value + ? _value.value + : value // ignore: cast_nullable_to_non_nullable + as dynamic, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$IRegistryGetDetailResponseImpl implements _IRegistryGetDetailResponse { + const _$IRegistryGetDetailResponseImpl( + {required this.updatedAt, required this.value}); + + factory _$IRegistryGetDetailResponseImpl.fromJson( + Map json) => + _$$IRegistryGetDetailResponseImplFromJson(json); + + @override + final DateTime updatedAt; + @override + final dynamic value; + + @override + String toString() { + return 'IRegistryGetDetailResponse(updatedAt: $updatedAt, value: $value)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$IRegistryGetDetailResponseImpl && + (identical(other.updatedAt, updatedAt) || + other.updatedAt == updatedAt) && + const DeepCollectionEquality().equals(other.value, value)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, updatedAt, const DeepCollectionEquality().hash(value)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$IRegistryGetDetailResponseImplCopyWith<_$IRegistryGetDetailResponseImpl> + get copyWith => __$$IRegistryGetDetailResponseImplCopyWithImpl< + _$IRegistryGetDetailResponseImpl>(this, _$identity); + + @override + Map toJson() { + return _$$IRegistryGetDetailResponseImplToJson( + this, + ); + } +} + +abstract class _IRegistryGetDetailResponse + implements IRegistryGetDetailResponse { + const factory _IRegistryGetDetailResponse( + {required final DateTime updatedAt, + required final dynamic value}) = _$IRegistryGetDetailResponseImpl; + + factory _IRegistryGetDetailResponse.fromJson(Map json) = + _$IRegistryGetDetailResponseImpl.fromJson; + + @override + DateTime get updatedAt; + @override + dynamic get value; + @override + @JsonKey(ignore: true) + _$$IRegistryGetDetailResponseImplCopyWith<_$IRegistryGetDetailResponseImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/lib/src/data/i/registry/i_registry_get_detail_response.g.dart b/lib/src/data/i/registry/i_registry_get_detail_response.g.dart new file mode 100644 index 00000000..1d7a1c66 --- /dev/null +++ b/lib/src/data/i/registry/i_registry_get_detail_response.g.dart @@ -0,0 +1,21 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'i_registry_get_detail_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$IRegistryGetDetailResponseImpl _$$IRegistryGetDetailResponseImplFromJson( + Map json) => + _$IRegistryGetDetailResponseImpl( + updatedAt: DateTime.parse(json['updatedAt'] as String), + value: json['value'], + ); + +Map _$$IRegistryGetDetailResponseImplToJson( + _$IRegistryGetDetailResponseImpl instance) => + { + 'updatedAt': instance.updatedAt.toIso8601String(), + 'value': instance.value, + }; diff --git a/lib/src/data/i/registry/i_registry_get_request.dart b/lib/src/data/i/registry/i_registry_get_request.dart index 1f09ecf5..4c9b9ef4 100644 --- a/lib/src/data/i/registry/i_registry_get_request.dart +++ b/lib/src/data/i/registry/i_registry_get_request.dart @@ -8,7 +8,7 @@ class IRegistryGetRequest with _$IRegistryGetRequest { const factory IRegistryGetRequest({ required String key, required List scope, - required String? domain, + String? domain, }) = _IRegistryGetRequest; factory IRegistryGetRequest.fromJson(Map json) => diff --git a/lib/src/data/i/registry/i_registry_get_request.freezed.dart b/lib/src/data/i/registry/i_registry_get_request.freezed.dart index 04afe12d..f937b77b 100644 --- a/lib/src/data/i/registry/i_registry_get_request.freezed.dart +++ b/lib/src/data/i/registry/i_registry_get_request.freezed.dart @@ -120,9 +120,7 @@ class __$$IRegistryGetRequestImplCopyWithImpl<$Res> @JsonSerializable() class _$IRegistryGetRequestImpl implements _IRegistryGetRequest { const _$IRegistryGetRequestImpl( - {required this.key, - required final List scope, - required this.domain}) + {required this.key, required final List scope, this.domain}) : _scope = scope; factory _$IRegistryGetRequestImpl.fromJson(Map json) => @@ -180,7 +178,7 @@ abstract class _IRegistryGetRequest implements IRegistryGetRequest { const factory _IRegistryGetRequest( {required final String key, required final List scope, - required final String? domain}) = _$IRegistryGetRequestImpl; + final String? domain}) = _$IRegistryGetRequestImpl; factory _IRegistryGetRequest.fromJson(Map json) = _$IRegistryGetRequestImpl.fromJson; diff --git a/lib/src/data/i/registry/i_registry_keys_request.dart b/lib/src/data/i/registry/i_registry_keys_request.dart new file mode 100644 index 00000000..5f155200 --- /dev/null +++ b/lib/src/data/i/registry/i_registry_keys_request.dart @@ -0,0 +1,15 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'i_registry_keys_request.freezed.dart'; +part 'i_registry_keys_request.g.dart'; + +@freezed +class IRegistryKeysRequest with _$IRegistryKeysRequest { + const factory IRegistryKeysRequest({ + required List scope, + String? domain, + }) = _IRegistryKeysRequest; + + factory IRegistryKeysRequest.fromJson(Map json) => + _$IRegistryKeysRequestFromJson(json); +} diff --git a/lib/src/data/i/registry/i_registry_keys_request.freezed.dart b/lib/src/data/i/registry/i_registry_keys_request.freezed.dart new file mode 100644 index 00000000..a6302a5b --- /dev/null +++ b/lib/src/data/i/registry/i_registry_keys_request.freezed.dart @@ -0,0 +1,181 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'i_registry_keys_request.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +IRegistryKeysRequest _$IRegistryKeysRequestFromJson(Map json) { + return _IRegistryKeysRequest.fromJson(json); +} + +/// @nodoc +mixin _$IRegistryKeysRequest { + List get scope => throw _privateConstructorUsedError; + String? get domain => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $IRegistryKeysRequestCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $IRegistryKeysRequestCopyWith<$Res> { + factory $IRegistryKeysRequestCopyWith(IRegistryKeysRequest value, + $Res Function(IRegistryKeysRequest) then) = + _$IRegistryKeysRequestCopyWithImpl<$Res, IRegistryKeysRequest>; + @useResult + $Res call({List scope, String? domain}); +} + +/// @nodoc +class _$IRegistryKeysRequestCopyWithImpl<$Res, + $Val extends IRegistryKeysRequest> + implements $IRegistryKeysRequestCopyWith<$Res> { + _$IRegistryKeysRequestCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? scope = null, + Object? domain = freezed, + }) { + return _then(_value.copyWith( + scope: null == scope + ? _value.scope + : scope // ignore: cast_nullable_to_non_nullable + as List, + domain: freezed == domain + ? _value.domain + : domain // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$IRegistryKeysRequestImplCopyWith<$Res> + implements $IRegistryKeysRequestCopyWith<$Res> { + factory _$$IRegistryKeysRequestImplCopyWith(_$IRegistryKeysRequestImpl value, + $Res Function(_$IRegistryKeysRequestImpl) then) = + __$$IRegistryKeysRequestImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({List scope, String? domain}); +} + +/// @nodoc +class __$$IRegistryKeysRequestImplCopyWithImpl<$Res> + extends _$IRegistryKeysRequestCopyWithImpl<$Res, _$IRegistryKeysRequestImpl> + implements _$$IRegistryKeysRequestImplCopyWith<$Res> { + __$$IRegistryKeysRequestImplCopyWithImpl(_$IRegistryKeysRequestImpl _value, + $Res Function(_$IRegistryKeysRequestImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? scope = null, + Object? domain = freezed, + }) { + return _then(_$IRegistryKeysRequestImpl( + scope: null == scope + ? _value._scope + : scope // ignore: cast_nullable_to_non_nullable + as List, + domain: freezed == domain + ? _value.domain + : domain // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$IRegistryKeysRequestImpl implements _IRegistryKeysRequest { + const _$IRegistryKeysRequestImpl( + {required final List scope, this.domain}) + : _scope = scope; + + factory _$IRegistryKeysRequestImpl.fromJson(Map json) => + _$$IRegistryKeysRequestImplFromJson(json); + + final List _scope; + @override + List get scope { + if (_scope is EqualUnmodifiableListView) return _scope; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_scope); + } + + @override + final String? domain; + + @override + String toString() { + return 'IRegistryKeysRequest(scope: $scope, domain: $domain)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$IRegistryKeysRequestImpl && + const DeepCollectionEquality().equals(other._scope, _scope) && + (identical(other.domain, domain) || other.domain == domain)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, const DeepCollectionEquality().hash(_scope), domain); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$IRegistryKeysRequestImplCopyWith<_$IRegistryKeysRequestImpl> + get copyWith => + __$$IRegistryKeysRequestImplCopyWithImpl<_$IRegistryKeysRequestImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$IRegistryKeysRequestImplToJson( + this, + ); + } +} + +abstract class _IRegistryKeysRequest implements IRegistryKeysRequest { + const factory _IRegistryKeysRequest( + {required final List scope, + final String? domain}) = _$IRegistryKeysRequestImpl; + + factory _IRegistryKeysRequest.fromJson(Map json) = + _$IRegistryKeysRequestImpl.fromJson; + + @override + List get scope; + @override + String? get domain; + @override + @JsonKey(ignore: true) + _$$IRegistryKeysRequestImplCopyWith<_$IRegistryKeysRequestImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/lib/src/data/i/registry/i_registry_keys_request.g.dart b/lib/src/data/i/registry/i_registry_keys_request.g.dart new file mode 100644 index 00000000..76f08c54 --- /dev/null +++ b/lib/src/data/i/registry/i_registry_keys_request.g.dart @@ -0,0 +1,21 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'i_registry_keys_request.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$IRegistryKeysRequestImpl _$$IRegistryKeysRequestImplFromJson( + Map json) => + _$IRegistryKeysRequestImpl( + scope: (json['scope'] as List).map((e) => e as String).toList(), + domain: json['domain'] as String?, + ); + +Map _$$IRegistryKeysRequestImplToJson( + _$IRegistryKeysRequestImpl instance) => + { + 'scope': instance.scope, + 'domain': instance.domain, + }; diff --git a/lib/src/data/i/registry/i_registry_keys_with_type_request.dart b/lib/src/data/i/registry/i_registry_keys_with_type_request.dart new file mode 100644 index 00000000..81dbdf26 --- /dev/null +++ b/lib/src/data/i/registry/i_registry_keys_with_type_request.dart @@ -0,0 +1,15 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'i_registry_keys_with_type_request.freezed.dart'; +part 'i_registry_keys_with_type_request.g.dart'; + +@freezed +class IRegistryKeysWithTypeRequest with _$IRegistryKeysWithTypeRequest { + const factory IRegistryKeysWithTypeRequest({ + required List scope, + String? domain, + }) = _IRegistryKeysWithTypeRequest; + + factory IRegistryKeysWithTypeRequest.fromJson(Map json) => + _$IRegistryKeysWithTypeRequestFromJson(json); +} diff --git a/lib/src/data/i/registry/i_registry_keys_with_type_request.freezed.dart b/lib/src/data/i/registry/i_registry_keys_with_type_request.freezed.dart new file mode 100644 index 00000000..4911a6a2 --- /dev/null +++ b/lib/src/data/i/registry/i_registry_keys_with_type_request.freezed.dart @@ -0,0 +1,191 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'i_registry_keys_with_type_request.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +IRegistryKeysWithTypeRequest _$IRegistryKeysWithTypeRequestFromJson( + Map json) { + return _IRegistryKeysWithTypeRequest.fromJson(json); +} + +/// @nodoc +mixin _$IRegistryKeysWithTypeRequest { + List get scope => throw _privateConstructorUsedError; + String? get domain => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $IRegistryKeysWithTypeRequestCopyWith + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $IRegistryKeysWithTypeRequestCopyWith<$Res> { + factory $IRegistryKeysWithTypeRequestCopyWith( + IRegistryKeysWithTypeRequest value, + $Res Function(IRegistryKeysWithTypeRequest) then) = + _$IRegistryKeysWithTypeRequestCopyWithImpl<$Res, + IRegistryKeysWithTypeRequest>; + @useResult + $Res call({List scope, String? domain}); +} + +/// @nodoc +class _$IRegistryKeysWithTypeRequestCopyWithImpl<$Res, + $Val extends IRegistryKeysWithTypeRequest> + implements $IRegistryKeysWithTypeRequestCopyWith<$Res> { + _$IRegistryKeysWithTypeRequestCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? scope = null, + Object? domain = freezed, + }) { + return _then(_value.copyWith( + scope: null == scope + ? _value.scope + : scope // ignore: cast_nullable_to_non_nullable + as List, + domain: freezed == domain + ? _value.domain + : domain // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$IRegistryKeysWithTypeRequestImplCopyWith<$Res> + implements $IRegistryKeysWithTypeRequestCopyWith<$Res> { + factory _$$IRegistryKeysWithTypeRequestImplCopyWith( + _$IRegistryKeysWithTypeRequestImpl value, + $Res Function(_$IRegistryKeysWithTypeRequestImpl) then) = + __$$IRegistryKeysWithTypeRequestImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({List scope, String? domain}); +} + +/// @nodoc +class __$$IRegistryKeysWithTypeRequestImplCopyWithImpl<$Res> + extends _$IRegistryKeysWithTypeRequestCopyWithImpl<$Res, + _$IRegistryKeysWithTypeRequestImpl> + implements _$$IRegistryKeysWithTypeRequestImplCopyWith<$Res> { + __$$IRegistryKeysWithTypeRequestImplCopyWithImpl( + _$IRegistryKeysWithTypeRequestImpl _value, + $Res Function(_$IRegistryKeysWithTypeRequestImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? scope = null, + Object? domain = freezed, + }) { + return _then(_$IRegistryKeysWithTypeRequestImpl( + scope: null == scope + ? _value._scope + : scope // ignore: cast_nullable_to_non_nullable + as List, + domain: freezed == domain + ? _value.domain + : domain // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$IRegistryKeysWithTypeRequestImpl + implements _IRegistryKeysWithTypeRequest { + const _$IRegistryKeysWithTypeRequestImpl( + {required final List scope, this.domain}) + : _scope = scope; + + factory _$IRegistryKeysWithTypeRequestImpl.fromJson( + Map json) => + _$$IRegistryKeysWithTypeRequestImplFromJson(json); + + final List _scope; + @override + List get scope { + if (_scope is EqualUnmodifiableListView) return _scope; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_scope); + } + + @override + final String? domain; + + @override + String toString() { + return 'IRegistryKeysWithTypeRequest(scope: $scope, domain: $domain)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$IRegistryKeysWithTypeRequestImpl && + const DeepCollectionEquality().equals(other._scope, _scope) && + (identical(other.domain, domain) || other.domain == domain)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, const DeepCollectionEquality().hash(_scope), domain); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$IRegistryKeysWithTypeRequestImplCopyWith< + _$IRegistryKeysWithTypeRequestImpl> + get copyWith => __$$IRegistryKeysWithTypeRequestImplCopyWithImpl< + _$IRegistryKeysWithTypeRequestImpl>(this, _$identity); + + @override + Map toJson() { + return _$$IRegistryKeysWithTypeRequestImplToJson( + this, + ); + } +} + +abstract class _IRegistryKeysWithTypeRequest + implements IRegistryKeysWithTypeRequest { + const factory _IRegistryKeysWithTypeRequest( + {required final List scope, + final String? domain}) = _$IRegistryKeysWithTypeRequestImpl; + + factory _IRegistryKeysWithTypeRequest.fromJson(Map json) = + _$IRegistryKeysWithTypeRequestImpl.fromJson; + + @override + List get scope; + @override + String? get domain; + @override + @JsonKey(ignore: true) + _$$IRegistryKeysWithTypeRequestImplCopyWith< + _$IRegistryKeysWithTypeRequestImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/lib/src/data/i/registry/i_registry_keys_with_type_request.g.dart b/lib/src/data/i/registry/i_registry_keys_with_type_request.g.dart new file mode 100644 index 00000000..ac70751f --- /dev/null +++ b/lib/src/data/i/registry/i_registry_keys_with_type_request.g.dart @@ -0,0 +1,21 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'i_registry_keys_with_type_request.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$IRegistryKeysWithTypeRequestImpl _$$IRegistryKeysWithTypeRequestImplFromJson( + Map json) => + _$IRegistryKeysWithTypeRequestImpl( + scope: (json['scope'] as List).map((e) => e as String).toList(), + domain: json['domain'] as String?, + ); + +Map _$$IRegistryKeysWithTypeRequestImplToJson( + _$IRegistryKeysWithTypeRequestImpl instance) => + { + 'scope': instance.scope, + 'domain': instance.domain, + }; diff --git a/lib/src/data/i/registry/i_registry_scopes_with_domain_response.dart b/lib/src/data/i/registry/i_registry_scopes_with_domain_response.dart new file mode 100644 index 00000000..ca368822 --- /dev/null +++ b/lib/src/data/i/registry/i_registry_scopes_with_domain_response.dart @@ -0,0 +1,18 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'i_registry_scopes_with_domain_response.freezed.dart'; +part 'i_registry_scopes_with_domain_response.g.dart'; + +@freezed +class IRegistryScopesWithDomainResponse + with _$IRegistryScopesWithDomainResponse { + const factory IRegistryScopesWithDomainResponse({ + required List> scopes, + String? domain, + }) = _IRegistryScopesWithDomainResponse; + + factory IRegistryScopesWithDomainResponse.fromJson( + Map json, + ) => + _$IRegistryScopesWithDomainResponseFromJson(json); +} diff --git a/lib/src/data/i/registry/i_registry_scopes_with_domain_response.freezed.dart b/lib/src/data/i/registry/i_registry_scopes_with_domain_response.freezed.dart new file mode 100644 index 00000000..8dde74c0 --- /dev/null +++ b/lib/src/data/i/registry/i_registry_scopes_with_domain_response.freezed.dart @@ -0,0 +1,192 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'i_registry_scopes_with_domain_response.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +IRegistryScopesWithDomainResponse _$IRegistryScopesWithDomainResponseFromJson( + Map json) { + return _IRegistryScopesWithDomainResponse.fromJson(json); +} + +/// @nodoc +mixin _$IRegistryScopesWithDomainResponse { + List> get scopes => throw _privateConstructorUsedError; + String? get domain => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $IRegistryScopesWithDomainResponseCopyWith + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $IRegistryScopesWithDomainResponseCopyWith<$Res> { + factory $IRegistryScopesWithDomainResponseCopyWith( + IRegistryScopesWithDomainResponse value, + $Res Function(IRegistryScopesWithDomainResponse) then) = + _$IRegistryScopesWithDomainResponseCopyWithImpl<$Res, + IRegistryScopesWithDomainResponse>; + @useResult + $Res call({List> scopes, String? domain}); +} + +/// @nodoc +class _$IRegistryScopesWithDomainResponseCopyWithImpl<$Res, + $Val extends IRegistryScopesWithDomainResponse> + implements $IRegistryScopesWithDomainResponseCopyWith<$Res> { + _$IRegistryScopesWithDomainResponseCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? scopes = null, + Object? domain = freezed, + }) { + return _then(_value.copyWith( + scopes: null == scopes + ? _value.scopes + : scopes // ignore: cast_nullable_to_non_nullable + as List>, + domain: freezed == domain + ? _value.domain + : domain // ignore: cast_nullable_to_non_nullable + as String?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$IRegistryScopesWithDomainResponseImplCopyWith<$Res> + implements $IRegistryScopesWithDomainResponseCopyWith<$Res> { + factory _$$IRegistryScopesWithDomainResponseImplCopyWith( + _$IRegistryScopesWithDomainResponseImpl value, + $Res Function(_$IRegistryScopesWithDomainResponseImpl) then) = + __$$IRegistryScopesWithDomainResponseImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({List> scopes, String? domain}); +} + +/// @nodoc +class __$$IRegistryScopesWithDomainResponseImplCopyWithImpl<$Res> + extends _$IRegistryScopesWithDomainResponseCopyWithImpl<$Res, + _$IRegistryScopesWithDomainResponseImpl> + implements _$$IRegistryScopesWithDomainResponseImplCopyWith<$Res> { + __$$IRegistryScopesWithDomainResponseImplCopyWithImpl( + _$IRegistryScopesWithDomainResponseImpl _value, + $Res Function(_$IRegistryScopesWithDomainResponseImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? scopes = null, + Object? domain = freezed, + }) { + return _then(_$IRegistryScopesWithDomainResponseImpl( + scopes: null == scopes + ? _value._scopes + : scopes // ignore: cast_nullable_to_non_nullable + as List>, + domain: freezed == domain + ? _value.domain + : domain // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$IRegistryScopesWithDomainResponseImpl + implements _IRegistryScopesWithDomainResponse { + const _$IRegistryScopesWithDomainResponseImpl( + {required final List> scopes, this.domain}) + : _scopes = scopes; + + factory _$IRegistryScopesWithDomainResponseImpl.fromJson( + Map json) => + _$$IRegistryScopesWithDomainResponseImplFromJson(json); + + final List> _scopes; + @override + List> get scopes { + if (_scopes is EqualUnmodifiableListView) return _scopes; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_scopes); + } + + @override + final String? domain; + + @override + String toString() { + return 'IRegistryScopesWithDomainResponse(scopes: $scopes, domain: $domain)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$IRegistryScopesWithDomainResponseImpl && + const DeepCollectionEquality().equals(other._scopes, _scopes) && + (identical(other.domain, domain) || other.domain == domain)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, const DeepCollectionEquality().hash(_scopes), domain); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$IRegistryScopesWithDomainResponseImplCopyWith< + _$IRegistryScopesWithDomainResponseImpl> + get copyWith => __$$IRegistryScopesWithDomainResponseImplCopyWithImpl< + _$IRegistryScopesWithDomainResponseImpl>(this, _$identity); + + @override + Map toJson() { + return _$$IRegistryScopesWithDomainResponseImplToJson( + this, + ); + } +} + +abstract class _IRegistryScopesWithDomainResponse + implements IRegistryScopesWithDomainResponse { + const factory _IRegistryScopesWithDomainResponse( + {required final List> scopes, + final String? domain}) = _$IRegistryScopesWithDomainResponseImpl; + + factory _IRegistryScopesWithDomainResponse.fromJson( + Map json) = + _$IRegistryScopesWithDomainResponseImpl.fromJson; + + @override + List> get scopes; + @override + String? get domain; + @override + @JsonKey(ignore: true) + _$$IRegistryScopesWithDomainResponseImplCopyWith< + _$IRegistryScopesWithDomainResponseImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/lib/src/data/i/registry/i_registry_scopes_with_domain_response.g.dart b/lib/src/data/i/registry/i_registry_scopes_with_domain_response.g.dart new file mode 100644 index 00000000..b84105e8 --- /dev/null +++ b/lib/src/data/i/registry/i_registry_scopes_with_domain_response.g.dart @@ -0,0 +1,24 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'i_registry_scopes_with_domain_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$IRegistryScopesWithDomainResponseImpl + _$$IRegistryScopesWithDomainResponseImplFromJson( + Map json) => + _$IRegistryScopesWithDomainResponseImpl( + scopes: (json['scopes'] as List) + .map((e) => (e as List).map((e) => e as String).toList()) + .toList(), + domain: json['domain'] as String?, + ); + +Map _$$IRegistryScopesWithDomainResponseImplToJson( + _$IRegistryScopesWithDomainResponseImpl instance) => + { + 'scopes': instance.scopes, + 'domain': instance.domain, + }; diff --git a/lib/src/data/i/registry/i_registry_set_request.dart b/lib/src/data/i/registry/i_registry_set_request.dart index 6b88e1fd..185e618c 100644 --- a/lib/src/data/i/registry/i_registry_set_request.dart +++ b/lib/src/data/i/registry/i_registry_set_request.dart @@ -7,7 +7,7 @@ part 'i_registry_set_request.g.dart'; class IRegistrySetRequest with _$IRegistrySetRequest { const factory IRegistrySetRequest({ required String key, - required String value, + required dynamic value, required List scope, String? domain, }) = _IRegistrySetRequest; diff --git a/lib/src/data/i/registry/i_registry_set_request.freezed.dart b/lib/src/data/i/registry/i_registry_set_request.freezed.dart index e392eb87..423f48e2 100644 --- a/lib/src/data/i/registry/i_registry_set_request.freezed.dart +++ b/lib/src/data/i/registry/i_registry_set_request.freezed.dart @@ -21,7 +21,7 @@ IRegistrySetRequest _$IRegistrySetRequestFromJson(Map json) { /// @nodoc mixin _$IRegistrySetRequest { String get key => throw _privateConstructorUsedError; - String get value => throw _privateConstructorUsedError; + dynamic get value => throw _privateConstructorUsedError; List get scope => throw _privateConstructorUsedError; String? get domain => throw _privateConstructorUsedError; @@ -37,7 +37,7 @@ abstract class $IRegistrySetRequestCopyWith<$Res> { IRegistrySetRequest value, $Res Function(IRegistrySetRequest) then) = _$IRegistrySetRequestCopyWithImpl<$Res, IRegistrySetRequest>; @useResult - $Res call({String key, String value, List scope, String? domain}); + $Res call({String key, dynamic value, List scope, String? domain}); } /// @nodoc @@ -54,7 +54,7 @@ class _$IRegistrySetRequestCopyWithImpl<$Res, $Val extends IRegistrySetRequest> @override $Res call({ Object? key = null, - Object? value = null, + Object? value = freezed, Object? scope = null, Object? domain = freezed, }) { @@ -63,10 +63,10 @@ class _$IRegistrySetRequestCopyWithImpl<$Res, $Val extends IRegistrySetRequest> ? _value.key : key // ignore: cast_nullable_to_non_nullable as String, - value: null == value + value: freezed == value ? _value.value : value // ignore: cast_nullable_to_non_nullable - as String, + as dynamic, scope: null == scope ? _value.scope : scope // ignore: cast_nullable_to_non_nullable @@ -87,7 +87,7 @@ abstract class _$$IRegistrySetRequestImplCopyWith<$Res> __$$IRegistrySetRequestImplCopyWithImpl<$Res>; @override @useResult - $Res call({String key, String value, List scope, String? domain}); + $Res call({String key, dynamic value, List scope, String? domain}); } /// @nodoc @@ -102,7 +102,7 @@ class __$$IRegistrySetRequestImplCopyWithImpl<$Res> @override $Res call({ Object? key = null, - Object? value = null, + Object? value = freezed, Object? scope = null, Object? domain = freezed, }) { @@ -111,10 +111,10 @@ class __$$IRegistrySetRequestImplCopyWithImpl<$Res> ? _value.key : key // ignore: cast_nullable_to_non_nullable as String, - value: null == value + value: freezed == value ? _value.value : value // ignore: cast_nullable_to_non_nullable - as String, + as dynamic, scope: null == scope ? _value._scope : scope // ignore: cast_nullable_to_non_nullable @@ -143,7 +143,7 @@ class _$IRegistrySetRequestImpl implements _IRegistrySetRequest { @override final String key; @override - final String value; + final dynamic value; final List _scope; @override List get scope { @@ -166,15 +166,19 @@ class _$IRegistrySetRequestImpl implements _IRegistrySetRequest { (other.runtimeType == runtimeType && other is _$IRegistrySetRequestImpl && (identical(other.key, key) || other.key == key) && - (identical(other.value, value) || other.value == value) && + const DeepCollectionEquality().equals(other.value, value) && const DeepCollectionEquality().equals(other._scope, _scope) && (identical(other.domain, domain) || other.domain == domain)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, key, value, - const DeepCollectionEquality().hash(_scope), domain); + int get hashCode => Object.hash( + runtimeType, + key, + const DeepCollectionEquality().hash(value), + const DeepCollectionEquality().hash(_scope), + domain); @JsonKey(ignore: true) @override @@ -194,7 +198,7 @@ class _$IRegistrySetRequestImpl implements _IRegistrySetRequest { abstract class _IRegistrySetRequest implements IRegistrySetRequest { const factory _IRegistrySetRequest( {required final String key, - required final String value, + required final dynamic value, required final List scope, final String? domain}) = _$IRegistrySetRequestImpl; @@ -204,7 +208,7 @@ abstract class _IRegistrySetRequest implements IRegistrySetRequest { @override String get key; @override - String get value; + dynamic get value; @override List get scope; @override diff --git a/lib/src/data/i/registry/i_registry_set_request.g.dart b/lib/src/data/i/registry/i_registry_set_request.g.dart index 16b000f0..d7a7f956 100644 --- a/lib/src/data/i/registry/i_registry_set_request.g.dart +++ b/lib/src/data/i/registry/i_registry_set_request.g.dart @@ -10,7 +10,7 @@ _$IRegistrySetRequestImpl _$$IRegistrySetRequestImplFromJson( Map json) => _$IRegistrySetRequestImpl( key: json['key'] as String, - value: json['value'] as String, + value: json['value'], scope: (json['scope'] as List).map((e) => e as String).toList(), domain: json['domain'] as String?, ); diff --git a/lib/src/misskey_i.dart b/lib/src/misskey_i.dart index a01bc56d..10880181 100644 --- a/lib/src/misskey_i.dart +++ b/lib/src/misskey_i.dart @@ -1,8 +1,6 @@ +import 'dart:convert'; + import 'package:misskey_dart/misskey_dart.dart'; -import 'package:misskey_dart/src/data/i/registry/i_registry_get_all_request.dart'; -import 'package:misskey_dart/src/data/i/registry/i_registry_get_detail_request.dart'; -import 'package:misskey_dart/src/data/i/registry/i_registry_remove_request.dart'; -import 'package:misskey_dart/src/data/i/registry/i_registry_set_request.dart'; import 'package:misskey_dart/src/services/api_service.dart'; class MisskeyI { @@ -55,7 +53,8 @@ class MisskeyIRegistry { MisskeyIRegistry({required ApiService apiService}) : _apiService = apiService; - Future getAll(IRegistryGetAllRequest request) async { + /// 指定したスコープの全てのキーと値を取得します。 + Future> getAll(IRegistryGetAllRequest request) async { final response = await _apiService.post>( "i/registry/get-all", request.toJson(), @@ -63,33 +62,72 @@ class MisskeyIRegistry { return response; } - Future getDetail(IRegistryGetDetailRequest request) async { + /// 指定したキーに対応した値と更新日時を取得します。 + Future getDetail( + IRegistryGetDetailRequest request, + ) async { final response = await _apiService.post>( "i/registry/get-detail", request.toJson(), ); - return response; + return IRegistryGetDetailResponse.fromJson(response); } - Future get(IRegistryGetRequest request) async { - final response = await _apiService.post>( + /// 指定したキーに対応した値を取得します。 + Future get(IRegistryGetRequest request) async { + final response = await _apiService.post( "i/registry/get", request.toJson(), ); - return response; + if (response is String) { + if (response.isEmpty) { + return null; + } else { + return jsonDecode(response); + } + } else { + return response; + } } - Future remove(IRegistryRemoveRequest request) async { - await _apiService.post>( - "i/registry/remove", + /// 指定したスコープの全てのキーと型を取得します。 + Future> keysWithType( + IRegistryKeysWithTypeRequest request, + ) async { + final response = await _apiService.post>( + "i/registry/keys-with-type", + request.toJson(), + ); + return response.map((key, value) => MapEntry(key, value as String)); + } + + /// 指定したスコープの全てのキーを取得します。 + Future> keys(IRegistryKeysRequest request) async { + final response = await _apiService.post( + "i/registry/keys", request.toJson(), ); + return response.whereType(); + } + + /// 指定したキーを削除します。 + Future remove(IRegistryRemoveRequest request) async { + await _apiService.post("i/registry/remove", request.toJson()); + } + + /// 全てのドメインの全てのスコープを取得します。 + Future> scopesWithDomain() async { + final response = + await _apiService.post("i/registry/scopes-with-domain", {}); + return response.map((e) => IRegistryScopesWithDomainResponse.fromJson(e)); } + /// 指定したキーに値を設定します。 Future set(IRegistrySetRequest request) async { - await _apiService.post>( + await _apiService.post( "i/registry/set", request.toJson(), + excludeRemoveNullPredicate: (key, _) => key == "value", ); } } diff --git a/test/misskey_i_test.dart b/test/misskey_i_test.dart index 474510ba..49737d30 100644 --- a/test/misskey_i_test.dart +++ b/test/misskey_i_test.dart @@ -1,5 +1,6 @@ import 'package:misskey_dart/misskey_dart.dart'; import 'package:test/test.dart'; +import 'package:uuid/uuid.dart'; import 'util/misskey_dart_test_util.dart'; @@ -48,4 +49,184 @@ void main() async { test("update", () async { await userClient.i.update(IUpdateRequest()); }); + + group("registry", () { + test("getAll", () async { + final key = Uuid().v4(); + await userClient.i.registry.set( + IRegistrySetRequest( + key: key, + value: "test", + scope: [], + ), + ); + final response = + await userClient.i.registry.getAll(IRegistryGetAllRequest(scope: [])); + expect(response[key], equals("test")); + }); + + test("getDetail", () async { + final key = Uuid().v4(); + await userClient.i.registry.set( + IRegistrySetRequest( + key: key, + value: "test", + scope: [], + ), + ); + final response = await userClient.i.registry + .getDetail(IRegistryGetDetailRequest(key: key, scope: [])); + expect(response.value, equals("test")); + }); + + test("get", () async { + final key = Uuid().v4(); + await userClient.i.registry.set( + IRegistrySetRequest( + key: key, + value: "test", + scope: [], + ), + ); + final response = await userClient.i.registry + .get(IRegistryGetRequest(key: key, scope: [])); + expect(response, equals("test")); + }); + + test("keysWithType", () async { + final nullKey = Uuid().v4(); + await userClient.i.registry.set( + IRegistrySetRequest( + key: nullKey, + value: null, + scope: [], + ), + ); + final arrayKey = Uuid().v4(); + await userClient.i.registry.set( + IRegistrySetRequest( + key: arrayKey, + value: [1, 2], + scope: [], + ), + ); + final numberKey = Uuid().v4(); + await userClient.i.registry.set( + IRegistrySetRequest( + key: numberKey, + value: 1.2, + scope: [], + ), + ); + final stringKey = Uuid().v4(); + await userClient.i.registry.set( + IRegistrySetRequest( + key: stringKey, + value: "test", + scope: [], + ), + ); + final booleanKey = Uuid().v4(); + await userClient.i.registry.set( + IRegistrySetRequest( + key: booleanKey, + value: false, + scope: [], + ), + ); + final objectKey = Uuid().v4(); + await userClient.i.registry.set( + IRegistrySetRequest( + key: objectKey, + value: {'key': 'value'}, + scope: [], + ), + ); + final response = await userClient.i.registry + .keysWithType(IRegistryKeysWithTypeRequest(scope: [])); + expect(response[nullKey], equals("null")); + final nullValue = await userClient.i.registry + .get(IRegistryGetRequest(key: nullKey, scope: [])); + // ignore: prefer_void_to_null + expect(nullValue, isA()); + expect(response[arrayKey], equals("array")); + final arrayValue = await userClient.i.registry + .get(IRegistryGetRequest(key: arrayKey, scope: [])); + expect(arrayValue, isA()); + expect(response[numberKey], equals("number")); + final numberValue = await userClient.i.registry + .get(IRegistryGetRequest(key: numberKey, scope: [])); + expect(numberValue, isA()); + expect(response[stringKey], equals("string")); + final stringValue = await userClient.i.registry + .get(IRegistryGetRequest(key: stringKey, scope: [])); + expect(stringValue, isA()); + expect(response[booleanKey], equals("boolean")); + final booleanValue = await userClient.i.registry + .get(IRegistryGetRequest(key: booleanKey, scope: [])); + expect(booleanValue, isA()); + expect(response[objectKey], equals("object")); + final objectValue = await userClient.i.registry + .get(IRegistryGetRequest(key: objectKey, scope: [])); + expect(objectValue, isA()); + }); + + test("keys", () async { + final key = Uuid().v4(); + await userClient.i.registry.set( + IRegistrySetRequest( + key: key, + value: "test", + scope: [], + ), + ); + final response = + await userClient.i.registry.keys(IRegistryKeysRequest(scope: [])); + expect(response, contains(key)); + }); + + test("remove", () async { + final key = Uuid().v4(); + await userClient.i.registry.set( + IRegistrySetRequest( + key: key, + value: "test", + scope: [], + ), + ); + await userClient.i.registry + .remove(IRegistryRemoveRequest(key: key, scope: [])); + final keys = + await userClient.i.registry.keys(IRegistryKeysRequest(scope: [])); + expect(keys, isNot(contains(key))); + }); + + test("scopes-with-domain", () async { + final key = Uuid().v4(); + final scope = Uuid().v4().replaceAll('-', '_'); + await userClient.i.registry.set( + IRegistrySetRequest( + key: key, + value: "test", + scope: [scope], + ), + ); + final response = await userClient.i.registry.scopesWithDomain(); + expect( + response.map((e) => e.scopes), + anyElement(anyElement(contains(scope))), + ); + }); + + test("set", () async { + final key = Uuid().v4(); + await userClient.i.registry.set( + IRegistrySetRequest( + key: key, + value: "test", + scope: [], + ), + ); + }); + }); }