Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgraded NuGet packages & refactored domain aggregates. #469

Merged
merged 2 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

<ItemGroup>
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Logitar.Net" Version="6.0.0" />
<PackageReference Include="Logitar.Net" Version="6.1.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

<ItemGroup>
<PackageReference Include="Logitar" Version="6.1.0" />
<PackageReference Include="Logitar.Identity.Contracts" Version="0.12.0" />
<PackageReference Include="Logitar.Identity.Contracts" Version="1.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@ public static ConfigurationAggregate Initialize(ActorId actorId)
ConfigurationId id = new();
ConfigurationAggregate configuration = new(id.AggregateId);

LocaleUnit? defaultLocale = null;
JwtSecretUnit secret = JwtSecretUnit.Generate();
ReadOnlyUniqueNameSettings uniqueNameSettings = new();
ReadOnlyPasswordSettings passordSettings = new();
bool requireUniqueEmail = true;
ReadOnlyLoggingSettings loggingSettings = new();
configuration.Raise(new ConfigurationInitializedEvent(actorId, defaultLocale: null, secret, uniqueNameSettings, passordSettings, requireUniqueEmail, loggingSettings));
configuration.Raise(new ConfigurationInitializedEvent(defaultLocale, secret, uniqueNameSettings, passordSettings, requireUniqueEmail, loggingSettings), actorId);

return configuration;
}
Expand All @@ -125,8 +126,7 @@ public void Update(ActorId actorId)
{
if (_updatedEvent.HasChanges)
{
_updatedEvent.ActorId = actorId;
Raise(_updatedEvent);
Raise(_updatedEvent, actorId, DateTime.Now);
_updatedEvent = new();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,5 @@

namespace Logitar.Portal.Domain.Configurations.Events;

public record ConfigurationInitializedEvent : DomainEvent, INotification
{
public LocaleUnit? DefaultLocale { get; }
public JwtSecretUnit Secret { get; }

public ReadOnlyUniqueNameSettings UniqueNameSettings { get; }
public ReadOnlyPasswordSettings PasswordSettings { get; }
public bool RequireUniqueEmail { get; }

public ReadOnlyLoggingSettings LoggingSettings { get; }

public ConfigurationInitializedEvent(ActorId actorId, LocaleUnit? defaultLocale, JwtSecretUnit secret, ReadOnlyUniqueNameSettings uniqueNameSettings,
ReadOnlyPasswordSettings passwordSettings, bool requireUniqueEmail, ReadOnlyLoggingSettings loggingSettings)
{
ActorId = actorId;
DefaultLocale = defaultLocale;
Secret = secret;
UniqueNameSettings = uniqueNameSettings;
PasswordSettings = passwordSettings;
RequireUniqueEmail = requireUniqueEmail;
LoggingSettings = loggingSettings;
}
}
public record ConfigurationInitializedEvent(LocaleUnit? DefaultLocale, JwtSecretUnit Secret, ReadOnlyUniqueNameSettings UniqueNameSettings,
ReadOnlyPasswordSettings PasswordSettings, bool RequireUniqueEmail, ReadOnlyLoggingSettings LoggingSettings) : DomainEvent, INotification;
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public DictionaryAggregate(AggregateId id) : base(id)
public DictionaryAggregate(LocaleUnit locale, TenantId? tenantId = null, ActorId actorId = default, DictionaryId? id = null)
: base((id ?? DictionaryId.NewId()).AggregateId)
{
Raise(new DictionaryCreatedEvent(actorId, locale, tenantId));
Raise(new DictionaryCreatedEvent(tenantId, locale), actorId);
}
protected virtual void Apply(DictionaryCreatedEvent @event)
{
Expand All @@ -39,7 +39,7 @@ public void Delete(ActorId actorId = default)
{
if (!IsDeleted)
{
Raise(new DictionaryDeletedEvent(actorId));
Raise(new DictionaryDeletedEvent(), actorId);
}
}

Expand Down Expand Up @@ -71,7 +71,7 @@ public void SetLocale(LocaleUnit locale, ActorId actorId = default)
{
if (locale != _locale)
{
Raise(new DictionaryLocaleChangedEvent(actorId, locale));
Raise(new DictionaryLocaleChangedEvent(locale), actorId);
}
}
protected virtual void Apply(DictionaryLocaleChangedEvent @event)
Expand All @@ -85,8 +85,7 @@ public void Update(ActorId actorId = default)
{
if (_updatedEvent.HasChanges)
{
_updatedEvent.ActorId = actorId;
Raise(_updatedEvent);
Raise(_updatedEvent, actorId, DateTime.Now);
_updatedEvent = new();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,4 @@

namespace Logitar.Portal.Domain.Dictionaries.Events;

public record DictionaryCreatedEvent : DomainEvent, INotification
{
public TenantId? TenantId { get; }

public LocaleUnit Locale { get; }

public DictionaryCreatedEvent(ActorId actorId, LocaleUnit locale, TenantId? tenantId)
{
ActorId = actorId;
Locale = locale;
TenantId = tenantId;
}
}
public record DictionaryCreatedEvent(TenantId? TenantId, LocaleUnit Locale) : DomainEvent, INotification;
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ namespace Logitar.Portal.Domain.Dictionaries.Events;

public record DictionaryDeletedEvent : DomainEvent, INotification
{
public DictionaryDeletedEvent(ActorId actorId)
public DictionaryDeletedEvent()
{
ActorId = actorId;
IsDeleted = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,4 @@

namespace Logitar.Portal.Domain.Dictionaries.Events;

public record DictionaryLocaleChangedEvent : DomainEvent, INotification
{
public LocaleUnit Locale { get; }

public DictionaryLocaleChangedEvent(ActorId actorId, LocaleUnit locale)
{
ActorId = actorId;
Locale = locale;
}
}
public record DictionaryLocaleChangedEvent(LocaleUnit Locale) : DomainEvent, INotification;
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Logitar.Identity.Domain" Version="0.12.0" />
<PackageReference Include="Logitar.Identity.Domain" Version="1.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,6 @@

namespace Logitar.Portal.Domain.Messages.Events;

public record MessageCreatedEvent : DomainEvent, INotification
{
public TenantId? TenantId { get; }

public SubjectUnit Subject { get; }
public ContentUnit Body { get; }

public IReadOnlyCollection<RecipientUnit> Recipients { get; }
public SenderSummary Sender { get; }
public TemplateSummary Template { get; }

public bool IgnoreUserLocale { get; }
public LocaleUnit? Locale { get; }

public IReadOnlyDictionary<string, string> Variables { get; }

public bool IsDemo { get; }

public MessageCreatedEvent(ActorId actorId, TenantId? tenantId, SubjectUnit subject, ContentUnit body, IReadOnlyCollection<RecipientUnit> recipients,
SenderSummary sender, TemplateSummary template, bool ignoreUserLocale, LocaleUnit? locale, IReadOnlyDictionary<string, string> variables, bool isDemo)
{
ActorId = actorId;
TenantId = tenantId;
Subject = subject;
Body = body;
Recipients = recipients;
Sender = sender;
Template = template;
IgnoreUserLocale = ignoreUserLocale;
Locale = locale;
Variables = variables;
IsDemo = isDemo;
}
}
public record MessageCreatedEvent(TenantId? TenantId, SubjectUnit Subject, ContentUnit Body, IReadOnlyCollection<RecipientUnit> Recipients,
SenderSummary Sender, TemplateSummary Template, bool IgnoreUserLocale, LocaleUnit? Locale, IReadOnlyDictionary<string, string> Variables, bool IsDemo)
: DomainEvent, INotification;
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ namespace Logitar.Portal.Domain.Messages.Events;

public record MessageDeletedEvent : DomainEvent, INotification
{
public MessageDeletedEvent(ActorId actorId)
public MessageDeletedEvent()
{
ActorId = actorId;
IsDeleted = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,4 @@

namespace Logitar.Portal.Domain.Messages.Events;

public record MessageFailedEvent : DomainEvent, INotification
{
public IReadOnlyDictionary<string, string> ResultData { get; }

public MessageFailedEvent(ActorId actorId, IReadOnlyDictionary<string, string> resultData)
{
ActorId = actorId;
ResultData = resultData;
}
}
public record MessageFailedEvent(IReadOnlyDictionary<string, string> ResultData) : DomainEvent, INotification;
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,4 @@

namespace Logitar.Portal.Domain.Messages.Events;

public record MessageSucceededEvent : DomainEvent, INotification
{
public IReadOnlyDictionary<string, string> ResultData { get; }

public MessageSucceededEvent(ActorId actorId, IReadOnlyDictionary<string, string> resultData)
{
ActorId = actorId;
ResultData = resultData;
}
}
public record MessageSucceededEvent(IReadOnlyDictionary<string, string> ResultData) : DomainEvent, INotification;
10 changes: 5 additions & 5 deletions backend/src/Logitar.Portal.Domain/Messages/MessageAggregate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public MessageAggregate(SubjectUnit subject, ContentUnit body, IReadOnlyCollecti
throw new TemplateNotInTenantException(template, tenantId);
}

Raise(new MessageCreatedEvent(actorId, tenantId, subject, body, recipients, new SenderSummary(sender),
new TemplateSummary(template), ignoreUserLocale, locale, variables ?? new Dictionary<string, string>(), isDemo));
Raise(new MessageCreatedEvent(tenantId, subject, body, recipients, new SenderSummary(sender), new TemplateSummary(template),
ignoreUserLocale, locale, variables ?? new Dictionary<string, string>(), isDemo), actorId);
}
protected virtual void Apply(MessageCreatedEvent @event)
{
Expand Down Expand Up @@ -112,7 +112,7 @@ public void Delete(ActorId actorId = default)
{
if (!IsDeleted)
{
Raise(new MessageDeletedEvent(actorId));
Raise(new MessageDeletedEvent(), actorId);
}
}

Expand All @@ -121,7 +121,7 @@ public void Fail(IReadOnlyDictionary<string, string> resultData, ActorId actorId
{
if (Status == MessageStatus.Unsent)
{
Raise(new MessageFailedEvent(actorId, resultData));
Raise(new MessageFailedEvent(resultData), actorId);
}
}
protected virtual void Apply(MessageFailedEvent @event)
Expand All @@ -140,7 +140,7 @@ public void Succeed(IReadOnlyDictionary<string, string> resultData, ActorId acto
{
if (Status == MessageStatus.Unsent)
{
Raise(new MessageSucceededEvent(actorId, resultData));
Raise(new MessageSucceededEvent(resultData), actorId);
}
}
protected virtual void Apply(MessageSucceededEvent @event)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,5 @@

namespace Logitar.Portal.Domain.Realms.Events;

public record RealmCreatedEvent : DomainEvent, INotification
{
public UniqueSlugUnit UniqueSlug { get; }

public JwtSecretUnit Secret { get; }

public ReadOnlyUniqueNameSettings UniqueNameSettings { get; }
public ReadOnlyPasswordSettings PasswordSettings { get; }
public bool RequireUniqueEmail { get; }

public RealmCreatedEvent(ActorId actorId, UniqueSlugUnit uniqueSlug, JwtSecretUnit secret, ReadOnlyUniqueNameSettings uniqueNameSettings,
ReadOnlyPasswordSettings passwordSettings, bool requireUniqueEmail)
{
ActorId = actorId;
UniqueSlug = uniqueSlug;
Secret = secret;
UniqueNameSettings = uniqueNameSettings;
PasswordSettings = passwordSettings;
RequireUniqueEmail = requireUniqueEmail;
}
}
public record RealmCreatedEvent(UniqueSlugUnit UniqueSlug, JwtSecretUnit Secret, ReadOnlyUniqueNameSettings UniqueNameSettings,
ReadOnlyPasswordSettings PasswordSettings, bool RequireUniqueEmail) : DomainEvent, INotification;
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ namespace Logitar.Portal.Domain.Realms.Events;

public record RealmDeletedEvent : DomainEvent, INotification
{
public RealmDeletedEvent(ActorId actorId)
public RealmDeletedEvent()
{
ActorId = actorId;
IsDeleted = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,4 @@

namespace Logitar.Portal.Domain.Realms.Events;

public record RealmUniqueSlugChangedEvent : DomainEvent, INotification
{
public UniqueSlugUnit UniqueSlug { get; }

public RealmUniqueSlugChangedEvent(ActorId actorId, UniqueSlugUnit uniqueSlug)
{
ActorId = actorId;
UniqueSlug = uniqueSlug;
}
}
public record RealmUniqueSlugChangedEvent(UniqueSlugUnit UniqueSlug) : DomainEvent, INotification;
9 changes: 4 additions & 5 deletions backend/src/Logitar.Portal.Domain/Realms/RealmAggregate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public RealmAggregate(UniqueSlugUnit uniqueSlug, ActorId actorId = default, Real
ReadOnlyUniqueNameSettings uniqueNameSettings = new();
ReadOnlyPasswordSettings passwordSettings = new();
bool requireUniqueEmail = true;
Raise(new RealmCreatedEvent(actorId, uniqueSlug, secret, uniqueNameSettings, passwordSettings, requireUniqueEmail));
Raise(new RealmCreatedEvent(uniqueSlug, secret, uniqueNameSettings, passwordSettings, requireUniqueEmail), actorId);
}
protected virtual void Apply(RealmCreatedEvent @event)
{
Expand All @@ -149,7 +149,7 @@ public void Delete(ActorId actorId = default)
{
if (!IsDeleted)
{
Raise(new RealmDeletedEvent(actorId));
Raise(new RealmDeletedEvent(), actorId);
}
}

Expand Down Expand Up @@ -180,7 +180,7 @@ public void SetCustomAttribute(string key, string value)

public void SetUniqueSlug(UniqueSlugUnit uniqueSlug, ActorId actorId = default)
{
Raise(new RealmUniqueSlugChangedEvent(actorId, uniqueSlug));
Raise(new RealmUniqueSlugChangedEvent(uniqueSlug), actorId);
}
protected virtual void Apply(RealmUniqueSlugChangedEvent @event)
{
Expand All @@ -191,8 +191,7 @@ public void Update(ActorId actorId = default)
{
if (_updatedEvent.HasChanges)
{
_updatedEvent.ActorId = actorId;
Raise(_updatedEvent);
Raise(_updatedEvent, actorId, DateTime.Now);
_updatedEvent = new();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Logitar.EventSourcing;
using Logitar.Identity.Domain.Shared;
using Logitar.Identity.Domain.Shared;
using Logitar.Identity.Domain.Users;
using Logitar.Portal.Contracts.Senders;
using MediatR;
Expand All @@ -8,7 +7,7 @@ namespace Logitar.Portal.Domain.Senders.Events;

public record EmailSenderCreatedEvent : SenderCreatedEvent, INotification
{
public EmailSenderCreatedEvent(ActorId actorId, EmailUnit email, SenderProvider provider, TenantId? tenantId) : base(actorId, email, provider, tenantId)
public EmailSenderCreatedEvent(TenantId? tenantId, EmailUnit email, SenderProvider provider) : base(tenantId, email, provider)
{
}
}
Loading