From 9ac371ab56ffaffbd0f9c5f579922efadd1bc0aa Mon Sep 17 00:00:00 2001 From: Bryan Oltman Date: Mon, 17 Nov 2025 16:29:44 -0500 Subject: [PATCH] chore: rename OrganizationRole to Role (#3387) --- .../src/code_push_client_wrapper_test.dart | 4 ++-- .../test/src/commands/init_command_test.dart | 8 ++++---- .../test/src/code_push_client_test.dart | 2 +- .../create_release_artifact_request.g.dart | 2 +- .../patch_check/patch_check_response.g.dart | 2 +- .../lib/src/models/models.dart | 1 + .../lib/src/models/organization.dart | 18 ------------------ .../src/models/organization_membership.dart | 4 ++-- .../src/models/organization_membership.g.dart | 17 +++++++---------- .../lib/src/models/organization_user.dart | 2 +- .../lib/src/models/organization_user.g.dart | 17 +++++++---------- .../lib/src/models/role.dart | 19 +++++++++++++++++++ .../get_organization_users_response_test.dart | 2 +- .../get_organizations_response_test.dart | 2 +- .../models/organization_membership_test.dart | 10 +++++----- .../src/models/organization_user_test.dart | 2 +- 16 files changed, 54 insertions(+), 58 deletions(-) create mode 100644 packages/shorebird_code_push_protocol/lib/src/models/role.dart diff --git a/packages/shorebird_cli/test/src/code_push_client_wrapper_test.dart b/packages/shorebird_cli/test/src/code_push_client_wrapper_test.dart index 623ee8c7..f656efd7 100644 --- a/packages/shorebird_cli/test/src/code_push_client_wrapper_test.dart +++ b/packages/shorebird_cli/test/src/code_push_client_wrapper_test.dart @@ -298,11 +298,11 @@ void main() { final expectedMemberships = [ OrganizationMembership( organization: Organization.forTest(), - role: OrganizationRole.admin, + role: Role.admin, ), OrganizationMembership( organization: Organization.forTest(), - role: OrganizationRole.member, + role: Role.member, ), ]; when( diff --git a/packages/shorebird_cli/test/src/commands/init_command_test.dart b/packages/shorebird_cli/test/src/commands/init_command_test.dart index 823820ec..2ea11d95 100644 --- a/packages/shorebird_cli/test/src/commands/init_command_test.dart +++ b/packages/shorebird_cli/test/src/commands/init_command_test.dart @@ -98,7 +98,7 @@ environment: when(() => codePushClientWrapper.getOrganizationMemberships()).thenAnswer( (_) async => [ OrganizationMembership( - role: OrganizationRole.owner, + role: Role.owner, organization: Organization.forTest(id: organizationId), ), ], @@ -398,7 +398,7 @@ Please make sure you are running "shorebird init" from within your Flutter proje ).thenAnswer( (_) async => [ OrganizationMembership( - role: OrganizationRole.owner, + role: Role.owner, organization: Organization.forTest(id: organizationId), ), ], @@ -440,11 +440,11 @@ Please make sure you are running "shorebird init" from within your Flutter proje ).thenAnswer( (_) async => [ OrganizationMembership( - role: OrganizationRole.owner, + role: Role.owner, organization: org1, ), OrganizationMembership( - role: OrganizationRole.owner, + role: Role.owner, organization: org2, ), ], diff --git a/packages/shorebird_code_push_client/test/src/code_push_client_test.dart b/packages/shorebird_code_push_client/test/src/code_push_client_test.dart index 20427e11..2e48f709 100644 --- a/packages/shorebird_code_push_client/test/src/code_push_client_test.dart +++ b/packages/shorebird_code_push_client/test/src/code_push_client_test.dart @@ -2046,7 +2046,7 @@ void main() { setUp(() { membership = OrganizationMembership( - role: OrganizationRole.admin, + role: Role.admin, organization: Organization.forTest(), ); response = GetOrganizationsResponse(organizations: [membership]); diff --git a/packages/shorebird_code_push_protocol/lib/src/messages/create_release_artifact/create_release_artifact_request.g.dart b/packages/shorebird_code_push_protocol/lib/src/messages/create_release_artifact/create_release_artifact_request.g.dart index 480fc7df..ae6ec2e0 100644 --- a/packages/shorebird_code_push_protocol/lib/src/messages/create_release_artifact/create_release_artifact_request.g.dart +++ b/packages/shorebird_code_push_protocol/lib/src/messages/create_release_artifact/create_release_artifact_request.g.dart @@ -54,7 +54,7 @@ Map _$CreateReleaseArtifactRequestToJson( instance.canSideload, ), 'size': CreateReleaseArtifactRequest._parseIntToString(instance.size), - if (instance.podfileLockHash case final value?) 'podfile_lock_hash': value, + 'podfile_lock_hash': ?instance.podfileLockHash, }; const _$ReleasePlatformEnumMap = { diff --git a/packages/shorebird_code_push_protocol/lib/src/messages/patch_check/patch_check_response.g.dart b/packages/shorebird_code_push_protocol/lib/src/messages/patch_check/patch_check_response.g.dart index 01895087..4a7e3543 100644 --- a/packages/shorebird_code_push_protocol/lib/src/messages/patch_check/patch_check_response.g.dart +++ b/packages/shorebird_code_push_protocol/lib/src/messages/patch_check/patch_check_response.g.dart @@ -66,5 +66,5 @@ Map _$PatchCheckMetadataToJson(PatchCheckMetadata instance) => 'number': instance.number, 'download_url': instance.downloadUrl, 'hash': instance.hash, - if (instance.hashSignature case final value?) 'hash_signature': value, + 'hash_signature': ?instance.hashSignature, }; 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 59f0c14e..016b5479 100644 --- a/packages/shorebird_code_push_protocol/lib/src/models/models.dart +++ b/packages/shorebird_code_push_protocol/lib/src/models/models.dart @@ -17,3 +17,4 @@ export 'release_artifact.dart'; export 'release_patch.dart'; export 'release_platform.dart'; export 'release_status.dart'; +export 'role.dart'; diff --git a/packages/shorebird_code_push_protocol/lib/src/models/organization.dart b/packages/shorebird_code_push_protocol/lib/src/models/organization.dart index 2fea694d..aee49eda 100644 --- a/packages/shorebird_code_push_protocol/lib/src/models/organization.dart +++ b/packages/shorebird_code_push_protocol/lib/src/models/organization.dart @@ -4,24 +4,6 @@ import 'package:meta/meta.dart'; part 'organization.g.dart'; -/// {@template organization_role} -/// A role that a user can have in an organization. -/// {@endtemplate} -enum OrganizationRole { - /// User that created the organization. - owner, - - /// Users who have permissions to manage the organization. - admin, - - /// Users who are part of the organization but have limited permissions. - member, - - /// Users who are not part of the organization but have visibility into it via - /// app collaborator permissions. - none, -} - /// {@template organization_type} /// Distinguishes between automatically created organizations that are limited /// to a single user and organizations that support multiple users. diff --git a/packages/shorebird_code_push_protocol/lib/src/models/organization_membership.dart b/packages/shorebird_code_push_protocol/lib/src/models/organization_membership.dart index 898b3527..6ead8d75 100644 --- a/packages/shorebird_code_push_protocol/lib/src/models/organization_membership.dart +++ b/packages/shorebird_code_push_protocol/lib/src/models/organization_membership.dart @@ -1,6 +1,6 @@ import 'package:equatable/equatable.dart'; import 'package:json_annotation/json_annotation.dart'; -import 'package:shorebird_code_push_protocol/src/models/organization.dart'; +import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart'; part 'organization_membership.g.dart'; @@ -26,7 +26,7 @@ class OrganizationMembership extends Equatable { final Organization organization; /// The user's role in the organization. - final OrganizationRole role; + final Role role; @override List get props => [organization, role]; diff --git a/packages/shorebird_code_push_protocol/lib/src/models/organization_membership.g.dart b/packages/shorebird_code_push_protocol/lib/src/models/organization_membership.g.dart index b58d17b9..579094ed 100644 --- a/packages/shorebird_code_push_protocol/lib/src/models/organization_membership.g.dart +++ b/packages/shorebird_code_push_protocol/lib/src/models/organization_membership.g.dart @@ -16,10 +16,7 @@ OrganizationMembership _$OrganizationMembershipFromJson( 'organization', (v) => Organization.fromJson(v as Map), ), - role: $checkedConvert( - 'role', - (v) => $enumDecode(_$OrganizationRoleEnumMap, v), - ), + role: $checkedConvert('role', (v) => $enumDecode(_$RoleEnumMap, v)), ); return val; }); @@ -28,12 +25,12 @@ Map _$OrganizationMembershipToJson( OrganizationMembership instance, ) => { 'organization': instance.organization.toJson(), - 'role': _$OrganizationRoleEnumMap[instance.role]!, + 'role': _$RoleEnumMap[instance.role]!, }; -const _$OrganizationRoleEnumMap = { - OrganizationRole.owner: 'owner', - OrganizationRole.admin: 'admin', - OrganizationRole.member: 'member', - OrganizationRole.none: 'none', +const _$RoleEnumMap = { + Role.owner: 'owner', + Role.admin: 'admin', + Role.member: 'member', + Role.none: 'none', }; diff --git a/packages/shorebird_code_push_protocol/lib/src/models/organization_user.dart b/packages/shorebird_code_push_protocol/lib/src/models/organization_user.dart index d7bfd902..b0d2cf12 100644 --- a/packages/shorebird_code_push_protocol/lib/src/models/organization_user.dart +++ b/packages/shorebird_code_push_protocol/lib/src/models/organization_user.dart @@ -22,5 +22,5 @@ class OrganizationUser { final PublicUser user; /// The role [user] has in the organization. - final OrganizationRole role; + final Role role; } diff --git a/packages/shorebird_code_push_protocol/lib/src/models/organization_user.g.dart b/packages/shorebird_code_push_protocol/lib/src/models/organization_user.g.dart index 332bbcee..49e2baec 100644 --- a/packages/shorebird_code_push_protocol/lib/src/models/organization_user.g.dart +++ b/packages/shorebird_code_push_protocol/lib/src/models/organization_user.g.dart @@ -15,10 +15,7 @@ OrganizationUser _$OrganizationUserFromJson(Map json) => 'user', (v) => PublicUser.fromJson(v as Map), ), - role: $checkedConvert( - 'role', - (v) => $enumDecode(_$OrganizationRoleEnumMap, v), - ), + role: $checkedConvert('role', (v) => $enumDecode(_$RoleEnumMap, v)), ); return val; }); @@ -26,12 +23,12 @@ OrganizationUser _$OrganizationUserFromJson(Map json) => Map _$OrganizationUserToJson(OrganizationUser instance) => { 'user': instance.user.toJson(), - 'role': _$OrganizationRoleEnumMap[instance.role]!, + 'role': _$RoleEnumMap[instance.role]!, }; -const _$OrganizationRoleEnumMap = { - OrganizationRole.owner: 'owner', - OrganizationRole.admin: 'admin', - OrganizationRole.member: 'member', - OrganizationRole.none: 'none', +const _$RoleEnumMap = { + Role.owner: 'owner', + Role.admin: 'admin', + Role.member: 'member', + Role.none: 'none', }; diff --git a/packages/shorebird_code_push_protocol/lib/src/models/role.dart b/packages/shorebird_code_push_protocol/lib/src/models/role.dart new file mode 100644 index 00000000..dcd3e13b --- /dev/null +++ b/packages/shorebird_code_push_protocol/lib/src/models/role.dart @@ -0,0 +1,19 @@ +import 'package:shorebird_code_push_protocol/shorebird_code_push_protocol.dart'; + +/// {@template role} +/// A role that a user can have relative to an [Organization] or [App]. +/// {@endtemplate} +enum Role { + /// User that created the organization. + owner, + + /// Users who have permissions to manage the organization. + admin, + + /// Users who are part of the organization but have limited permissions. + member, + + /// Users who are not part of the organization but have visibility into it via + /// app collaborator permissions. + none, +} diff --git a/packages/shorebird_code_push_protocol/test/src/messages/get_organization_users/get_organization_users_response_test.dart b/packages/shorebird_code_push_protocol/test/src/messages/get_organization_users/get_organization_users_response_test.dart index ffee3ca7..17620363 100644 --- a/packages/shorebird_code_push_protocol/test/src/messages/get_organization_users/get_organization_users_response_test.dart +++ b/packages/shorebird_code_push_protocol/test/src/messages/get_organization_users/get_organization_users_response_test.dart @@ -8,7 +8,7 @@ void main() { users: [ OrganizationUser( user: PublicUser.fromPrivateUser(PrivateUser.forTest()), - role: OrganizationRole.owner, + role: Role.owner, ), ], ); diff --git a/packages/shorebird_code_push_protocol/test/src/messages/get_organizations/get_organizations_response_test.dart b/packages/shorebird_code_push_protocol/test/src/messages/get_organizations/get_organizations_response_test.dart index 5f441e4f..6c3b08ef 100644 --- a/packages/shorebird_code_push_protocol/test/src/messages/get_organizations/get_organizations_response_test.dart +++ b/packages/shorebird_code_push_protocol/test/src/messages/get_organizations/get_organizations_response_test.dart @@ -8,7 +8,7 @@ void main() { organizations: [ OrganizationMembership( organization: Organization.forTest(), - role: OrganizationRole.member, + role: Role.member, ), ], ); diff --git a/packages/shorebird_code_push_protocol/test/src/models/organization_membership_test.dart b/packages/shorebird_code_push_protocol/test/src/models/organization_membership_test.dart index 3a55e65b..6daf13ee 100644 --- a/packages/shorebird_code_push_protocol/test/src/models/organization_membership_test.dart +++ b/packages/shorebird_code_push_protocol/test/src/models/organization_membership_test.dart @@ -6,7 +6,7 @@ void main() { test('can be (de)serialized', () { final membership = OrganizationMembership( organization: Organization.forTest(), - role: OrganizationRole.member, + role: Role.member, ); expect( OrganizationMembership.fromJson(membership.toJson()).toJson(), @@ -24,14 +24,14 @@ void main() { createdAt: date, updatedAt: date, ), - role: OrganizationRole.member, + role: Role.member, ); final otherMembership = OrganizationMembership( organization: Organization.forTest( createdAt: date, updatedAt: date, ), - role: OrganizationRole.member, + role: Role.member, ); expect(membership, equals(otherMembership)); }); @@ -44,14 +44,14 @@ void main() { createdAt: date, updatedAt: date, ), - role: OrganizationRole.member, + role: Role.member, ); final otherMembership = OrganizationMembership( organization: Organization.forTest( createdAt: date, updatedAt: date, ), - role: OrganizationRole.admin, + role: Role.admin, ); expect(membership, isNot(equals(otherMembership))); }); diff --git a/packages/shorebird_code_push_protocol/test/src/models/organization_user_test.dart b/packages/shorebird_code_push_protocol/test/src/models/organization_user_test.dart index d456681f..c4cbd5af 100644 --- a/packages/shorebird_code_push_protocol/test/src/models/organization_user_test.dart +++ b/packages/shorebird_code_push_protocol/test/src/models/organization_user_test.dart @@ -6,7 +6,7 @@ void main() { test('can be (de)serialized', () { final organizationUser = OrganizationUser( user: PublicUser.fromPrivateUser(PrivateUser.forTest()), - role: OrganizationRole.member, + role: Role.member, ); expect( OrganizationUser.fromJson(organizationUser.toJson()).toJson(),