Files
ccs/src/api/services/provider-presets.ts
T
Tam Nhu Tran 21d6754ec6 refactor(presets): centralize shared provider preset catalog
- add shared preset catalog used by CLI and Dashboard

- enforce alias/id integrity and canonical normalization

- replace duplicated preset definitions in service and UI layers

- allow Vite dev fs access to repo root for shared catalog imports
2026-02-20 23:24:11 +07:00

49 lines
1.4 KiB
TypeScript

/**
* Provider Presets for CLI
*
* Pre-configured templates for common API providers.
* Uses shared source-of-truth catalog in src/shared/provider-preset-catalog.ts.
*/
import {
OPENROUTER_BASE_URL,
PROVIDER_PRESET_ALIASES,
createProviderPresetDefinitions,
normalizeProviderPresetId,
type PresetCategory,
type ProviderPresetDefinition,
} from '../../shared/provider-preset-catalog';
export { OPENROUTER_BASE_URL };
export type { PresetCategory };
export type ProviderPreset = ProviderPresetDefinition;
/**
* Provider presets available via CLI and UI
*/
export const PROVIDER_PRESETS: readonly ProviderPreset[] = Object.freeze(
createProviderPresetDefinitions()
);
export const PRESET_ALIASES: Readonly<Record<string, string>> = PROVIDER_PRESET_ALIASES;
/** Get preset by ID */
export function getPresetById(id: string): ProviderPreset | undefined {
const canonical = normalizeProviderPresetId(id);
return PROVIDER_PRESETS.find((p) => p.id === canonical);
}
/** Get all preset IDs */
export function getPresetIds(): string[] {
return PROVIDER_PRESETS.map((p) => p.id);
}
/** Get alias map (alias -> canonical preset ID). */
export function getPresetAliases(): Readonly<Record<string, string>> {
return PRESET_ALIASES;
}
/** Check if preset ID is valid */
export function isValidPresetId(id: string): boolean {
return getPresetById(id) !== undefined;
}