/** * Region Filter Service * Manages Asia-Pacific region filtering (Seoul, Tokyo, Osaka, Singapore, Hong Kong) */ /** * Asia-Pacific region codes by provider * Limited to 5 major cities in East/Southeast Asia */ export const ASIA_REGIONS: Record = { linode: ['jp-tyo-3', 'jp-osa', 'sg-sin-2'], vultr: ['icn', 'nrt', 'itm'], aws: ['ap-northeast-1', 'ap-northeast-2', 'ap-northeast-3', 'ap-southeast-1', 'ap-east-1'], }; /** * Region code to display name mapping */ export const REGION_DISPLAY_NAMES: Record = { // Linode 'jp-tyo-3': 'Tokyo', 'jp-osa': 'Osaka', 'sg-sin-2': 'Singapore', // Vultr 'icn': 'Seoul', 'nrt': 'Tokyo', 'itm': 'Osaka', // AWS 'ap-northeast-1': 'Tokyo', 'ap-northeast-2': 'Seoul', 'ap-northeast-3': 'Osaka', 'ap-southeast-1': 'Singapore', 'ap-east-1': 'Hong Kong', }; /** * Check if a region code is in the Asia-Pacific filter list * * @param provider - Cloud provider name (case-insensitive) * @param regionCode - Region code to check (case-insensitive) * @returns true if region is in Asia-Pacific filter list */ export function isAsiaRegion(provider: string, regionCode: string): boolean { const regions = ASIA_REGIONS[provider.toLowerCase()]; if (!regions) return false; return regions.includes(regionCode.toLowerCase()); } /** * Get all Asia-Pacific region codes for a provider * * @param provider - Cloud provider name (case-insensitive) * @returns Array of region codes, empty if provider not found */ export function getAsiaRegionCodes(provider: string): string[] { return ASIA_REGIONS[provider.toLowerCase()] || []; } /** * Get display name for a region code * * @param regionCode - Region code to look up * @returns Display name (e.g., "Tokyo"), or original code if not found */ export function getRegionDisplayName(regionCode: string): string { return REGION_DISPLAY_NAMES[regionCode] || regionCode; }