Skip to content

Commit

Permalink
Merge branch 'main' into query-get-deletion-process-by-id
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Feb 21, 2024
2 parents 8c187d1 + 46920ec commit 198600c
Show file tree
Hide file tree
Showing 291 changed files with 836 additions and 1,173 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\AdminUi.Infrastructure\AdminUi.Infrastructure.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\AdminUi.Infrastructure\AdminUi.Infrastructure.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\BuildingBlocks\src\BuildingBlocks.Infrastructure\BuildingBlocks.Infrastructure.csproj" />
</ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions AdminUi/src/AdminUi.Infrastructure/DTOs/ClientOverview.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
namespace Backbone.AdminUi.Infrastructure.DTOs;
public class ClientOverview
{
public string ClientId { get; set; }
public string DisplayName { get; set; }
public TierDTO DefaultTier { get; set; }
public DateTime CreatedAt { get; set; }
public required string ClientId { get; set; }
public required string DisplayName { get; set; }
public required TierDTO DefaultTier { get; set; }
public required DateTime CreatedAt { get; set; }
public int? MaxIdentities { get; set; }
public int NumberOfIdentities { get; set; }
public required int NumberOfIdentities { get; set; }
}
8 changes: 4 additions & 4 deletions AdminUi/src/AdminUi.Infrastructure/DTOs/IdentityOverview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

public class IdentityOverview
{
public string Address { get; set; }
public DateTime CreatedAt { get; set; }
public required string Address { get; set; }
public required DateTime CreatedAt { get; set; }
public DateTime? LastLoginAt { get; set; }
public string? CreatedWithClient { get; set; }
public int? DatawalletVersion { get; set; }
public byte IdentityVersion { get; set; }
public TierDTO Tier { get; set; }
public required byte IdentityVersion { get; set; }
public required TierDTO Tier { get; set; }
public int? NumberOfDevices { get; set; }
}
14 changes: 7 additions & 7 deletions AdminUi/src/AdminUi.Infrastructure/DTOs/RelationshipOverview.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
namespace Backbone.AdminUi.Infrastructure.DTOs;
public class RelationshipOverview
{
public string From { get; set; }
public string To { get; set; }
public string RelationshipTemplateId { get; set; }
public RelationshipStatus Status { get; set; }
public DateTime CreatedAt { get; set; }
public required string From { get; set; }
public required string To { get; set; }
public required string RelationshipTemplateId { get; set; }
public required RelationshipStatus Status { get; set; }
public required DateTime CreatedAt { get; set; }
public DateTime? AnsweredAt { get; set; }
public string CreatedByDevice { get; set; }
public string? AnsweredByDevice { get; set; }
public required string CreatedByDevice { get; set; }
public required string? AnsweredByDevice { get; set; }
}

public enum RelationshipStatus
Expand Down
6 changes: 3 additions & 3 deletions AdminUi/src/AdminUi.Infrastructure/DTOs/TierOverview.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Backbone.AdminUi.Infrastructure.DTOs;
public class TierOverview
{
public string Id { get; set; }
public string Name { get; set; }
public int NumberOfIdentities { get; set; }
public required string Id { get; set; }
public required string Name { get; set; }
public required int NumberOfIdentities { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ public AdminUiDbContext(DbContextOptions<AdminUiDbContext> options, IServiceProv
{
}

public DbSet<IdentityOverview> IdentityOverviews { get; set; }
public DbSet<IdentityOverview> IdentityOverviews { get; set; } = null!;

public DbSet<TierOverview> TierOverviews { get; set; }
public DbSet<TierOverview> TierOverviews { get; set; } = null!;

public DbSet<ClientOverview> ClientOverviews { get; set; }
public DbSet<ClientOverview> ClientOverviews { get; set; } = null!;

public DbSet<RelationshipOverview> RelationshipOverviews { get; set; }
public DbSet<RelationshipOverview> RelationshipOverviews { get; set; } = null!;

protected override void OnModelCreating(ModelBuilder builder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static IServiceCollection AddDatabase(this IServiceCollection services, S
public static IServiceCollection AddDatabase(this IServiceCollection services, Action<DbOptions> setupOptions)
{
var options = new DbOptions();
setupOptions?.Invoke(options);
setupOptions.Invoke(options);

services
.AddDbContext<AdminUiDbContext>(dbContextOptions =>
Expand Down Expand Up @@ -61,8 +61,8 @@ public static IServiceCollection AddDatabase(this IServiceCollection services, A

public class DbOptions
{
public string Provider { get; set; }
public string ConnectionString { get; set; }
public string Provider { get; set; } = null!;
public string ConnectionString { get; set; } = null!;
public RetryOptions RetryOptions { get; set; } = new();
}

Expand Down
7 changes: 3 additions & 4 deletions AdminUi/src/AdminUi/AdminUi.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<SpaRoot>ClientApp\</SpaRoot>
<SpaProxyServerUrl>http://localhost:4200</SpaProxyServerUrl>
Expand All @@ -12,9 +11,9 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OData" Version="8.2.4" />
<PackageReference Include="Microsoft.AspNetCore.SpaProxy" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.SpaProxy" Version="8.0.2" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -23,7 +22,7 @@
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
<PackageReference Include="NetEscapades.AspNetCore.SecurityHeaders" Version="0.21.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
<PackageReference Include="ReHackt.Extensions.Options.Validation" Version="8.0.1" />
<PackageReference Include="ReHackt.Extensions.Options.Validation" Version="8.0.2" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageReference Include="Serilog.Enrichers.ClientInfo" Version="2.0.3" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class ApiKeyAuthenticationSchemeHandler : AuthenticationHandler<ApiKeyAut
private readonly ApiKeyValidator _apiKeyValidator;
private const string API_KEY_HEADER_NAME = "X-API-KEY";

public ApiKeyAuthenticationSchemeHandler(IOptionsMonitor<ApiKeyAuthenticationSchemeOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock, ApiKeyValidator apiKeyValidator) : base(options, logger, encoder, clock)
public ApiKeyAuthenticationSchemeHandler(IOptionsMonitor<ApiKeyAuthenticationSchemeOptions> options, ILoggerFactory logger, UrlEncoder encoder, ApiKeyValidator apiKeyValidator) : base(options, logger, encoder)
{
_apiKeyValidator = apiKeyValidator;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h2 mat-dialog-title>{{ header }}</h2>
<mat-hint>A Client Secret will be generated if this field is left blank.</mat-hint>
</mat-form-field>
<div *ngIf="displayClientSecretWarning" class="client-secret-warning-container">
<span class="client-secret-warning">Please save the Client Secret since it will be unaccessible after exiting.</span>
<span class="client-secret-warning">Please save the Client Secret since it will be inaccessible after exiting.</span>
</div>
</div>
</mat-dialog-content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ <h2 class="header-title">{{ headerCreate }}</h2>
</mat-form-field>
</div>
<div *ngIf="displayClientSecretWarning" class="client-secret-warning-container">
<span class="client-secret-warning">Please save the Client Secret since it will be unaccessible after exiting.</span>
<span class="client-secret-warning">Please save the Client Secret since it will be inaccessible after exiting.</span>
</div>
<mat-list>
<mat-list-item class="auto-height">
Expand Down
4 changes: 2 additions & 2 deletions AdminUi/src/AdminUi/Controllers/ClientsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ public async Task<IActionResult> DeleteClient([FromRoute] string clientId, Cance

public class ChangeClientSecretRequest
{
public string NewSecret { get; set; }
public required string NewSecret { get; set; }
}

public class UpdateClientRequest
{
public string DefaultTier { get; set; }
public required string DefaultTier { get; set; }
public int? MaxIdentities { get; set; }
}
32 changes: 15 additions & 17 deletions AdminUi/src/AdminUi/Controllers/IdentitiesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
using Microsoft.AspNetCore.Mvc;
using GetIdentityQueryDevices = Backbone.Modules.Devices.Application.Identities.Queries.GetIdentity.GetIdentityQuery;
using GetIdentityQueryQuotas = Backbone.Modules.Quotas.Application.Identities.Queries.GetIdentity.GetIdentityQuery;
using GetIdentityResponseDevices = Backbone.Modules.Devices.Application.Identities.Queries.GetIdentity.GetIdentityResponse;
using GetIdentityResponseQuotas = Backbone.Modules.Quotas.Application.Identities.Queries.GetIdentity.GetIdentityResponse;

namespace Backbone.AdminUi.Controllers;

Expand Down Expand Up @@ -52,8 +50,8 @@ public async Task<IActionResult> DeleteIndividualQuota([FromRoute] string identi
[ProducesError(StatusCodes.Status404NotFound)]
public async Task<IActionResult> GetIdentityByAddress([FromRoute] string address, CancellationToken cancellationToken)
{
var identity = await _mediator.Send<GetIdentityResponseDevices>(new GetIdentityQueryDevices(address), cancellationToken);
var quotas = await _mediator.Send<GetIdentityResponseQuotas>(new GetIdentityQueryQuotas(address), cancellationToken);
var identity = await _mediator.Send(new GetIdentityQueryDevices(address), cancellationToken);
var quotas = await _mediator.Send(new GetIdentityQueryQuotas(address), cancellationToken);

var response = new GetIdentityResponse
{
Expand Down Expand Up @@ -118,27 +116,27 @@ public async Task<IActionResult> StartDeletionProcessAsSupport([FromRoute] strin

public class CreateQuotaForIdentityRequest
{
public string MetricKey { get; set; }
public int Max { get; set; }
public QuotaPeriod Period { get; set; }
public required string MetricKey { get; set; }
public required int Max { get; set; }
public required QuotaPeriod Period { get; set; }
}

public class UpdateIdentityTierRequest
{
public string TierId { get; set; }
public required string TierId { get; set; }
}

public class GetIdentityResponse
{
public string Address { get; set; }
public string ClientId { get; set; }
public byte[] PublicKey { get; set; }
public string TierId { get; set; }
public DateTime CreatedAt { get; set; }
public byte IdentityVersion { get; set; }
public int NumberOfDevices { get; set; }
public IEnumerable<DeviceDTO> Devices { get; set; }
public IEnumerable<QuotaDTO> Quotas { get; set; }
public required string Address { get; set; }
public required string? ClientId { get; set; }
public required byte[] PublicKey { get; set; }
public required string TierId { get; set; }
public required DateTime CreatedAt { get; set; }
public required byte IdentityVersion { get; set; }
public required int NumberOfDevices { get; set; }
public required IEnumerable<DeviceDTO> Devices { get; set; }
public required IEnumerable<QuotaDTO> Quotas { get; set; }
}

public class CreateIdentityRequest
Expand Down
15 changes: 5 additions & 10 deletions AdminUi/src/AdminUi/Controllers/LogsController.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using Backbone.BuildingBlocks.API.Mvc;
using Backbone.BuildingBlocks.API.Mvc.ControllerAttributes;
using Backbone.BuildingBlocks.Application.Abstractions.Exceptions;
using Backbone.Modules.Devices.Application;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using ApplicationException = Backbone.BuildingBlocks.Application.Abstractions.Exceptions.ApplicationException;

namespace Backbone.AdminUi.Controllers;
Expand All @@ -14,13 +12,11 @@ namespace Backbone.AdminUi.Controllers;
[Authorize("ApiKey")]
public class LogsController : ApiControllerBase
{
private readonly ApplicationOptions _options;
private readonly ILoggerFactory _loggerFactory;

public LogsController(
IMediator mediator, IOptions<ApplicationOptions> options, ILoggerFactory logger) : base(mediator)
IMediator mediator, ILoggerFactory logger) : base(mediator)
{
_options = options.Value;
_loggerFactory = logger;
}

Expand Down Expand Up @@ -54,7 +50,6 @@ public IActionResult CreateLog(LogRequest request)
break;
default:
throw new ApplicationException(GenericApplicationErrors.Validation.InvalidPropertyValue(nameof(request.LogLevel)));
break;
}

return NoContent();
Expand All @@ -63,10 +58,10 @@ public IActionResult CreateLog(LogRequest request)

public class LogRequest
{
public LogLevel LogLevel { get; set; }
public string Category { get; set; }
public string MessageTemplate { get; set; }
public object[] Arguments { get; set; }
public required LogLevel LogLevel { get; set; }
public required string Category { get; set; }
public required string MessageTemplate { get; set; }
public object[] Arguments { get; set; } = [];
}

public enum LogLevel
Expand Down
12 changes: 4 additions & 8 deletions AdminUi/src/AdminUi/Controllers/TiersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Backbone.BuildingBlocks.API;
using Backbone.BuildingBlocks.API.Mvc;
using Backbone.BuildingBlocks.API.Mvc.ControllerAttributes;
using Backbone.Modules.Devices.Application;
using Backbone.Modules.Devices.Application.Tiers.Commands.CreateTier;
using Backbone.Modules.Devices.Application.Tiers.Commands.DeleteTier;
using Backbone.Modules.Quotas.Application.DTOs;
Expand All @@ -15,7 +14,6 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;

namespace Backbone.AdminUi.Controllers;

Expand All @@ -24,12 +22,10 @@ namespace Backbone.AdminUi.Controllers;
public class TiersController : ApiControllerBase
{
private readonly AdminUiDbContext _adminUiDbContext;
private readonly ApplicationOptions _options;

public TiersController(IMediator mediator, IOptions<ApplicationOptions> options, AdminUiDbContext adminUiDbContext) : base(mediator)
public TiersController(IMediator mediator, AdminUiDbContext adminUiDbContext) : base(mediator)
{
_adminUiDbContext = adminUiDbContext;
_options = options.Value;
}

[HttpGet]
Expand Down Expand Up @@ -91,7 +87,7 @@ public async Task<IActionResult> DeleteTierQuota([FromRoute] string tierId, [Fro

public class CreateQuotaForTierRequest
{
public string MetricKey { get; set; }
public int Max { get; set; }
public QuotaPeriod Period { get; set; }
public required string MetricKey { get; set; }
public required int Max { get; set; }
public required QuotaPeriod Period { get; set; }
}
10 changes: 4 additions & 6 deletions AdminUi/src/AdminUi/Extensions/IServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static IServiceCollection AddCustomAspNetCore(this IServiceCollection ser
options.InvalidModelStateResponseFactory = context =>
{
var firstPropertyWithError =
context.ModelState.First(p => p.Value != null && p.Value.Errors.Count > 0);
context.ModelState.First(p => p.Value is { Errors.Count: > 0 });
var nameOfPropertyWithError = firstPropertyWithError.Key;
var firstError = firstPropertyWithError.Value!.Errors.First();
var firstErrorMessage = !string.IsNullOrWhiteSpace(firstError.ErrorMessage)
Expand Down Expand Up @@ -125,12 +125,10 @@ public static IServiceCollection AddCustomAspNetCore(this IServiceCollection ser
var modules = configuration.Modules.GetType().GetProperties();
foreach (var moduleProperty in modules)
{
if (moduleProperty is null) continue;

var moduleName = moduleProperty.Name;
var module = configuration.Modules.GetType().GetProperty(moduleName).GetValue(configuration.Modules, null);
var module = configuration.Modules.GetType().GetProperty(moduleName)!.GetValue(configuration.Modules, null)!;
var provider = GetPropertyValue(module, "Infrastructure.SqlDatabase.Provider") as string;
var connectionString = GetPropertyValue(module, "Infrastructure.SqlDatabase.ConnectionString") as string;
var connectionString = (string)GetPropertyValue(module, "Infrastructure.SqlDatabase.ConnectionString");

switch (provider)
{
Expand Down Expand Up @@ -158,7 +156,7 @@ public static IServiceCollection AddCustomAspNetCore(this IServiceCollection ser
private static object GetPropertyValue(object source, string propertyPath)
{
foreach (var property in propertyPath.Split('.').Select(s => source.GetType().GetProperty(s)))
source = property.GetValue(source, null);
source = property!.GetValue(source, null)!;

return source;
}
Expand Down
Loading

0 comments on commit 198600c

Please sign in to comment.