-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds an extremely simply AppCapabilities model to support perce…
…ntage-based rollouts
- Loading branch information
1 parent
6704e56
commit 51770e7
Showing
7 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...rebird_code_push_protocol/lib/src/messages/get_app_capabilities/get_app_capabilities.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export 'get_app_capabilities_response.dart'; |
27 changes: 27 additions & 0 deletions
27
...de_push_protocol/lib/src/messages/get_app_capabilities/get_app_capabilities_response.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'package:json_annotation/json_annotation.dart'; | ||
import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart'; | ||
|
||
part 'get_app_capabilities_response.g.dart'; | ||
|
||
/// {@template get_app_capabilities_response} | ||
/// The capabilities of the requesting user for the specified app. | ||
/// {@endtemplate} | ||
@JsonSerializable() | ||
class GetAppCapabilitiesResponse { | ||
/// {@macro get_app_capabilities_response} | ||
GetAppCapabilitiesResponse({required this.capabilities}); | ||
|
||
/// Deserializes the [GetAppCapabilitiesResponse] from a JSON map. | ||
factory GetAppCapabilitiesResponse.fromJson(Map<String, dynamic> json) => | ||
_$GetAppCapabilitiesResponseFromJson(json); | ||
|
||
/// Converts this [GetAppCapabilitiesResponse] to a JSON map. | ||
Map<String, dynamic> toJson() => _$GetAppCapabilitiesResponseToJson(this); | ||
|
||
/// The list of capabilities the user has for the app. There are the things | ||
/// that the requesting user can do to or in relation to the app. These are | ||
/// determined by the user's role in the organization that owns the app, the | ||
/// user's app collaborator status, and the plan associated with the app's | ||
/// organization. | ||
final List<AppCapability> capabilities; | ||
} |
37 changes: 37 additions & 0 deletions
37
..._push_protocol/lib/src/messages/get_app_capabilities/get_app_capabilities_response.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/shorebird_code_push_protocol/lib/src/models/app_capability.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/// Operations that a user may or may not be able to perform to or in relation | ||
/// to an app. | ||
enum AppCapability { | ||
/// Allows the user to create patches for an app at a non-100 rollout | ||
/// percentage. | ||
phasedPatchRollout, | ||
} |
1 change: 1 addition & 0 deletions
1
packages/shorebird_code_push_protocol/lib/src/models/models.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...h_protocol/test/src/messages/get_app_capabilities/get_app_capabilities_response_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group(GetAppCapabilitiesResponse, () { | ||
test('can be (de)serialized', () { | ||
final response = GetAppCapabilitiesResponse(capabilities: [ | ||
AppCapability.phasedPatchRollout, | ||
]); | ||
expect( | ||
GetAppCapabilitiesResponse.fromJson(response.toJson()).toJson(), | ||
equals(response.toJson()), | ||
); | ||
}); | ||
}); | ||
} |