-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Contracts. * Aggregate * Errors. * Error * Core layer. * Infrastructure layer. * Contracts. * Core layer. * Core & Infrastructure. * EFCore. * Contracts & Core. * Handlers. * Persistence. * Web interface. * Bootstrap.
- Loading branch information
Showing
99 changed files
with
3,000 additions
and
26 deletions.
There are no files selected for viewing
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
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,39 @@ | ||
namespace Logitar.Cms.Contracts.Actors; | ||
|
||
public class Actor | ||
{ | ||
public static Actor System => new(ActorType.System.ToString()); | ||
|
||
public Guid Id { get; set; } | ||
public ActorType Type { get; set; } | ||
public bool IsDeleted { get; set; } | ||
|
||
public string DisplayName { get; set; } | ||
public string? EmailAddress { get; set; } | ||
public string? PictureUrl { get; set; } | ||
|
||
public Actor() : this(string.Empty) | ||
{ | ||
} | ||
|
||
public Actor(string displayName) | ||
{ | ||
DisplayName = displayName; | ||
} | ||
|
||
public override bool Equals(object obj) => obj is Actor actor && actor.Id == Id; | ||
public override int GetHashCode() => Id.GetHashCode(); | ||
public override string ToString() | ||
{ | ||
StringBuilder s = new(); | ||
|
||
s.Append(DisplayName); | ||
if (EmailAddress != null) | ||
{ | ||
s.Append(" <").Append(EmailAddress).Append('>'); | ||
} | ||
s.Append(" (").Append(Type).Append(".Id=").Append(Id).Append(')'); | ||
|
||
return s.ToString(); | ||
} | ||
} |
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,8 @@ | ||
namespace Logitar.Cms.Contracts.Actors; | ||
|
||
public enum ActorType | ||
{ | ||
System = 0, | ||
User = 1, | ||
ApiKey = 2 | ||
} |
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,19 @@ | ||
using Logitar.Cms.Contracts.Actors; | ||
|
||
namespace Logitar.Cms.Contracts; | ||
|
||
public abstract class Aggregate | ||
{ | ||
public Guid Id { get; set; } | ||
public long Version { get; set; } | ||
|
||
public Actor CreatedBy { get; set; } = new(); | ||
public DateTime CreatedOn { get; set; } | ||
|
||
public Actor UpdatedBy { get; set; } = new(); | ||
public DateTime UpdatedOn { get; set; } | ||
|
||
public override bool Equals(object obj) => obj is Aggregate aggregate && aggregate.GetType().Equals(GetType()) && aggregate.Id == Id; | ||
public override int GetHashCode() => HashCode.Combine(GetType(), Id); | ||
public override string ToString() => $"{GetType()} (Id={Id})"; | ||
} |
26 changes: 26 additions & 0 deletions
26
backend/src/Logitar.Cms.Contracts/Configurations/Configuration.cs
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,26 @@ | ||
namespace Logitar.Cms.Contracts.Configurations; | ||
|
||
public class Configuration : Aggregate | ||
{ | ||
public string Secret { get; set; } | ||
|
||
public UniqueNameSettings UniqueNameSettings { get; set; } | ||
public PasswordSettings PasswordSettings { get; set; } | ||
public bool RequireUniqueName { get; set; } | ||
|
||
public LoggingSettings LoggingSettings { get; set; } | ||
|
||
public Configuration() : this(string.Empty) | ||
{ | ||
} | ||
|
||
public Configuration(string secret) | ||
{ | ||
Secret = secret; | ||
|
||
UniqueNameSettings = new(); | ||
PasswordSettings = new(); | ||
|
||
LoggingSettings = new(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
backend/src/Logitar.Cms.Contracts/Configurations/ILoggingSettings.cs
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 @@ | ||
namespace Logitar.Cms.Contracts.Configurations; | ||
|
||
public interface ILoggingSettings | ||
{ | ||
LoggingExtent Extent { get; } | ||
bool OnlyErrors { get; } | ||
} |
8 changes: 8 additions & 0 deletions
8
backend/src/Logitar.Cms.Contracts/Configurations/LoggingExtent.cs
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,8 @@ | ||
namespace Logitar.Cms.Contracts.Configurations; | ||
|
||
public enum LoggingExtent | ||
{ | ||
None = 0, | ||
ActivityOnly = 1, | ||
Full = 2 | ||
} |
21 changes: 21 additions & 0 deletions
21
backend/src/Logitar.Cms.Contracts/Configurations/LoggingSettings.cs
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,21 @@ | ||
namespace Logitar.Cms.Contracts.Configurations; | ||
|
||
public record LoggingSettings : ILoggingSettings | ||
{ | ||
public LoggingExtent Extent { get; set; } = LoggingExtent.ActivityOnly; | ||
public bool OnlyErrors { get; set; } | ||
|
||
public LoggingSettings() : this(LoggingExtent.ActivityOnly, onlyErrors: false) | ||
{ | ||
} | ||
|
||
public LoggingSettings(ILoggingSettings logging) : this(logging.Extent, logging.OnlyErrors) | ||
{ | ||
} | ||
|
||
public LoggingSettings(LoggingExtent extent, bool onlyErrors) | ||
{ | ||
Extent = extent; | ||
OnlyErrors = onlyErrors; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
backend/src/Logitar.Cms.Contracts/Configurations/PasswordSettings.cs
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,41 @@ | ||
using Logitar.Identity.Contracts.Settings; | ||
|
||
namespace Logitar.Cms.Contracts.Configurations; | ||
|
||
public record PasswordSettings : IPasswordSettings | ||
{ | ||
public int RequiredLength { get; set; } | ||
public int RequiredUniqueChars { get; set; } | ||
public bool RequireNonAlphanumeric { get; set; } | ||
public bool RequireLowercase { get; set; } | ||
public bool RequireUppercase { get; set; } | ||
public bool RequireDigit { get; set; } | ||
public string HashingStrategy { get; set; } | ||
|
||
public PasswordSettings() : this(new PasswordSettings()) | ||
{ | ||
} | ||
|
||
public PasswordSettings(IPasswordSettings password) | ||
: this(password.RequiredLength, password.RequiredUniqueChars, password.RequireNonAlphanumeric, password.RequireLowercase, password.RequireUppercase, password.RequireDigit, password.HashingStrategy) | ||
{ | ||
} | ||
|
||
public PasswordSettings( | ||
int requiredLength, | ||
int requiredUniqueChars, | ||
bool requireNonAlphanumeric, | ||
bool requireLowercase, | ||
bool requireUppercase, | ||
bool requireDigit, | ||
string hashingStrategy) | ||
{ | ||
RequiredLength = requiredLength; | ||
RequiredUniqueChars = requiredUniqueChars; | ||
RequireNonAlphanumeric = requireNonAlphanumeric; | ||
RequireLowercase = requireLowercase; | ||
RequireUppercase = requireUppercase; | ||
RequireDigit = requireDigit; | ||
HashingStrategy = hashingStrategy; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
backend/src/Logitar.Cms.Contracts/Configurations/UniqueNameSettings.cs
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,21 @@ | ||
using Logitar.Identity.Contracts.Settings; | ||
|
||
namespace Logitar.Cms.Contracts.Configurations; | ||
|
||
public record UniqueNameSettings : IUniqueNameSettings | ||
{ | ||
public string? AllowedCharacters { get; set; } | ||
|
||
public UniqueNameSettings() : this(allowedCharacters: null) | ||
{ | ||
} | ||
|
||
public UniqueNameSettings(IUniqueNameSettings uniqueName) : this(uniqueName.AllowedCharacters) | ||
{ | ||
} | ||
|
||
public UniqueNameSettings(string? allowedCharacters) | ||
{ | ||
AllowedCharacters = allowedCharacters; | ||
} | ||
} |
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,21 @@ | ||
namespace Logitar.Cms.Contracts.Errors; | ||
|
||
public record Error | ||
{ | ||
public string Code { get; set; } | ||
public string Message { get; set; } | ||
public List<ErrorData> Data { get; set; } | ||
|
||
public Error() : this(string.Empty, string.Empty) | ||
{ | ||
} | ||
|
||
public Error(string code, string message, IEnumerable<ErrorData>? data = null) | ||
{ | ||
Code = code; | ||
Message = message; | ||
Data = data?.ToList() ?? []; | ||
} | ||
|
||
public void Add(ErrorData data) => Data.Add(data); | ||
} |
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,21 @@ | ||
namespace Logitar.Cms.Contracts.Errors; | ||
|
||
public record ErrorData | ||
{ | ||
public string Key { get; set; } | ||
public string Value { get; set; } | ||
|
||
public ErrorData() : this(string.Empty, string.Empty) | ||
{ | ||
} | ||
|
||
public ErrorData(KeyValuePair<string, string> data) : this(data.Key, data.Value) | ||
{ | ||
} | ||
|
||
public ErrorData(string key, string value) | ||
{ | ||
Key = key; | ||
Value = value; | ||
} | ||
} |
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,18 @@ | ||
namespace Logitar.Cms.Contracts.Errors; | ||
|
||
public record PropertyError : Error | ||
{ | ||
public string? PropertyName { get; set; } | ||
public object? AttemptedValue { get; set; } | ||
|
||
public PropertyError() : this(string.Empty, string.Empty, null, null) | ||
{ | ||
} | ||
|
||
public PropertyError(string code, string message, string? propertyName, object? attemptedValue, IEnumerable<ErrorData>? data = null) | ||
: base(code, message, data) | ||
{ | ||
PropertyName = propertyName; | ||
AttemptedValue = attemptedValue; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
backend/src/Logitar.Cms.Contracts/Errors/ValidationError.cs
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,18 @@ | ||
namespace Logitar.Cms.Contracts.Errors; | ||
|
||
public record ValidationError : Error | ||
{ | ||
public List<PropertyError> Errors { get; set; } | ||
|
||
public ValidationError() : this("Validation", "Validation failed.") | ||
{ | ||
} | ||
|
||
public ValidationError(string code, string message, IEnumerable<ErrorData>? data = null, IEnumerable<PropertyError>? errors = null) | ||
: base(code, message, data) | ||
{ | ||
Errors = errors?.ToList() ?? []; | ||
} | ||
|
||
public void Add(PropertyError error) => Errors.Add(error); | ||
} |
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
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,14 @@ | ||
using Logitar.Cms.Contracts.Actors; | ||
using Logitar.Cms.Contracts.Configurations; | ||
using Logitar.EventSourcing; | ||
|
||
namespace Logitar.Cms.Core.Caching; | ||
|
||
public interface ICacheService | ||
{ | ||
Configuration? Configuration { get; set; } | ||
|
||
Actor? GetActor(ActorId id); | ||
void RemoveActor(ActorId id); | ||
void SetActor(Actor actor); | ||
} |
5 changes: 5 additions & 0 deletions
5
backend/src/Logitar.Cms.Core/Configurations/Commands/InitializeConfigurationCommand.cs
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,5 @@ | ||
using MediatR; | ||
|
||
namespace Logitar.Cms.Core.Configurations.Commands; | ||
|
||
public record InitializeConfigurationCommand(string DefaultLocale, string Username, string Password) : IRequest; |
Oops, something went wrong.