countries-states-cities-service
Version:
Get the World's countries, states, regions and cities
62 lines (59 loc) • 1.53 kB
TypeScript
type TranslationLocale = 'kr' | 'br' | 'pt' | 'nl' | 'hr' | 'fa' | 'de' | 'es' | 'fr' | 'ja' | 'it' | 'cn';
type SortType = 'alphabetical' | 'asc' | 'desc';
interface Country {
id: number;
name: string;
iso3: string;
iso2: string;
numeric_code: string;
phone_code: string;
capital: string;
currency: string;
currency_symbol: string;
tld: string;
native: string;
region: string;
subregion: string;
timezones: Array<{
zoneName: string;
gmtOffset: number;
gmtOffsetName: string;
abbreviation: string;
tzName: string;
}>;
translations: Partial<Record<TranslationLocale, string>>;
latitude: string;
longitude: string;
emoji: string;
emojiU: string;
}
interface State {
id: number;
name: string;
state_code: string;
country_code: string;
country_id: number;
latitude: string;
longitude: string;
is_region?: boolean;
translations?: Partial<Record<TranslationLocale, string>>;
}
interface City {
id: number;
name: string;
state_id: number;
state_code: string;
country_id: number;
country_code: string;
latitude: string;
longitude: string;
}
type AlphabeticalSort<D> = {
mode: 'alphabetical';
key: keyof D & string;
};
type DirectionalSort = {
mode: 'asc' | 'desc';
};
type SortArgs<D> = AlphabeticalSort<D> | DirectionalSort;
export type { City as C, SortArgs as S, TranslationLocale as T, Country as a, SortType as b, State as c };