feat: add model groups, verified registration and CNY credit grants
This commit is contained in:
1 parent
f5ba6cb255
commit
7a18db2123
40 files changed
+1980
-263
No files matched your search
@@ -13,6 +13,7 @@ export interface AuthUser {
|
||||
|
||||
export interface RegisterInput {
|
||||
invitationCode: string
|
||||
verificationCode: string
|
||||
account: string
|
||||
password: string
|
||||
displayName?: string
|
||||
@@ -24,6 +25,8 @@ export interface LoginInput {
|
||||
}
|
||||
|
||||
export interface AuthClient {
|
||||
verificationChannels(): Promise<{ email: boolean; phone: boolean }>
|
||||
sendVerificationCode(account: string, invitationCode: string): Promise<{ retryAfterSeconds: number }>
|
||||
health(): Promise<{ status: 'ok'; service: string; capabilities: { verificationCode: boolean; passwordReset: boolean } }>
|
||||
login(input: LoginInput): Promise<AuthUser>
|
||||
register(input: RegisterInput): Promise<AuthUser>
|
||||
@@ -34,6 +37,16 @@ export interface AuthClient {
|
||||
class HttpAuthClient implements AuthClient {
|
||||
constructor(private readonly baseUrl: string) {}
|
||||
|
||||
verificationChannels() {
|
||||
return this.request<{ email: boolean; phone: boolean }>('/api/auth/verification')
|
||||
}
|
||||
|
||||
sendVerificationCode(account: string, invitationCode: string) {
|
||||
return this.request<{ retryAfterSeconds: number }>('/api/auth/verification', {
|
||||
method: 'POST', body: JSON.stringify({ account, invitationCode }),
|
||||
})
|
||||
}
|
||||
|
||||
async health() {
|
||||
return this.request<{ status: 'ok'; service: string; capabilities: { verificationCode: boolean; passwordReset: boolean } }>('/health')
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ export interface CatalogProvider {
|
||||
|
||||
export interface CatalogModel {
|
||||
id: string
|
||||
logicalModelId: string
|
||||
providerId: string
|
||||
modelKey?: string
|
||||
sourceLabel?: string
|
||||
@@ -33,6 +34,28 @@ export interface CatalogModel {
|
||||
status: 'active' | 'disabled'
|
||||
}
|
||||
|
||||
export interface LogicalModel {
|
||||
id: string
|
||||
publicName: string
|
||||
modelKey?: string
|
||||
type: CatalogModelType
|
||||
mode: CatalogCallMode
|
||||
description: string
|
||||
inputTypes: string[]
|
||||
outputTypes: string[]
|
||||
status: 'active' | 'disabled'
|
||||
}
|
||||
|
||||
export interface WalletEntry {
|
||||
id: string
|
||||
amount: number
|
||||
balanceAfter: number
|
||||
currency: 'CNY'
|
||||
reason: string
|
||||
createdAt: string
|
||||
actor: string
|
||||
}
|
||||
|
||||
export interface CatalogProject {
|
||||
id: string
|
||||
ownerUserId: string
|
||||
@@ -180,7 +203,7 @@ class HttpCatalogClient {
|
||||
constructor(private readonly baseUrl: string) {}
|
||||
|
||||
async listModels() {
|
||||
return this.request<{ providers: CatalogProvider[]; models: CatalogModel[] }>('/api/models')
|
||||
return this.request<{ providers: CatalogProvider[]; models: CatalogModel[]; logicalModels: LogicalModel[] }>('/api/models')
|
||||
}
|
||||
|
||||
async listProjects() {
|
||||
@@ -251,7 +274,7 @@ class HttpCatalogClient {
|
||||
}
|
||||
|
||||
async listAdminModels() {
|
||||
return this.request<{ models: CatalogModel[] }>('/api/admin/models')
|
||||
return this.request<{ models: CatalogModel[]; logicalModels: LogicalModel[] }>('/api/admin/models')
|
||||
}
|
||||
|
||||
async listAdminUsage(filters: { q?: string; keyId?: string; modelId?: string; status?: string; eventKind?: string; page?: number; size?: number } = {}) {
|
||||
@@ -286,6 +309,22 @@ class HttpCatalogClient {
|
||||
return this.request<{ users: AdminCatalogUser[] }>('/api/admin/users')
|
||||
}
|
||||
|
||||
async createAdminUser(input: { account: string; displayName: string; password: string }) {
|
||||
return this.request<{ user: AdminCatalogUser }>('/api/admin/users', { method: 'POST', body: JSON.stringify(input) })
|
||||
}
|
||||
|
||||
async listWallets() {
|
||||
return this.request<{ wallets: Array<{ userId: string; balance: number }> }>('/api/admin/wallets')
|
||||
}
|
||||
|
||||
async walletEntries(userId: string) {
|
||||
return this.request<{ entries: WalletEntry[] }>(`/api/admin/users/${encodeURIComponent(userId)}/wallet`)
|
||||
}
|
||||
|
||||
async grantCredit(userId: string, input: { requestId: string; amount: string; reason: string }) {
|
||||
return this.request<{ id: string; balance: number; currency: 'CNY' }>(`/api/admin/users/${encodeURIComponent(userId)}/wallet/grants`, { method: 'POST', body: JSON.stringify(input) })
|
||||
}
|
||||
|
||||
async changeUserRole(id: string, role: 'user' | 'admin') {
|
||||
return this.request<{ user: AdminCatalogUser }>(`/api/admin/users/${encodeURIComponent(id)}/role`, {
|
||||
method: 'POST', body: JSON.stringify({ role }),
|
||||
@@ -312,6 +351,18 @@ class HttpCatalogClient {
|
||||
return this.request<{ provider: CatalogProvider }>('/api/admin/providers', { method: 'POST', body: JSON.stringify(input) })
|
||||
}
|
||||
|
||||
async updateAdminProvider(id: string, input: Partial<CatalogProvider> & { credentialSecret?: string }) {
|
||||
return this.request<{ provider: CatalogProvider }>(`/api/admin/providers/${encodeURIComponent(id)}`, { method: 'PATCH', body: JSON.stringify(input) })
|
||||
}
|
||||
|
||||
async saveDefinition(id: string | undefined, input: Partial<LogicalModel>) {
|
||||
return this.request<{ model: LogicalModel }>(`/api/admin/model-definitions${id ? `/${encodeURIComponent(id)}` : ''}`, { method: id ? 'PATCH' : 'POST', body: JSON.stringify(input) })
|
||||
}
|
||||
|
||||
async saveGroup(id: string | undefined, input: Partial<CatalogModel>) {
|
||||
return this.request<{ model: CatalogModel }>(`/api/admin/models${id ? `/${encodeURIComponent(id)}` : ''}`, { method: id ? 'PATCH' : 'POST', body: JSON.stringify(input) })
|
||||
}
|
||||
|
||||
async createAdminModel(input: { providerId: string; publicName: string; upstreamModel: string; modelKey?: string; sourceLabel?: string; type: CatalogModelType; mode: CatalogCallMode; description?: string; inputTypes?: string[]; outputTypes?: string[]; pricing?: { input?: number; output?: number; unit?: string }; priority?: number; maxConcurrency?: number }) {
|
||||
return this.request<{ model: CatalogModel }>('/api/admin/models', { method: 'POST', body: JSON.stringify(input) })
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user