Добавить apiLogin из credentials, сводку и health-индикаторы на /accounts, фильтры, раздельную форму логина и пароля, безопасное удаление с 409 и тесты API/repository. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -25,6 +25,10 @@
|
||||
"./geo/*": {
|
||||
"types": "./dist/geo/*.d.ts",
|
||||
"default": "./dist/geo/*.js"
|
||||
},
|
||||
"./utils/*": {
|
||||
"types": "./dist/utils/*.d.ts",
|
||||
"default": "./dist/utils/*.js"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
@@ -1,15 +1,29 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const providerAccountSchema = z.object({
|
||||
export const billingModeSchema = z.enum(['daily', 'monthly'])
|
||||
|
||||
export const providerAccountInputSchema = z.object({
|
||||
id: z.string().optional(),
|
||||
providerId: z.string().min(1, 'Provider is required'),
|
||||
name: z.string().min(1, 'Name is required'),
|
||||
panelUrl: z.string().optional().default(''),
|
||||
currency: z.string().optional().default(''),
|
||||
billingMode: z.string().optional().default(''),
|
||||
billingMode: billingModeSchema.optional().default('monthly'),
|
||||
notes: z.string().optional().default(''),
|
||||
apiCredentials: z.string().optional().default(''),
|
||||
balanceAlertBelow: z.union([z.number(), z.null()]).optional(),
|
||||
})
|
||||
|
||||
export type ProviderAccount = z.infer<typeof providerAccountSchema>
|
||||
export const providerAccountPublicSchema = providerAccountInputSchema
|
||||
.omit({ apiCredentials: true })
|
||||
.extend({
|
||||
apiCredentialsSet: z.boolean().optional(),
|
||||
apiLogin: z.string().optional(),
|
||||
})
|
||||
|
||||
/** @deprecated Используйте providerAccountInputSchema */
|
||||
export const providerAccountSchema = providerAccountInputSchema
|
||||
|
||||
export type ProviderAccountInput = z.infer<typeof providerAccountInputSchema>
|
||||
export type ProviderAccountPublic = z.infer<typeof providerAccountPublicSchema>
|
||||
export type ProviderAccount = ProviderAccountInput
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export * from './contracts/provider.js'
|
||||
export * from './contracts/provider-account.js'
|
||||
export * from './utils/api-credentials.js'
|
||||
export * from './contracts/vps.js'
|
||||
export * from './contracts/payment.js'
|
||||
export * from './contracts/balance-ledger.js'
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/** Логин из BILLmanager-кредов формата `login:password`. */
|
||||
export function parseApiLogin(credentials: string | null | undefined): string {
|
||||
const cred = String(credentials ?? '').trim()
|
||||
const idx = cred.indexOf(':')
|
||||
return idx > 0 ? cred.slice(0, idx) : ''
|
||||
}
|
||||
|
||||
/** Собрать креды для API из отдельных полей формы. */
|
||||
export function buildApiCredentials(login: string, password: string): string {
|
||||
const l = login.trim()
|
||||
const p = password
|
||||
if (!l && !p) return ''
|
||||
if (!l) return p
|
||||
return p ? `${l}:${p}` : ''
|
||||
}
|
||||
Reference in New Issue
Block a user