feat: scaffold ai gateway identity and design

This commit is contained in:
2026-05-09 16:01:32 +08:00
parent 6323e70e49
commit 5b20f017eb
18 changed files with 3043 additions and 372 deletions
+202
View File
@@ -5,12 +5,57 @@ export interface AuthUser {
username: string;
role?: string[];
tenantId?: string | null;
gatewayTenantId?: string;
tenantKey?: string;
sso_id?: string;
source?: 'gateway' | 'server-main' | 'sync' | string;
gatewayUserId?: string;
userGroupId?: string;
userGroupKey?: string;
userGroupKeys?: string[];
apiKeyId?: string;
apiKeySecret?: string;
apiKeyName?: string;
}
export interface AuthResponse {
accessToken: string;
tokenType: 'Bearer';
expiresIn: number;
user: AuthUser;
}
export interface LocalRegisterRequest {
username: string;
email?: string;
password: string;
displayName?: string;
tenantKey?: string;
tenantName?: string;
invitationCode?: string;
}
export interface LocalLoginRequest {
account: string;
password: string;
}
export interface GatewayInvitation {
id: string;
tenantId: string;
inviteCode: string;
role: 'user' | 'creator' | 'operator' | 'admin' | string;
userGroupId?: string;
maxUses?: number;
usedCount: number;
expiresAt?: string;
status: 'active' | 'disabled' | 'expired' | string;
metadata?: Record<string, unknown>;
createdBy?: string;
createdAt: string;
updatedAt: string;
}
export interface IntegrationPlatform {
id: string;
provider: string;
@@ -89,6 +134,156 @@ export interface PricingRule {
updatedAt: string;
}
export interface GatewayUser {
id: string;
userKey: string;
source: 'gateway' | 'server-main' | 'sync' | string;
externalUserId?: string;
username: string;
displayName?: string;
email?: string;
phone?: string;
avatarUrl?: string;
gatewayTenantId?: string;
tenantId?: string;
tenantKey?: string;
defaultUserGroupId?: string;
roles?: string[];
authProfile?: Record<string, unknown>;
metadata?: Record<string, unknown>;
status: 'active' | 'disabled' | 'locked' | 'deleted' | string;
lastLoginAt?: string;
syncedAt?: string;
sourceUpdatedAt?: string;
createdAt: string;
updatedAt: string;
}
export interface GatewayTenant {
id: string;
tenantKey: string;
source: 'gateway' | 'server-main' | 'sync' | string;
externalTenantId?: string;
name: string;
description?: string;
defaultUserGroupId?: string;
planKey?: string;
billingProfile?: Record<string, unknown>;
rateLimitPolicy?: RateLimitPolicy;
authPolicy?: Record<string, unknown>;
metadata?: Record<string, unknown>;
status: 'active' | 'disabled' | 'locked' | 'deleted' | string;
syncedAt?: string;
sourceUpdatedAt?: string;
createdAt: string;
updatedAt: string;
}
export interface UserGroup {
id: string;
groupKey: string;
name: string;
description?: string;
source: 'gateway' | 'server-main' | 'sync' | string;
priority: number;
rechargeDiscountPolicy?: Record<string, unknown>;
billingDiscountPolicy?: Record<string, unknown>;
rateLimitPolicy?: RateLimitPolicy;
quotaPolicy?: Record<string, unknown>;
status: 'active' | 'disabled' | string;
createdAt: string;
updatedAt: string;
}
export interface UserGroupMembership {
id: string;
groupId: string;
principalType: 'user' | 'tenant' | 'api_key' | 'organization' | string;
principalId: string;
source: 'gateway' | 'server-main' | 'sync' | string;
priority: number;
effectiveFrom?: string;
effectiveTo?: string;
status: 'active' | 'disabled' | string;
createdAt: string;
updatedAt: string;
}
export interface GatewayApiKey {
id: string;
gatewayTenantId?: string;
gatewayUserId: string;
tenantId?: string;
tenantKey?: string;
userId?: string;
keyPrefix: string;
name: string;
scopes?: string[];
userGroupId?: string;
rateLimitPolicy?: RateLimitPolicy;
quotaPolicy?: Record<string, unknown>;
status: 'active' | 'disabled' | 'revoked' | string;
expiresAt?: string;
lastUsedAt?: string;
createdAt: string;
updatedAt: string;
}
export interface GatewayWalletAccount {
id: string;
gatewayTenantId?: string;
gatewayUserId: string;
tenantId?: string;
tenantKey?: string;
userId?: string;
currency: 'resource' | 'credit' | 'cny' | 'usd' | string;
balance: number;
frozenBalance: number;
totalRecharged: number;
totalSpent: number;
status: 'active' | 'frozen' | 'disabled' | string;
createdAt: string;
updatedAt: string;
}
export interface GatewayWalletTransaction {
id: string;
accountId: string;
gatewayTenantId?: string;
gatewayUserId?: string;
direction: 'credit' | 'debit' | 'freeze' | 'unfreeze' | string;
transactionType: 'recharge' | 'billing' | 'refund' | 'adjustment' | string;
amount: number;
balanceBefore: number;
balanceAfter: number;
idempotencyKey?: string;
referenceType?: string;
referenceId?: string;
metadata?: Record<string, unknown>;
createdAt: string;
}
export interface GatewayRechargeOrder {
id: string;
gatewayTenantId?: string;
gatewayUserId: string;
tenantId?: string;
tenantKey?: string;
userId?: string;
amount: number;
bonusAmount: number;
payableAmount: number;
currency: 'resource' | 'credit' | 'cny' | 'usd' | string;
channel: 'manual' | 'wechat' | 'alipay' | 'stripe' | 'paypal' | string;
status: 'created' | 'pending' | 'paid' | 'closed' | 'failed' | string;
externalOrderId?: string;
idempotencyKey?: string;
paidAt?: string;
metadata?: Record<string, unknown>;
createdAt: string;
updatedAt: string;
}
export interface RateLimitRule {
metric: RateLimitMetric;
limit: number;
@@ -147,7 +342,14 @@ export interface GatewayTask {
id: string;
kind: string;
userId: string;
gatewayUserId?: string;
userSource?: 'gateway' | 'server-main' | 'sync' | string;
gatewayTenantId?: string;
tenantId?: string;
tenantKey?: string;
userGroupId?: string;
userGroupKey?: string;
userGroupPolicySnapshot?: Record<string, unknown>;
model: string;
request?: Record<string, unknown>;
status: 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled' | string;