Cayaqui.MPS.BuildingBlocks
0.4.2
dotnet add package Cayaqui.MPS.BuildingBlocks --version 0.4.2
NuGet\Install-Package Cayaqui.MPS.BuildingBlocks -Version 0.4.2
<PackageReference Include="Cayaqui.MPS.BuildingBlocks" Version="0.4.2" />
<PackageVersion Include="Cayaqui.MPS.BuildingBlocks" Version="0.4.2" />
<PackageReference Include="Cayaqui.MPS.BuildingBlocks" />
paket add Cayaqui.MPS.BuildingBlocks --version 0.4.2
#r "nuget: Cayaqui.MPS.BuildingBlocks, 0.4.2"
#:package Cayaqui.MPS.BuildingBlocks@0.4.2
#addin nuget:?package=Cayaqui.MPS.BuildingBlocks&version=0.4.2
#tool nuget:?package=Cayaqui.MPS.BuildingBlocks&version=0.4.2
Cayaqui.MPS.BuildingBlocks
Kernel DDD/CQRS genérico para .NET 10, sin dependencia de EF Core. API fiel al
MPS.SharedKernel original (apto para reemplazarlo como shim). Para la integración EF
(outbox, interceptors, handlers scoped) usá Cayaqui.MPS.BuildingBlocks.EntityFrameworkCore.
Contenido
| Área | Tipos |
|---|---|
| Result | Result<T> (where T:notnull), DomainError (+None), Unit |
| Invariantes | DomainRuleException(DomainError), Guard (Against/AgainstNullOrWhiteSpace/AgainstNull/Found) |
| Entidades base | AuditableEntity (Id, CreatedAt/By, UpdatedAt/By, soft-delete, buffer de eventos; AddDomainEvent protegido), ImmutableEntity |
| Eventos | IDomainEvent, IIntegrationEvent, IDomainEventHandler<T>, IHasDomainEvents, IDomainEventDispatcher, DomainEvent, DomainEventDispatcher |
| Usuario actual | ICurrentUserService, SystemCurrentUserService |
| Value objects | Money, Percentage, Geocoordinate, IStronglyTypedId |
| Caché | CacheKeyHash.OfProjectSet(...) |
Result (railway)
public Result<ProjectDto> Get(Guid id)
{
var p = _repo.Find(id);
if (p is null) return new DomainError("NotFound", "Proyecto no existe");
return new ProjectDto(p); // conversión implícita a éxito
}
Invariantes (Guard → DomainRuleException)
public void Approve(string by)
{
Guard.Against(Status != ContractStatus.Draft,
DomainError.Conflict("Contract.NotDraft", "Solo en estado Draft."));
Status = ContractStatus.Active;
}
Guard lanza DomainRuleException(DomainError) ante una invariante de aggregate. El companion
Cayaqui.MPS.BuildingBlocks.AspNetCore la mapea a ProblemDetails por ErrorType (Conflict→409,
Validation→400, NotFound→404…) en vez de un 500 genérico. Para outcomes de Application (NotFound de
repositorio, autorización, orquestación) preferí Result<T> en vez de lanzar.
Entidad + evento
public sealed record ProjectCreated(Guid Id) : DomainEvent;
public sealed class Project : AuditableEntity
{
public static Project Create()
{
var p = new Project();
p.AddDomainEvent(new ProjectCreated(p.Id)); // protegido: solo la entidad emite
return p;
}
}
public sealed class OnProjectCreated : IDomainEventHandler<ProjectCreated>
{
public Task HandleAsync(ProjectCreated e, CancellationToken ct) => Task.CompletedTask;
}
DomainEventDispatcher invoca todos los handlers registrados; si alguno falla, lanza
AggregateException al final (señal que usa el outbox para reintentar). El despacho
post-commit + persistencia transaccional se hace con el paquete EF Core.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.8)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Cayaqui.MPS.BuildingBlocks:
| Package | Downloads |
|---|---|
|
Cayaqui.MPS.BuildingBlocks.EntityFrameworkCore
EF Core integration for Cayaqui.MPS.BuildingBlocks: transactional Outbox (EfOutboxStore with Postgres FOR UPDATE SKIP LOCKED + redispatch/purge hosted services + multi-store health check), audit + domain-event-dispatch SaveChanges interceptors, and Blazor Server-safe scoped CQRS handlers (ScopedQueryHandler/ScopedCommandHandler over IDbContextFactory returning Result<T>). Proprietary — requires a commercial agreement with Cayaqui. |
|
|
Cayaqui.MPS.BuildingBlocks.AspNetCore
ASP.NET Core companion for Cayaqui.MPS.BuildingBlocks: maps Result<T>/DomainError to RFC7807 ProblemDetails by ErrorType, provides a global IExceptionHandler (500 + traceId) and AddMpsErrorHandling DI wiring. Requires a commercial agreement with Cayaqui. |
|
|
Cayaqui.MPS.Abstractions.Validation
FluentValidation cross-cutting decorator for the MPS CQRS IHandler pipeline. Wraps any IHandler<TIn, Result<TResult>> with an optional IValidator<TIn>; on validation failure returns a typed DomainError (ErrorType.Validation) with per-field Metadata — no control-flow exceptions. Kept as a separate package so FluentValidation is not forced on zero-dep consumers of Cayaqui.MPS.Abstractions. Proprietary — requires a commercial agreement with Cayaqui. |
|
|
Cayaqui.MPS.Cqrs
CQRS handler-pipeline decorators (logging) for the MPS IHandler. Contains LoggingHandlerDecorator<TIn, TResult> which wraps any IHandler<TIn, Result<TResult>> with structured logging of entry/success/failure/exceptions. Kept separate from Cayaqui.MPS.Abstractions so that the zero-dependency core is preserved. Proprietary — requires a commercial agreement with Cayaqui. |
|
|
Cayaqui.MPS.ApiClient
Result-based typed HTTP client for consuming MPS APIs from Blazor/MAUI/any .NET. Mirrors the companion server error contract (ProblemDetails ↔ Result<DomainError>): the API serializes DomainError→ProblemDetails, this package deserializes ProblemDetails→Result<T>.Failure(DomainError). Provides IBaseApiService marker + BaseApiService verb-helpers (Get/Post/Put/Delete → Result<T>, never throws on business errors), IAccessTokenProvider + BearerTokenHandler for reusable auth. Zero ASP.NET dependency. Proprietary — requires a commercial agreement with Cayaqui. |
GitHub repositories
This package is not used by any popular GitHub repositories.
0.4.2 — Guard con anotaciones de nulabilidad: Against([DoesNotReturnIf(true)]) + [NotNull] en AgainstNullOrWhiteSpace/AgainstNull/Found → el análisis de flujo del compilador reconoce el guard (sin CS8602/8604 tras `Guard.Against(x is null, …)`). 0.4.1 — Aditivo/no-breaking: DomainRuleException(DomainError) + Guard (Against/AgainstNullOrWhiteSpace/AgainstNull/Found) para invariantes de aggregate que lanzan un DomainError tipado; el companion AspNetCore 0.1.1 mapea la excepción a ProblemDetails por ErrorType (409/400/404…) en vez de 500. 0.4.0 — BREAKING: public namespace MPS.BuildingBlocks.* (folder-matched, ya NO MPS.SharedKernel.*) + DomainError tipado (enum ErrorType + Metadata + factories NotFound/Conflict/Validation/Unauthorized/Forbidden/Concurrency/Unexpected) — aditivo/no-breaking: `new DomainError(code,msg)` y `var (code,msg)=error` siguen válidos. 0.3.0 — namespace MPS.SharedKernel.* (shim). 0.2.0 — DDD/CQRS API: Result<T> (where T:notnull) + DomainError.None + Unit; AuditableEntity (AddDomainEvent protected, SetCreated/SetUpdated(string), SoftDelete, DomainEvents IReadOnlyList); DomainEventDispatcher con AggregateException en fallo de handler; ICurrentUserService con props no-nullable; value objects Money/Percentage/Geocoordinate (records). 0.1.0 — initial simplified release.