feat(api, web): интеграция хостера 4VPS.SU — синк VPS, баланса и тарифов
Docker / build (push) Has been cancelled
Docker / build (push) Has been cancelled
Добавлен адаптер 4vps, обобщён pipeline синхронизации через ProviderAdapter и обновлён UI для Panel ID и API Key. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import type { schema } from '@cfdm/db'
|
||||
import { parseFourVpsCredentials } from '@cfdm/shared/utils/api-credentials'
|
||||
|
||||
type AccountRow = typeof schema.providerAccounts.$inferSelect
|
||||
type ProviderRow = typeof schema.providers.$inferSelect
|
||||
|
||||
export interface FourvpsSyncAccount extends AccountRow {
|
||||
apiType: '4vps'
|
||||
apiBaseUrl: string
|
||||
panelId: number | null
|
||||
apiKey: string
|
||||
}
|
||||
|
||||
export function resolveFourvpsApi(
|
||||
accountRow: AccountRow | null | undefined,
|
||||
providerRow: ProviderRow | null | undefined,
|
||||
): { apiType: string; apiBaseUrl: string } {
|
||||
const apiType = String(providerRow?.apiType || accountRow?.apiType || '').trim()
|
||||
const apiBaseUrl = String(providerRow?.apiBaseUrl || accountRow?.apiBaseUrl || '').trim()
|
||||
return { apiType, apiBaseUrl }
|
||||
}
|
||||
|
||||
export function fourvpsAccountRowForSync(
|
||||
accountRow: AccountRow | null | undefined,
|
||||
providerRow: ProviderRow | null | undefined,
|
||||
): FourvpsSyncAccount | null {
|
||||
if (!accountRow) return null
|
||||
const { apiType, apiBaseUrl } = resolveFourvpsApi(accountRow, providerRow)
|
||||
const cred = String(accountRow.apiCredentials || '').trim()
|
||||
const { panelId, apiKey } = parseFourVpsCredentials(cred)
|
||||
if (apiType !== '4vps' || !apiBaseUrl || !apiKey) return null
|
||||
return { ...accountRow, apiType: '4vps', apiBaseUrl, panelId, apiKey }
|
||||
}
|
||||
Reference in New Issue
Block a user