| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| import { getDbInstance, isBuildPhase, isCloud } from "./core"; |
|
|
| |
|
|
| |
| |
| |
| export function saveCliToolLastConfigured( |
| toolId: string, |
| timestamp: string = new Date().toISOString() |
| ) { |
| if (isBuildPhase || isCloud) return; |
| const db = getDbInstance(); |
| db.prepare("INSERT OR REPLACE INTO key_value (namespace, key, value) VALUES (?, ?, ?)").run( |
| "cliToolLastConfig", |
| toolId, |
| JSON.stringify(timestamp) |
| ); |
| } |
|
|
| |
| |
| |
| |
| export function getCliToolLastConfigured(toolId: string): string | null { |
| if (isBuildPhase || isCloud) return null; |
| const db = getDbInstance(); |
| const row: any = db |
| .prepare("SELECT value FROM key_value WHERE namespace = ? AND key = ?") |
| .get("cliToolLastConfig", toolId); |
| return row ? JSON.parse(row.value) : null; |
| } |
|
|
| |
| |
| |
| |
| export function getAllCliToolLastConfigured(): Record<string, string> { |
| if (isBuildPhase || isCloud) return {}; |
| const db = getDbInstance(); |
| const rows: any[] = db |
| .prepare("SELECT key, value FROM key_value WHERE namespace = ?") |
| .all("cliToolLastConfig"); |
| const result: Record<string, string> = {}; |
| for (const row of rows) { |
| result[row.key] = JSON.parse(row.value); |
| } |
| return result; |
| } |
|
|
| |
| |
| |
| export function deleteCliToolLastConfigured(toolId: string) { |
| if (isBuildPhase || isCloud) return; |
| const db = getDbInstance(); |
| db.prepare("DELETE FROM key_value WHERE namespace = ? AND key = ?").run( |
| "cliToolLastConfig", |
| toolId |
| ); |
| } |
|
|
| |
|
|
| |
| |
| |
| |
| |
| export function saveCliToolInitialConfig(toolId: string, config: Record<string, any>): boolean { |
| if (isBuildPhase || isCloud) return false; |
| const db = getDbInstance(); |
| |
| const existing: any = db |
| .prepare("SELECT value FROM key_value WHERE namespace = ? AND key = ?") |
| .get("cliToolInitialConfig", toolId); |
| if (existing) return false; |
|
|
| db.prepare("INSERT OR REPLACE INTO key_value (namespace, key, value) VALUES (?, ?, ?)").run( |
| "cliToolInitialConfig", |
| toolId, |
| JSON.stringify(config) |
| ); |
| return true; |
| } |
|
|
| |
| |
| |
| |
| export function getCliToolInitialConfig(toolId: string): Record<string, any> | null { |
| if (isBuildPhase || isCloud) return null; |
| const db = getDbInstance(); |
| const row: any = db |
| .prepare("SELECT value FROM key_value WHERE namespace = ? AND key = ?") |
| .get("cliToolInitialConfig", toolId); |
| return row ? JSON.parse(row.value) : null; |
| } |
|
|
| |
| |
| |
| export function deleteCliToolInitialConfig(toolId: string) { |
| if (isBuildPhase || isCloud) return; |
| const db = getDbInstance(); |
| db.prepare("DELETE FROM key_value WHERE namespace = ? AND key = ?").run( |
| "cliToolInitialConfig", |
| toolId |
| ); |
| } |
|
|