/** * TypeScript interfaces for @countrystatecity/countries-browser * Copied from @countrystatecity/countries for API compatibility */ interface ITimezone { zoneName: string; gmtOffset: number; gmtOffsetName: string; abbreviation: string; tzName: string; } interface ITranslations { [languageCode: string]: string; } interface ICountry { id: number; name: string; iso2: string; iso3: string; numeric_code: string; phonecode: string; capital: string; currency: string; currency_name: string; currency_symbol: string; tld: string; native: string; population: number | null; gdp: number | null; region: string; region_id: number | null; subregion: string; subregion_id: number | null; nationality: string; latitude: string; longitude: string; emoji: string; emojiU: string; } interface ICountryMeta extends ICountry { timezones: ITimezone[]; translations: ITranslations; } interface IRegion { id: number; name: string; translations: ITranslations; wikiDataId: string | null; } interface ISubregion { id: number; name: string; region_id: number; translations: ITranslations; wikiDataId: string | null; } /** Projected state fields; upstream type_local, level and parent_id are omitted. */ interface IState { id: number; name: string; country_id: number; country_code: string; fips_code: string | null; iso2: string; iso3166_2: string | null; type: string | null; latitude: string | null; longitude: string | null; native: string | null; timezone: string | null; translations: ITranslations; } /** Projected city fields; upstream type_local, county_id, level and parent_id are omitted. */ interface ICity { id: number; name: string; state_id: number | null; state_code: string | null; country_id: number; country_code: string; latitude: string; longitude: string; native: string | null; timezone: string | null; translations: ITranslations; /** Upstream classification (e.g. "municipality", "city", "town", "village", "locality", "section", or legacy "adm1"/"adm2"). Null if unavailable. */ type?: string | null; population?: number | null; population_year?: number | null; wikiDataId?: string | null; } /** * Which source-data release this package's data was generated from. * * Same shape as the Country State City API's `GET /v1/meta/data-version` * response, minus `regions`/`subregions` in `recordCounts`, which these * packages don't ship. * * To check whether this package and a live API response describe the same * data, compare `sourceRelease` — not `dataVersion`. Both sides format * `dataVersion` as `-`, but the date half comes * from a different event on each side: the release's publish date here, and * the date that release was imported into the API database on the API side. * The two strings therefore routinely differ by a day or more even when both * hold exactly the same data. */ interface IDataVersion { /** `-`, where the date is this release's publish date. */ dataVersion: string; /** The upstream release tag — identical on the API side, so use it for parity checks. */ sourceRelease: string; /** ISO 8601 UTC timestamp of the release's publish time, to millisecond precision. */ updatedAt: string; /** Row counts for this release. Narrower than the API's, which also reports regions/subregions. */ recordCounts: { countries: number; states: number; cities: number; }; } interface ConfigOptions { baseURL?: string; timeout?: number; headers?: Record; cacheSize?: number; } /** * Error classes for @countrystatecity/countries-browser */ declare class NetworkError extends Error { readonly url: string; readonly statusCode?: number; /** * Creates a NetworkError for failed HTTP requests. * @param message - Human-readable error description * @param url - The URL that caused the failure * @param statusCode - Optional HTTP status code */ constructor(message: string, url: string, statusCode?: number); } declare class TimeoutError extends Error { readonly timeout: number; /** * Creates a TimeoutError for requests that exceeded the time limit. * @param message - Human-readable error description * @param timeout - The timeout duration in milliseconds */ constructor(message: string, timeout: number); } /** * Configuration management for @countrystatecity/countries-browser */ /** * Override default configuration options * @param options - Partial configuration to merge with defaults */ declare function configure(options: ConfigOptions): void; /** * Reset configuration to defaults */ declare function resetConfiguration(): void; /** * Data loaders for @countrystatecity/countries-browser * Uses fetch API to load JSON from jsDelivr CDN with LRU caching */ /** * Clear the cache (forces re-initialization on next use, picking up any config changes) */ declare function clearCache(): void; /** * Get lightweight list of all countries * @returns Array of countries (basic info only) */ declare function getCountries(): Promise; /** * Get list of all regions (continents) * @returns Array of regions */ declare function getRegions(): Promise; /** * Get list of all subregions * @returns Array of subregions */ declare function getSubregions(): Promise; /** * Get the source-data release this package's data was generated from. * Never loads country, state, or city data — only the small version.json file. * @returns The data version info */ declare function getDataVersion(): Promise; /** * Get full country metadata including timezones and translations * @param countryCode - ISO2 country code (e.g., 'US', 'IN') * @returns Full country metadata or null if not found */ declare function getCountryByCode(countryCode: string): Promise; /** * Get all states/provinces for a specific country * @param countryCode - ISO2 country code * @returns Array of states or empty array if not found */ declare function getStatesOfCountry(countryCode: string): Promise; /** * Get specific state by code * @param countryCode - ISO2 country code * @param stateCode - State code (e.g., 'CA', 'TX') * @returns State object or null if not found */ declare function getStateByCode(countryCode: string, stateCode: string): Promise; /** * Get all cities in a specific state * @param countryCode - ISO2 country code * @param stateCode - State code * @returns Array of cities or empty array if not found */ declare function getCitiesOfState(countryCode: string, stateCode: string | null): Promise; /** * Get specific city by ID * @param countryCode - ISO2 country code * @param stateCode - State code * @param cityId - City ID * @returns City object or null if not found */ declare function getCityById(countryCode: string, stateCode: string | null, cityId: number): Promise; /** * Get ALL cities in an entire country * WARNING: Loads all state city files * @param countryCode - ISO2 country code * @returns Array of all cities in country */ declare function getAllCitiesOfCountry(countryCode: string): Promise; /** * Get every city globally * WARNING: MASSIVE data * @returns Array of all cities worldwide */ declare function getAllCitiesInWorld(): Promise; /** * Utility functions for @countrystatecity/countries-browser */ /** * Validate if a country code exists * @param countryCode - ISO2 country code to validate * @returns True if the country code is valid */ declare function isValidCountryCode(countryCode: string): Promise; /** * Validate if a state code exists in a country * @param countryCode - ISO2 country code * @param stateCode - State code to validate * @returns True if the state code is valid for the given country */ declare function isValidStateCode(countryCode: string, stateCode: string): Promise; /** * Search cities by name (partial match, case-insensitive) * @param countryCode - ISO2 country code * @param stateCode - State code * @param searchTerm - Partial city name to search for * @returns Array of matching cities */ declare function searchCitiesByName(countryCode: string, stateCode: string, searchTerm: string): Promise; /** * Get country name from ISO2 code * @param countryCode - ISO2 country code * @returns Country name or null if not found */ declare function getCountryNameByCode(countryCode: string): Promise; /** * Get state name from codes * @param countryCode - ISO2 country code * @param stateCode - State code * @returns State name or null if not found */ declare function getStateNameByCode(countryCode: string, stateCode: string): Promise; /** * Get timezone for a specific city * @param countryCode - ISO2 country code * @param stateCode - State code * @param cityName - Exact city name * @returns Timezone string or null if not found */ declare function getTimezoneForCity(countryCode: string, stateCode: string, cityName: string): Promise; /** * Get all timezone names for a country * @param countryCode - ISO2 country code * @returns Array of timezone zone names or empty array if not found */ declare function getCountryTimezones(countryCode: string): Promise; /** * Get all subregions belonging to a region * @param regionId - Region ID (see getRegions()) * @returns Array of subregions */ declare function getSubregionsOfRegion(regionId: number): Promise; /** * Get all countries in a region * @param region - Region name (case-insensitive, e.g. 'Europe') or region ID * @returns Array of countries */ declare function getCountriesByRegion(region: string | number): Promise; /** * Get all countries in a subregion * @param subregion - Subregion name (case-insensitive, e.g. 'South America') or subregion ID * @returns Array of countries */ declare function getCountriesBySubregion(subregion: string | number): Promise; export { type ConfigOptions, type ICity, type ICountry, type ICountryMeta, type IDataVersion, type IRegion, type IState, type ISubregion, type ITimezone, type ITranslations, NetworkError, TimeoutError, clearCache, configure, getAllCitiesInWorld, getAllCitiesOfCountry, getCitiesOfState, getCityById, getCountries, getCountriesByRegion, getCountriesBySubregion, getCountryByCode, getCountryNameByCode, getCountryTimezones, getDataVersion, getRegions, getStateByCode, getStateNameByCode, getStatesOfCountry, getSubregions, getSubregionsOfRegion, getTimezoneForCity, isValidCountryCode, isValidStateCode, resetConfiguration, searchCitiesByName };