File size: 1,070 Bytes
d47b053
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
 * Database - 配置
 * 从环境变量读取数据库开关和连接信息
 */

export interface DatabaseConfig {
  historyEnabled: boolean
  studioEnabled: boolean
  supabaseUrl: string
  supabaseKey: string
}

export function getDatabaseConfig(): DatabaseConfig {
  return {
    historyEnabled: process.env.ENABLE_HISTORY_DB === 'true',
    studioEnabled: process.env.ENABLE_STUDIO_DB === 'true',
    supabaseUrl: process.env.SUPABASE_URL?.trim() || '',
    supabaseKey: process.env.SUPABASE_KEY?.trim() || '',
  }
}

export function isSupabaseConfigured(): boolean {
  const cfg = getDatabaseConfig()
  return Boolean(cfg.supabaseUrl) && Boolean(cfg.supabaseKey)
}

/**
 * 检查历史记录数据库配置是否就绪
 */
export function isDatabaseReady(): boolean {
  const cfg = getDatabaseConfig()
  return cfg.historyEnabled && isSupabaseConfigured()
}

/**
 * 检查 Studio 持久化数据库配置是否就绪
 */
export function isStudioDatabaseReady(): boolean {
  const cfg = getDatabaseConfig()
  return cfg.studioEnabled && isSupabaseConfigured()
}