mirror of
https://gitee.com/wanwujie/sub2api
synced 2026-04-03 15:02:13 +08:00
29 lines
880 B
TypeScript
29 lines
880 B
TypeScript
import type { Account } from '@/types'
|
|
|
|
const normalizeUsageRefreshValue = (value: unknown): string => {
|
|
if (value == null) return ''
|
|
return String(value)
|
|
}
|
|
|
|
export const buildOpenAIUsageRefreshKey = (account: Pick<Account, 'id' | 'platform' | 'type' | 'updated_at' | 'rate_limit_reset_at' | 'extra'>): string => {
|
|
if (account.platform !== 'openai' || account.type !== 'oauth') {
|
|
return ''
|
|
}
|
|
|
|
const extra = account.extra ?? {}
|
|
return [
|
|
account.id,
|
|
account.updated_at,
|
|
account.rate_limit_reset_at,
|
|
extra.codex_usage_updated_at,
|
|
extra.codex_5h_used_percent,
|
|
extra.codex_5h_reset_at,
|
|
extra.codex_5h_reset_after_seconds,
|
|
extra.codex_5h_window_minutes,
|
|
extra.codex_7d_used_percent,
|
|
extra.codex_7d_reset_at,
|
|
extra.codex_7d_reset_after_seconds,
|
|
extra.codex_7d_window_minutes
|
|
].map(normalizeUsageRefreshValue).join('|')
|
|
}
|