diff --git a/lib/src/endpoints.dart b/lib/src/endpoints.dart index ee3ac36..0cb436f 100644 --- a/lib/src/endpoints.dart +++ b/lib/src/endpoints.dart @@ -2,8 +2,7 @@ import 'models/search_order.dart'; /// Pub.dev api Endpoints class Endpoint { - static const defaultBaseUrl = - 'https://pub.dartlang.org'; // Use pub.dev instead? + static const defaultBaseUrl = 'https://pub.dev'; final String baseUrl; late final String apiUrl; @@ -60,7 +59,7 @@ class Endpoint { int page, SearchOrder sort, ) => - '$searchUrl?q=$query&page=$page&sort=${sort.value}'; + '$searchUrl?q=$query&page=$page&sort=${sort.name}'; /// Next search page String nextPage(String nextPageUrl) => diff --git a/lib/src/models/barrel.dart b/lib/src/models/barrel.dart index 0047681..814050f 100644 --- a/lib/src/models/barrel.dart +++ b/lib/src/models/barrel.dart @@ -1,7 +1,10 @@ +export 'package:pub_api_client/src/models/latest_version_model.dart'; export 'package:pub_api_client/src/models/package_documentation_model.dart'; +export 'package:pub_api_client/src/models/package_like_model.dart'; export 'package:pub_api_client/src/models/package_metrics_model.dart'; export 'package:pub_api_client/src/models/package_options_model.dart'; export 'package:pub_api_client/src/models/package_publisher_model.dart'; +export 'package:pub_api_client/src/models/package_score_card.dart'; export 'package:pub_api_client/src/models/package_score_model.dart'; export 'package:pub_api_client/src/models/pub_package_model.dart'; export 'package:pub_api_client/src/models/pubspec_extensions.dart'; diff --git a/lib/src/models/latest_version_model.dart b/lib/src/models/latest_version_model.dart index 32d50d2..ba70bef 100644 --- a/lib/src/models/latest_version_model.dart +++ b/lib/src/models/latest_version_model.dart @@ -1,7 +1,12 @@ -import 'pub_package_model.dart'; +import 'package:dart_mappable/dart_mappable.dart'; + +import '../../pub_api_client.dart'; + +part 'latest_version_model.mapper.dart'; /// Latest Version update for package -class LatestVersion { +@MappableClass() +class LatestVersion with LatestVersionMappable { final bool needUpdate; final String latestVersion; final PubPackage packageInfo; @@ -13,21 +18,6 @@ class LatestVersion { required this.packageInfo, }); - @override - bool operator ==(Object other) { - if (identical(this, other)) return true; - - return other is LatestVersion && - other.needUpdate == needUpdate && - other.latestVersion == latestVersion && - other.packageInfo == packageInfo; - } - - @override - int get hashCode => - needUpdate.hashCode ^ latestVersion.hashCode ^ packageInfo.hashCode; - - @override - String toString() => - '''LatestVersion(needUpdate: $needUpdate, latestVersion: $latestVersion, packageInfo: $packageInfo)'''; + static const fromMap = LatestVersionMapper.fromMap; + static const fromJson = LatestVersionMapper.fromJson; } diff --git a/lib/src/models/latest_version_model.mapper.dart b/lib/src/models/latest_version_model.mapper.dart new file mode 100644 index 0000000..a10549b --- /dev/null +++ b/lib/src/models/latest_version_model.mapper.dart @@ -0,0 +1,136 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, unnecessary_cast +// ignore_for_file: strict_raw_type, inference_failure_on_untyped_parameter + +part of 'latest_version_model.dart'; + +class LatestVersionMapper extends ClassMapperBase { + LatestVersionMapper._(); + + static LatestVersionMapper? _instance; + static LatestVersionMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = LatestVersionMapper._()); + PubPackageMapper.ensureInitialized(); + } + return _instance!; + } + + @override + final String id = 'LatestVersion'; + + static bool _$needUpdate(LatestVersion v) => v.needUpdate; + static const Field _f$needUpdate = + Field('needUpdate', _$needUpdate); + static String _$latestVersion(LatestVersion v) => v.latestVersion; + static const Field _f$latestVersion = + Field('latestVersion', _$latestVersion); + static PubPackage _$packageInfo(LatestVersion v) => v.packageInfo; + static const Field _f$packageInfo = + Field('packageInfo', _$packageInfo); + + @override + final MappableFields fields = const { + #needUpdate: _f$needUpdate, + #latestVersion: _f$latestVersion, + #packageInfo: _f$packageInfo, + }; + + static LatestVersion _instantiate(DecodingData data) { + return LatestVersion( + needUpdate: data.dec(_f$needUpdate), + latestVersion: data.dec(_f$latestVersion), + packageInfo: data.dec(_f$packageInfo)); + } + + @override + final Function instantiate = _instantiate; + + static LatestVersion fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static LatestVersion fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin LatestVersionMappable { + String toJson() { + return LatestVersionMapper.ensureInitialized() + .encodeJson(this as LatestVersion); + } + + Map toMap() { + return LatestVersionMapper.ensureInitialized() + .encodeMap(this as LatestVersion); + } + + LatestVersionCopyWith + get copyWith => _LatestVersionCopyWithImpl( + this as LatestVersion, $identity, $identity); + @override + String toString() { + return LatestVersionMapper.ensureInitialized() + .stringifyValue(this as LatestVersion); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (runtimeType == other.runtimeType && + LatestVersionMapper.ensureInitialized() + .isValueEqual(this as LatestVersion, other)); + } + + @override + int get hashCode { + return LatestVersionMapper.ensureInitialized() + .hashValue(this as LatestVersion); + } +} + +extension LatestVersionValueCopy<$R, $Out> + on ObjectCopyWith<$R, LatestVersion, $Out> { + LatestVersionCopyWith<$R, LatestVersion, $Out> get $asLatestVersion => + $base.as((v, t, t2) => _LatestVersionCopyWithImpl(v, t, t2)); +} + +abstract class LatestVersionCopyWith<$R, $In extends LatestVersion, $Out> + implements ClassCopyWith<$R, $In, $Out> { + PubPackageCopyWith<$R, PubPackage, PubPackage> get packageInfo; + $R call({bool? needUpdate, String? latestVersion, PubPackage? packageInfo}); + LatestVersionCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t); +} + +class _LatestVersionCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, LatestVersion, $Out> + implements LatestVersionCopyWith<$R, LatestVersion, $Out> { + _LatestVersionCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + LatestVersionMapper.ensureInitialized(); + @override + PubPackageCopyWith<$R, PubPackage, PubPackage> get packageInfo => + $value.packageInfo.copyWith.$chain((v) => call(packageInfo: v)); + @override + $R call({bool? needUpdate, String? latestVersion, PubPackage? packageInfo}) => + $apply(FieldCopyWithData({ + if (needUpdate != null) #needUpdate: needUpdate, + if (latestVersion != null) #latestVersion: latestVersion, + if (packageInfo != null) #packageInfo: packageInfo + })); + @override + LatestVersion $make(CopyWithData data) => LatestVersion( + needUpdate: data.get(#needUpdate, or: $value.needUpdate), + latestVersion: data.get(#latestVersion, or: $value.latestVersion), + packageInfo: data.get(#packageInfo, or: $value.packageInfo)); + + @override + LatestVersionCopyWith<$R2, LatestVersion, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t) => + _LatestVersionCopyWithImpl($value, $cast, t); +} diff --git a/lib/src/models/package_documentation_model.dart b/lib/src/models/package_documentation_model.dart index 96994a3..f63a093 100644 --- a/lib/src/models/package_documentation_model.dart +++ b/lib/src/models/package_documentation_model.dart @@ -1,10 +1,10 @@ -import 'dart:convert'; +import 'package:dart_mappable/dart_mappable.dart'; -import 'package:collection/collection.dart'; +part 'package_documentation_model.mapper.dart'; /// Package Documentation Model - -class PackageDocumentation { +@MappableClass() +class PackageDocumentation with PackageDocumentationMappable { final String name; final List versions; @@ -13,47 +13,13 @@ class PackageDocumentation { this.versions = const [], }); - Map toMap() => { - 'name': name, - 'versions': versions.map((x) => x.toMap()).toList(), - }; - - factory PackageDocumentation.fromMap(Map map) { - final versionMap = map['versions'] as List? ?? []; - - return PackageDocumentation( - name: map['name'] as String? ?? '', - versions: versionMap - .map((x) => - PackageDocumentationVersion.fromMap(x as Map)) - .toList(), - ); - } - String toJson() => json.encode(toMap()); - - factory PackageDocumentation.fromJson(String source) => - PackageDocumentation.fromMap(json.decode(source) as Map); - - @override - bool operator ==(Object other) { - if (identical(this, other)) return true; - final listEquals = const DeepCollectionEquality().equals; - - return other is PackageDocumentation && - other.name == name && - listEquals(other.versions, versions); - } - - @override - int get hashCode => name.hashCode ^ versions.hashCode; - - @override - String toString() => 'PackageDocumentation(name: $name, versions: $versions)'; + static const fromMap = PackageDocumentationMapper.fromMap; + static const fromJson = PackageDocumentationMapper.fromJson; } /// Package Documentation Version Model - -class PackageDocumentationVersion { +@MappableClass() +class PackageDocumentationVersion with PackageDocumentationVersionMappable { final String version; final String status; final bool hasDocumentation; @@ -63,40 +29,6 @@ class PackageDocumentationVersion { required this.hasDocumentation, }); - Map toMap() => { - 'version': version, - 'status': status, - 'hasDocumentation': hasDocumentation, - }; - - factory PackageDocumentationVersion.fromMap(Map map) => - PackageDocumentationVersion( - version: map['version'] as String? ?? '', - status: map['status'] as String? ?? '', - hasDocumentation: map['hasDocumentation'] as bool? ?? false, - ); - - String toJson() => json.encode(toMap()); - - factory PackageDocumentationVersion.fromJson(String source) => - PackageDocumentationVersion.fromMap( - json.decode(source) as Map); - - @override - bool operator ==(Object other) { - if (identical(this, other)) return true; - - return other is PackageDocumentationVersion && - other.version == version && - other.status == status && - other.hasDocumentation == hasDocumentation; - } - - @override - int get hashCode => - version.hashCode ^ status.hashCode ^ hasDocumentation.hashCode; - - @override - String toString() => - '''PackageDocumentationVersion(version: $version, status: $status, hasDocumentation: $hasDocumentation)'''; + static const fromMap = PackageDocumentationVersionMapper.fromMap; + static const fromJson = PackageDocumentationVersionMapper.fromJson; } diff --git a/lib/src/models/package_documentation_model.mapper.dart b/lib/src/models/package_documentation_model.mapper.dart new file mode 100644 index 0000000..406ba8a --- /dev/null +++ b/lib/src/models/package_documentation_model.mapper.dart @@ -0,0 +1,283 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, unnecessary_cast +// ignore_for_file: strict_raw_type, inference_failure_on_untyped_parameter + +part of 'package_documentation_model.dart'; + +class PackageDocumentationMapper extends ClassMapperBase { + PackageDocumentationMapper._(); + + static PackageDocumentationMapper? _instance; + static PackageDocumentationMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = PackageDocumentationMapper._()); + PackageDocumentationVersionMapper.ensureInitialized(); + } + return _instance!; + } + + @override + final String id = 'PackageDocumentation'; + + static String _$name(PackageDocumentation v) => v.name; + static const Field _f$name = + Field('name', _$name); + static List _$versions(PackageDocumentation v) => + v.versions; + static const Field> + _f$versions = Field('versions', _$versions, opt: true, def: const []); + + @override + final MappableFields fields = const { + #name: _f$name, + #versions: _f$versions, + }; + + static PackageDocumentation _instantiate(DecodingData data) { + return PackageDocumentation( + name: data.dec(_f$name), versions: data.dec(_f$versions)); + } + + @override + final Function instantiate = _instantiate; + + static PackageDocumentation fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static PackageDocumentation fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin PackageDocumentationMappable { + String toJson() { + return PackageDocumentationMapper.ensureInitialized() + .encodeJson(this as PackageDocumentation); + } + + Map toMap() { + return PackageDocumentationMapper.ensureInitialized() + .encodeMap(this as PackageDocumentation); + } + + PackageDocumentationCopyWith + get copyWith => _PackageDocumentationCopyWithImpl( + this as PackageDocumentation, $identity, $identity); + @override + String toString() { + return PackageDocumentationMapper.ensureInitialized() + .stringifyValue(this as PackageDocumentation); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (runtimeType == other.runtimeType && + PackageDocumentationMapper.ensureInitialized() + .isValueEqual(this as PackageDocumentation, other)); + } + + @override + int get hashCode { + return PackageDocumentationMapper.ensureInitialized() + .hashValue(this as PackageDocumentation); + } +} + +extension PackageDocumentationValueCopy<$R, $Out> + on ObjectCopyWith<$R, PackageDocumentation, $Out> { + PackageDocumentationCopyWith<$R, PackageDocumentation, $Out> + get $asPackageDocumentation => + $base.as((v, t, t2) => _PackageDocumentationCopyWithImpl(v, t, t2)); +} + +abstract class PackageDocumentationCopyWith< + $R, + $In extends PackageDocumentation, + $Out> implements ClassCopyWith<$R, $In, $Out> { + ListCopyWith< + $R, + PackageDocumentationVersion, + PackageDocumentationVersionCopyWith<$R, PackageDocumentationVersion, + PackageDocumentationVersion>> get versions; + $R call({String? name, List? versions}); + PackageDocumentationCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t); +} + +class _PackageDocumentationCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, PackageDocumentation, $Out> + implements PackageDocumentationCopyWith<$R, PackageDocumentation, $Out> { + _PackageDocumentationCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + PackageDocumentationMapper.ensureInitialized(); + @override + ListCopyWith< + $R, + PackageDocumentationVersion, + PackageDocumentationVersionCopyWith<$R, PackageDocumentationVersion, + PackageDocumentationVersion>> get versions => ListCopyWith( + $value.versions, + (v, t) => v.copyWith.$chain(t), + (v) => call(versions: v)); + @override + $R call({String? name, List? versions}) => + $apply(FieldCopyWithData({ + if (name != null) #name: name, + if (versions != null) #versions: versions + })); + @override + PackageDocumentation $make(CopyWithData data) => PackageDocumentation( + name: data.get(#name, or: $value.name), + versions: data.get(#versions, or: $value.versions)); + + @override + PackageDocumentationCopyWith<$R2, PackageDocumentation, $Out2> + $chain<$R2, $Out2>(Then<$Out2, $R2> t) => + _PackageDocumentationCopyWithImpl($value, $cast, t); +} + +class PackageDocumentationVersionMapper + extends ClassMapperBase { + PackageDocumentationVersionMapper._(); + + static PackageDocumentationVersionMapper? _instance; + static PackageDocumentationVersionMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals + .use(_instance = PackageDocumentationVersionMapper._()); + } + return _instance!; + } + + @override + final String id = 'PackageDocumentationVersion'; + + static String _$version(PackageDocumentationVersion v) => v.version; + static const Field _f$version = + Field('version', _$version); + static String _$status(PackageDocumentationVersion v) => v.status; + static const Field _f$status = + Field('status', _$status); + static bool _$hasDocumentation(PackageDocumentationVersion v) => + v.hasDocumentation; + static const Field _f$hasDocumentation = + Field('hasDocumentation', _$hasDocumentation); + + @override + final MappableFields fields = const { + #version: _f$version, + #status: _f$status, + #hasDocumentation: _f$hasDocumentation, + }; + + static PackageDocumentationVersion _instantiate(DecodingData data) { + return PackageDocumentationVersion( + version: data.dec(_f$version), + status: data.dec(_f$status), + hasDocumentation: data.dec(_f$hasDocumentation)); + } + + @override + final Function instantiate = _instantiate; + + static PackageDocumentationVersion fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static PackageDocumentationVersion fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin PackageDocumentationVersionMappable { + String toJson() { + return PackageDocumentationVersionMapper.ensureInitialized() + .encodeJson( + this as PackageDocumentationVersion); + } + + Map toMap() { + return PackageDocumentationVersionMapper.ensureInitialized() + .encodeMap( + this as PackageDocumentationVersion); + } + + PackageDocumentationVersionCopyWith + get copyWith => _PackageDocumentationVersionCopyWithImpl( + this as PackageDocumentationVersion, $identity, $identity); + @override + String toString() { + return PackageDocumentationVersionMapper.ensureInitialized() + .stringifyValue(this as PackageDocumentationVersion); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (runtimeType == other.runtimeType && + PackageDocumentationVersionMapper.ensureInitialized() + .isValueEqual(this as PackageDocumentationVersion, other)); + } + + @override + int get hashCode { + return PackageDocumentationVersionMapper.ensureInitialized() + .hashValue(this as PackageDocumentationVersion); + } +} + +extension PackageDocumentationVersionValueCopy<$R, $Out> + on ObjectCopyWith<$R, PackageDocumentationVersion, $Out> { + PackageDocumentationVersionCopyWith<$R, PackageDocumentationVersion, $Out> + get $asPackageDocumentationVersion => $base + .as((v, t, t2) => _PackageDocumentationVersionCopyWithImpl(v, t, t2)); +} + +abstract class PackageDocumentationVersionCopyWith< + $R, + $In extends PackageDocumentationVersion, + $Out> implements ClassCopyWith<$R, $In, $Out> { + $R call({String? version, String? status, bool? hasDocumentation}); + PackageDocumentationVersionCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t); +} + +class _PackageDocumentationVersionCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, PackageDocumentationVersion, $Out> + implements + PackageDocumentationVersionCopyWith<$R, PackageDocumentationVersion, + $Out> { + _PackageDocumentationVersionCopyWithImpl( + super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + PackageDocumentationVersionMapper.ensureInitialized(); + @override + $R call({String? version, String? status, bool? hasDocumentation}) => + $apply(FieldCopyWithData({ + if (version != null) #version: version, + if (status != null) #status: status, + if (hasDocumentation != null) #hasDocumentation: hasDocumentation + })); + @override + PackageDocumentationVersion $make(CopyWithData data) => + PackageDocumentationVersion( + version: data.get(#version, or: $value.version), + status: data.get(#status, or: $value.status), + hasDocumentation: + data.get(#hasDocumentation, or: $value.hasDocumentation)); + + @override + PackageDocumentationVersionCopyWith<$R2, PackageDocumentationVersion, $Out2> + $chain<$R2, $Out2>(Then<$Out2, $R2> t) => + _PackageDocumentationVersionCopyWithImpl($value, $cast, t); +} diff --git a/lib/src/models/package_like_model.dart b/lib/src/models/package_like_model.dart index 3264c1b..c1595a8 100644 --- a/lib/src/models/package_like_model.dart +++ b/lib/src/models/package_like_model.dart @@ -1,6 +1,10 @@ -/// Package like +import 'package:dart_mappable/dart_mappable.dart'; + +part 'package_like_model.mapper.dart'; -class PackageLike { +/// Package like +@MappableClass() +class PackageLike with PackageLikeMappable { final String package; final bool liked; const PackageLike({ @@ -8,28 +12,6 @@ class PackageLike { required this.liked, }); - Map toMap() => { - 'package': package, - 'liked': liked, - }; - - factory PackageLike.fromMap(Map map) => PackageLike( - package: map['package'] as String? ?? '', - liked: map['liked'] as bool? ?? false, - ); - - @override - bool operator ==(Object other) { - if (identical(this, other)) return true; - - return other is PackageLike && - other.package == package && - other.liked == liked; - } - - @override - int get hashCode => package.hashCode ^ liked.hashCode; - - @override - String toString() => 'PackageLike(package: $package, liked: $liked)'; + static const fromMap = PackageLikeMapper.fromMap; + static const fromJson = PackageLikeMapper.fromJson; } diff --git a/lib/src/models/package_like_model.mapper.dart b/lib/src/models/package_like_model.mapper.dart new file mode 100644 index 0000000..89a96ee --- /dev/null +++ b/lib/src/models/package_like_model.mapper.dart @@ -0,0 +1,119 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, unnecessary_cast +// ignore_for_file: strict_raw_type, inference_failure_on_untyped_parameter + +part of 'package_like_model.dart'; + +class PackageLikeMapper extends ClassMapperBase { + PackageLikeMapper._(); + + static PackageLikeMapper? _instance; + static PackageLikeMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = PackageLikeMapper._()); + } + return _instance!; + } + + @override + final String id = 'PackageLike'; + + static String _$package(PackageLike v) => v.package; + static const Field _f$package = + Field('package', _$package); + static bool _$liked(PackageLike v) => v.liked; + static const Field _f$liked = Field('liked', _$liked); + + @override + final MappableFields fields = const { + #package: _f$package, + #liked: _f$liked, + }; + + static PackageLike _instantiate(DecodingData data) { + return PackageLike( + package: data.dec(_f$package), liked: data.dec(_f$liked)); + } + + @override + final Function instantiate = _instantiate; + + static PackageLike fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static PackageLike fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin PackageLikeMappable { + String toJson() { + return PackageLikeMapper.ensureInitialized() + .encodeJson(this as PackageLike); + } + + Map toMap() { + return PackageLikeMapper.ensureInitialized() + .encodeMap(this as PackageLike); + } + + PackageLikeCopyWith get copyWith => + _PackageLikeCopyWithImpl(this as PackageLike, $identity, $identity); + @override + String toString() { + return PackageLikeMapper.ensureInitialized() + .stringifyValue(this as PackageLike); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (runtimeType == other.runtimeType && + PackageLikeMapper.ensureInitialized() + .isValueEqual(this as PackageLike, other)); + } + + @override + int get hashCode { + return PackageLikeMapper.ensureInitialized().hashValue(this as PackageLike); + } +} + +extension PackageLikeValueCopy<$R, $Out> + on ObjectCopyWith<$R, PackageLike, $Out> { + PackageLikeCopyWith<$R, PackageLike, $Out> get $asPackageLike => + $base.as((v, t, t2) => _PackageLikeCopyWithImpl(v, t, t2)); +} + +abstract class PackageLikeCopyWith<$R, $In extends PackageLike, $Out> + implements ClassCopyWith<$R, $In, $Out> { + $R call({String? package, bool? liked}); + PackageLikeCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t); +} + +class _PackageLikeCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, PackageLike, $Out> + implements PackageLikeCopyWith<$R, PackageLike, $Out> { + _PackageLikeCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + PackageLikeMapper.ensureInitialized(); + @override + $R call({String? package, bool? liked}) => $apply(FieldCopyWithData({ + if (package != null) #package: package, + if (liked != null) #liked: liked + })); + @override + PackageLike $make(CopyWithData data) => PackageLike( + package: data.get(#package, or: $value.package), + liked: data.get(#liked, or: $value.liked)); + + @override + PackageLikeCopyWith<$R2, PackageLike, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t) => + _PackageLikeCopyWithImpl($value, $cast, t); +} diff --git a/lib/src/models/package_metrics_model.dart b/lib/src/models/package_metrics_model.dart index aac682e..9d17178 100644 --- a/lib/src/models/package_metrics_model.dart +++ b/lib/src/models/package_metrics_model.dart @@ -1,8 +1,12 @@ +import 'package:dart_mappable/dart_mappable.dart'; + import '../../pub_api_client.dart'; -/// Package Metrics Model +part 'package_metrics_model.mapper.dart'; -class PackageMetrics { +/// Package Metrics Model +@MappableClass() +class PackageMetrics with PackageMetricsMappable { final PackageScore score; final PackageScoreCard scorecard; const PackageMetrics({ @@ -10,29 +14,6 @@ class PackageMetrics { required this.scorecard, }); - Map toMap() => { - 'score': score.toMap(), - 'scorecard': scorecard.toMap(), - }; - - factory PackageMetrics.fromMap(Map map) => PackageMetrics( - score: PackageScore.fromMap(map['score'] as Map), - scorecard: - PackageScoreCard.fromMap(map['scorecard'] as Map), - ); - - @override - String toString() => 'PackageMetrics(score: $score, scorecard: $scorecard)'; - - @override - bool operator ==(Object other) { - if (identical(this, other)) return true; - - return other is PackageMetrics && - other.score == score && - other.scorecard == scorecard; - } - - @override - int get hashCode => score.hashCode ^ scorecard.hashCode; + static const fromMap = PackageMetricsMapper.fromMap; + static const fromJson = PackageMetricsMapper.fromJson; } diff --git a/lib/src/models/package_metrics_model.mapper.dart b/lib/src/models/package_metrics_model.mapper.dart new file mode 100644 index 0000000..b7c6eb8 --- /dev/null +++ b/lib/src/models/package_metrics_model.mapper.dart @@ -0,0 +1,136 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, unnecessary_cast +// ignore_for_file: strict_raw_type, inference_failure_on_untyped_parameter + +part of 'package_metrics_model.dart'; + +class PackageMetricsMapper extends ClassMapperBase { + PackageMetricsMapper._(); + + static PackageMetricsMapper? _instance; + static PackageMetricsMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = PackageMetricsMapper._()); + PackageScoreMapper.ensureInitialized(); + PackageScoreCardMapper.ensureInitialized(); + } + return _instance!; + } + + @override + final String id = 'PackageMetrics'; + + static PackageScore _$score(PackageMetrics v) => v.score; + static const Field _f$score = + Field('score', _$score); + static PackageScoreCard _$scorecard(PackageMetrics v) => v.scorecard; + static const Field _f$scorecard = + Field('scorecard', _$scorecard); + + @override + final MappableFields fields = const { + #score: _f$score, + #scorecard: _f$scorecard, + }; + + static PackageMetrics _instantiate(DecodingData data) { + return PackageMetrics( + score: data.dec(_f$score), scorecard: data.dec(_f$scorecard)); + } + + @override + final Function instantiate = _instantiate; + + static PackageMetrics fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static PackageMetrics fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin PackageMetricsMappable { + String toJson() { + return PackageMetricsMapper.ensureInitialized() + .encodeJson(this as PackageMetrics); + } + + Map toMap() { + return PackageMetricsMapper.ensureInitialized() + .encodeMap(this as PackageMetrics); + } + + PackageMetricsCopyWith + get copyWith => _PackageMetricsCopyWithImpl( + this as PackageMetrics, $identity, $identity); + @override + String toString() { + return PackageMetricsMapper.ensureInitialized() + .stringifyValue(this as PackageMetrics); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (runtimeType == other.runtimeType && + PackageMetricsMapper.ensureInitialized() + .isValueEqual(this as PackageMetrics, other)); + } + + @override + int get hashCode { + return PackageMetricsMapper.ensureInitialized() + .hashValue(this as PackageMetrics); + } +} + +extension PackageMetricsValueCopy<$R, $Out> + on ObjectCopyWith<$R, PackageMetrics, $Out> { + PackageMetricsCopyWith<$R, PackageMetrics, $Out> get $asPackageMetrics => + $base.as((v, t, t2) => _PackageMetricsCopyWithImpl(v, t, t2)); +} + +abstract class PackageMetricsCopyWith<$R, $In extends PackageMetrics, $Out> + implements ClassCopyWith<$R, $In, $Out> { + PackageScoreCopyWith<$R, PackageScore, PackageScore> get score; + PackageScoreCardCopyWith<$R, PackageScoreCard, PackageScoreCard> + get scorecard; + $R call({PackageScore? score, PackageScoreCard? scorecard}); + PackageMetricsCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t); +} + +class _PackageMetricsCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, PackageMetrics, $Out> + implements PackageMetricsCopyWith<$R, PackageMetrics, $Out> { + _PackageMetricsCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + PackageMetricsMapper.ensureInitialized(); + @override + PackageScoreCopyWith<$R, PackageScore, PackageScore> get score => + $value.score.copyWith.$chain((v) => call(score: v)); + @override + PackageScoreCardCopyWith<$R, PackageScoreCard, PackageScoreCard> + get scorecard => + $value.scorecard.copyWith.$chain((v) => call(scorecard: v)); + @override + $R call({PackageScore? score, PackageScoreCard? scorecard}) => + $apply(FieldCopyWithData({ + if (score != null) #score: score, + if (scorecard != null) #scorecard: scorecard + })); + @override + PackageMetrics $make(CopyWithData data) => PackageMetrics( + score: data.get(#score, or: $value.score), + scorecard: data.get(#scorecard, or: $value.scorecard)); + + @override + PackageMetricsCopyWith<$R2, PackageMetrics, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t) => + _PackageMetricsCopyWithImpl($value, $cast, t); +} diff --git a/lib/src/models/package_options_model.dart b/lib/src/models/package_options_model.dart index 3f45e30..b3350f9 100644 --- a/lib/src/models/package_options_model.dart +++ b/lib/src/models/package_options_model.dart @@ -1,6 +1,10 @@ -/// Package Options Model +import 'package:dart_mappable/dart_mappable.dart'; + +part 'package_options_model.mapper.dart'; -class PackageOptions { +/// Package Options Model +@MappableClass() +class PackageOptions with PackageOptionsMappable { final bool isDiscontinued; final bool isUnlisted; final String? replacedBy; @@ -11,33 +15,6 @@ class PackageOptions { this.replacedBy, }); - Map toMap() => { - 'isDiscontinued': isDiscontinued, - 'isUnlisted': isUnlisted, - 'replacedBy': replacedBy, - }; - - factory PackageOptions.fromMap(Map map) => PackageOptions( - isDiscontinued: map['isDiscontinued'] as bool? ?? false, - isUnlisted: map['isUnlisted'] as bool? ?? false, - replacedBy: map['replacedBy'] as String?, - ); - - @override - String toString() => - '''PackageOptions(isDiscontinued: $isDiscontinued, isUnlisted: $isUnlisted, replacedBy: $replacedBy)'''; - - @override - bool operator ==(Object other) { - if (identical(this, other)) return true; - - return other is PackageOptions && - other.isDiscontinued == isDiscontinued && - other.isUnlisted == isUnlisted && - other.replacedBy == replacedBy; - } - - @override - int get hashCode => - isDiscontinued.hashCode ^ isUnlisted.hashCode ^ replacedBy.hashCode; + static const fromMap = PackageOptionsMapper.fromMap; + static const fromJson = PackageOptionsMapper.fromJson; } diff --git a/lib/src/models/package_options_model.mapper.dart b/lib/src/models/package_options_model.mapper.dart new file mode 100644 index 0000000..0fca9e8 --- /dev/null +++ b/lib/src/models/package_options_model.mapper.dart @@ -0,0 +1,135 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, unnecessary_cast +// ignore_for_file: strict_raw_type, inference_failure_on_untyped_parameter + +part of 'package_options_model.dart'; + +class PackageOptionsMapper extends ClassMapperBase { + PackageOptionsMapper._(); + + static PackageOptionsMapper? _instance; + static PackageOptionsMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = PackageOptionsMapper._()); + } + return _instance!; + } + + @override + final String id = 'PackageOptions'; + + static bool _$isDiscontinued(PackageOptions v) => v.isDiscontinued; + static const Field _f$isDiscontinued = + Field('isDiscontinued', _$isDiscontinued, opt: true, def: false); + static bool _$isUnlisted(PackageOptions v) => v.isUnlisted; + static const Field _f$isUnlisted = + Field('isUnlisted', _$isUnlisted, opt: true, def: false); + static String? _$replacedBy(PackageOptions v) => v.replacedBy; + static const Field _f$replacedBy = + Field('replacedBy', _$replacedBy, opt: true); + + @override + final MappableFields fields = const { + #isDiscontinued: _f$isDiscontinued, + #isUnlisted: _f$isUnlisted, + #replacedBy: _f$replacedBy, + }; + + static PackageOptions _instantiate(DecodingData data) { + return PackageOptions( + isDiscontinued: data.dec(_f$isDiscontinued), + isUnlisted: data.dec(_f$isUnlisted), + replacedBy: data.dec(_f$replacedBy)); + } + + @override + final Function instantiate = _instantiate; + + static PackageOptions fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static PackageOptions fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin PackageOptionsMappable { + String toJson() { + return PackageOptionsMapper.ensureInitialized() + .encodeJson(this as PackageOptions); + } + + Map toMap() { + return PackageOptionsMapper.ensureInitialized() + .encodeMap(this as PackageOptions); + } + + PackageOptionsCopyWith + get copyWith => _PackageOptionsCopyWithImpl( + this as PackageOptions, $identity, $identity); + @override + String toString() { + return PackageOptionsMapper.ensureInitialized() + .stringifyValue(this as PackageOptions); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (runtimeType == other.runtimeType && + PackageOptionsMapper.ensureInitialized() + .isValueEqual(this as PackageOptions, other)); + } + + @override + int get hashCode { + return PackageOptionsMapper.ensureInitialized() + .hashValue(this as PackageOptions); + } +} + +extension PackageOptionsValueCopy<$R, $Out> + on ObjectCopyWith<$R, PackageOptions, $Out> { + PackageOptionsCopyWith<$R, PackageOptions, $Out> get $asPackageOptions => + $base.as((v, t, t2) => _PackageOptionsCopyWithImpl(v, t, t2)); +} + +abstract class PackageOptionsCopyWith<$R, $In extends PackageOptions, $Out> + implements ClassCopyWith<$R, $In, $Out> { + $R call({bool? isDiscontinued, bool? isUnlisted, String? replacedBy}); + PackageOptionsCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t); +} + +class _PackageOptionsCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, PackageOptions, $Out> + implements PackageOptionsCopyWith<$R, PackageOptions, $Out> { + _PackageOptionsCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + PackageOptionsMapper.ensureInitialized(); + @override + $R call( + {bool? isDiscontinued, + bool? isUnlisted, + Object? replacedBy = $none}) => + $apply(FieldCopyWithData({ + if (isDiscontinued != null) #isDiscontinued: isDiscontinued, + if (isUnlisted != null) #isUnlisted: isUnlisted, + if (replacedBy != $none) #replacedBy: replacedBy + })); + @override + PackageOptions $make(CopyWithData data) => PackageOptions( + isDiscontinued: data.get(#isDiscontinued, or: $value.isDiscontinued), + isUnlisted: data.get(#isUnlisted, or: $value.isUnlisted), + replacedBy: data.get(#replacedBy, or: $value.replacedBy)); + + @override + PackageOptionsCopyWith<$R2, PackageOptions, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t) => + _PackageOptionsCopyWithImpl($value, $cast, t); +} diff --git a/lib/src/models/package_publisher_model.dart b/lib/src/models/package_publisher_model.dart index c77d9bd..7c4e1c8 100644 --- a/lib/src/models/package_publisher_model.dart +++ b/lib/src/models/package_publisher_model.dart @@ -1,30 +1,16 @@ +import 'package:dart_mappable/dart_mappable.dart'; + +part 'package_publisher_model.mapper.dart'; + /// Package Publisher Model -class PackagePublisher { +@MappableClass() +class PackagePublisher with PackagePublisherMappable { final String? publisherId; const PackagePublisher({ this.publisherId, }); - Map toMap() => { - 'publisherId': publisherId, - }; - - factory PackagePublisher.fromMap(Map map) => - PackagePublisher( - publisherId: map['publisherId'] as String?, - ); - - @override - String toString() => 'PackagePublisher(publisherId: $publisherId)'; - - @override - bool operator ==(Object other) { - if (identical(this, other)) return true; - - return other is PackagePublisher && other.publisherId == publisherId; - } - - @override - int get hashCode => publisherId.hashCode; + static const fromMap = PackagePublisherMapper.fromMap; + static const fromJson = PackagePublisherMapper.fromJson; } diff --git a/lib/src/models/package_publisher_model.mapper.dart b/lib/src/models/package_publisher_model.mapper.dart new file mode 100644 index 0000000..b9396d0 --- /dev/null +++ b/lib/src/models/package_publisher_model.mapper.dart @@ -0,0 +1,116 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, unnecessary_cast +// ignore_for_file: strict_raw_type, inference_failure_on_untyped_parameter + +part of 'package_publisher_model.dart'; + +class PackagePublisherMapper extends ClassMapperBase { + PackagePublisherMapper._(); + + static PackagePublisherMapper? _instance; + static PackagePublisherMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = PackagePublisherMapper._()); + } + return _instance!; + } + + @override + final String id = 'PackagePublisher'; + + static String? _$publisherId(PackagePublisher v) => v.publisherId; + static const Field _f$publisherId = + Field('publisherId', _$publisherId, opt: true); + + @override + final MappableFields fields = const { + #publisherId: _f$publisherId, + }; + + static PackagePublisher _instantiate(DecodingData data) { + return PackagePublisher(publisherId: data.dec(_f$publisherId)); + } + + @override + final Function instantiate = _instantiate; + + static PackagePublisher fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static PackagePublisher fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin PackagePublisherMappable { + String toJson() { + return PackagePublisherMapper.ensureInitialized() + .encodeJson(this as PackagePublisher); + } + + Map toMap() { + return PackagePublisherMapper.ensureInitialized() + .encodeMap(this as PackagePublisher); + } + + PackagePublisherCopyWith + get copyWith => _PackagePublisherCopyWithImpl( + this as PackagePublisher, $identity, $identity); + @override + String toString() { + return PackagePublisherMapper.ensureInitialized() + .stringifyValue(this as PackagePublisher); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (runtimeType == other.runtimeType && + PackagePublisherMapper.ensureInitialized() + .isValueEqual(this as PackagePublisher, other)); + } + + @override + int get hashCode { + return PackagePublisherMapper.ensureInitialized() + .hashValue(this as PackagePublisher); + } +} + +extension PackagePublisherValueCopy<$R, $Out> + on ObjectCopyWith<$R, PackagePublisher, $Out> { + PackagePublisherCopyWith<$R, PackagePublisher, $Out> + get $asPackagePublisher => + $base.as((v, t, t2) => _PackagePublisherCopyWithImpl(v, t, t2)); +} + +abstract class PackagePublisherCopyWith<$R, $In extends PackagePublisher, $Out> + implements ClassCopyWith<$R, $In, $Out> { + $R call({String? publisherId}); + PackagePublisherCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t); +} + +class _PackagePublisherCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, PackagePublisher, $Out> + implements PackagePublisherCopyWith<$R, PackagePublisher, $Out> { + _PackagePublisherCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + PackagePublisherMapper.ensureInitialized(); + @override + $R call({Object? publisherId = $none}) => $apply( + FieldCopyWithData({if (publisherId != $none) #publisherId: publisherId})); + @override + PackagePublisher $make(CopyWithData data) => PackagePublisher( + publisherId: data.get(#publisherId, or: $value.publisherId)); + + @override + PackagePublisherCopyWith<$R2, PackagePublisher, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t) => + _PackagePublisherCopyWithImpl($value, $cast, t); +} diff --git a/lib/src/models/package_score_card.dart b/lib/src/models/package_score_card.dart new file mode 100644 index 0000000..607896c --- /dev/null +++ b/lib/src/models/package_score_card.dart @@ -0,0 +1,198 @@ +import 'package:dart_mappable/dart_mappable.dart'; + +part 'package_score_card.mapper.dart'; + +@MappableClass() +class PackageScoreCard with PackageScoreCardMappable { + final String packageName; + final String packageVersion; + final String runtimeVersion; + final DateTime updated; + final DartdocReport? dartdocReport; + final PanaReport? panaReport; + final String? taskStatus; + + PackageScoreCard({ + required this.packageName, + required this.packageVersion, + required this.runtimeVersion, + required this.updated, + required this.dartdocReport, + required this.panaReport, + required this.taskStatus, + }); + + static const fromMap = PackageScoreCardMapper.fromMap; + static const fromJson = PackageScoreCardMapper.fromJson; +} + +@MappableClass() +class DartdocReport with DartdocReportMappable { + final String? reportStatus; + + DartdocReport({ + required this.reportStatus, + }); + + static const fromMap = DartdocReportMapper.fromMap; + static const fromJson = DartdocReportMapper.fromJson; +} + +@MappableClass() +class PanaReport with PanaReportMappable { + final DateTime? timestamp; + final PanaRuntimeInfo? panaRuntimeInfo; + final String? reportStatus; + final List? derivedTags; + final List? allDependencies; + final List? licenses; + final Report? report; + final Result? result; + final List? screenshots; + final List? urlProblems; + + PanaReport({ + required this.timestamp, + required this.panaRuntimeInfo, + required this.reportStatus, + required this.derivedTags, + required this.allDependencies, + required this.licenses, + required this.report, + required this.result, + required this.screenshots, + required this.urlProblems, + }); + + static const fromMap = PanaReportMapper.fromMap; + static const fromJson = PanaReportMapper.fromJson; +} + +@MappableClass() +class License with LicenseMappable { + final String? path; + final String? spdxIdentifier; + + License({ + required this.path, + required this.spdxIdentifier, + }); + + static const fromMap = LicenseMapper.fromMap; + static const fromJson = LicenseMapper.fromJson; +} + +@MappableClass() +class PanaRuntimeInfo with PanaRuntimeInfoMappable { + final String? panaVersion; + final String? sdkVersion; + final FlutterVersions? flutterVersions; + + PanaRuntimeInfo({ + required this.panaVersion, + required this.sdkVersion, + required this.flutterVersions, + }); + + static const fromMap = PanaRuntimeInfoMapper.fromMap; + static const fromJson = PanaRuntimeInfoMapper.fromJson; +} + +@MappableClass() +class FlutterVersions with FlutterVersionsMappable { + final String? frameworkVersion; + final String? channel; + final String? repositoryUrl; + final String? frameworkRevision; + final String? frameworkCommitDate; + final String? engineRevision; + final String? dartSdkVersion; + final String? devToolsVersion; + final String? flutterVersion; + final String? flutterRoot; + + FlutterVersions({ + required this.frameworkVersion, + required this.channel, + required this.repositoryUrl, + required this.frameworkRevision, + required this.frameworkCommitDate, + required this.engineRevision, + required this.dartSdkVersion, + required this.devToolsVersion, + required this.flutterVersion, + required this.flutterRoot, + }); + + static const fromMap = FlutterVersionsMapper.fromMap; + static const fromJson = FlutterVersionsMapper.fromJson; +} + +@MappableClass() +class Report with ReportMappable { + final List
? sections; + + Report({ + required this.sections, + }); + + static const fromMap = ReportMapper.fromMap; + static const fromJson = ReportMapper.fromJson; +} + +@MappableClass() +class Section with SectionMappable { + final String? id; + final String? title; + final int? grantedPoints; + final int? maxPoints; + final String? status; + final String? summary; + + Section({ + required this.id, + required this.title, + required this.grantedPoints, + required this.maxPoints, + required this.status, + required this.summary, + }); + + static const fromMap = SectionMapper.fromMap; + static const fromJson = SectionMapper.fromJson; +} + +@MappableClass() +class Result with ResultMappable { + final String repositoryUrl; + final String issueTrackerUrl; + final Repository repository; + final int grantedPoints; + final int maxPoints; + + Result({ + required this.repositoryUrl, + required this.issueTrackerUrl, + required this.repository, + required this.grantedPoints, + required this.maxPoints, + }); + + static const fromMap = ResultMapper.fromMap; + static const fromJson = ResultMapper.fromJson; +} + +@MappableClass() +class Repository with RepositoryMappable { + final String? provider; + final String? host; + final String? repository; + final String? branch; + + Repository({ + required this.provider, + required this.host, + required this.repository, + required this.branch, + }); +} diff --git a/lib/src/models/package_score_card.mapper.dart b/lib/src/models/package_score_card.mapper.dart new file mode 100644 index 0000000..d511546 --- /dev/null +++ b/lib/src/models/package_score_card.mapper.dart @@ -0,0 +1,1524 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, unnecessary_cast +// ignore_for_file: strict_raw_type, inference_failure_on_untyped_parameter + +part of 'package_score_card.dart'; + +class PackageScoreCardMapper extends ClassMapperBase { + PackageScoreCardMapper._(); + + static PackageScoreCardMapper? _instance; + static PackageScoreCardMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = PackageScoreCardMapper._()); + DartdocReportMapper.ensureInitialized(); + PanaReportMapper.ensureInitialized(); + } + return _instance!; + } + + @override + final String id = 'PackageScoreCard'; + + static String _$packageName(PackageScoreCard v) => v.packageName; + static const Field _f$packageName = + Field('packageName', _$packageName); + static String _$packageVersion(PackageScoreCard v) => v.packageVersion; + static const Field _f$packageVersion = + Field('packageVersion', _$packageVersion); + static String _$runtimeVersion(PackageScoreCard v) => v.runtimeVersion; + static const Field _f$runtimeVersion = + Field('runtimeVersion', _$runtimeVersion); + static DateTime _$updated(PackageScoreCard v) => v.updated; + static const Field _f$updated = + Field('updated', _$updated); + static DartdocReport? _$dartdocReport(PackageScoreCard v) => v.dartdocReport; + static const Field _f$dartdocReport = + Field('dartdocReport', _$dartdocReport); + static PanaReport? _$panaReport(PackageScoreCard v) => v.panaReport; + static const Field _f$panaReport = + Field('panaReport', _$panaReport); + static String? _$taskStatus(PackageScoreCard v) => v.taskStatus; + static const Field _f$taskStatus = + Field('taskStatus', _$taskStatus); + + @override + final MappableFields fields = const { + #packageName: _f$packageName, + #packageVersion: _f$packageVersion, + #runtimeVersion: _f$runtimeVersion, + #updated: _f$updated, + #dartdocReport: _f$dartdocReport, + #panaReport: _f$panaReport, + #taskStatus: _f$taskStatus, + }; + + static PackageScoreCard _instantiate(DecodingData data) { + return PackageScoreCard( + packageName: data.dec(_f$packageName), + packageVersion: data.dec(_f$packageVersion), + runtimeVersion: data.dec(_f$runtimeVersion), + updated: data.dec(_f$updated), + dartdocReport: data.dec(_f$dartdocReport), + panaReport: data.dec(_f$panaReport), + taskStatus: data.dec(_f$taskStatus)); + } + + @override + final Function instantiate = _instantiate; + + static PackageScoreCard fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static PackageScoreCard fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin PackageScoreCardMappable { + String toJson() { + return PackageScoreCardMapper.ensureInitialized() + .encodeJson(this as PackageScoreCard); + } + + Map toMap() { + return PackageScoreCardMapper.ensureInitialized() + .encodeMap(this as PackageScoreCard); + } + + PackageScoreCardCopyWith + get copyWith => _PackageScoreCardCopyWithImpl( + this as PackageScoreCard, $identity, $identity); + @override + String toString() { + return PackageScoreCardMapper.ensureInitialized() + .stringifyValue(this as PackageScoreCard); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (runtimeType == other.runtimeType && + PackageScoreCardMapper.ensureInitialized() + .isValueEqual(this as PackageScoreCard, other)); + } + + @override + int get hashCode { + return PackageScoreCardMapper.ensureInitialized() + .hashValue(this as PackageScoreCard); + } +} + +extension PackageScoreCardValueCopy<$R, $Out> + on ObjectCopyWith<$R, PackageScoreCard, $Out> { + PackageScoreCardCopyWith<$R, PackageScoreCard, $Out> + get $asPackageScoreCard => + $base.as((v, t, t2) => _PackageScoreCardCopyWithImpl(v, t, t2)); +} + +abstract class PackageScoreCardCopyWith<$R, $In extends PackageScoreCard, $Out> + implements ClassCopyWith<$R, $In, $Out> { + DartdocReportCopyWith<$R, DartdocReport, DartdocReport>? get dartdocReport; + PanaReportCopyWith<$R, PanaReport, PanaReport>? get panaReport; + $R call( + {String? packageName, + String? packageVersion, + String? runtimeVersion, + DateTime? updated, + DartdocReport? dartdocReport, + PanaReport? panaReport, + String? taskStatus}); + PackageScoreCardCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t); +} + +class _PackageScoreCardCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, PackageScoreCard, $Out> + implements PackageScoreCardCopyWith<$R, PackageScoreCard, $Out> { + _PackageScoreCardCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + PackageScoreCardMapper.ensureInitialized(); + @override + DartdocReportCopyWith<$R, DartdocReport, DartdocReport>? get dartdocReport => + $value.dartdocReport?.copyWith.$chain((v) => call(dartdocReport: v)); + @override + PanaReportCopyWith<$R, PanaReport, PanaReport>? get panaReport => + $value.panaReport?.copyWith.$chain((v) => call(panaReport: v)); + @override + $R call( + {String? packageName, + String? packageVersion, + String? runtimeVersion, + DateTime? updated, + Object? dartdocReport = $none, + Object? panaReport = $none, + Object? taskStatus = $none}) => + $apply(FieldCopyWithData({ + if (packageName != null) #packageName: packageName, + if (packageVersion != null) #packageVersion: packageVersion, + if (runtimeVersion != null) #runtimeVersion: runtimeVersion, + if (updated != null) #updated: updated, + if (dartdocReport != $none) #dartdocReport: dartdocReport, + if (panaReport != $none) #panaReport: panaReport, + if (taskStatus != $none) #taskStatus: taskStatus + })); + @override + PackageScoreCard $make(CopyWithData data) => PackageScoreCard( + packageName: data.get(#packageName, or: $value.packageName), + packageVersion: data.get(#packageVersion, or: $value.packageVersion), + runtimeVersion: data.get(#runtimeVersion, or: $value.runtimeVersion), + updated: data.get(#updated, or: $value.updated), + dartdocReport: data.get(#dartdocReport, or: $value.dartdocReport), + panaReport: data.get(#panaReport, or: $value.panaReport), + taskStatus: data.get(#taskStatus, or: $value.taskStatus)); + + @override + PackageScoreCardCopyWith<$R2, PackageScoreCard, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t) => + _PackageScoreCardCopyWithImpl($value, $cast, t); +} + +class DartdocReportMapper extends ClassMapperBase { + DartdocReportMapper._(); + + static DartdocReportMapper? _instance; + static DartdocReportMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = DartdocReportMapper._()); + } + return _instance!; + } + + @override + final String id = 'DartdocReport'; + + static String? _$reportStatus(DartdocReport v) => v.reportStatus; + static const Field _f$reportStatus = + Field('reportStatus', _$reportStatus); + + @override + final MappableFields fields = const { + #reportStatus: _f$reportStatus, + }; + + static DartdocReport _instantiate(DecodingData data) { + return DartdocReport(reportStatus: data.dec(_f$reportStatus)); + } + + @override + final Function instantiate = _instantiate; + + static DartdocReport fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static DartdocReport fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin DartdocReportMappable { + String toJson() { + return DartdocReportMapper.ensureInitialized() + .encodeJson(this as DartdocReport); + } + + Map toMap() { + return DartdocReportMapper.ensureInitialized() + .encodeMap(this as DartdocReport); + } + + DartdocReportCopyWith + get copyWith => _DartdocReportCopyWithImpl( + this as DartdocReport, $identity, $identity); + @override + String toString() { + return DartdocReportMapper.ensureInitialized() + .stringifyValue(this as DartdocReport); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (runtimeType == other.runtimeType && + DartdocReportMapper.ensureInitialized() + .isValueEqual(this as DartdocReport, other)); + } + + @override + int get hashCode { + return DartdocReportMapper.ensureInitialized() + .hashValue(this as DartdocReport); + } +} + +extension DartdocReportValueCopy<$R, $Out> + on ObjectCopyWith<$R, DartdocReport, $Out> { + DartdocReportCopyWith<$R, DartdocReport, $Out> get $asDartdocReport => + $base.as((v, t, t2) => _DartdocReportCopyWithImpl(v, t, t2)); +} + +abstract class DartdocReportCopyWith<$R, $In extends DartdocReport, $Out> + implements ClassCopyWith<$R, $In, $Out> { + $R call({String? reportStatus}); + DartdocReportCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t); +} + +class _DartdocReportCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, DartdocReport, $Out> + implements DartdocReportCopyWith<$R, DartdocReport, $Out> { + _DartdocReportCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + DartdocReportMapper.ensureInitialized(); + @override + $R call({Object? reportStatus = $none}) => $apply(FieldCopyWithData( + {if (reportStatus != $none) #reportStatus: reportStatus})); + @override + DartdocReport $make(CopyWithData data) => DartdocReport( + reportStatus: data.get(#reportStatus, or: $value.reportStatus)); + + @override + DartdocReportCopyWith<$R2, DartdocReport, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t) => + _DartdocReportCopyWithImpl($value, $cast, t); +} + +class PanaReportMapper extends ClassMapperBase { + PanaReportMapper._(); + + static PanaReportMapper? _instance; + static PanaReportMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = PanaReportMapper._()); + PanaRuntimeInfoMapper.ensureInitialized(); + LicenseMapper.ensureInitialized(); + ReportMapper.ensureInitialized(); + ResultMapper.ensureInitialized(); + } + return _instance!; + } + + @override + final String id = 'PanaReport'; + + static DateTime? _$timestamp(PanaReport v) => v.timestamp; + static const Field _f$timestamp = + Field('timestamp', _$timestamp); + static PanaRuntimeInfo? _$panaRuntimeInfo(PanaReport v) => v.panaRuntimeInfo; + static const Field _f$panaRuntimeInfo = + Field('panaRuntimeInfo', _$panaRuntimeInfo); + static String? _$reportStatus(PanaReport v) => v.reportStatus; + static const Field _f$reportStatus = + Field('reportStatus', _$reportStatus); + static List? _$derivedTags(PanaReport v) => v.derivedTags; + static const Field> _f$derivedTags = + Field('derivedTags', _$derivedTags); + static List? _$allDependencies(PanaReport v) => v.allDependencies; + static const Field> _f$allDependencies = + Field('allDependencies', _$allDependencies); + static List? _$licenses(PanaReport v) => v.licenses; + static const Field> _f$licenses = + Field('licenses', _$licenses); + static Report? _$report(PanaReport v) => v.report; + static const Field _f$report = Field('report', _$report); + static Result? _$result(PanaReport v) => v.result; + static const Field _f$result = Field('result', _$result); + static List? _$screenshots(PanaReport v) => v.screenshots; + static const Field> _f$screenshots = + Field('screenshots', _$screenshots); + static List? _$urlProblems(PanaReport v) => v.urlProblems; + static const Field> _f$urlProblems = + Field('urlProblems', _$urlProblems); + + @override + final MappableFields fields = const { + #timestamp: _f$timestamp, + #panaRuntimeInfo: _f$panaRuntimeInfo, + #reportStatus: _f$reportStatus, + #derivedTags: _f$derivedTags, + #allDependencies: _f$allDependencies, + #licenses: _f$licenses, + #report: _f$report, + #result: _f$result, + #screenshots: _f$screenshots, + #urlProblems: _f$urlProblems, + }; + + static PanaReport _instantiate(DecodingData data) { + return PanaReport( + timestamp: data.dec(_f$timestamp), + panaRuntimeInfo: data.dec(_f$panaRuntimeInfo), + reportStatus: data.dec(_f$reportStatus), + derivedTags: data.dec(_f$derivedTags), + allDependencies: data.dec(_f$allDependencies), + licenses: data.dec(_f$licenses), + report: data.dec(_f$report), + result: data.dec(_f$result), + screenshots: data.dec(_f$screenshots), + urlProblems: data.dec(_f$urlProblems)); + } + + @override + final Function instantiate = _instantiate; + + static PanaReport fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static PanaReport fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin PanaReportMappable { + String toJson() { + return PanaReportMapper.ensureInitialized() + .encodeJson(this as PanaReport); + } + + Map toMap() { + return PanaReportMapper.ensureInitialized() + .encodeMap(this as PanaReport); + } + + PanaReportCopyWith get copyWith => + _PanaReportCopyWithImpl(this as PanaReport, $identity, $identity); + @override + String toString() { + return PanaReportMapper.ensureInitialized() + .stringifyValue(this as PanaReport); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (runtimeType == other.runtimeType && + PanaReportMapper.ensureInitialized() + .isValueEqual(this as PanaReport, other)); + } + + @override + int get hashCode { + return PanaReportMapper.ensureInitialized().hashValue(this as PanaReport); + } +} + +extension PanaReportValueCopy<$R, $Out> + on ObjectCopyWith<$R, PanaReport, $Out> { + PanaReportCopyWith<$R, PanaReport, $Out> get $asPanaReport => + $base.as((v, t, t2) => _PanaReportCopyWithImpl(v, t, t2)); +} + +abstract class PanaReportCopyWith<$R, $In extends PanaReport, $Out> + implements ClassCopyWith<$R, $In, $Out> { + PanaRuntimeInfoCopyWith<$R, PanaRuntimeInfo, PanaRuntimeInfo>? + get panaRuntimeInfo; + ListCopyWith<$R, String, ObjectCopyWith<$R, String, String>>? get derivedTags; + ListCopyWith<$R, String, ObjectCopyWith<$R, String, String>>? + get allDependencies; + ListCopyWith<$R, License, LicenseCopyWith<$R, License, License>>? + get licenses; + ReportCopyWith<$R, Report, Report>? get report; + ResultCopyWith<$R, Result, Result>? get result; + ListCopyWith<$R, dynamic, ObjectCopyWith<$R, dynamic, dynamic>>? + get screenshots; + ListCopyWith<$R, dynamic, ObjectCopyWith<$R, dynamic, dynamic>>? + get urlProblems; + $R call( + {DateTime? timestamp, + PanaRuntimeInfo? panaRuntimeInfo, + String? reportStatus, + List? derivedTags, + List? allDependencies, + List? licenses, + Report? report, + Result? result, + List? screenshots, + List? urlProblems}); + PanaReportCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t); +} + +class _PanaReportCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, PanaReport, $Out> + implements PanaReportCopyWith<$R, PanaReport, $Out> { + _PanaReportCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + PanaReportMapper.ensureInitialized(); + @override + PanaRuntimeInfoCopyWith<$R, PanaRuntimeInfo, PanaRuntimeInfo>? + get panaRuntimeInfo => $value.panaRuntimeInfo?.copyWith + .$chain((v) => call(panaRuntimeInfo: v)); + @override + ListCopyWith<$R, String, ObjectCopyWith<$R, String, String>>? + get derivedTags => $value.derivedTags != null + ? ListCopyWith( + $value.derivedTags!, + (v, t) => ObjectCopyWith(v, $identity, t), + (v) => call(derivedTags: v)) + : null; + @override + ListCopyWith<$R, String, ObjectCopyWith<$R, String, String>>? + get allDependencies => $value.allDependencies != null + ? ListCopyWith( + $value.allDependencies!, + (v, t) => ObjectCopyWith(v, $identity, t), + (v) => call(allDependencies: v)) + : null; + @override + ListCopyWith<$R, License, LicenseCopyWith<$R, License, License>>? + get licenses => $value.licenses != null + ? ListCopyWith($value.licenses!, (v, t) => v.copyWith.$chain(t), + (v) => call(licenses: v)) + : null; + @override + ReportCopyWith<$R, Report, Report>? get report => + $value.report?.copyWith.$chain((v) => call(report: v)); + @override + ResultCopyWith<$R, Result, Result>? get result => + $value.result?.copyWith.$chain((v) => call(result: v)); + @override + ListCopyWith<$R, dynamic, ObjectCopyWith<$R, dynamic, dynamic>>? + get screenshots => $value.screenshots != null + ? ListCopyWith( + $value.screenshots!, + (v, t) => ObjectCopyWith(v, $identity, t), + (v) => call(screenshots: v)) + : null; + @override + ListCopyWith<$R, dynamic, ObjectCopyWith<$R, dynamic, dynamic>>? + get urlProblems => $value.urlProblems != null + ? ListCopyWith( + $value.urlProblems!, + (v, t) => ObjectCopyWith(v, $identity, t), + (v) => call(urlProblems: v)) + : null; + @override + $R call( + {Object? timestamp = $none, + Object? panaRuntimeInfo = $none, + Object? reportStatus = $none, + Object? derivedTags = $none, + Object? allDependencies = $none, + Object? licenses = $none, + Object? report = $none, + Object? result = $none, + Object? screenshots = $none, + Object? urlProblems = $none}) => + $apply(FieldCopyWithData({ + if (timestamp != $none) #timestamp: timestamp, + if (panaRuntimeInfo != $none) #panaRuntimeInfo: panaRuntimeInfo, + if (reportStatus != $none) #reportStatus: reportStatus, + if (derivedTags != $none) #derivedTags: derivedTags, + if (allDependencies != $none) #allDependencies: allDependencies, + if (licenses != $none) #licenses: licenses, + if (report != $none) #report: report, + if (result != $none) #result: result, + if (screenshots != $none) #screenshots: screenshots, + if (urlProblems != $none) #urlProblems: urlProblems + })); + @override + PanaReport $make(CopyWithData data) => PanaReport( + timestamp: data.get(#timestamp, or: $value.timestamp), + panaRuntimeInfo: data.get(#panaRuntimeInfo, or: $value.panaRuntimeInfo), + reportStatus: data.get(#reportStatus, or: $value.reportStatus), + derivedTags: data.get(#derivedTags, or: $value.derivedTags), + allDependencies: data.get(#allDependencies, or: $value.allDependencies), + licenses: data.get(#licenses, or: $value.licenses), + report: data.get(#report, or: $value.report), + result: data.get(#result, or: $value.result), + screenshots: data.get(#screenshots, or: $value.screenshots), + urlProblems: data.get(#urlProblems, or: $value.urlProblems)); + + @override + PanaReportCopyWith<$R2, PanaReport, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t) => + _PanaReportCopyWithImpl($value, $cast, t); +} + +class PanaRuntimeInfoMapper extends ClassMapperBase { + PanaRuntimeInfoMapper._(); + + static PanaRuntimeInfoMapper? _instance; + static PanaRuntimeInfoMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = PanaRuntimeInfoMapper._()); + FlutterVersionsMapper.ensureInitialized(); + } + return _instance!; + } + + @override + final String id = 'PanaRuntimeInfo'; + + static String? _$panaVersion(PanaRuntimeInfo v) => v.panaVersion; + static const Field _f$panaVersion = + Field('panaVersion', _$panaVersion); + static String? _$sdkVersion(PanaRuntimeInfo v) => v.sdkVersion; + static const Field _f$sdkVersion = + Field('sdkVersion', _$sdkVersion); + static FlutterVersions? _$flutterVersions(PanaRuntimeInfo v) => + v.flutterVersions; + static const Field _f$flutterVersions = + Field('flutterVersions', _$flutterVersions); + + @override + final MappableFields fields = const { + #panaVersion: _f$panaVersion, + #sdkVersion: _f$sdkVersion, + #flutterVersions: _f$flutterVersions, + }; + + static PanaRuntimeInfo _instantiate(DecodingData data) { + return PanaRuntimeInfo( + panaVersion: data.dec(_f$panaVersion), + sdkVersion: data.dec(_f$sdkVersion), + flutterVersions: data.dec(_f$flutterVersions)); + } + + @override + final Function instantiate = _instantiate; + + static PanaRuntimeInfo fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static PanaRuntimeInfo fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin PanaRuntimeInfoMappable { + String toJson() { + return PanaRuntimeInfoMapper.ensureInitialized() + .encodeJson(this as PanaRuntimeInfo); + } + + Map toMap() { + return PanaRuntimeInfoMapper.ensureInitialized() + .encodeMap(this as PanaRuntimeInfo); + } + + PanaRuntimeInfoCopyWith + get copyWith => _PanaRuntimeInfoCopyWithImpl( + this as PanaRuntimeInfo, $identity, $identity); + @override + String toString() { + return PanaRuntimeInfoMapper.ensureInitialized() + .stringifyValue(this as PanaRuntimeInfo); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (runtimeType == other.runtimeType && + PanaRuntimeInfoMapper.ensureInitialized() + .isValueEqual(this as PanaRuntimeInfo, other)); + } + + @override + int get hashCode { + return PanaRuntimeInfoMapper.ensureInitialized() + .hashValue(this as PanaRuntimeInfo); + } +} + +extension PanaRuntimeInfoValueCopy<$R, $Out> + on ObjectCopyWith<$R, PanaRuntimeInfo, $Out> { + PanaRuntimeInfoCopyWith<$R, PanaRuntimeInfo, $Out> get $asPanaRuntimeInfo => + $base.as((v, t, t2) => _PanaRuntimeInfoCopyWithImpl(v, t, t2)); +} + +abstract class PanaRuntimeInfoCopyWith<$R, $In extends PanaRuntimeInfo, $Out> + implements ClassCopyWith<$R, $In, $Out> { + FlutterVersionsCopyWith<$R, FlutterVersions, FlutterVersions>? + get flutterVersions; + $R call( + {String? panaVersion, + String? sdkVersion, + FlutterVersions? flutterVersions}); + PanaRuntimeInfoCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t); +} + +class _PanaRuntimeInfoCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, PanaRuntimeInfo, $Out> + implements PanaRuntimeInfoCopyWith<$R, PanaRuntimeInfo, $Out> { + _PanaRuntimeInfoCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + PanaRuntimeInfoMapper.ensureInitialized(); + @override + FlutterVersionsCopyWith<$R, FlutterVersions, FlutterVersions>? + get flutterVersions => $value.flutterVersions?.copyWith + .$chain((v) => call(flutterVersions: v)); + @override + $R call( + {Object? panaVersion = $none, + Object? sdkVersion = $none, + Object? flutterVersions = $none}) => + $apply(FieldCopyWithData({ + if (panaVersion != $none) #panaVersion: panaVersion, + if (sdkVersion != $none) #sdkVersion: sdkVersion, + if (flutterVersions != $none) #flutterVersions: flutterVersions + })); + @override + PanaRuntimeInfo $make(CopyWithData data) => PanaRuntimeInfo( + panaVersion: data.get(#panaVersion, or: $value.panaVersion), + sdkVersion: data.get(#sdkVersion, or: $value.sdkVersion), + flutterVersions: data.get(#flutterVersions, or: $value.flutterVersions)); + + @override + PanaRuntimeInfoCopyWith<$R2, PanaRuntimeInfo, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t) => + _PanaRuntimeInfoCopyWithImpl($value, $cast, t); +} + +class FlutterVersionsMapper extends ClassMapperBase { + FlutterVersionsMapper._(); + + static FlutterVersionsMapper? _instance; + static FlutterVersionsMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = FlutterVersionsMapper._()); + } + return _instance!; + } + + @override + final String id = 'FlutterVersions'; + + static String? _$frameworkVersion(FlutterVersions v) => v.frameworkVersion; + static const Field _f$frameworkVersion = + Field('frameworkVersion', _$frameworkVersion); + static String? _$channel(FlutterVersions v) => v.channel; + static const Field _f$channel = + Field('channel', _$channel); + static String? _$repositoryUrl(FlutterVersions v) => v.repositoryUrl; + static const Field _f$repositoryUrl = + Field('repositoryUrl', _$repositoryUrl); + static String? _$frameworkRevision(FlutterVersions v) => v.frameworkRevision; + static const Field _f$frameworkRevision = + Field('frameworkRevision', _$frameworkRevision); + static String? _$frameworkCommitDate(FlutterVersions v) => + v.frameworkCommitDate; + static const Field _f$frameworkCommitDate = + Field('frameworkCommitDate', _$frameworkCommitDate); + static String? _$engineRevision(FlutterVersions v) => v.engineRevision; + static const Field _f$engineRevision = + Field('engineRevision', _$engineRevision); + static String? _$dartSdkVersion(FlutterVersions v) => v.dartSdkVersion; + static const Field _f$dartSdkVersion = + Field('dartSdkVersion', _$dartSdkVersion); + static String? _$devToolsVersion(FlutterVersions v) => v.devToolsVersion; + static const Field _f$devToolsVersion = + Field('devToolsVersion', _$devToolsVersion); + static String? _$flutterVersion(FlutterVersions v) => v.flutterVersion; + static const Field _f$flutterVersion = + Field('flutterVersion', _$flutterVersion); + static String? _$flutterRoot(FlutterVersions v) => v.flutterRoot; + static const Field _f$flutterRoot = + Field('flutterRoot', _$flutterRoot); + + @override + final MappableFields fields = const { + #frameworkVersion: _f$frameworkVersion, + #channel: _f$channel, + #repositoryUrl: _f$repositoryUrl, + #frameworkRevision: _f$frameworkRevision, + #frameworkCommitDate: _f$frameworkCommitDate, + #engineRevision: _f$engineRevision, + #dartSdkVersion: _f$dartSdkVersion, + #devToolsVersion: _f$devToolsVersion, + #flutterVersion: _f$flutterVersion, + #flutterRoot: _f$flutterRoot, + }; + + static FlutterVersions _instantiate(DecodingData data) { + return FlutterVersions( + frameworkVersion: data.dec(_f$frameworkVersion), + channel: data.dec(_f$channel), + repositoryUrl: data.dec(_f$repositoryUrl), + frameworkRevision: data.dec(_f$frameworkRevision), + frameworkCommitDate: data.dec(_f$frameworkCommitDate), + engineRevision: data.dec(_f$engineRevision), + dartSdkVersion: data.dec(_f$dartSdkVersion), + devToolsVersion: data.dec(_f$devToolsVersion), + flutterVersion: data.dec(_f$flutterVersion), + flutterRoot: data.dec(_f$flutterRoot)); + } + + @override + final Function instantiate = _instantiate; + + static FlutterVersions fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static FlutterVersions fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin FlutterVersionsMappable { + String toJson() { + return FlutterVersionsMapper.ensureInitialized() + .encodeJson(this as FlutterVersions); + } + + Map toMap() { + return FlutterVersionsMapper.ensureInitialized() + .encodeMap(this as FlutterVersions); + } + + FlutterVersionsCopyWith + get copyWith => _FlutterVersionsCopyWithImpl( + this as FlutterVersions, $identity, $identity); + @override + String toString() { + return FlutterVersionsMapper.ensureInitialized() + .stringifyValue(this as FlutterVersions); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (runtimeType == other.runtimeType && + FlutterVersionsMapper.ensureInitialized() + .isValueEqual(this as FlutterVersions, other)); + } + + @override + int get hashCode { + return FlutterVersionsMapper.ensureInitialized() + .hashValue(this as FlutterVersions); + } +} + +extension FlutterVersionsValueCopy<$R, $Out> + on ObjectCopyWith<$R, FlutterVersions, $Out> { + FlutterVersionsCopyWith<$R, FlutterVersions, $Out> get $asFlutterVersions => + $base.as((v, t, t2) => _FlutterVersionsCopyWithImpl(v, t, t2)); +} + +abstract class FlutterVersionsCopyWith<$R, $In extends FlutterVersions, $Out> + implements ClassCopyWith<$R, $In, $Out> { + $R call( + {String? frameworkVersion, + String? channel, + String? repositoryUrl, + String? frameworkRevision, + String? frameworkCommitDate, + String? engineRevision, + String? dartSdkVersion, + String? devToolsVersion, + String? flutterVersion, + String? flutterRoot}); + FlutterVersionsCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t); +} + +class _FlutterVersionsCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, FlutterVersions, $Out> + implements FlutterVersionsCopyWith<$R, FlutterVersions, $Out> { + _FlutterVersionsCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + FlutterVersionsMapper.ensureInitialized(); + @override + $R call( + {Object? frameworkVersion = $none, + Object? channel = $none, + Object? repositoryUrl = $none, + Object? frameworkRevision = $none, + Object? frameworkCommitDate = $none, + Object? engineRevision = $none, + Object? dartSdkVersion = $none, + Object? devToolsVersion = $none, + Object? flutterVersion = $none, + Object? flutterRoot = $none}) => + $apply(FieldCopyWithData({ + if (frameworkVersion != $none) #frameworkVersion: frameworkVersion, + if (channel != $none) #channel: channel, + if (repositoryUrl != $none) #repositoryUrl: repositoryUrl, + if (frameworkRevision != $none) #frameworkRevision: frameworkRevision, + if (frameworkCommitDate != $none) + #frameworkCommitDate: frameworkCommitDate, + if (engineRevision != $none) #engineRevision: engineRevision, + if (dartSdkVersion != $none) #dartSdkVersion: dartSdkVersion, + if (devToolsVersion != $none) #devToolsVersion: devToolsVersion, + if (flutterVersion != $none) #flutterVersion: flutterVersion, + if (flutterRoot != $none) #flutterRoot: flutterRoot + })); + @override + FlutterVersions $make(CopyWithData data) => FlutterVersions( + frameworkVersion: + data.get(#frameworkVersion, or: $value.frameworkVersion), + channel: data.get(#channel, or: $value.channel), + repositoryUrl: data.get(#repositoryUrl, or: $value.repositoryUrl), + frameworkRevision: + data.get(#frameworkRevision, or: $value.frameworkRevision), + frameworkCommitDate: + data.get(#frameworkCommitDate, or: $value.frameworkCommitDate), + engineRevision: data.get(#engineRevision, or: $value.engineRevision), + dartSdkVersion: data.get(#dartSdkVersion, or: $value.dartSdkVersion), + devToolsVersion: data.get(#devToolsVersion, or: $value.devToolsVersion), + flutterVersion: data.get(#flutterVersion, or: $value.flutterVersion), + flutterRoot: data.get(#flutterRoot, or: $value.flutterRoot)); + + @override + FlutterVersionsCopyWith<$R2, FlutterVersions, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t) => + _FlutterVersionsCopyWithImpl($value, $cast, t); +} + +class LicenseMapper extends ClassMapperBase { + LicenseMapper._(); + + static LicenseMapper? _instance; + static LicenseMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = LicenseMapper._()); + } + return _instance!; + } + + @override + final String id = 'License'; + + static String? _$path(License v) => v.path; + static const Field _f$path = Field('path', _$path); + static String? _$spdxIdentifier(License v) => v.spdxIdentifier; + static const Field _f$spdxIdentifier = + Field('spdxIdentifier', _$spdxIdentifier); + + @override + final MappableFields fields = const { + #path: _f$path, + #spdxIdentifier: _f$spdxIdentifier, + }; + + static License _instantiate(DecodingData data) { + return License( + path: data.dec(_f$path), spdxIdentifier: data.dec(_f$spdxIdentifier)); + } + + @override + final Function instantiate = _instantiate; + + static License fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static License fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin LicenseMappable { + String toJson() { + return LicenseMapper.ensureInitialized() + .encodeJson(this as License); + } + + Map toMap() { + return LicenseMapper.ensureInitialized() + .encodeMap(this as License); + } + + LicenseCopyWith get copyWith => + _LicenseCopyWithImpl(this as License, $identity, $identity); + @override + String toString() { + return LicenseMapper.ensureInitialized().stringifyValue(this as License); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (runtimeType == other.runtimeType && + LicenseMapper.ensureInitialized() + .isValueEqual(this as License, other)); + } + + @override + int get hashCode { + return LicenseMapper.ensureInitialized().hashValue(this as License); + } +} + +extension LicenseValueCopy<$R, $Out> on ObjectCopyWith<$R, License, $Out> { + LicenseCopyWith<$R, License, $Out> get $asLicense => + $base.as((v, t, t2) => _LicenseCopyWithImpl(v, t, t2)); +} + +abstract class LicenseCopyWith<$R, $In extends License, $Out> + implements ClassCopyWith<$R, $In, $Out> { + $R call({String? path, String? spdxIdentifier}); + LicenseCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t); +} + +class _LicenseCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, License, $Out> + implements LicenseCopyWith<$R, License, $Out> { + _LicenseCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + LicenseMapper.ensureInitialized(); + @override + $R call({Object? path = $none, Object? spdxIdentifier = $none}) => + $apply(FieldCopyWithData({ + if (path != $none) #path: path, + if (spdxIdentifier != $none) #spdxIdentifier: spdxIdentifier + })); + @override + License $make(CopyWithData data) => License( + path: data.get(#path, or: $value.path), + spdxIdentifier: data.get(#spdxIdentifier, or: $value.spdxIdentifier)); + + @override + LicenseCopyWith<$R2, License, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t) => + _LicenseCopyWithImpl($value, $cast, t); +} + +class ReportMapper extends ClassMapperBase { + ReportMapper._(); + + static ReportMapper? _instance; + static ReportMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = ReportMapper._()); + SectionMapper.ensureInitialized(); + } + return _instance!; + } + + @override + final String id = 'Report'; + + static List
? _$sections(Report v) => v.sections; + static const Field> _f$sections = + Field('sections', _$sections); + + @override + final MappableFields fields = const { + #sections: _f$sections, + }; + + static Report _instantiate(DecodingData data) { + return Report(sections: data.dec(_f$sections)); + } + + @override + final Function instantiate = _instantiate; + + static Report fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static Report fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin ReportMappable { + String toJson() { + return ReportMapper.ensureInitialized().encodeJson(this as Report); + } + + Map toMap() { + return ReportMapper.ensureInitialized().encodeMap(this as Report); + } + + ReportCopyWith get copyWith => + _ReportCopyWithImpl(this as Report, $identity, $identity); + @override + String toString() { + return ReportMapper.ensureInitialized().stringifyValue(this as Report); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (runtimeType == other.runtimeType && + ReportMapper.ensureInitialized() + .isValueEqual(this as Report, other)); + } + + @override + int get hashCode { + return ReportMapper.ensureInitialized().hashValue(this as Report); + } +} + +extension ReportValueCopy<$R, $Out> on ObjectCopyWith<$R, Report, $Out> { + ReportCopyWith<$R, Report, $Out> get $asReport => + $base.as((v, t, t2) => _ReportCopyWithImpl(v, t, t2)); +} + +abstract class ReportCopyWith<$R, $In extends Report, $Out> + implements ClassCopyWith<$R, $In, $Out> { + ListCopyWith<$R, Section, SectionCopyWith<$R, Section, Section>>? + get sections; + $R call({List
? sections}); + ReportCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t); +} + +class _ReportCopyWithImpl<$R, $Out> extends ClassCopyWithBase<$R, Report, $Out> + implements ReportCopyWith<$R, Report, $Out> { + _ReportCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = ReportMapper.ensureInitialized(); + @override + ListCopyWith<$R, Section, SectionCopyWith<$R, Section, Section>>? + get sections => $value.sections != null + ? ListCopyWith($value.sections!, (v, t) => v.copyWith.$chain(t), + (v) => call(sections: v)) + : null; + @override + $R call({Object? sections = $none}) => + $apply(FieldCopyWithData({if (sections != $none) #sections: sections})); + @override + Report $make(CopyWithData data) => + Report(sections: data.get(#sections, or: $value.sections)); + + @override + ReportCopyWith<$R2, Report, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t) => + _ReportCopyWithImpl($value, $cast, t); +} + +class SectionMapper extends ClassMapperBase
{ + SectionMapper._(); + + static SectionMapper? _instance; + static SectionMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = SectionMapper._()); + } + return _instance!; + } + + @override + final String id = 'Section'; + + static String? _$id(Section v) => v.id; + static const Field _f$id = Field('id', _$id); + static String? _$title(Section v) => v.title; + static const Field _f$title = Field('title', _$title); + static int? _$grantedPoints(Section v) => v.grantedPoints; + static const Field _f$grantedPoints = + Field('grantedPoints', _$grantedPoints); + static int? _$maxPoints(Section v) => v.maxPoints; + static const Field _f$maxPoints = + Field('maxPoints', _$maxPoints); + static String? _$status(Section v) => v.status; + static const Field _f$status = Field('status', _$status); + static String? _$summary(Section v) => v.summary; + static const Field _f$summary = Field('summary', _$summary); + + @override + final MappableFields
fields = const { + #id: _f$id, + #title: _f$title, + #grantedPoints: _f$grantedPoints, + #maxPoints: _f$maxPoints, + #status: _f$status, + #summary: _f$summary, + }; + + static Section _instantiate(DecodingData data) { + return Section( + id: data.dec(_f$id), + title: data.dec(_f$title), + grantedPoints: data.dec(_f$grantedPoints), + maxPoints: data.dec(_f$maxPoints), + status: data.dec(_f$status), + summary: data.dec(_f$summary)); + } + + @override + final Function instantiate = _instantiate; + + static Section fromMap(Map map) { + return ensureInitialized().decodeMap
(map); + } + + static Section fromJson(String json) { + return ensureInitialized().decodeJson
(json); + } +} + +mixin SectionMappable { + String toJson() { + return SectionMapper.ensureInitialized() + .encodeJson
(this as Section); + } + + Map toMap() { + return SectionMapper.ensureInitialized() + .encodeMap
(this as Section); + } + + SectionCopyWith get copyWith => + _SectionCopyWithImpl(this as Section, $identity, $identity); + @override + String toString() { + return SectionMapper.ensureInitialized().stringifyValue(this as Section); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (runtimeType == other.runtimeType && + SectionMapper.ensureInitialized() + .isValueEqual(this as Section, other)); + } + + @override + int get hashCode { + return SectionMapper.ensureInitialized().hashValue(this as Section); + } +} + +extension SectionValueCopy<$R, $Out> on ObjectCopyWith<$R, Section, $Out> { + SectionCopyWith<$R, Section, $Out> get $asSection => + $base.as((v, t, t2) => _SectionCopyWithImpl(v, t, t2)); +} + +abstract class SectionCopyWith<$R, $In extends Section, $Out> + implements ClassCopyWith<$R, $In, $Out> { + $R call( + {String? id, + String? title, + int? grantedPoints, + int? maxPoints, + String? status, + String? summary}); + SectionCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t); +} + +class _SectionCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, Section, $Out> + implements SectionCopyWith<$R, Section, $Out> { + _SectionCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase
$mapper = + SectionMapper.ensureInitialized(); + @override + $R call( + {Object? id = $none, + Object? title = $none, + Object? grantedPoints = $none, + Object? maxPoints = $none, + Object? status = $none, + Object? summary = $none}) => + $apply(FieldCopyWithData({ + if (id != $none) #id: id, + if (title != $none) #title: title, + if (grantedPoints != $none) #grantedPoints: grantedPoints, + if (maxPoints != $none) #maxPoints: maxPoints, + if (status != $none) #status: status, + if (summary != $none) #summary: summary + })); + @override + Section $make(CopyWithData data) => Section( + id: data.get(#id, or: $value.id), + title: data.get(#title, or: $value.title), + grantedPoints: data.get(#grantedPoints, or: $value.grantedPoints), + maxPoints: data.get(#maxPoints, or: $value.maxPoints), + status: data.get(#status, or: $value.status), + summary: data.get(#summary, or: $value.summary)); + + @override + SectionCopyWith<$R2, Section, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t) => + _SectionCopyWithImpl($value, $cast, t); +} + +class ResultMapper extends ClassMapperBase { + ResultMapper._(); + + static ResultMapper? _instance; + static ResultMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = ResultMapper._()); + RepositoryMapper.ensureInitialized(); + } + return _instance!; + } + + @override + final String id = 'Result'; + + static String? _$repositoryUrl(Result v) => v.repositoryUrl; + static const Field _f$repositoryUrl = + Field('repositoryUrl', _$repositoryUrl); + static String? _$issueTrackerUrl(Result v) => v.issueTrackerUrl; + static const Field _f$issueTrackerUrl = + Field('issueTrackerUrl', _$issueTrackerUrl); + static Repository? _$repository(Result v) => v.repository; + static const Field _f$repository = + Field('repository', _$repository); + static int? _$grantedPoints(Result v) => v.grantedPoints; + static const Field _f$grantedPoints = + Field('grantedPoints', _$grantedPoints); + static int? _$maxPoints(Result v) => v.maxPoints; + static const Field _f$maxPoints = + Field('maxPoints', _$maxPoints); + + @override + final MappableFields fields = const { + #repositoryUrl: _f$repositoryUrl, + #issueTrackerUrl: _f$issueTrackerUrl, + #repository: _f$repository, + #grantedPoints: _f$grantedPoints, + #maxPoints: _f$maxPoints, + }; + + static Result _instantiate(DecodingData data) { + return Result( + repositoryUrl: data.dec(_f$repositoryUrl), + issueTrackerUrl: data.dec(_f$issueTrackerUrl), + repository: data.dec(_f$repository), + grantedPoints: data.dec(_f$grantedPoints), + maxPoints: data.dec(_f$maxPoints)); + } + + @override + final Function instantiate = _instantiate; + + static Result fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static Result fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin ResultMappable { + String toJson() { + return ResultMapper.ensureInitialized().encodeJson(this as Result); + } + + Map toMap() { + return ResultMapper.ensureInitialized().encodeMap(this as Result); + } + + ResultCopyWith get copyWith => + _ResultCopyWithImpl(this as Result, $identity, $identity); + @override + String toString() { + return ResultMapper.ensureInitialized().stringifyValue(this as Result); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (runtimeType == other.runtimeType && + ResultMapper.ensureInitialized() + .isValueEqual(this as Result, other)); + } + + @override + int get hashCode { + return ResultMapper.ensureInitialized().hashValue(this as Result); + } +} + +extension ResultValueCopy<$R, $Out> on ObjectCopyWith<$R, Result, $Out> { + ResultCopyWith<$R, Result, $Out> get $asResult => + $base.as((v, t, t2) => _ResultCopyWithImpl(v, t, t2)); +} + +abstract class ResultCopyWith<$R, $In extends Result, $Out> + implements ClassCopyWith<$R, $In, $Out> { + RepositoryCopyWith<$R, Repository, Repository>? get repository; + $R call( + {String? repositoryUrl, + String? issueTrackerUrl, + Repository? repository, + int? grantedPoints, + int? maxPoints}); + ResultCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t); +} + +class _ResultCopyWithImpl<$R, $Out> extends ClassCopyWithBase<$R, Result, $Out> + implements ResultCopyWith<$R, Result, $Out> { + _ResultCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = ResultMapper.ensureInitialized(); + @override + RepositoryCopyWith<$R, Repository, Repository>? get repository => + $value.repository.copyWith.$chain((v) => call(repository: v)); + @override + $R call( + {Object? repositoryUrl = $none, + Object? issueTrackerUrl = $none, + Object? repository = $none, + Object? grantedPoints = $none, + Object? maxPoints = $none}) => + $apply(FieldCopyWithData({ + if (repositoryUrl != $none) #repositoryUrl: repositoryUrl, + if (issueTrackerUrl != $none) #issueTrackerUrl: issueTrackerUrl, + if (repository != $none) #repository: repository, + if (grantedPoints != $none) #grantedPoints: grantedPoints, + if (maxPoints != $none) #maxPoints: maxPoints + })); + @override + Result $make(CopyWithData data) => Result( + repositoryUrl: data.get(#repositoryUrl, or: $value.repositoryUrl), + issueTrackerUrl: data.get(#issueTrackerUrl, or: $value.issueTrackerUrl), + repository: data.get(#repository, or: $value.repository), + grantedPoints: data.get(#grantedPoints, or: $value.grantedPoints), + maxPoints: data.get(#maxPoints, or: $value.maxPoints)); + + @override + ResultCopyWith<$R2, Result, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t) => + _ResultCopyWithImpl($value, $cast, t); +} + +class RepositoryMapper extends ClassMapperBase { + RepositoryMapper._(); + + static RepositoryMapper? _instance; + static RepositoryMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = RepositoryMapper._()); + } + return _instance!; + } + + @override + final String id = 'Repository'; + + static String? _$provider(Repository v) => v.provider; + static const Field _f$provider = + Field('provider', _$provider); + static String? _$host(Repository v) => v.host; + static const Field _f$host = Field('host', _$host); + static String? _$repository(Repository v) => v.repository; + static const Field _f$repository = + Field('repository', _$repository); + static String? _$branch(Repository v) => v.branch; + static const Field _f$branch = Field('branch', _$branch); + + @override + final MappableFields fields = const { + #provider: _f$provider, + #host: _f$host, + #repository: _f$repository, + #branch: _f$branch, + }; + + static Repository _instantiate(DecodingData data) { + return Repository( + provider: data.dec(_f$provider), + host: data.dec(_f$host), + repository: data.dec(_f$repository), + branch: data.dec(_f$branch)); + } + + @override + final Function instantiate = _instantiate; + + static Repository fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static Repository fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin RepositoryMappable { + String toJson() { + return RepositoryMapper.ensureInitialized() + .encodeJson(this as Repository); + } + + Map toMap() { + return RepositoryMapper.ensureInitialized() + .encodeMap(this as Repository); + } + + RepositoryCopyWith get copyWith => + _RepositoryCopyWithImpl(this as Repository, $identity, $identity); + @override + String toString() { + return RepositoryMapper.ensureInitialized() + .stringifyValue(this as Repository); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (runtimeType == other.runtimeType && + RepositoryMapper.ensureInitialized() + .isValueEqual(this as Repository, other)); + } + + @override + int get hashCode { + return RepositoryMapper.ensureInitialized().hashValue(this as Repository); + } +} + +extension RepositoryValueCopy<$R, $Out> + on ObjectCopyWith<$R, Repository, $Out> { + RepositoryCopyWith<$R, Repository, $Out> get $asRepository => + $base.as((v, t, t2) => _RepositoryCopyWithImpl(v, t, t2)); +} + +abstract class RepositoryCopyWith<$R, $In extends Repository, $Out> + implements ClassCopyWith<$R, $In, $Out> { + $R call({String? provider, String? host, String? repository, String? branch}); + RepositoryCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t); +} + +class _RepositoryCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, Repository, $Out> + implements RepositoryCopyWith<$R, Repository, $Out> { + _RepositoryCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + RepositoryMapper.ensureInitialized(); + @override + $R call( + {Object? provider = $none, + Object? host = $none, + Object? repository = $none, + Object? branch = $none}) => + $apply(FieldCopyWithData({ + if (provider != $none) #provider: provider, + if (host != $none) #host: host, + if (repository != $none) #repository: repository, + if (branch != $none) #branch: branch + })); + @override + Repository $make(CopyWithData data) => Repository( + provider: data.get(#provider, or: $value.provider), + host: data.get(#host, or: $value.host), + repository: data.get(#repository, or: $value.repository), + branch: data.get(#branch, or: $value.branch)); + + @override + RepositoryCopyWith<$R2, Repository, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t) => + _RepositoryCopyWithImpl($value, $cast, t); +} diff --git a/lib/src/models/package_score_model.dart b/lib/src/models/package_score_model.dart index 3296b04..349f1ee 100644 --- a/lib/src/models/package_score_model.dart +++ b/lib/src/models/package_score_model.dart @@ -1,144 +1,25 @@ -import 'package:collection/collection.dart'; +import 'package:dart_mappable/dart_mappable.dart'; -// ignore_for_file: lines_longer_than_80_chars +part 'package_score_model.mapper.dart'; -/// Package Score Model -class PackageScore { - final int? grantedPoints; - final int? maxPoints; +@MappableClass() +class PackageScore with PackageScoreMappable { + final int grantedPoints; + final int maxPoints; final int likeCount; final double? popularityScore; + final List tags; final DateTime lastUpdated; - const PackageScore({ + + PackageScore({ required this.grantedPoints, required this.maxPoints, required this.likeCount, required this.popularityScore, + required this.tags, required this.lastUpdated, }); - Map toMap() => { - 'grantedPoints': grantedPoints, - 'maxPoints': maxPoints, - 'likeCount': likeCount, - 'popularityScore': popularityScore, - 'lastUpdated': lastUpdated.millisecondsSinceEpoch, - }; - - factory PackageScore.fromMap(Map map) => PackageScore( - grantedPoints: map['grantedPoints'] as int? ?? 0, - maxPoints: map['maxPoints'] as int? ?? 0, - likeCount: map['likeCount'] as int? ?? 0, - popularityScore: map['popularityScore'] as double? ?? 0.0, - lastUpdated: DateTime.parse(map['lastUpdated'] as String? ?? ''), - ); - - @override - String toString() => - 'PackageScore(grantedPoints: $grantedPoints, maxPoints: $maxPoints, likeCount: $likeCount, popularityScore: $popularityScore, lastUpdated: $lastUpdated)'; - - @override - bool operator ==(Object other) { - if (identical(this, other)) return true; - - return other is PackageScore && - other.grantedPoints == grantedPoints && - other.maxPoints == maxPoints && - other.likeCount == likeCount && - other.popularityScore == popularityScore && - other.lastUpdated == lastUpdated; - } - - @override - int get hashCode => - grantedPoints.hashCode ^ - maxPoints.hashCode ^ - likeCount.hashCode ^ - popularityScore.hashCode ^ - lastUpdated.hashCode; -} - -/// Package Score Card Model -class PackageScoreCard { - final String packageName; - final String packageVersion; - final String runtimeVersion; - final DateTime updated; - final DateTime packageCreated; - final DateTime packageVersionCreated; - final List derivedTags; - final List flags; - final List reportTypes; - const PackageScoreCard({ - required this.packageName, - required this.packageVersion, - required this.runtimeVersion, - required this.updated, - required this.packageCreated, - required this.packageVersionCreated, - this.derivedTags = const [], - this.flags = const [], - this.reportTypes = const [], - }); - - Map toMap() => { - 'packageName': packageName, - 'packageVersion': packageVersion, - 'runtimeVersion': runtimeVersion, - 'updated': updated.millisecondsSinceEpoch, - 'packageCreated': packageCreated.millisecondsSinceEpoch, - 'packageVersionCreated': packageVersionCreated.millisecondsSinceEpoch, - 'derivedTags': derivedTags, - 'flags': flags, - 'reportTypes': reportTypes, - }; - - factory PackageScoreCard.fromMap(Map map) => - PackageScoreCard( - packageName: map['packageName'] as String? ?? '', - packageVersion: map['packageVersion'] as String? ?? '', - runtimeVersion: map['runtimeVersion'] as String? ?? '', - updated: DateTime.parse(map['updated'] as String? ?? ''), - packageCreated: DateTime.parse(map['packageCreated'] as String? ?? ''), - packageVersionCreated: - DateTime.parse(map['packageVersionCreated'] as String? ?? ''), - derivedTags: - List.from(map['derivedTags'] as List? ?? []), - flags: List.from(map['flags'] as List? ?? []), - reportTypes: - List.from(map['reportTypes'] as List? ?? []), - ); - - @override - String toString() => - 'PackageScoreCard(packageName: $packageName, packageVersion: $packageVersion, runtimeVersion: $runtimeVersion, updated: $updated, packageCreated: $packageCreated, packageVersionCreated: $packageVersionCreated, derivedTags: $derivedTags, flags: $flags, reportTypes: $reportTypes)'; - - @override - bool operator ==(Object other) { - if (identical(this, other)) return true; - final listEquals = const DeepCollectionEquality().equals; - - return other is PackageScoreCard && - other.packageName == packageName && - other.packageVersion == packageVersion && - other.runtimeVersion == runtimeVersion && - other.updated == updated && - other.packageCreated == packageCreated && - other.packageVersionCreated == packageVersionCreated && - listEquals(other.derivedTags, derivedTags) && - listEquals(other.flags, flags) && - listEquals(other.reportTypes, reportTypes); - } - - @override - int get hashCode => - packageName.hashCode ^ - packageVersion.hashCode ^ - runtimeVersion.hashCode ^ - updated.hashCode ^ - packageCreated.hashCode ^ - packageVersionCreated.hashCode ^ - derivedTags.hashCode ^ - flags.hashCode ^ - reportTypes.hashCode; + static const fromMap = PackageScoreMapper.fromMap; + static const fromJson = PackageScoreMapper.fromJson; } diff --git a/lib/src/models/package_score_model.mapper.dart b/lib/src/models/package_score_model.mapper.dart new file mode 100644 index 0000000..ae3eaab --- /dev/null +++ b/lib/src/models/package_score_model.mapper.dart @@ -0,0 +1,170 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, unnecessary_cast +// ignore_for_file: strict_raw_type, inference_failure_on_untyped_parameter + +part of 'package_score_model.dart'; + +class PackageScoreMapper extends ClassMapperBase { + PackageScoreMapper._(); + + static PackageScoreMapper? _instance; + static PackageScoreMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = PackageScoreMapper._()); + } + return _instance!; + } + + @override + final String id = 'PackageScore'; + + static int _$grantedPoints(PackageScore v) => v.grantedPoints; + static const Field _f$grantedPoints = + Field('grantedPoints', _$grantedPoints); + static int _$maxPoints(PackageScore v) => v.maxPoints; + static const Field _f$maxPoints = + Field('maxPoints', _$maxPoints); + static int _$likeCount(PackageScore v) => v.likeCount; + static const Field _f$likeCount = + Field('likeCount', _$likeCount); + static double? _$popularityScore(PackageScore v) => v.popularityScore; + static const Field _f$popularityScore = + Field('popularityScore', _$popularityScore); + static List? _$tags(PackageScore v) => v.tags; + static const Field> _f$tags = + Field('tags', _$tags); + static DateTime _$lastUpdated(PackageScore v) => v.lastUpdated; + static const Field _f$lastUpdated = + Field('lastUpdated', _$lastUpdated); + + @override + final MappableFields fields = const { + #grantedPoints: _f$grantedPoints, + #maxPoints: _f$maxPoints, + #likeCount: _f$likeCount, + #popularityScore: _f$popularityScore, + #tags: _f$tags, + #lastUpdated: _f$lastUpdated, + }; + + static PackageScore _instantiate(DecodingData data) { + return PackageScore( + grantedPoints: data.dec(_f$grantedPoints), + maxPoints: data.dec(_f$maxPoints), + likeCount: data.dec(_f$likeCount), + popularityScore: data.dec(_f$popularityScore), + tags: data.dec(_f$tags), + lastUpdated: data.dec(_f$lastUpdated)); + } + + @override + final Function instantiate = _instantiate; + + static PackageScore fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static PackageScore fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin PackageScoreMappable { + String toJson() { + return PackageScoreMapper.ensureInitialized() + .encodeJson(this as PackageScore); + } + + Map toMap() { + return PackageScoreMapper.ensureInitialized() + .encodeMap(this as PackageScore); + } + + PackageScoreCopyWith get copyWith => + _PackageScoreCopyWithImpl(this as PackageScore, $identity, $identity); + @override + String toString() { + return PackageScoreMapper.ensureInitialized() + .stringifyValue(this as PackageScore); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (runtimeType == other.runtimeType && + PackageScoreMapper.ensureInitialized() + .isValueEqual(this as PackageScore, other)); + } + + @override + int get hashCode { + return PackageScoreMapper.ensureInitialized() + .hashValue(this as PackageScore); + } +} + +extension PackageScoreValueCopy<$R, $Out> + on ObjectCopyWith<$R, PackageScore, $Out> { + PackageScoreCopyWith<$R, PackageScore, $Out> get $asPackageScore => + $base.as((v, t, t2) => _PackageScoreCopyWithImpl(v, t, t2)); +} + +abstract class PackageScoreCopyWith<$R, $In extends PackageScore, $Out> + implements ClassCopyWith<$R, $In, $Out> { + ListCopyWith<$R, String, ObjectCopyWith<$R, String, String>>? get tags; + $R call( + {int? grantedPoints, + int? maxPoints, + int? likeCount, + double? popularityScore, + List? tags, + DateTime? lastUpdated}); + PackageScoreCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t); +} + +class _PackageScoreCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, PackageScore, $Out> + implements PackageScoreCopyWith<$R, PackageScore, $Out> { + _PackageScoreCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + PackageScoreMapper.ensureInitialized(); + @override + ListCopyWith<$R, String, ObjectCopyWith<$R, String, String>>? get tags => + $value.tags != null + ? ListCopyWith($value.tags, (v, t) => ObjectCopyWith(v, $identity, t), + (v) => call(tags: v)) + : null; + @override + $R call( + {int? grantedPoints, + int? maxPoints, + int? likeCount, + Object? popularityScore = $none, + Object? tags = $none, + DateTime? lastUpdated}) => + $apply(FieldCopyWithData({ + if (grantedPoints != null) #grantedPoints: grantedPoints, + if (maxPoints != null) #maxPoints: maxPoints, + if (likeCount != null) #likeCount: likeCount, + if (popularityScore != $none) #popularityScore: popularityScore, + if (tags != $none) #tags: tags, + if (lastUpdated != null) #lastUpdated: lastUpdated + })); + @override + PackageScore $make(CopyWithData data) => PackageScore( + grantedPoints: data.get(#grantedPoints, or: $value.grantedPoints), + maxPoints: data.get(#maxPoints, or: $value.maxPoints), + likeCount: data.get(#likeCount, or: $value.likeCount), + popularityScore: data.get(#popularityScore, or: $value.popularityScore), + tags: data.get(#tags, or: $value.tags), + lastUpdated: data.get(#lastUpdated, or: $value.lastUpdated)); + + @override + PackageScoreCopyWith<$R2, PackageScore, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t) => + _PackageScoreCopyWithImpl($value, $cast, t); +} diff --git a/lib/src/models/pub_package_model.dart b/lib/src/models/pub_package_model.dart index 6e5395c..4f0df3f 100644 --- a/lib/src/models/pub_package_model.dart +++ b/lib/src/models/pub_package_model.dart @@ -1,8 +1,11 @@ -import 'package:collection/collection.dart'; +import 'package:dart_mappable/dart_mappable.dart'; import 'package:pubspec/pubspec.dart'; +part 'pub_package_model.mapper.dart'; + /// Package Model -class PubPackage { +@MappableClass(includeCustomMappers: [PubspecMapper()]) +class PubPackage with PubPackageMappable { final String name; final PackageVersion latest; final List versions; @@ -18,92 +21,40 @@ class PubPackage { String get changelogUrl => '$url/changelog'; PubSpec get latestPubspec => latest.pubspec; - Map toMap() => { - 'name': name, - 'latest': latest.toMap(), - 'versions': versions.map((x) => x.toMap()).toList(), - }; - - factory PubPackage.fromMap(Map map) { - final versionMap = map['versions'] as List? ?? []; - return PubPackage( - name: map['name'] as String? ?? '', - latest: - PackageVersion.fromMap(map['latest'] as Map? ?? {}), - versions: List.from( - versionMap.map( - (x) => PackageVersion.fromMap(x as Map), - ), - ), - ); - } - - @override - String toString() => - 'PubPackage(name: $name, latest: $latest, versions: $versions)'; - - @override - bool operator ==(Object other) { - if (identical(this, other)) return true; - final listEquals = const DeepCollectionEquality().equals; - - return other is PubPackage && - other.name == name && - other.latest == latest && - listEquals(other.versions, versions); - } - - @override - int get hashCode => name.hashCode ^ latest.hashCode ^ versions.hashCode; + static const fromMap = PubPackageMapper.fromMap; + static const fromJson = PubPackageMapper.fromJson; } /// Package Version Model -class PackageVersion { +@MappableClass(includeCustomMappers: [PubspecMapper()]) +class PackageVersion with PackageVersionMappable { final String version; final PubSpec pubspec; + @MappableField(key: 'archive_url') final String archiveUrl; final DateTime published; + @MappableField(key: 'archive_sha256') + final String archiveSha256; const PackageVersion({ required this.version, required this.pubspec, required this.archiveUrl, required this.published, + required this.archiveSha256, }); - Map toMap() => { - 'version': version, - 'pubspec': pubspec.toJson(), - 'archiveUrl': archiveUrl, - 'published': published.millisecondsSinceEpoch, - }; - - factory PackageVersion.fromMap(Map map) => PackageVersion( - version: map['version'] as String? ?? '', - pubspec: - PubSpec.fromJson(map['pubspec'] as Map? ?? {}), - archiveUrl: map['archiveUrl'] as String? ?? '', - published: DateTime.parse(map['published'] as String? ?? ''), - ); + static const fromMap = PackageVersionMapper.fromMap; + static const fromJson = PackageVersionMapper.fromJson; +} - @override - String toString() => - '''PackageVersion(version: $version, pubspec: $pubspec, archiveUrl: $archiveUrl, published: $published)'''; +class PubspecMapper extends SimpleMapper { + const PubspecMapper(); @override - bool operator ==(Object other) { - if (identical(this, other)) return true; - - return other is PackageVersion && - other.version == version && - other.pubspec == pubspec && - other.archiveUrl == archiveUrl && - other.published == published; - } + // ignore: avoid-dynamic + PubSpec decode(dynamic value) => PubSpec.fromJson(value); @override - int get hashCode => - version.hashCode ^ - pubspec.hashCode ^ - archiveUrl.hashCode ^ - published.hashCode; + // ignore: avoid-dynamic + dynamic encode(PubSpec self) => self.toString(); } diff --git a/lib/src/models/pub_package_model.mapper.dart b/lib/src/models/pub_package_model.mapper.dart new file mode 100644 index 0000000..455ccf1 --- /dev/null +++ b/lib/src/models/pub_package_model.mapper.dart @@ -0,0 +1,295 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, unnecessary_cast +// ignore_for_file: strict_raw_type, inference_failure_on_untyped_parameter + +part of 'pub_package_model.dart'; + +class PubPackageMapper extends ClassMapperBase { + PubPackageMapper._(); + + static PubPackageMapper? _instance; + static PubPackageMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = PubPackageMapper._()); + MapperContainer.globals.useAll([PubspecMapper()]); + PackageVersionMapper.ensureInitialized(); + } + return _instance!; + } + + @override + final String id = 'PubPackage'; + + static String _$name(PubPackage v) => v.name; + static const Field _f$name = Field('name', _$name); + static PackageVersion _$latest(PubPackage v) => v.latest; + static const Field _f$latest = + Field('latest', _$latest); + static List _$versions(PubPackage v) => v.versions; + static const Field> _f$versions = + Field('versions', _$versions, opt: true, def: const []); + + @override + final MappableFields fields = const { + #name: _f$name, + #latest: _f$latest, + #versions: _f$versions, + }; + + static PubPackage _instantiate(DecodingData data) { + return PubPackage( + name: data.dec(_f$name), + latest: data.dec(_f$latest), + versions: data.dec(_f$versions)); + } + + @override + final Function instantiate = _instantiate; + + static PubPackage fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static PubPackage fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin PubPackageMappable { + String toJson() { + return PubPackageMapper.ensureInitialized() + .encodeJson(this as PubPackage); + } + + Map toMap() { + return PubPackageMapper.ensureInitialized() + .encodeMap(this as PubPackage); + } + + PubPackageCopyWith get copyWith => + _PubPackageCopyWithImpl(this as PubPackage, $identity, $identity); + @override + String toString() { + return PubPackageMapper.ensureInitialized() + .stringifyValue(this as PubPackage); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (runtimeType == other.runtimeType && + PubPackageMapper.ensureInitialized() + .isValueEqual(this as PubPackage, other)); + } + + @override + int get hashCode { + return PubPackageMapper.ensureInitialized().hashValue(this as PubPackage); + } +} + +extension PubPackageValueCopy<$R, $Out> + on ObjectCopyWith<$R, PubPackage, $Out> { + PubPackageCopyWith<$R, PubPackage, $Out> get $asPubPackage => + $base.as((v, t, t2) => _PubPackageCopyWithImpl(v, t, t2)); +} + +abstract class PubPackageCopyWith<$R, $In extends PubPackage, $Out> + implements ClassCopyWith<$R, $In, $Out> { + PackageVersionCopyWith<$R, PackageVersion, PackageVersion> get latest; + ListCopyWith<$R, PackageVersion, + PackageVersionCopyWith<$R, PackageVersion, PackageVersion>> get versions; + $R call( + {String? name, PackageVersion? latest, List? versions}); + PubPackageCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t); +} + +class _PubPackageCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, PubPackage, $Out> + implements PubPackageCopyWith<$R, PubPackage, $Out> { + _PubPackageCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + PubPackageMapper.ensureInitialized(); + @override + PackageVersionCopyWith<$R, PackageVersion, PackageVersion> get latest => + $value.latest.copyWith.$chain((v) => call(latest: v)); + @override + ListCopyWith<$R, PackageVersion, + PackageVersionCopyWith<$R, PackageVersion, PackageVersion>> + get versions => ListCopyWith($value.versions, + (v, t) => v.copyWith.$chain(t), (v) => call(versions: v)); + @override + $R call( + {String? name, + PackageVersion? latest, + List? versions}) => + $apply(FieldCopyWithData({ + if (name != null) #name: name, + if (latest != null) #latest: latest, + if (versions != null) #versions: versions + })); + @override + PubPackage $make(CopyWithData data) => PubPackage( + name: data.get(#name, or: $value.name), + latest: data.get(#latest, or: $value.latest), + versions: data.get(#versions, or: $value.versions)); + + @override + PubPackageCopyWith<$R2, PubPackage, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t) => + _PubPackageCopyWithImpl($value, $cast, t); +} + +class PackageVersionMapper extends ClassMapperBase { + PackageVersionMapper._(); + + static PackageVersionMapper? _instance; + static PackageVersionMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = PackageVersionMapper._()); + MapperContainer.globals.useAll([PubspecMapper()]); + } + return _instance!; + } + + @override + final String id = 'PackageVersion'; + + static String _$version(PackageVersion v) => v.version; + static const Field _f$version = + Field('version', _$version); + static PubSpec _$pubspec(PackageVersion v) => v.pubspec; + static const Field _f$pubspec = + Field('pubspec', _$pubspec); + static String _$archiveUrl(PackageVersion v) => v.archiveUrl; + static const Field _f$archiveUrl = + Field('archiveUrl', _$archiveUrl, key: 'archive_url'); + static DateTime _$published(PackageVersion v) => v.published; + static const Field _f$published = + Field('published', _$published); + static String _$archiveSha256(PackageVersion v) => v.archiveSha256; + static const Field _f$archiveSha256 = + Field('archiveSha256', _$archiveSha256, key: 'archive_sha256'); + + @override + final MappableFields fields = const { + #version: _f$version, + #pubspec: _f$pubspec, + #archiveUrl: _f$archiveUrl, + #published: _f$published, + #archiveSha256: _f$archiveSha256, + }; + + static PackageVersion _instantiate(DecodingData data) { + return PackageVersion( + version: data.dec(_f$version), + pubspec: data.dec(_f$pubspec), + archiveUrl: data.dec(_f$archiveUrl), + published: data.dec(_f$published), + archiveSha256: data.dec(_f$archiveSha256)); + } + + @override + final Function instantiate = _instantiate; + + static PackageVersion fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static PackageVersion fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin PackageVersionMappable { + String toJson() { + return PackageVersionMapper.ensureInitialized() + .encodeJson(this as PackageVersion); + } + + Map toMap() { + return PackageVersionMapper.ensureInitialized() + .encodeMap(this as PackageVersion); + } + + PackageVersionCopyWith + get copyWith => _PackageVersionCopyWithImpl( + this as PackageVersion, $identity, $identity); + @override + String toString() { + return PackageVersionMapper.ensureInitialized() + .stringifyValue(this as PackageVersion); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (runtimeType == other.runtimeType && + PackageVersionMapper.ensureInitialized() + .isValueEqual(this as PackageVersion, other)); + } + + @override + int get hashCode { + return PackageVersionMapper.ensureInitialized() + .hashValue(this as PackageVersion); + } +} + +extension PackageVersionValueCopy<$R, $Out> + on ObjectCopyWith<$R, PackageVersion, $Out> { + PackageVersionCopyWith<$R, PackageVersion, $Out> get $asPackageVersion => + $base.as((v, t, t2) => _PackageVersionCopyWithImpl(v, t, t2)); +} + +abstract class PackageVersionCopyWith<$R, $In extends PackageVersion, $Out> + implements ClassCopyWith<$R, $In, $Out> { + $R call( + {String? version, + PubSpec? pubspec, + String? archiveUrl, + DateTime? published, + String? archiveSha256}); + PackageVersionCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t); +} + +class _PackageVersionCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, PackageVersion, $Out> + implements PackageVersionCopyWith<$R, PackageVersion, $Out> { + _PackageVersionCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + PackageVersionMapper.ensureInitialized(); + @override + $R call( + {String? version, + PubSpec? pubspec, + String? archiveUrl, + DateTime? published, + String? archiveSha256}) => + $apply(FieldCopyWithData({ + if (version != null) #version: version, + if (pubspec != null) #pubspec: pubspec, + if (archiveUrl != null) #archiveUrl: archiveUrl, + if (published != null) #published: published, + if (archiveSha256 != null) #archiveSha256: archiveSha256 + })); + @override + PackageVersion $make(CopyWithData data) => PackageVersion( + version: data.get(#version, or: $value.version), + pubspec: data.get(#pubspec, or: $value.pubspec), + archiveUrl: data.get(#archiveUrl, or: $value.archiveUrl), + published: data.get(#published, or: $value.published), + archiveSha256: data.get(#archiveSha256, or: $value.archiveSha256)); + + @override + PackageVersionCopyWith<$R2, PackageVersion, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t) => + _PackageVersionCopyWithImpl($value, $cast, t); +} diff --git a/lib/src/models/search_order.dart b/lib/src/models/search_order.dart index 641a276..e30b868 100644 --- a/lib/src/models/search_order.dart +++ b/lib/src/models/search_order.dart @@ -1,3 +1,8 @@ +import 'package:dart_mappable/dart_mappable.dart'; + +part 'search_order.mapper.dart'; + +@MappableEnum() enum SearchOrder { /// Search score should be a weighted value of [text], [popularity], [points] /// and [like], ordered decreasing. @@ -20,13 +25,9 @@ enum SearchOrder { like, /// Search order should be in decreasing pub points. - points, -} + points; + + const SearchOrder(); -extension SearchOrderExtension on SearchOrder { - /// Name of the channel - String get value { - final self = this; - return self.toString().split('.').last; - } + String get value => name; } diff --git a/lib/src/models/search_order.mapper.dart b/lib/src/models/search_order.mapper.dart new file mode 100644 index 0000000..09f5821 --- /dev/null +++ b/lib/src/models/search_order.mapper.dart @@ -0,0 +1,73 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, unnecessary_cast +// ignore_for_file: strict_raw_type, inference_failure_on_untyped_parameter + +part of 'search_order.dart'; + +class SearchOrderMapper extends EnumMapper { + SearchOrderMapper._(); + + static SearchOrderMapper? _instance; + static SearchOrderMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = SearchOrderMapper._()); + } + return _instance!; + } + + static SearchOrder fromValue(dynamic value) { + ensureInitialized(); + return MapperContainer.globals.fromValue(value); + } + + @override + SearchOrder decode(dynamic value) { + switch (value) { + case 'top': + return SearchOrder.top; + case 'text': + return SearchOrder.text; + case 'created': + return SearchOrder.created; + case 'updated': + return SearchOrder.updated; + case 'popularity': + return SearchOrder.popularity; + case 'like': + return SearchOrder.like; + case 'points': + return SearchOrder.points; + default: + throw MapperException.unknownEnumValue(value); + } + } + + @override + dynamic encode(SearchOrder self) { + switch (self) { + case SearchOrder.top: + return 'top'; + case SearchOrder.text: + return 'text'; + case SearchOrder.created: + return 'created'; + case SearchOrder.updated: + return 'updated'; + case SearchOrder.popularity: + return 'popularity'; + case SearchOrder.like: + return 'like'; + case SearchOrder.points: + return 'points'; + } + } +} + +extension SearchOrderMapperExtension on SearchOrder { + String toValue() { + SearchOrderMapper.ensureInitialized(); + return MapperContainer.globals.toValue(this) as String; + } +} diff --git a/lib/src/models/search_results_model.dart b/lib/src/models/search_results_model.dart index 82663dc..8202b85 100644 --- a/lib/src/models/search_results_model.dart +++ b/lib/src/models/search_results_model.dart @@ -1,7 +1,10 @@ -import 'package:collection/collection.dart'; +import 'package:dart_mappable/dart_mappable.dart'; + +part 'search_results_model.mapper.dart'; /// Search Results Model -class SearchResults { +@MappableClass() +class SearchResults with SearchResultsMappable { final List packages; final String? next; const SearchResults({ @@ -9,63 +12,16 @@ class SearchResults { this.next, }); - Map toMap() => { - 'packages': packages.map((x) => x.toMap()).toList(), - 'next': next, - }; - - factory SearchResults.fromMap(Map map) { - final packagesMap = map['packages'] as List? ?? []; - return SearchResults( - packages: List.from( - packagesMap.map( - (x) => PackageResult.fromMap(x as Map), - ), - ), - next: map['next'] as String?, - ); - } - - @override - String toString() => 'SearchResults(packages: $packages, next: $next)'; - - @override - bool operator ==(Object other) { - if (identical(this, other)) return true; - final listEquals = const DeepCollectionEquality().equals; - - return other is SearchResults && - listEquals(other.packages, packages) && - other.next == next; - } - - @override - int get hashCode => packages.hashCode ^ next.hashCode; + static const fromMap = SearchResultsMapper.fromMap; + static const fromJson = SearchResultsMapper.fromJson; } /// Package Result Model returns within a `SearchResult` -class PackageResult { +@MappableClass() +class PackageResult with PackageResultMappable { final String package; const PackageResult({required this.package}); - Map toMap() => { - 'package': package, - }; - - factory PackageResult.fromMap(Map map) => PackageResult( - package: map['package'] as String? ?? '', - ); - - @override - String toString() => 'PackageResult(package: $package)'; - - @override - bool operator ==(Object other) { - if (identical(this, other)) return true; - - return other is PackageResult && other.package == package; - } - - @override - int get hashCode => package.hashCode; + static const fromMap = PackageResultMapper.fromMap; + static const fromJson = PackageResultMapper.fromJson; } diff --git a/lib/src/models/search_results_model.mapper.dart b/lib/src/models/search_results_model.mapper.dart new file mode 100644 index 0000000..3682628 --- /dev/null +++ b/lib/src/models/search_results_model.mapper.dart @@ -0,0 +1,238 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, unnecessary_cast +// ignore_for_file: strict_raw_type, inference_failure_on_untyped_parameter + +part of 'search_results_model.dart'; + +class SearchResultsMapper extends ClassMapperBase { + SearchResultsMapper._(); + + static SearchResultsMapper? _instance; + static SearchResultsMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = SearchResultsMapper._()); + PackageResultMapper.ensureInitialized(); + } + return _instance!; + } + + @override + final String id = 'SearchResults'; + + static List _$packages(SearchResults v) => v.packages; + static const Field> _f$packages = + Field('packages', _$packages); + static String? _$next(SearchResults v) => v.next; + static const Field _f$next = + Field('next', _$next, opt: true); + + @override + final MappableFields fields = const { + #packages: _f$packages, + #next: _f$next, + }; + + static SearchResults _instantiate(DecodingData data) { + return SearchResults( + packages: data.dec(_f$packages), next: data.dec(_f$next)); + } + + @override + final Function instantiate = _instantiate; + + static SearchResults fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static SearchResults fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin SearchResultsMappable { + String toJson() { + return SearchResultsMapper.ensureInitialized() + .encodeJson(this as SearchResults); + } + + Map toMap() { + return SearchResultsMapper.ensureInitialized() + .encodeMap(this as SearchResults); + } + + SearchResultsCopyWith + get copyWith => _SearchResultsCopyWithImpl( + this as SearchResults, $identity, $identity); + @override + String toString() { + return SearchResultsMapper.ensureInitialized() + .stringifyValue(this as SearchResults); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (runtimeType == other.runtimeType && + SearchResultsMapper.ensureInitialized() + .isValueEqual(this as SearchResults, other)); + } + + @override + int get hashCode { + return SearchResultsMapper.ensureInitialized() + .hashValue(this as SearchResults); + } +} + +extension SearchResultsValueCopy<$R, $Out> + on ObjectCopyWith<$R, SearchResults, $Out> { + SearchResultsCopyWith<$R, SearchResults, $Out> get $asSearchResults => + $base.as((v, t, t2) => _SearchResultsCopyWithImpl(v, t, t2)); +} + +abstract class SearchResultsCopyWith<$R, $In extends SearchResults, $Out> + implements ClassCopyWith<$R, $In, $Out> { + ListCopyWith<$R, PackageResult, + PackageResultCopyWith<$R, PackageResult, PackageResult>> get packages; + $R call({List? packages, String? next}); + SearchResultsCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t); +} + +class _SearchResultsCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, SearchResults, $Out> + implements SearchResultsCopyWith<$R, SearchResults, $Out> { + _SearchResultsCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + SearchResultsMapper.ensureInitialized(); + @override + ListCopyWith<$R, PackageResult, + PackageResultCopyWith<$R, PackageResult, PackageResult>> + get packages => ListCopyWith($value.packages, + (v, t) => v.copyWith.$chain(t), (v) => call(packages: v)); + @override + $R call({List? packages, Object? next = $none}) => + $apply(FieldCopyWithData({ + if (packages != null) #packages: packages, + if (next != $none) #next: next + })); + @override + SearchResults $make(CopyWithData data) => SearchResults( + packages: data.get(#packages, or: $value.packages), + next: data.get(#next, or: $value.next)); + + @override + SearchResultsCopyWith<$R2, SearchResults, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t) => + _SearchResultsCopyWithImpl($value, $cast, t); +} + +class PackageResultMapper extends ClassMapperBase { + PackageResultMapper._(); + + static PackageResultMapper? _instance; + static PackageResultMapper ensureInitialized() { + if (_instance == null) { + MapperContainer.globals.use(_instance = PackageResultMapper._()); + } + return _instance!; + } + + @override + final String id = 'PackageResult'; + + static String _$package(PackageResult v) => v.package; + static const Field _f$package = + Field('package', _$package); + + @override + final MappableFields fields = const { + #package: _f$package, + }; + + static PackageResult _instantiate(DecodingData data) { + return PackageResult(package: data.dec(_f$package)); + } + + @override + final Function instantiate = _instantiate; + + static PackageResult fromMap(Map map) { + return ensureInitialized().decodeMap(map); + } + + static PackageResult fromJson(String json) { + return ensureInitialized().decodeJson(json); + } +} + +mixin PackageResultMappable { + String toJson() { + return PackageResultMapper.ensureInitialized() + .encodeJson(this as PackageResult); + } + + Map toMap() { + return PackageResultMapper.ensureInitialized() + .encodeMap(this as PackageResult); + } + + PackageResultCopyWith + get copyWith => _PackageResultCopyWithImpl( + this as PackageResult, $identity, $identity); + @override + String toString() { + return PackageResultMapper.ensureInitialized() + .stringifyValue(this as PackageResult); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (runtimeType == other.runtimeType && + PackageResultMapper.ensureInitialized() + .isValueEqual(this as PackageResult, other)); + } + + @override + int get hashCode { + return PackageResultMapper.ensureInitialized() + .hashValue(this as PackageResult); + } +} + +extension PackageResultValueCopy<$R, $Out> + on ObjectCopyWith<$R, PackageResult, $Out> { + PackageResultCopyWith<$R, PackageResult, $Out> get $asPackageResult => + $base.as((v, t, t2) => _PackageResultCopyWithImpl(v, t, t2)); +} + +abstract class PackageResultCopyWith<$R, $In extends PackageResult, $Out> + implements ClassCopyWith<$R, $In, $Out> { + $R call({String? package}); + PackageResultCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t); +} + +class _PackageResultCopyWithImpl<$R, $Out> + extends ClassCopyWithBase<$R, PackageResult, $Out> + implements PackageResultCopyWith<$R, PackageResult, $Out> { + _PackageResultCopyWithImpl(super.value, super.then, super.then2); + + @override + late final ClassMapperBase $mapper = + PackageResultMapper.ensureInitialized(); + @override + $R call({String? package}) => + $apply(FieldCopyWithData({if (package != null) #package: package})); + @override + PackageResult $make(CopyWithData data) => + PackageResult(package: data.get(#package, or: $value.package)); + + @override + PackageResultCopyWith<$R2, PackageResult, $Out2> $chain<$R2, $Out2>( + Then<$Out2, $R2> t) => + _PackageResultCopyWithImpl($value, $cast, t); +} diff --git a/pubspec.yaml b/pubspec.yaml index 04a5132..cf95389 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -8,14 +8,16 @@ environment: dependencies: collection: ^1.17.2 + dart_mappable: ^4.2.1 http: ^1.1.0 oauth2: ^2.0.2 path: ^1.8.3 pubspec: ^2.3.0 dev_dependencies: - build_runner: ^2.4.6 + build_runner: ^2.4.8 build_version: ^2.1.1 + dart_mappable_builder: ^4.2.1 lints: ^2.1.1 test: ^1.24.4 test_cov: ^1.0.1 diff --git a/test/pubdev_api_test.dart b/test/pubdev_api_test.dart index dace594..756b898 100644 --- a/test/pubdev_api_test.dart +++ b/test/pubdev_api_test.dart @@ -26,6 +26,16 @@ void main() { expect(payload.length, greaterThan(0)); expect(payload.length, packageInfo.versions.length); }); + + test('Get package score', () async { + final payload = await client.packageScore(packageName); + + expect(payload.lastUpdated, isNotNull); + expect(payload.grantedPoints, isNotNull); + expect(payload.likeCount, greaterThan(50)); + expect(payload.maxPoints, greaterThan(100)); + }); + test('Get package metrics', () async { final score = await client.packageScore(packageName); final metrics = await client.packageMetrics(packageName); @@ -58,7 +68,7 @@ void main() { test('Get package publisher', () async { final publisher = await client.packagePublisher(packageName); - expect(publisher.publisherId, 'fvm.app'); + expect(publisher.publisherId, 'leoafarias.com'); }); test('Get package publisher if unregistered', () async { @@ -111,8 +121,8 @@ void main() { }); test('Search for packages of a publisher', () async { - final payload = - await client.search('', tags: [PackageTag.publisher('fvm.app')]); + final payload = await client + .search('', tags: [PackageTag.publisher('leoafarias.com')]); final nextPagePayload = await client.search( '', tags: [PackageTag.dependency('pub_api_client')], @@ -139,29 +149,6 @@ void main() { expect(zeroResults.packages.length, 0); }); - // test('Can like, unlike, and view liked packages', () async { - // if (pubCredentials == null) { - // print('Skipping test. No credentials found.'); - // return; - // } - // final authedClient = PubClient( - // credentials: pubCredentials, - // ); - // final unlikeRes = await authedClient.likePackageStatus('fvm'); - - // await authedClient.unlikePackage('fvm'); - - // final likeRes = await authedClient.likePackage('fvm'); - - // expect(unlikeRes.liked, false); - // expect(likeRes.liked, true); - // // Can make an authenticated request - // final likedPackages = await authedClient.listPackageLikes(); - - // expect(likedPackages, isNotNull); - // expect(likedPackages.length, greaterThan(1)); - // }); - test('Exceptions', () async { void mockRes(int code) { final res = Response('{error:{message:"test"}}', code);