obs-ss-plugin-webui/lib/constants.ts
Decobus a89fa7c8d6
All checks were successful
Lint and Build / build (pull_request) Successful in 2m46s
Standardize screen position naming to snake_case
- Update screen position naming from camelCase to snake_case (top_left, top_right, bottom_left, bottom_right)
- Refactor getActive route to use SCREEN_POSITIONS constant for DRY code
- Update documentation to reflect new file naming convention
- Remove unnecessary console.log for internal network requests in middleware
- Improve code maintainability and consistency across the codebase

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-25 19:25:38 -04:00

68 lines
1.8 KiB
TypeScript

// Base table names
export const BASE_TABLE_NAMES = {
STREAMS: 'streams',
TEAMS: 'teams',
} as const;
// Table configuration interface
export interface TableConfig {
year: number;
season: 'spring' | 'summer' | 'fall' | 'winter';
suffix?: string;
}
// Default configuration
export const DEFAULT_TABLE_CONFIG: TableConfig = {
year: 2025,
season: 'summer',
suffix: 'sat'
};
/**
* Generates a full table name using the provided configuration
* @param baseTableName - The base table name (e.g., 'streams' or 'teams')
* @param config - Optional configuration object. If not provided, uses DEFAULT_TABLE_CONFIG
* @returns The full table name with year, season, and suffix
*/
export function getTableName(
baseTableName: typeof BASE_TABLE_NAMES[keyof typeof BASE_TABLE_NAMES],
config: Partial<TableConfig> = {}
): string {
const finalConfig = {...DEFAULT_TABLE_CONFIG, ...config};
const suffix = finalConfig.suffix ? `_${finalConfig.suffix}` : '';
return `${baseTableName}_${finalConfig.year}_${finalConfig.season}${suffix}`;
}
// Export commonly used full table names with default configuration
export const TABLE_NAMES = {
STREAMS: getTableName(BASE_TABLE_NAMES.STREAMS),
TEAMS: getTableName(BASE_TABLE_NAMES.TEAMS),
} as const;
// Screen position constants
export const SCREEN_POSITIONS = [
'large',
'left',
'right',
'top_left',
'top_right',
'bottom_left',
'bottom_right'
] as const;
export const SOURCE_SWITCHER_NAMES = [
'ss_large',
'ss_left',
'ss_right',
'ss_top_left',
'ss_top_right',
'ss_bottom_left',
'ss_bottom_right'
] as const;
// OBS utility functions
export function cleanObsName(name: string): string {
return name.toLowerCase().replace(/\s+/g, '_');
}