From a5c3d64fe3b5fcd1998ec0f8c7270de0a26cfa27 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 16 Aug 2025 13:39:12 -0400 Subject: [PATCH] Move transformers to GraphQL namespace and remove GraphQL from name --- .../Authority/LoginAuthority.cs | 4 +-- .../Authority/UserAuthority.cs | 4 +-- .../GraphQL/Mutations/UserGroupMutations.cs | 6 ++-- .../GraphQL/Mutations/UserMutations.cs | 20 ++++++------- .../OAuthConnectionTransformer.cs | 22 ++++++++++++++ .../Transformers/OidcConnectionTransformer.cs | 22 ++++++++++++++ .../Transformers/PermissionSetTransformer.cs} | 16 +++++----- .../RightsHolderTransformer{TRight}.cs} | 9 +++--- .../Transformers/UpdatedUserTransformer.cs | 20 +++++++++++++ .../Transformers/UserGroupTransformer.cs | 26 +++++++++++++++++ .../Transformers/UserNameTransformer.cs | 22 ++++++++++++++ .../Transformers/UserTransformer.cs} | 29 ++++++++++--------- .../GraphQL/Types/UpdatedUser.cs | 4 +-- .../GraphQL/Types/User.cs | 10 +++---- .../GraphQL/Types/UserGroup.cs | 8 ++--- .../GraphQL/Types/UserGroupsRepository.cs | 8 ++--- .../GraphQL/Types/UserName.cs | 4 +-- .../GraphQL/Types/UsersRepository.cs | 6 ++-- .../Models/OAuthConnection.cs | 4 +-- .../Models/OidcConnection.cs | 4 +-- .../Models/PermissionSet.cs | 4 +-- .../TransformerBase{TInput,TOutput}.cs | 2 +- .../OAuthConnectionGraphQLTransformer.cs | 20 ------------- .../OidcConnectionGraphQLTransformer.cs | 20 ------------- .../UpdatedUserGraphQLTransformer.cs | 18 ------------ .../UserGroupGraphQLTransformer.cs | 24 --------------- .../UserNameGraphQLTransformer.cs | 20 ------------- .../Models/UpdatedUser.cs | 4 +-- src/Tgstation.Server.Host/Models/User.cs | 6 ++-- src/Tgstation.Server.Host/Models/UserGroup.cs | 4 +-- 30 files changed, 191 insertions(+), 179 deletions(-) create mode 100644 src/Tgstation.Server.Host/GraphQL/Transformers/OAuthConnectionTransformer.cs create mode 100644 src/Tgstation.Server.Host/GraphQL/Transformers/OidcConnectionTransformer.cs rename src/Tgstation.Server.Host/{Models/Transformers/PermissionSetGraphQLTransformer.cs => GraphQL/Transformers/PermissionSetTransformer.cs} (64%) rename src/Tgstation.Server.Host/{Models/Transformers/RightsHolderGraphQLTransformer{TRight}.cs => GraphQL/Transformers/RightsHolderTransformer{TRight}.cs} (61%) create mode 100644 src/Tgstation.Server.Host/GraphQL/Transformers/UpdatedUserTransformer.cs create mode 100644 src/Tgstation.Server.Host/GraphQL/Transformers/UserGroupTransformer.cs create mode 100644 src/Tgstation.Server.Host/GraphQL/Transformers/UserNameTransformer.cs rename src/Tgstation.Server.Host/{Models/Transformers/UserGraphQLTransformer.cs => GraphQL/Transformers/UserTransformer.cs} (51%) rename src/Tgstation.Server.Host/Models/{Transformers => }/TransformerBase{TInput,TOutput}.cs (99%) delete mode 100644 src/Tgstation.Server.Host/Models/Transformers/OAuthConnectionGraphQLTransformer.cs delete mode 100644 src/Tgstation.Server.Host/Models/Transformers/OidcConnectionGraphQLTransformer.cs delete mode 100644 src/Tgstation.Server.Host/Models/Transformers/UpdatedUserGraphQLTransformer.cs delete mode 100644 src/Tgstation.Server.Host/Models/Transformers/UserGroupGraphQLTransformer.cs delete mode 100644 src/Tgstation.Server.Host/Models/Transformers/UserNameGraphQLTransformer.cs diff --git a/src/Tgstation.Server.Host/Authority/LoginAuthority.cs b/src/Tgstation.Server.Host/Authority/LoginAuthority.cs index f0286767e4..1d1ba896db 100644 --- a/src/Tgstation.Server.Host/Authority/LoginAuthority.cs +++ b/src/Tgstation.Server.Host/Authority/LoginAuthority.cs @@ -15,8 +15,8 @@ using Tgstation.Server.Host.Authority.Core; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Database; using Tgstation.Server.Host.GraphQL.Mutations.Payloads; +using Tgstation.Server.Host.GraphQL.Transformers; using Tgstation.Server.Host.Models; -using Tgstation.Server.Host.Models.Transformers; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Security.OAuth; using Tgstation.Server.Host.Utils; @@ -302,7 +302,7 @@ namespace Tgstation.Server.Host.Authority var payload = new LoginResult { Bearer = token, - User = ((IApiTransformable)user).ToApi(), + User = ((IApiTransformable)user).ToApi(), }; if (usingSystemIdentity) diff --git a/src/Tgstation.Server.Host/Authority/UserAuthority.cs b/src/Tgstation.Server.Host/Authority/UserAuthority.cs index f3f1037868..59769f696f 100644 --- a/src/Tgstation.Server.Host/Authority/UserAuthority.cs +++ b/src/Tgstation.Server.Host/Authority/UserAuthority.cs @@ -24,8 +24,8 @@ using Tgstation.Server.Host.Authority.Core; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Extensions; +using Tgstation.Server.Host.GraphQL.Transformers; using Tgstation.Server.Host.Models; -using Tgstation.Server.Host.Models.Transformers; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Security.RightsEvaluation; @@ -743,7 +743,7 @@ namespace Tgstation.Server.Host.Authority user.Require(x => x.Id)) .Select(topic => topicEventSender.SendAsync( topic, - ((IApiTransformable)user).ToApi(), + ((IApiTransformable)user).ToApi(), CancellationToken.None))); // DCT: Operation should always run /// diff --git a/src/Tgstation.Server.Host/GraphQL/Mutations/UserGroupMutations.cs b/src/Tgstation.Server.Host/GraphQL/Mutations/UserGroupMutations.cs index 912780cacb..1c6fb976d9 100644 --- a/src/Tgstation.Server.Host/GraphQL/Mutations/UserGroupMutations.cs +++ b/src/Tgstation.Server.Host/GraphQL/Mutations/UserGroupMutations.cs @@ -8,8 +8,8 @@ using HotChocolate.Types.Relay; using Tgstation.Server.Host.Authority; using Tgstation.Server.Host.GraphQL.Mutations.Payloads; +using Tgstation.Server.Host.GraphQL.Transformers; using Tgstation.Server.Host.GraphQL.Types; -using Tgstation.Server.Host.Models.Transformers; namespace Tgstation.Server.Host.GraphQL.Mutations { @@ -52,7 +52,7 @@ namespace Tgstation.Server.Host.GraphQL.Mutations ArgumentNullException.ThrowIfNull(name); ArgumentNullException.ThrowIfNull(userGroupAuthority); - return userGroupAuthority.InvokeTransformable( + return userGroupAuthority.InvokeTransformable( authority => authority.Create(name, TransformApiPermissionSet(permissionSet), cancellationToken)); } @@ -74,7 +74,7 @@ namespace Tgstation.Server.Host.GraphQL.Mutations CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(userGroupAuthority); - return userGroupAuthority.InvokeTransformable( + return userGroupAuthority.InvokeTransformable( authority => authority.Update(id, newName, TransformApiPermissionSet(newPermissionSet), cancellationToken)); } diff --git a/src/Tgstation.Server.Host/GraphQL/Mutations/UserMutations.cs b/src/Tgstation.Server.Host/GraphQL/Mutations/UserMutations.cs index b616be34d2..ff1cc21963 100644 --- a/src/Tgstation.Server.Host/GraphQL/Mutations/UserMutations.cs +++ b/src/Tgstation.Server.Host/GraphQL/Mutations/UserMutations.cs @@ -11,9 +11,9 @@ using HotChocolate.Types.Relay; using Tgstation.Server.Api.Models.Request; using Tgstation.Server.Host.Authority; using Tgstation.Server.Host.GraphQL.Mutations.Payloads; +using Tgstation.Server.Host.GraphQL.Transformers; using Tgstation.Server.Host.GraphQL.Types; using Tgstation.Server.Host.GraphQL.Types.OAuth; -using Tgstation.Server.Host.Models.Transformers; using Tgstation.Server.Host.Security; namespace Tgstation.Server.Host.GraphQL.Mutations @@ -52,7 +52,7 @@ namespace Tgstation.Server.Host.GraphQL.Mutations ArgumentNullException.ThrowIfNull(password); ArgumentNullException.ThrowIfNull(userAuthority); - return userAuthority.InvokeTransformable( + return userAuthority.InvokeTransformable( authority => authority.Create( new UserCreateRequest { @@ -112,7 +112,7 @@ namespace Tgstation.Server.Host.GraphQL.Mutations ArgumentNullException.ThrowIfNull(password); ArgumentNullException.ThrowIfNull(userAuthority); - return userAuthority.InvokeTransformable( + return userAuthority.InvokeTransformable( authority => authority.Create( new UserCreateRequest { @@ -167,7 +167,7 @@ namespace Tgstation.Server.Host.GraphQL.Mutations ArgumentNullException.ThrowIfNull(oAuthConnections); ArgumentNullException.ThrowIfNull(userAuthority); - return userAuthority.InvokeTransformable( + return userAuthority.InvokeTransformable( authority => authority.Create( new UserCreateRequest { @@ -225,7 +225,7 @@ namespace Tgstation.Server.Host.GraphQL.Mutations ArgumentNullException.ThrowIfNull(oAuthConnections); ArgumentNullException.ThrowIfNull(userAuthority); - return userAuthority.InvokeTransformable( + return userAuthority.InvokeTransformable( authority => authority.Create( new UserCreateRequest { @@ -279,7 +279,7 @@ namespace Tgstation.Server.Host.GraphQL.Mutations ArgumentNullException.ThrowIfNull(systemIdentifier); ArgumentNullException.ThrowIfNull(userAuthority); - return userAuthority.InvokeTransformable( + return userAuthority.InvokeTransformable( authority => authority.Create( new UserCreateRequest { @@ -335,7 +335,7 @@ namespace Tgstation.Server.Host.GraphQL.Mutations ArgumentNullException.ThrowIfNull(systemIdentifier); ArgumentNullException.ThrowIfNull(userAuthority); - return userAuthority.InvokeTransformable( + return userAuthority.InvokeTransformable( authority => authority.Create( new UserCreateRequest { @@ -381,7 +381,7 @@ namespace Tgstation.Server.Host.GraphQL.Mutations { ArgumentNullException.ThrowIfNull(newPassword); ArgumentNullException.ThrowIfNull(userAuthority); - return userAuthority.InvokeTransformable( + return userAuthority.InvokeTransformable( authority => authority.Update( new UserUpdateRequest { @@ -410,7 +410,7 @@ namespace Tgstation.Server.Host.GraphQL.Mutations { ArgumentNullException.ThrowIfNull(newOAuthConnections); ArgumentNullException.ThrowIfNull(userAuthority); - return userAuthority.InvokeTransformable( + return userAuthority.InvokeTransformable( authority => authority.Update( new UserUpdateRequest { @@ -573,7 +573,7 @@ namespace Tgstation.Server.Host.GraphQL.Mutations IEnumerable? newOidcConnections, IGraphQLAuthorityInvoker userAuthority, CancellationToken cancellationToken) - => userAuthority.InvokeTransformable( + => userAuthority.InvokeTransformable( authority => authority.Update( new UserUpdateRequest { diff --git a/src/Tgstation.Server.Host/GraphQL/Transformers/OAuthConnectionTransformer.cs b/src/Tgstation.Server.Host/GraphQL/Transformers/OAuthConnectionTransformer.cs new file mode 100644 index 0000000000..213c752f27 --- /dev/null +++ b/src/Tgstation.Server.Host/GraphQL/Transformers/OAuthConnectionTransformer.cs @@ -0,0 +1,22 @@ +using Tgstation.Server.Host.GraphQL.Types.OAuth; + +namespace Tgstation.Server.Host.GraphQL.Transformers +{ + /// + /// for s. + /// + sealed class OAuthConnectionTransformer : Models.TransformerBase + { + /// + /// Initializes a new instance of the class. + /// + public OAuthConnectionTransformer() + : base(model => new Types.OAuth.OAuthConnection + { + ExternalUserId = model.ExternalUserId ?? NotNullFallback(), + Provider = model.Provider, + }) + { + } + } +} diff --git a/src/Tgstation.Server.Host/GraphQL/Transformers/OidcConnectionTransformer.cs b/src/Tgstation.Server.Host/GraphQL/Transformers/OidcConnectionTransformer.cs new file mode 100644 index 0000000000..dcfe3c90b3 --- /dev/null +++ b/src/Tgstation.Server.Host/GraphQL/Transformers/OidcConnectionTransformer.cs @@ -0,0 +1,22 @@ +using Tgstation.Server.Host.GraphQL.Types.OAuth; + +namespace Tgstation.Server.Host.GraphQL.Transformers +{ + /// + /// for s. + /// + sealed class OidcConnectionTransformer : Models.TransformerBase + { + /// + /// Initializes a new instance of the class. + /// + public OidcConnectionTransformer() + : base(model => new OidcConnection + { + ExternalUserId = model.ExternalUserId ?? NotNullFallback(), + SchemeKey = model.SchemeKey ?? NotNullFallback(), + }) + { + } + } +} diff --git a/src/Tgstation.Server.Host/Models/Transformers/PermissionSetGraphQLTransformer.cs b/src/Tgstation.Server.Host/GraphQL/Transformers/PermissionSetTransformer.cs similarity index 64% rename from src/Tgstation.Server.Host/Models/Transformers/PermissionSetGraphQLTransformer.cs rename to src/Tgstation.Server.Host/GraphQL/Transformers/PermissionSetTransformer.cs index 0c4d044e1c..a0a32c841c 100644 --- a/src/Tgstation.Server.Host/Models/Transformers/PermissionSetGraphQLTransformer.cs +++ b/src/Tgstation.Server.Host/GraphQL/Transformers/PermissionSetTransformer.cs @@ -1,26 +1,26 @@ using Tgstation.Server.Api.Rights; using Tgstation.Server.Host.GraphQL.Types; -namespace Tgstation.Server.Host.Models.Transformers +namespace Tgstation.Server.Host.GraphQL.Transformers { /// - /// for s. + /// for s. /// - sealed class PermissionSetGraphQLTransformer : TransformerBase + sealed class PermissionSetTransformer : Models.TransformerBase { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public PermissionSetGraphQLTransformer() + public PermissionSetTransformer() : base( BuildSubProjection< InstanceManagerRights?, AdministrationRights?, RightsHolder, RightsHolder, - RightsHolderGraphQLTransformer, - RightsHolderGraphQLTransformer>( - (model, instanceManagerRights, administrationRights) => new GraphQL.Types.PermissionSet + RightsHolderTransformer, + RightsHolderTransformer>( + (model, instanceManagerRights, administrationRights) => new PermissionSet { AdministrationRights = administrationRights ?? NotNullFallback>(), InstanceManagerRights = instanceManagerRights ?? NotNullFallback>(), diff --git a/src/Tgstation.Server.Host/Models/Transformers/RightsHolderGraphQLTransformer{TRight}.cs b/src/Tgstation.Server.Host/GraphQL/Transformers/RightsHolderTransformer{TRight}.cs similarity index 61% rename from src/Tgstation.Server.Host/Models/Transformers/RightsHolderGraphQLTransformer{TRight}.cs rename to src/Tgstation.Server.Host/GraphQL/Transformers/RightsHolderTransformer{TRight}.cs index a46cbfdd03..5a050e0c18 100644 --- a/src/Tgstation.Server.Host/Models/Transformers/RightsHolderGraphQLTransformer{TRight}.cs +++ b/src/Tgstation.Server.Host/GraphQL/Transformers/RightsHolderTransformer{TRight}.cs @@ -1,20 +1,21 @@ using System; using Tgstation.Server.Host.GraphQL.Types; +using Tgstation.Server.Host.Models; -namespace Tgstation.Server.Host.Models.Transformers +namespace Tgstation.Server.Host.GraphQL.Transformers { /// /// for s. /// /// The of the . - sealed class RightsHolderGraphQLTransformer : TransformerBase> + sealed class RightsHolderTransformer : TransformerBase> where TRight : struct, Enum { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public RightsHolderGraphQLTransformer() + public RightsHolderTransformer() : base(right => new RightsHolder { Right = right ?? NotNullFallback(), diff --git a/src/Tgstation.Server.Host/GraphQL/Transformers/UpdatedUserTransformer.cs b/src/Tgstation.Server.Host/GraphQL/Transformers/UpdatedUserTransformer.cs new file mode 100644 index 0000000000..cceb5ea027 --- /dev/null +++ b/src/Tgstation.Server.Host/GraphQL/Transformers/UpdatedUserTransformer.cs @@ -0,0 +1,20 @@ +using Tgstation.Server.Host.GraphQL.Types; + +namespace Tgstation.Server.Host.GraphQL.Transformers +{ + /// + /// for s. + /// + sealed class UpdatedUserTransformer : Models.TransformerBase + { + /// + /// Initializes a new instance of the class. + /// + public UpdatedUserTransformer() + : base(model => model.User != null + ? new UpdatedUser(model.User) + : new UpdatedUser(model.Id)) + { + } + } +} diff --git a/src/Tgstation.Server.Host/GraphQL/Transformers/UserGroupTransformer.cs b/src/Tgstation.Server.Host/GraphQL/Transformers/UserGroupTransformer.cs new file mode 100644 index 0000000000..815995acd1 --- /dev/null +++ b/src/Tgstation.Server.Host/GraphQL/Transformers/UserGroupTransformer.cs @@ -0,0 +1,26 @@ +using Tgstation.Server.Host.GraphQL.Types; + +namespace Tgstation.Server.Host.GraphQL.Transformers +{ + /// + /// for s. + /// + sealed class UserGroupTransformer : Models.TransformerBase + { + /// + /// Initializes a new instance of the class. + /// + public UserGroupTransformer() + : base( + BuildSubProjection( + (model, permissionSet) => new UserGroup + { + Id = model.Id!.Value, + Name = model.Name!, + PermissionSet = permissionSet!, + }, + model => model.PermissionSet)) + { + } + } +} diff --git a/src/Tgstation.Server.Host/GraphQL/Transformers/UserNameTransformer.cs b/src/Tgstation.Server.Host/GraphQL/Transformers/UserNameTransformer.cs new file mode 100644 index 0000000000..608a9b7a78 --- /dev/null +++ b/src/Tgstation.Server.Host/GraphQL/Transformers/UserNameTransformer.cs @@ -0,0 +1,22 @@ +using Tgstation.Server.Host.GraphQL.Types; + +namespace Tgstation.Server.Host.GraphQL.Transformers +{ + /// + /// for s. + /// + sealed class UserNameTransformer : Models.TransformerBase + { + /// + /// Initializes a new instance of the class. + /// + public UserNameTransformer() + : base(model => new UserName + { + Id = model.Id!.Value, + Name = model.Name!, + }) + { + } + } +} diff --git a/src/Tgstation.Server.Host/Models/Transformers/UserGraphQLTransformer.cs b/src/Tgstation.Server.Host/GraphQL/Transformers/UserTransformer.cs similarity index 51% rename from src/Tgstation.Server.Host/Models/Transformers/UserGraphQLTransformer.cs rename to src/Tgstation.Server.Host/GraphQL/Transformers/UserTransformer.cs index 7682f286ef..23109be9b9 100644 --- a/src/Tgstation.Server.Host/Models/Transformers/UserGraphQLTransformer.cs +++ b/src/Tgstation.Server.Host/GraphQL/Transformers/UserTransformer.cs @@ -1,25 +1,27 @@ using System; -namespace Tgstation.Server.Host.Models.Transformers +using Tgstation.Server.Host.GraphQL.Types; + +namespace Tgstation.Server.Host.GraphQL.Transformers { /// - /// for s. + /// for s. /// - sealed class UserGraphQLTransformer : TransformerBase + sealed class UserTransformer : Models.TransformerBase { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public UserGraphQLTransformer() + public UserTransformer() : base( BuildSubProjection< + Models.UserGroup, + Models.PermissionSet, UserGroup, PermissionSet, - GraphQL.Types.UserGroup, - GraphQL.Types.PermissionSet, - UserGroupGraphQLTransformer, - PermissionSetGraphQLTransformer>( - (model, group, ownedPermissionSet) => new GraphQL.Types.User + UserGroupTransformer, + PermissionSetTransformer>( + (model, group, ownedPermissionSet) => new User { CreatedAt = model.CreatedAt ?? NotNullFallback(), CanonicalName = model.CanonicalName ?? NotNullFallback(), @@ -29,11 +31,10 @@ namespace Tgstation.Server.Host.Models.Transformers Name = model.Name ?? NotNullFallback(), SystemIdentifier = model.SystemIdentifier, OwnedPermissionSet = ownedPermissionSet, - EffectivePermissionSet = ownedPermissionSet != null - ? ownedPermissionSet - : group != null + EffectivePermissionSet = ownedPermissionSet ?? + (group != null ? group.PermissionSet - : NotNullFallback(), + : NotNullFallback()), Group = group, }, model => model.Group, diff --git a/src/Tgstation.Server.Host/GraphQL/Types/UpdatedUser.cs b/src/Tgstation.Server.Host/GraphQL/Types/UpdatedUser.cs index 41cd8959df..18652abcb6 100644 --- a/src/Tgstation.Server.Host/GraphQL/Types/UpdatedUser.cs +++ b/src/Tgstation.Server.Host/GraphQL/Types/UpdatedUser.cs @@ -2,8 +2,8 @@ using HotChocolate.Types.Relay; +using Tgstation.Server.Host.GraphQL.Transformers; using Tgstation.Server.Host.Models; -using Tgstation.Server.Host.Models.Transformers; namespace Tgstation.Server.Host.GraphQL.Types { @@ -30,7 +30,7 @@ namespace Tgstation.Server.Host.GraphQL.Types public UpdatedUser(Models.User user) : this((user ?? throw new ArgumentNullException(nameof(user))).Require(u => u.Id)) { - User = ((IApiTransformable)user).ToApi(); + User = ((IApiTransformable)user).ToApi(); } /// diff --git a/src/Tgstation.Server.Host/GraphQL/Types/User.cs b/src/Tgstation.Server.Host/GraphQL/Types/User.cs index 9080743b78..8df9ef3c82 100644 --- a/src/Tgstation.Server.Host/GraphQL/Types/User.cs +++ b/src/Tgstation.Server.Host/GraphQL/Types/User.cs @@ -16,8 +16,8 @@ using Tgstation.Server.Host.Authority; using Tgstation.Server.Host.Authority.Core; using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.GraphQL.Interfaces; +using Tgstation.Server.Host.GraphQL.Transformers; using Tgstation.Server.Host.GraphQL.Types.OAuth; -using Tgstation.Server.Host.Models.Transformers; namespace Tgstation.Server.Host.GraphQL.Types { @@ -94,7 +94,7 @@ namespace Tgstation.Server.Host.GraphQL.Types ArgumentNullException.ThrowIfNull(ids); ArgumentNullException.ThrowIfNull(userAuthority); - return userAuthority.ExecuteDataLoader( + return userAuthority.ExecuteDataLoader( (authority, id) => authority.GetId(id, false, cancellationToken), ids, queryContext); @@ -132,7 +132,7 @@ namespace Tgstation.Server.Host.GraphQL.Types if (!CreatedById.HasValue) return null; - var user = await userAuthority.InvokeTransformable(authority => authority.GetId(CreatedById.Value, false, true, cancellationToken)); + var user = await userAuthority.InvokeTransformable(authority => authority.GetId(CreatedById.Value, false, true, cancellationToken)); if (user.CanonicalName == Models.User.CanonicalizeName(Models.User.TgsSystemUserName)) return new UserName(user); @@ -154,7 +154,7 @@ namespace Tgstation.Server.Host.GraphQL.Types CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(userAuthority); - return userAuthority.InvokeTransformableQueryable( + return userAuthority.InvokeTransformableQueryable( authority => authority.OAuthConnections(Id, cancellationToken)); } @@ -173,7 +173,7 @@ namespace Tgstation.Server.Host.GraphQL.Types CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(userAuthority); - return userAuthority.InvokeTransformableQueryable( + return userAuthority.InvokeTransformableQueryable( authority => authority.OidcConnections(Id, cancellationToken)); } } diff --git a/src/Tgstation.Server.Host/GraphQL/Types/UserGroup.cs b/src/Tgstation.Server.Host/GraphQL/Types/UserGroup.cs index c2cd444d77..7a5477b571 100644 --- a/src/Tgstation.Server.Host/GraphQL/Types/UserGroup.cs +++ b/src/Tgstation.Server.Host/GraphQL/Types/UserGroup.cs @@ -7,9 +7,9 @@ using HotChocolate; using HotChocolate.Data; using HotChocolate.Types; using HotChocolate.Types.Relay; -using Tgstation.Server.Host.Authority; -using Tgstation.Server.Host.Models.Transformers; +using Tgstation.Server.Host.Authority; +using Tgstation.Server.Host.GraphQL.Transformers; namespace Tgstation.Server.Host.GraphQL.Types { @@ -37,7 +37,7 @@ namespace Tgstation.Server.Host.GraphQL.Types CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(userGroupAuthority); - return userGroupAuthority.InvokeTransformableAllowMissing( + return userGroupAuthority.InvokeTransformableAllowMissing( authority => authority.GetId(id, false, cancellationToken)); } @@ -53,7 +53,7 @@ namespace Tgstation.Server.Host.GraphQL.Types [Service] IGraphQLAuthorityInvoker userAuthority) { ArgumentNullException.ThrowIfNull(userAuthority); - var dtoQueryable = await userAuthority.InvokeTransformableQueryable( + var dtoQueryable = await userAuthority.InvokeTransformableQueryable( authority => authority .Queryable(false), queryable => queryable.Where(user => user.GroupId == Id)); diff --git a/src/Tgstation.Server.Host/GraphQL/Types/UserGroupsRepository.cs b/src/Tgstation.Server.Host/GraphQL/Types/UserGroupsRepository.cs index d5ff1b5a76..ab1730cfc0 100644 --- a/src/Tgstation.Server.Host/GraphQL/Types/UserGroupsRepository.cs +++ b/src/Tgstation.Server.Host/GraphQL/Types/UserGroupsRepository.cs @@ -9,7 +9,7 @@ using HotChocolate.Types; using HotChocolate.Types.Relay; using Tgstation.Server.Host.Authority; -using Tgstation.Server.Host.Models.Transformers; +using Tgstation.Server.Host.GraphQL.Transformers; namespace Tgstation.Server.Host.GraphQL.Types { @@ -29,7 +29,7 @@ namespace Tgstation.Server.Host.GraphQL.Types CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(userGroupAuthority); - return userGroupAuthority.InvokeTransformableAllowMissing(authority => authority.Read(cancellationToken)); + return userGroupAuthority.InvokeTransformableAllowMissing(authority => authority.Read(cancellationToken)); } /// @@ -57,7 +57,7 @@ namespace Tgstation.Server.Host.GraphQL.Types [Service] IGraphQLAuthorityInvoker userGroupAuthority) { ArgumentNullException.ThrowIfNull(userGroupAuthority); - var dtoQueryable = await userGroupAuthority.InvokeTransformableQueryable( + var dtoQueryable = await userGroupAuthority.InvokeTransformableQueryable( authority => authority.Queryable(false)); return dtoQueryable; } @@ -76,7 +76,7 @@ namespace Tgstation.Server.Host.GraphQL.Types [Service] IGraphQLAuthorityInvoker userAuthority) { ArgumentNullException.ThrowIfNull(userAuthority); - var dtoQueryable = await userAuthority.InvokeTransformableQueryable( + var dtoQueryable = await userAuthority.InvokeTransformableQueryable( authority => authority .Queryable(false), queryable => queryable.Where(user => user.GroupId == groupId)); diff --git a/src/Tgstation.Server.Host/GraphQL/Types/UserName.cs b/src/Tgstation.Server.Host/GraphQL/Types/UserName.cs index 9ba7b79cf1..c3d9117241 100644 --- a/src/Tgstation.Server.Host/GraphQL/Types/UserName.cs +++ b/src/Tgstation.Server.Host/GraphQL/Types/UserName.cs @@ -8,7 +8,7 @@ using HotChocolate.Types.Relay; using Tgstation.Server.Host.Authority; using Tgstation.Server.Host.GraphQL.Interfaces; -using Tgstation.Server.Host.Models.Transformers; +using Tgstation.Server.Host.GraphQL.Transformers; namespace Tgstation.Server.Host.GraphQL.Types { @@ -31,7 +31,7 @@ namespace Tgstation.Server.Host.GraphQL.Types CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(userAuthority); - return userAuthority.InvokeTransformableAllowMissing( + return userAuthority.InvokeTransformableAllowMissing( authority => authority.GetId(id, false, true, cancellationToken)); } diff --git a/src/Tgstation.Server.Host/GraphQL/Types/UsersRepository.cs b/src/Tgstation.Server.Host/GraphQL/Types/UsersRepository.cs index d735684565..7b0d4bbc4e 100644 --- a/src/Tgstation.Server.Host/GraphQL/Types/UsersRepository.cs +++ b/src/Tgstation.Server.Host/GraphQL/Types/UsersRepository.cs @@ -14,7 +14,7 @@ using Microsoft.Extensions.Options; using Tgstation.Server.Host.Authority; using Tgstation.Server.Host.Configuration; -using Tgstation.Server.Host.Models.Transformers; +using Tgstation.Server.Host.GraphQL.Transformers; namespace Tgstation.Server.Host.GraphQL.Types { @@ -46,7 +46,7 @@ namespace Tgstation.Server.Host.GraphQL.Types CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(userAuthority); - return userAuthority.InvokeTransformable(authority => authority.Read(cancellationToken)); + return userAuthority.InvokeTransformable(authority => authority.Read(cancellationToken)); } /// @@ -77,7 +77,7 @@ namespace Tgstation.Server.Host.GraphQL.Types [Service] IGraphQLAuthorityInvoker userAuthority) { ArgumentNullException.ThrowIfNull(userAuthority); - var dtoQueryable = await userAuthority.InvokeTransformableQueryable( + var dtoQueryable = await userAuthority.InvokeTransformableQueryable( authority => authority.Queryable(false)); return dtoQueryable; } diff --git a/src/Tgstation.Server.Host/Models/OAuthConnection.cs b/src/Tgstation.Server.Host/Models/OAuthConnection.cs index c0fbc00840..1b652f79be 100644 --- a/src/Tgstation.Server.Host/Models/OAuthConnection.cs +++ b/src/Tgstation.Server.Host/Models/OAuthConnection.cs @@ -1,13 +1,13 @@ using System.ComponentModel.DataAnnotations; -using Tgstation.Server.Host.Models.Transformers; +using Tgstation.Server.Host.GraphQL.Transformers; namespace Tgstation.Server.Host.Models { /// public sealed class OAuthConnection : Api.Models.OAuthConnection, ILegacyApiTransformable, - IApiTransformable + IApiTransformable { /// /// The row Id. diff --git a/src/Tgstation.Server.Host/Models/OidcConnection.cs b/src/Tgstation.Server.Host/Models/OidcConnection.cs index b0248d1aa2..c80daceb87 100644 --- a/src/Tgstation.Server.Host/Models/OidcConnection.cs +++ b/src/Tgstation.Server.Host/Models/OidcConnection.cs @@ -1,13 +1,13 @@ using System.ComponentModel.DataAnnotations; -using Tgstation.Server.Host.Models.Transformers; +using Tgstation.Server.Host.GraphQL.Transformers; namespace Tgstation.Server.Host.Models { /// public sealed class OidcConnection : Api.Models.OidcConnection, ILegacyApiTransformable, - IApiTransformable + IApiTransformable { /// /// The row Id. diff --git a/src/Tgstation.Server.Host/Models/PermissionSet.cs b/src/Tgstation.Server.Host/Models/PermissionSet.cs index 94b769e4a8..3a5bbdaede 100644 --- a/src/Tgstation.Server.Host/Models/PermissionSet.cs +++ b/src/Tgstation.Server.Host/Models/PermissionSet.cs @@ -1,11 +1,11 @@ using System.Collections.Generic; -using Tgstation.Server.Host.Models.Transformers; +using Tgstation.Server.Host.GraphQL.Transformers; namespace Tgstation.Server.Host.Models { /// - public sealed class PermissionSet : Api.Models.PermissionSet, IApiTransformable + public sealed class PermissionSet : Api.Models.PermissionSet, IApiTransformable { /// /// The of . diff --git a/src/Tgstation.Server.Host/Models/Transformers/TransformerBase{TInput,TOutput}.cs b/src/Tgstation.Server.Host/Models/TransformerBase{TInput,TOutput}.cs similarity index 99% rename from src/Tgstation.Server.Host/Models/Transformers/TransformerBase{TInput,TOutput}.cs rename to src/Tgstation.Server.Host/Models/TransformerBase{TInput,TOutput}.cs index 318164c617..893f352067 100644 --- a/src/Tgstation.Server.Host/Models/Transformers/TransformerBase{TInput,TOutput}.cs +++ b/src/Tgstation.Server.Host/Models/TransformerBase{TInput,TOutput}.cs @@ -4,7 +4,7 @@ using System.Linq.Expressions; using Tgstation.Server.Host.Authority.Core; using Tgstation.Server.Host.Extensions; -namespace Tgstation.Server.Host.Models.Transformers +namespace Tgstation.Server.Host.Models { /// abstract class TransformerBase : ITransformer diff --git a/src/Tgstation.Server.Host/Models/Transformers/OAuthConnectionGraphQLTransformer.cs b/src/Tgstation.Server.Host/Models/Transformers/OAuthConnectionGraphQLTransformer.cs deleted file mode 100644 index ca37f34450..0000000000 --- a/src/Tgstation.Server.Host/Models/Transformers/OAuthConnectionGraphQLTransformer.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Tgstation.Server.Host.Models.Transformers -{ - /// - /// for s. - /// - sealed class OAuthConnectionGraphQLTransformer : TransformerBase - { - /// - /// Initializes a new instance of the class. - /// - public OAuthConnectionGraphQLTransformer() - : base(model => new GraphQL.Types.OAuth.OAuthConnection - { - ExternalUserId = model.ExternalUserId ?? NotNullFallback(), - Provider = model.Provider, - }) - { - } - } -} diff --git a/src/Tgstation.Server.Host/Models/Transformers/OidcConnectionGraphQLTransformer.cs b/src/Tgstation.Server.Host/Models/Transformers/OidcConnectionGraphQLTransformer.cs deleted file mode 100644 index 5287d5033f..0000000000 --- a/src/Tgstation.Server.Host/Models/Transformers/OidcConnectionGraphQLTransformer.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Tgstation.Server.Host.Models.Transformers -{ - /// - /// for s. - /// - sealed class OidcConnectionGraphQLTransformer : TransformerBase - { - /// - /// Initializes a new instance of the class. - /// - public OidcConnectionGraphQLTransformer() - : base(model => new GraphQL.Types.OAuth.OidcConnection - { - ExternalUserId = model.ExternalUserId ?? NotNullFallback(), - SchemeKey = model.SchemeKey ?? NotNullFallback(), - }) - { - } - } -} diff --git a/src/Tgstation.Server.Host/Models/Transformers/UpdatedUserGraphQLTransformer.cs b/src/Tgstation.Server.Host/Models/Transformers/UpdatedUserGraphQLTransformer.cs deleted file mode 100644 index 89ee7a93de..0000000000 --- a/src/Tgstation.Server.Host/Models/Transformers/UpdatedUserGraphQLTransformer.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Tgstation.Server.Host.Models.Transformers -{ - /// - /// for s. - /// - sealed class UpdatedUserGraphQLTransformer : TransformerBase - { - /// - /// Initializes a new instance of the class. - /// - public UpdatedUserGraphQLTransformer() - : base(model => model.User != null - ? new GraphQL.Types.UpdatedUser(model.User) - : new GraphQL.Types.UpdatedUser(model.Id)) - { - } - } -} diff --git a/src/Tgstation.Server.Host/Models/Transformers/UserGroupGraphQLTransformer.cs b/src/Tgstation.Server.Host/Models/Transformers/UserGroupGraphQLTransformer.cs deleted file mode 100644 index 2c53868511..0000000000 --- a/src/Tgstation.Server.Host/Models/Transformers/UserGroupGraphQLTransformer.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace Tgstation.Server.Host.Models.Transformers -{ - /// - /// for s. - /// - sealed class UserGroupGraphQLTransformer : TransformerBase - { - /// - /// Initializes a new instance of the class. - /// - public UserGroupGraphQLTransformer() - : base( - BuildSubProjection( - (model, permissionSet) => new GraphQL.Types.UserGroup - { - Id = model.Id!.Value, - Name = model.Name!, - PermissionSet = permissionSet!, - }, - model => model.PermissionSet)) - { - } - } -} diff --git a/src/Tgstation.Server.Host/Models/Transformers/UserNameGraphQLTransformer.cs b/src/Tgstation.Server.Host/Models/Transformers/UserNameGraphQLTransformer.cs deleted file mode 100644 index ebe6338895..0000000000 --- a/src/Tgstation.Server.Host/Models/Transformers/UserNameGraphQLTransformer.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Tgstation.Server.Host.Models.Transformers -{ - /// - /// for s. - /// - sealed class UserNameGraphQLTransformer : TransformerBase - { - /// - /// Initializes a new instance of the class. - /// - public UserNameGraphQLTransformer() - : base(model => new GraphQL.Types.UserName - { - Id = model.Id!.Value, - Name = model.Name!, - }) - { - } - } -} diff --git a/src/Tgstation.Server.Host/Models/UpdatedUser.cs b/src/Tgstation.Server.Host/Models/UpdatedUser.cs index ed7c6e2b6c..837a5146df 100644 --- a/src/Tgstation.Server.Host/Models/UpdatedUser.cs +++ b/src/Tgstation.Server.Host/Models/UpdatedUser.cs @@ -1,7 +1,7 @@ using System; using Tgstation.Server.Api.Models.Response; -using Tgstation.Server.Host.Models.Transformers; +using Tgstation.Server.Host.GraphQL.Transformers; namespace Tgstation.Server.Host.Models { @@ -10,7 +10,7 @@ namespace Tgstation.Server.Host.Models /// public sealed class UpdatedUser : ILegacyApiTransformable, - IApiTransformable + IApiTransformable { /// /// The 's . diff --git a/src/Tgstation.Server.Host/Models/User.cs b/src/Tgstation.Server.Host/Models/User.cs index e8bc06f6ba..dba5616b6d 100644 --- a/src/Tgstation.Server.Host/Models/User.cs +++ b/src/Tgstation.Server.Host/Models/User.cs @@ -5,15 +5,15 @@ using System.Linq; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Response; -using Tgstation.Server.Host.Models.Transformers; +using Tgstation.Server.Host.GraphQL.Transformers; namespace Tgstation.Server.Host.Models { /// public sealed class User : Api.Models.Internal.UserModelBase, ILegacyApiTransformable, - IApiTransformable, - IApiTransformable + IApiTransformable, + IApiTransformable { /// /// Username used when creating jobs automatically. diff --git a/src/Tgstation.Server.Host/Models/UserGroup.cs b/src/Tgstation.Server.Host/Models/UserGroup.cs index 6a8e21c18c..23907d9968 100644 --- a/src/Tgstation.Server.Host/Models/UserGroup.cs +++ b/src/Tgstation.Server.Host/Models/UserGroup.cs @@ -5,14 +5,14 @@ using System.Linq; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Response; -using Tgstation.Server.Host.Models.Transformers; +using Tgstation.Server.Host.GraphQL.Transformers; namespace Tgstation.Server.Host.Models { /// /// Represents a group of s. /// - public sealed class UserGroup : NamedEntity, ILegacyApiTransformable, IApiTransformable + public sealed class UserGroup : NamedEntity, ILegacyApiTransformable, IApiTransformable { /// /// The the has.