diff --git a/packages/shorebird_code_push_protocol/lib/src/models/artifact.dart b/packages/shorebird_code_push_protocol/lib/src/models/artifact.dart deleted file mode 100644 index 99f53924..00000000 --- a/packages/shorebird_code_push_protocol/lib/src/models/artifact.dart +++ /dev/null @@ -1,39 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; - -part 'artifact.g.dart'; - -/// {@template artifact} -/// An artifact represents the contents of an update (patch) for a specific -/// platform and architecture. -/// {@endtemplate} -@JsonSerializable() -class Artifact { - /// {@macro artifact} - const Artifact({ - required this.arch, - required this.platform, - required this.url, - required this.hash, - }); - - /// Converts a Map to an [Artifact] - factory Artifact.fromJson(Map json) => - _$ArtifactFromJson(json); - - /// Converts an [Artifact] to a Map - Map toJson() => _$ArtifactToJson(this); - - /// The architecture of the artifact. - /// e.g. arm64, x86_64 - final String arch; - - /// The platform of the artifact. - /// e.g. android, ios - final String platform; - - /// The URL of the artifact. - final String url; - - /// The hash of the artifact. - final String hash; -} diff --git a/packages/shorebird_code_push_protocol/lib/src/models/artifact.g.dart b/packages/shorebird_code_push_protocol/lib/src/models/artifact.g.dart deleted file mode 100644 index 70235a4f..00000000 --- a/packages/shorebird_code_push_protocol/lib/src/models/artifact.g.dart +++ /dev/null @@ -1,30 +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 'artifact.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -Artifact _$ArtifactFromJson(Map json) => $checkedCreate( - 'Artifact', - json, - ($checkedConvert) { - final val = Artifact( - arch: $checkedConvert('arch', (v) => v as String), - platform: $checkedConvert('platform', (v) => v as String), - url: $checkedConvert('url', (v) => v as String), - hash: $checkedConvert('hash', (v) => v as String), - ); - return val; - }, - ); - -Map _$ArtifactToJson(Artifact instance) => { - 'arch': instance.arch, - 'platform': instance.platform, - 'url': instance.url, - 'hash': instance.hash, - }; diff --git a/packages/shorebird_code_push_protocol/lib/src/models/models.dart b/packages/shorebird_code_push_protocol/lib/src/models/models.dart index 07882afe..ce00521a 100644 --- a/packages/shorebird_code_push_protocol/lib/src/models/models.dart +++ b/packages/shorebird_code_push_protocol/lib/src/models/models.dart @@ -1,4 +1,4 @@ export 'app.dart'; -export 'artifact.dart'; export 'patch.dart'; +export 'patch_artifact.dart'; export 'user.dart'; diff --git a/packages/shorebird_code_push_protocol/lib/src/models/patch.dart b/packages/shorebird_code_push_protocol/lib/src/models/patch.dart index e00a3fe5..07ddb9ad 100644 --- a/packages/shorebird_code_push_protocol/lib/src/models/patch.dart +++ b/packages/shorebird_code_push_protocol/lib/src/models/patch.dart @@ -19,6 +19,7 @@ class Patch { /// The unique patch identifier. final int id; - /// The patch number (newer patches are larger). + /// The patch number. + /// A larger number equates to a newer patch. final int number; } diff --git a/packages/shorebird_code_push_protocol/lib/src/models/patch_artifact.dart b/packages/shorebird_code_push_protocol/lib/src/models/patch_artifact.dart new file mode 100644 index 00000000..80891474 --- /dev/null +++ b/packages/shorebird_code_push_protocol/lib/src/models/patch_artifact.dart @@ -0,0 +1,33 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'patch_artifact.g.dart'; + +/// {@template patch_artifact} +/// A patch artifact represents the contents of an update (patch) for a specific +/// platform and architecture. +/// {@endtemplate} +@JsonSerializable() +class PatchArtifact { + /// {@macro patch_PatchArtifact} + const PatchArtifact({ + required this.patchNumber, + required this.downloadUrl, + required this.hash, + }); + + /// Converts a Map to an [PatchArtifact] + factory PatchArtifact.fromJson(Map json) => + _$PatchArtifactFromJson(json); + + /// Converts an [PatchArtifact] to a Map + Map toJson() => _$PatchArtifactToJson(this); + + /// The patch number associated with the artifact. + final int patchNumber; + + /// 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/models/patch_artifact.g.dart b/packages/shorebird_code_push_protocol/lib/src/models/patch_artifact.g.dart new file mode 100644 index 00000000..ead612da --- /dev/null +++ b/packages/shorebird_code_push_protocol/lib/src/models/patch_artifact.g.dart @@ -0,0 +1,34 @@ +// 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 'patch_artifact.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +PatchArtifact _$PatchArtifactFromJson(Map json) => + $checkedCreate( + 'PatchArtifact', + json, + ($checkedConvert) { + final val = PatchArtifact( + patchNumber: $checkedConvert('patch_number', (v) => v as int), + downloadUrl: $checkedConvert('download_url', (v) => v as String), + hash: $checkedConvert('hash', (v) => v as String), + ); + return val; + }, + fieldKeyMap: const { + 'patchNumber': 'patch_number', + 'downloadUrl': 'download_url' + }, + ); + +Map _$PatchArtifactToJson(PatchArtifact instance) => + { + 'patch_number': instance.patchNumber, + 'download_url': instance.downloadUrl, + 'hash': instance.hash, + }; diff --git a/packages/shorebird_code_push_protocol/test/src/models/artifact_test.dart b/packages/shorebird_code_push_protocol/test/src/models/artifact_test.dart deleted file mode 100644 index 91efeaf2..00000000 --- a/packages/shorebird_code_push_protocol/test/src/models/artifact_test.dart +++ /dev/null @@ -1,19 +0,0 @@ -import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart'; -import 'package:test/test.dart'; - -void main() { - group('Artifact', () { - test('can be (de)serialized', () { - const artifact = Artifact( - arch: 'aarm64', - platform: 'android', - url: 'https://example.com', - hash: '#', - ); - expect( - Artifact.fromJson(artifact.toJson()).toJson(), - equals(artifact.toJson()), - ); - }); - }); -} diff --git a/packages/shorebird_code_push_protocol/test/src/models/patch_artifact_test.dart b/packages/shorebird_code_push_protocol/test/src/models/patch_artifact_test.dart new file mode 100644 index 00000000..22581441 --- /dev/null +++ b/packages/shorebird_code_push_protocol/test/src/models/patch_artifact_test.dart @@ -0,0 +1,18 @@ +import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart'; +import 'package:test/test.dart'; + +void main() { + group('PatchArtifact', () { + test('can be (de)serialized', () { + const patchArtifact = PatchArtifact( + patchNumber: 1, + downloadUrl: 'https://example.com', + hash: '#', + ); + expect( + PatchArtifact.fromJson(patchArtifact.toJson()).toJson(), + equals(patchArtifact.toJson()), + ); + }); + }); +}