Files
flatrender/services/identity/FlatRender.IdentitySvc/Domain/Entities/Tenant.cs
T
soroush.asadi 90ac0b81d1 feat: V2 microservices stack — backend services, gateway, JWT auth
Add full V2 architecture: identity, content, studio (.NET 10) and file,
render, notification, gateway (Go) services with vendored deps, plus DB
migrations, event/API contracts, and an init-db script.

Wire the Next.js frontend to the gateway: server-side JWT auth routes
(login/register/refresh/logout/me), gateway fetch helper, and session/
cookie/jwt helpers under src/lib.

Containerize the stack via docker-compose.v2.yml and per-service
Dockerfiles. Base images resolve through a Nexus mirror (Docker Hub) and
MCR directly; npm/NuGet pull from Nexus groups. Self-host fonts via
next/font/local to avoid Google Fonts (geo-blocked).

Add CI workflow and ignore .env.v2, *.stackdump, and .NET bin/obj.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 23:29:31 +03:30

158 lines
5.7 KiB
C#

using FlatRender.IdentitySvc.Domain.Enums;
namespace FlatRender.IdentitySvc.Domain.Entities;
public class Tenant
{
public Guid Id { get; set; } = Guid.NewGuid();
public string Slug { get; set; } = default!;
public string Name { get; set; } = default!;
public TenantKind Kind { get; set; } = TenantKind.Reseller;
public TenantStatus Status { get; set; } = TenantStatus.Trial;
public string? CustomDomain { get; set; }
public bool DomainVerified { get; set; }
public string[] AllowedOrigins { get; set; } = [];
public string? ContactName { get; set; }
public string? ContactEmail { get; set; }
public string? ContactPhone { get; set; }
public string? BillingEmail { get; set; }
public int? MaxUsers { get; set; }
public int? MaxStorageGb { get; set; }
public int? MonthlyRenderQty { get; set; }
public int? MonthlyRenderSec { get; set; }
public DateTime? TrialEndsAt { get; set; }
public DateTime? SuspendedAt { get; set; }
public string? SuspensionReason { get; set; }
public string Metadata { get; set; } = "{}";
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
public DateTime? DeletedAt { get; set; }
public TenantBranding? Branding { get; set; }
public ICollection<TenantApiKey> ApiKeys { get; set; } = [];
public ICollection<TenantWebhook> Webhooks { get; set; } = [];
}
public class TenantBranding
{
public Guid Id { get; set; } = Guid.NewGuid();
public Guid TenantId { get; set; }
public Tenant Tenant { get; set; } = default!;
public string? DisplayName { get; set; }
public string? LogoUrl { get; set; }
public string? LogoDarkUrl { get; set; }
public string? FaviconUrl { get; set; }
public string? OgImageUrl { get; set; }
public string? PrimaryColor { get; set; }
public string? SecondaryColor { get; set; }
public string? AccentColor { get; set; }
public string? BackgroundColor { get; set; }
public string? FontFamily { get; set; }
public string? EmailFromName { get; set; }
public string? EmailFromAddress { get; set; }
public string? EmailReplyTo { get; set; }
public string? EmailFooterHtml { get; set; }
public string? SupportUrl { get; set; }
public string? TermsUrl { get; set; }
public string? PrivacyUrl { get; set; }
public bool EmbedEnabled { get; set; }
public string[] EmbedAllowedHosts { get; set; } = [];
public string? WatermarkText { get; set; }
public string? WatermarkImageUrl { get; set; }
public bool WatermarkEnabled { get; set; }
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
}
public class TenantApiKey
{
public Guid Id { get; set; } = Guid.NewGuid();
public Guid TenantId { get; set; }
public Tenant Tenant { get; set; } = default!;
public Guid? CreatedByUserId { get; set; }
public string Name { get; set; } = default!;
public string Environment { get; set; } = "Live";
public string KeyPrefix { get; set; } = default!;
public string KeyHash { get; set; } = default!;
public string Last4 { get; set; } = default!;
public string[] Scopes { get; set; } = [];
public string[] AllowedIps { get; set; } = [];
public int RateLimitRpm { get; set; } = 60;
public bool IsActive { get; set; } = true;
public DateTime? ExpiresAt { get; set; }
public DateTime? LastUsedAt { get; set; }
public long UsageCount { get; set; }
public string? RevokeReason { get; set; }
public DateTime? RevokedAt { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
}
public class TenantWebhook
{
public Guid Id { get; set; } = Guid.NewGuid();
public Guid TenantId { get; set; }
public Tenant Tenant { get; set; } = default!;
public string Name { get; set; } = default!;
public string Url { get; set; } = default!;
public string[] Events { get; set; } = [];
public string? SecretHash { get; set; }
public bool IsActive { get; set; } = true;
public DateTime? LastTriggeredAt { get; set; }
public int? LastStatusCode { get; set; }
public int ConsecutiveFailures { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
public ICollection<TenantWebhookDelivery> Deliveries { get; set; } = [];
}
public class TenantWebhookDelivery
{
public Guid Id { get; set; } = Guid.NewGuid();
public Guid WebhookId { get; set; }
public TenantWebhook Webhook { get; set; } = default!;
public string EventType { get; set; } = default!;
public string RequestUrl { get; set; } = default!;
public string? RequestBody { get; set; }
public int? ResponseStatus { get; set; }
public string? ResponseBody { get; set; }
public int DurationMs { get; set; }
public int Attempt { get; set; } = 1;
public bool Succeeded { get; set; }
public string? ErrorMessage { get; set; }
public DateTime? DeliveredAt { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
}
public class TenantUsageDaily
{
public Guid Id { get; set; } = Guid.NewGuid();
public Guid TenantId { get; set; }
public DateOnly UsageDate { get; set; }
public int RendersCompleted { get; set; }
public long RenderSeconds { get; set; }
public long StorageBytes { get; set; }
public long ApiCalls { get; set; }
public int ActiveUsers { get; set; }
public long AmountBilledMinor { get; set; }
public string BillingCurrency { get; set; } = "IRR";
public string? BillingStatus { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
}