From 01ef59217819edfe3b3e9a9255060cab19080465 Mon Sep 17 00:00:00 2001 From: Felix Angelov Date: Tue, 3 Oct 2023 12:09:16 -0500 Subject: [PATCH] chore(code_push_protocol): remove `CheckForPatchesRequest` and `CheckForPatchesResponse` (#1348) --- .../check_for_patches/check_for_patches.dart | 2 - .../check_for_patches_request.dart | 49 ----------------- .../check_for_patches_request.g.dart | 53 ------------------- .../check_for_patches_response.dart | 47 ---------------- .../check_for_patches_response.g.dart | 23 -------- .../lib/src/messages/messages.dart | 1 - .../check_for_patches_request_test.dart | 22 -------- .../check_for_patches_response_test.dart | 33 ------------ 8 files changed, 230 deletions(-) delete mode 100644 packages/shorebird_code_push_protocol/lib/src/messages/check_for_patches/check_for_patches.dart delete mode 100644 packages/shorebird_code_push_protocol/lib/src/messages/check_for_patches/check_for_patches_request.dart delete mode 100644 packages/shorebird_code_push_protocol/lib/src/messages/check_for_patches/check_for_patches_request.g.dart delete mode 100644 packages/shorebird_code_push_protocol/lib/src/messages/check_for_patches/check_for_patches_response.dart delete mode 100644 packages/shorebird_code_push_protocol/lib/src/messages/check_for_patches/check_for_patches_response.g.dart delete mode 100644 packages/shorebird_code_push_protocol/test/src/messages/check_for_patches/check_for_patches_request_test.dart delete mode 100644 packages/shorebird_code_push_protocol/test/src/messages/check_for_patches/check_for_patches_response_test.dart diff --git a/packages/shorebird_code_push_protocol/lib/src/messages/check_for_patches/check_for_patches.dart b/packages/shorebird_code_push_protocol/lib/src/messages/check_for_patches/check_for_patches.dart deleted file mode 100644 index b9eee12f..00000000 --- a/packages/shorebird_code_push_protocol/lib/src/messages/check_for_patches/check_for_patches.dart +++ /dev/null @@ -1,2 +0,0 @@ -export 'check_for_patches_request.dart'; -export 'check_for_patches_response.dart'; diff --git a/packages/shorebird_code_push_protocol/lib/src/messages/check_for_patches/check_for_patches_request.dart b/packages/shorebird_code_push_protocol/lib/src/messages/check_for_patches/check_for_patches_request.dart deleted file mode 100644 index 1ad46830..00000000 --- a/packages/shorebird_code_push_protocol/lib/src/messages/check_for_patches/check_for_patches_request.dart +++ /dev/null @@ -1,49 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; -import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart'; - -part 'check_for_patches_request.g.dart'; - -/// {@template check_for_patches_request} -/// The request body for POST /api/v1/patches/check -/// {@endtemplate} -@JsonSerializable() -class CheckForPatchesRequest { - /// {@macro check_for_patches_request} - const CheckForPatchesRequest({ - required this.releaseVersion, - required this.patchNumber, - required this.patchHash, - required this.platform, - required this.arch, - required this.appId, - required this.channel, - }); - - /// Converts a Map to a [CheckForPatchesRequest] - factory CheckForPatchesRequest.fromJson(Map json) => - _$CheckForPatchesRequestFromJson(json); - - /// Converts a [CheckForPatchesRequest] to a Map - Map toJson() => _$CheckForPatchesRequestToJson(this); - - /// The release version of the app. - final String releaseVersion; - - /// The current patch number of the app. - final int? patchNumber; - - /// The current patch hash of the app. - final String? patchHash; - - /// The platform of the app. - final ReleasePlatform platform; - - /// The architecture of the app. - final String arch; - - /// The ID of the app. - final String appId; - - /// The channel of the app. - final String channel; -} diff --git a/packages/shorebird_code_push_protocol/lib/src/messages/check_for_patches/check_for_patches_request.g.dart b/packages/shorebird_code_push_protocol/lib/src/messages/check_for_patches/check_for_patches_request.g.dart deleted file mode 100644 index 4b708000..00000000 --- a/packages/shorebird_code_push_protocol/lib/src/messages/check_for_patches/check_for_patches_request.g.dart +++ /dev/null @@ -1,53 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -// ignore_for_file: implicit_dynamic_parameter, require_trailing_commas, cast_nullable_to_non_nullable, lines_longer_than_80_chars - -part of 'check_for_patches_request.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -CheckForPatchesRequest _$CheckForPatchesRequestFromJson( - Map json) => - $checkedCreate( - 'CheckForPatchesRequest', - json, - ($checkedConvert) { - final val = CheckForPatchesRequest( - releaseVersion: - $checkedConvert('release_version', (v) => v as String), - patchNumber: $checkedConvert('patch_number', (v) => v as int?), - patchHash: $checkedConvert('patch_hash', (v) => v as String?), - platform: $checkedConvert( - 'platform', (v) => $enumDecode(_$ReleasePlatformEnumMap, v)), - arch: $checkedConvert('arch', (v) => v as String), - appId: $checkedConvert('app_id', (v) => v as String), - channel: $checkedConvert('channel', (v) => v as String), - ); - return val; - }, - fieldKeyMap: const { - 'releaseVersion': 'release_version', - 'patchNumber': 'patch_number', - 'patchHash': 'patch_hash', - 'appId': 'app_id' - }, - ); - -Map _$CheckForPatchesRequestToJson( - CheckForPatchesRequest instance) => - { - 'release_version': instance.releaseVersion, - 'patch_number': instance.patchNumber, - 'patch_hash': instance.patchHash, - 'platform': _$ReleasePlatformEnumMap[instance.platform]!, - 'arch': instance.arch, - 'app_id': instance.appId, - 'channel': instance.channel, - }; - -const _$ReleasePlatformEnumMap = { - ReleasePlatform.android: 'android', - ReleasePlatform.ios: 'ios', -}; diff --git a/packages/shorebird_code_push_protocol/lib/src/messages/check_for_patches/check_for_patches_response.dart b/packages/shorebird_code_push_protocol/lib/src/messages/check_for_patches/check_for_patches_response.dart deleted file mode 100644 index 2ab6b2c1..00000000 --- a/packages/shorebird_code_push_protocol/lib/src/messages/check_for_patches/check_for_patches_response.dart +++ /dev/null @@ -1,47 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; - -part 'check_for_patches_response.g.dart'; - -/// {@template check_for_patches_response} -/// The response body for POST /api/v1/patches/check -/// {@endtemplate} -@JsonSerializable(createFactory: false) -class CheckForPatchesResponse { - /// {@macro check_for_patches_response} - const CheckForPatchesResponse({required this.patchAvailable, this.patch}); - - /// Converts a [CheckForPatchesResponse] to a Map - Map toJson() => _$CheckForPatchesResponseToJson(this); - - /// Whether a patch is available. - final bool patchAvailable; - - /// The patch metadata. - final PatchMetadata? patch; -} - -/// {@template patch_metadata} -/// Patch metadata represents the contents of an update (patch) for a specific -/// platform and architecture. -/// {@endtemplate} -@JsonSerializable(createFactory: false) -class PatchMetadata { - /// {@macro patch_metadata} - const PatchMetadata({ - required this.number, - required this.downloadUrl, - required this.hash, - }); - - /// Converts an [PatchMetadata] to a Map - Map toJson() => _$PatchMetadataToJson(this); - - /// The patch number associated with the artifact. - final int number; - - /// The URL of the artifact. - final String downloadUrl; - - /// The hash of the artifact. - final String hash; -} diff --git a/packages/shorebird_code_push_protocol/lib/src/messages/check_for_patches/check_for_patches_response.g.dart b/packages/shorebird_code_push_protocol/lib/src/messages/check_for_patches/check_for_patches_response.g.dart deleted file mode 100644 index 6cbbd640..00000000 --- a/packages/shorebird_code_push_protocol/lib/src/messages/check_for_patches/check_for_patches_response.g.dart +++ /dev/null @@ -1,23 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -// ignore_for_file: implicit_dynamic_parameter, require_trailing_commas, cast_nullable_to_non_nullable, lines_longer_than_80_chars - -part of 'check_for_patches_response.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -Map _$CheckForPatchesResponseToJson( - CheckForPatchesResponse instance) => - { - 'patch_available': instance.patchAvailable, - 'patch': instance.patch?.toJson(), - }; - -Map _$PatchMetadataToJson(PatchMetadata instance) => - { - 'number': instance.number, - 'download_url': instance.downloadUrl, - 'hash': instance.hash, - }; diff --git a/packages/shorebird_code_push_protocol/lib/src/messages/messages.dart b/packages/shorebird_code_push_protocol/lib/src/messages/messages.dart index e27075bb..ac1c2209 100644 --- a/packages/shorebird_code_push_protocol/lib/src/messages/messages.dart +++ b/packages/shorebird_code_push_protocol/lib/src/messages/messages.dart @@ -1,4 +1,3 @@ -export 'check_for_patches/check_for_patches.dart'; export 'create_app/create_app.dart'; export 'create_app_collaborator/create_app_collaborator.dart'; export 'create_channel/create_channel.dart'; diff --git a/packages/shorebird_code_push_protocol/test/src/messages/check_for_patches/check_for_patches_request_test.dart b/packages/shorebird_code_push_protocol/test/src/messages/check_for_patches/check_for_patches_request_test.dart deleted file mode 100644 index c01db0ed..00000000 --- a/packages/shorebird_code_push_protocol/test/src/messages/check_for_patches/check_for_patches_request_test.dart +++ /dev/null @@ -1,22 +0,0 @@ -import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart'; -import 'package:test/test.dart'; - -void main() { - group(CheckForPatchesRequest, () { - test('can be (de)serialized', () { - const request = CheckForPatchesRequest( - releaseVersion: '1', - patchNumber: 2, - patchHash: '3', - platform: ReleasePlatform.android, - arch: 'arm64', - appId: 'app_123', - channel: 'channel_123', - ); - expect( - CheckForPatchesRequest.fromJson(request.toJson()).toJson(), - equals(request.toJson()), - ); - }); - }); -} diff --git a/packages/shorebird_code_push_protocol/test/src/messages/check_for_patches/check_for_patches_response_test.dart b/packages/shorebird_code_push_protocol/test/src/messages/check_for_patches/check_for_patches_response_test.dart deleted file mode 100644 index 52332781..00000000 --- a/packages/shorebird_code_push_protocol/test/src/messages/check_for_patches/check_for_patches_response_test.dart +++ /dev/null @@ -1,33 +0,0 @@ -import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart'; -import 'package:test/test.dart'; - -void main() { - group(CheckForPatchesRequest, () { - test('can be serialized to json without patch metadata', () { - const response = CheckForPatchesResponse(patchAvailable: true); - expect(response.toJson(), {'patch_available': true, 'patch': null}); - }); - - test('can be serialized to json with patch metadata', () { - const response = CheckForPatchesResponse( - patchAvailable: true, - patch: PatchMetadata( - number: 1, - downloadUrl: 'https://download.com', - hash: '1234', - ), - ); - expect( - response.toJson(), - { - 'patch_available': true, - 'patch': { - 'number': 1, - 'download_url': 'https://download.com', - 'hash': '1234', - }, - }, - ); - }); - }); -}