feat: modularize external providers
This commit is contained in:
23
Tiku.Application/Auth/IIdentityProvider.cs
Normal file
23
Tiku.Application/Auth/IIdentityProvider.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace Tiku.Application.Auth;
|
||||
|
||||
public sealed record IdentityProviderRequest(
|
||||
Guid TenantId,
|
||||
string Provider,
|
||||
string Identifier,
|
||||
string Secret,
|
||||
string? IpAddress,
|
||||
string? UserAgent);
|
||||
|
||||
public sealed record IdentityProviderResult(
|
||||
string Provider,
|
||||
string Subject,
|
||||
string? Phone,
|
||||
string? Email,
|
||||
string? DisplayName);
|
||||
|
||||
public interface IIdentityProvider
|
||||
{
|
||||
Task<IdentityProviderResult> AuthenticateAsync(
|
||||
IdentityProviderRequest request,
|
||||
CancellationToken cancellationToken = default);
|
||||
}
|
||||
23
Tiku.Application/Auth/ISmsProvider.cs
Normal file
23
Tiku.Application/Auth/ISmsProvider.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Tiku.Domain.Tenancy;
|
||||
|
||||
namespace Tiku.Application.Auth;
|
||||
|
||||
public sealed record SmsProviderSendRequest(
|
||||
Guid TenantId,
|
||||
string Phone,
|
||||
SmsPurpose Purpose,
|
||||
string Code,
|
||||
string? IpAddress,
|
||||
string? UserAgent);
|
||||
|
||||
public sealed record SmsProviderSendResult(
|
||||
string Provider,
|
||||
string Status,
|
||||
string? MessageId = null);
|
||||
|
||||
public interface ISmsProvider
|
||||
{
|
||||
Task<SmsProviderSendResult> SendAsync(
|
||||
SmsProviderSendRequest request,
|
||||
CancellationToken cancellationToken = default);
|
||||
}
|
||||
@@ -12,17 +12,21 @@ public sealed record TenantPointQuery(string? Status = null, int? Limit = null,
|
||||
|
||||
public sealed record UpsertPaymentAccountCommand(
|
||||
string Provider,
|
||||
TenantPaymentMode Mode,
|
||||
string? Mode,
|
||||
string? DisplayName,
|
||||
TenantPaymentAccountStatus Status,
|
||||
TenantExternalProviderStatus Status,
|
||||
string? SecretRef,
|
||||
int? Priority,
|
||||
JsonElement ConfigPublic);
|
||||
|
||||
public sealed record TenantPaymentAccountItem(
|
||||
public sealed record TenantPaymentProviderItem(
|
||||
Guid Id,
|
||||
string Provider,
|
||||
string Mode,
|
||||
string? DisplayName,
|
||||
string Status,
|
||||
TenantExternalProviderStatus Status,
|
||||
string? SecretRef,
|
||||
int Priority,
|
||||
JsonElement ConfigPublic,
|
||||
DateTimeOffset CreatedAt,
|
||||
DateTimeOffset UpdatedAt);
|
||||
@@ -150,12 +154,12 @@ public sealed record TenantCouponReport(int CouponCount, int ClaimedCount, int U
|
||||
|
||||
public interface ICommerceAdminService
|
||||
{
|
||||
Task<IReadOnlyCollection<TenantPaymentAccountItem>> GetPaymentAccountsAsync(
|
||||
Task<IReadOnlyCollection<TenantPaymentProviderItem>> GetPaymentAccountsAsync(
|
||||
CommerceAdminActor actor,
|
||||
CommerceAdminQuery query,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<TenantPaymentAccountItem> UpsertPaymentAccountAsync(
|
||||
Task<TenantPaymentProviderItem> UpsertPaymentAccountAsync(
|
||||
CommerceAdminActor actor,
|
||||
UpsertPaymentAccountCommand command,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
26
Tiku.Application/Notifications/INotificationProvider.cs
Normal file
26
Tiku.Application/Notifications/INotificationProvider.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Text.Json;
|
||||
using Tiku.Domain.Operations;
|
||||
|
||||
namespace Tiku.Application.Notifications;
|
||||
|
||||
public sealed record InAppNotificationRequest(
|
||||
Guid TenantId,
|
||||
Guid UserId,
|
||||
string NotificationType,
|
||||
NotificationSeverity Severity,
|
||||
string Title,
|
||||
string Message,
|
||||
Guid? CreatedBy = null,
|
||||
string? ActionLabel = null,
|
||||
string? ActionPath = null,
|
||||
string? SourceType = null,
|
||||
Guid? SourceId = null,
|
||||
string? DedupeKey = null,
|
||||
JsonElement Metadata = default);
|
||||
|
||||
public interface INotificationProvider
|
||||
{
|
||||
Task<UserNotification> UpsertInAppAsync(
|
||||
InAppNotificationRequest request,
|
||||
CancellationToken cancellationToken = default);
|
||||
}
|
||||
@@ -3,7 +3,6 @@ namespace Tiku.Application.Storage;
|
||||
public static class ObjectStorageProviders
|
||||
{
|
||||
public const string ExternalUrl = "external_url";
|
||||
public const string SupabaseStorage = "supabase_storage";
|
||||
public const string AliyunOss = "aliyun_oss";
|
||||
public const string TencentCos = "tencent_cos";
|
||||
public const string QiniuKodo = "qiniu_kodo";
|
||||
|
||||
65
Tiku.Application/Tenancy/TenantExternalProviderModels.cs
Normal file
65
Tiku.Application/Tenancy/TenantExternalProviderModels.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System.Text.Json;
|
||||
using Tiku.Domain.Tenancy;
|
||||
|
||||
namespace Tiku.Application.Tenancy;
|
||||
|
||||
public sealed record TenantExternalProviderAccount(
|
||||
Guid TenantId,
|
||||
TenantExternalProviderCapability Capability,
|
||||
string Provider,
|
||||
TenantExternalProviderStatus Status,
|
||||
string? DisplayName,
|
||||
JsonElement ConfigPublic,
|
||||
JsonElement SecretPayload,
|
||||
string? SecretRef,
|
||||
int Priority,
|
||||
JsonElement Metadata);
|
||||
|
||||
public sealed record UpsertTenantExternalProviderCommand(
|
||||
TenantExternalProviderCapability Capability,
|
||||
string Provider,
|
||||
TenantExternalProviderStatus Status,
|
||||
string? DisplayName,
|
||||
string? SecretRef,
|
||||
int? Priority,
|
||||
JsonElement ConfigPublic,
|
||||
JsonElement Metadata);
|
||||
|
||||
public sealed record TenantExternalProviderItem(
|
||||
Guid Id,
|
||||
TenantExternalProviderCapability Capability,
|
||||
string Provider,
|
||||
TenantExternalProviderStatus Status,
|
||||
string? DisplayName,
|
||||
string? SecretRef,
|
||||
int Priority,
|
||||
JsonElement ConfigPublic,
|
||||
JsonElement Metadata,
|
||||
DateTimeOffset CreatedAt,
|
||||
DateTimeOffset UpdatedAt);
|
||||
|
||||
public interface ITenantExternalProviderConfigService
|
||||
{
|
||||
Task<TenantExternalProviderAccount> GetActiveProviderAsync(
|
||||
Guid tenantId,
|
||||
TenantExternalProviderCapability capability,
|
||||
string? provider = null,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<IReadOnlyCollection<TenantExternalProviderItem>> GetProvidersAsync(
|
||||
Guid tenantId,
|
||||
TenantExternalProviderCapability? capability = null,
|
||||
string? provider = null,
|
||||
int? limit = null,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<TenantExternalProviderItem> UpsertProviderAsync(
|
||||
Guid tenantId,
|
||||
UpsertTenantExternalProviderCommand command,
|
||||
CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
public sealed class TenantExternalProviderException(string message, string code) : Exception(message)
|
||||
{
|
||||
public string Code { get; } = code;
|
||||
}
|
||||
@@ -146,13 +146,13 @@ public interface ITenantAdminDirectService
|
||||
CreateTenantDomainCommand command,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<CatalogList<TenantAuthProviderItem>> GetAuthProvidersAsync(
|
||||
Task<CatalogList<TenantIdentityProviderItem>> GetAuthProvidersAsync(
|
||||
TenantAdminActor actor,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<ContentManagementResult<TenantAuthProviderItem>> UpsertAuthProviderAsync(
|
||||
Task<ContentManagementResult<TenantIdentityProviderItem>> UpsertAuthProviderAsync(
|
||||
TenantAdminActor actor,
|
||||
UpsertTenantAuthProviderCommand command,
|
||||
UpsertTenantIdentityProviderCommand command,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<CatalogList<TenantAdminBadgeItem>> GetBadgesAsync(
|
||||
|
||||
@@ -189,10 +189,12 @@ public sealed record CreateTenantDomainCommand(
|
||||
string? DomainType,
|
||||
bool IsPrimary);
|
||||
|
||||
public sealed record UpsertTenantAuthProviderCommand(
|
||||
public sealed record UpsertTenantIdentityProviderCommand(
|
||||
string Provider,
|
||||
string? Status,
|
||||
string? DisplayName,
|
||||
string? SecretRef,
|
||||
int? Priority,
|
||||
JsonElement ConfigPublic);
|
||||
|
||||
public sealed record UpsertTenantAdminBadgeCommand(
|
||||
@@ -467,11 +469,13 @@ public sealed record TenantDomainItem(
|
||||
DateTimeOffset CreatedAt,
|
||||
DateTimeOffset UpdatedAt);
|
||||
|
||||
public sealed record TenantAuthProviderItem(
|
||||
public sealed record TenantIdentityProviderItem(
|
||||
Guid Id,
|
||||
string Provider,
|
||||
TenantAuthProviderStatus Status,
|
||||
TenantExternalProviderStatus Status,
|
||||
string? DisplayName,
|
||||
string? SecretRef,
|
||||
int Priority,
|
||||
JsonElement ConfigPublic,
|
||||
DateTimeOffset CreatedAt,
|
||||
DateTimeOffset UpdatedAt);
|
||||
|
||||
Reference in New Issue
Block a user