mirror of
https://github.com/tiennm99/ccs.git
synced 2026-08-15 18:23:12 +00:00
refactor(utils): use canonical ValidationResult from types/utils
- import ValidationResult from types/utils - create DelegationValidationResult extending base type - standardize on 'valid' property naming
This commit is contained in:
@@ -4,9 +4,13 @@ import * as fs from 'fs';
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import { Settings } from '../types';
|
import { Settings } from '../types';
|
||||||
|
import { ValidationResult } from '../types/utils';
|
||||||
|
|
||||||
interface ValidationResult {
|
/**
|
||||||
valid: boolean;
|
* Extended validation result for delegation profiles
|
||||||
|
* Extends base ValidationResult with domain-specific fields
|
||||||
|
*/
|
||||||
|
interface DelegationValidationResult extends ValidationResult {
|
||||||
error?: string;
|
error?: string;
|
||||||
suggestion?: string;
|
suggestion?: string;
|
||||||
settingsPath?: string;
|
settingsPath?: string;
|
||||||
@@ -23,7 +27,7 @@ export class DelegationValidator {
|
|||||||
* @param profileName - Name of profile to validate (e.g., 'glm', 'kimi')
|
* @param profileName - Name of profile to validate (e.g., 'glm', 'kimi')
|
||||||
* @returns Validation result { valid: boolean, error?: string, settingsPath?: string }
|
* @returns Validation result { valid: boolean, error?: string, settingsPath?: string }
|
||||||
*/
|
*/
|
||||||
static validate(profileName: string): ValidationResult {
|
static validate(profileName: string): DelegationValidationResult {
|
||||||
const homeDir = os.homedir();
|
const homeDir = os.homedir();
|
||||||
const settingsPath = path.join(homeDir, '.ccs', `${profileName}.settings.json`);
|
const settingsPath = path.join(homeDir, '.ccs', `${profileName}.settings.json`);
|
||||||
|
|
||||||
@@ -110,7 +114,7 @@ export class DelegationValidator {
|
|||||||
* @param result - Validation result from validate()
|
* @param result - Validation result from validate()
|
||||||
* @returns Formatted error message
|
* @returns Formatted error message
|
||||||
*/
|
*/
|
||||||
static formatError(result: ValidationResult): string {
|
static formatError(result: DelegationValidationResult): string {
|
||||||
if (result.valid) {
|
if (result.valid) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user