-
-
Notifications
You must be signed in to change notification settings - Fork 929
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(types): provide strong typing for locales (#363)
- Loading branch information
Showing
50 changed files
with
939 additions
and
488 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import { allOf } from './utils'; | ||
|
||
/** | ||
* The possible definitions related to addresses. | ||
*/ | ||
export interface AddressDefinitions { | ||
/** | ||
* Postcodes patterns by state | ||
*/ | ||
// TODO ST-DDT 2022-01-31: address.zipCodeByState() expects only { [state: string]: { min: number; max: number } } | ||
postcode_by_state: | ||
| string[] | ||
| { [state: string]: { min: number; max: number } }; | ||
/** | ||
* Postcodes patterns (Fake-Pattern | Fake-Pattern[]). | ||
*/ | ||
postcode: string | string[]; | ||
|
||
/** | ||
* Names of actual cities | ||
*/ | ||
city_name?: string[]; | ||
/** | ||
* Common city prefixes | ||
*/ | ||
city_prefix: string[]; | ||
/** | ||
* Common city suffixes | ||
*/ | ||
city_suffix: string[]; | ||
|
||
/** | ||
* The names of all countries | ||
*/ | ||
country: string[]; | ||
/** | ||
* The names of this country's states | ||
*/ | ||
state: string[]; | ||
/** | ||
* The abbreviated names of this country's states | ||
*/ | ||
state_abbr: string[]; | ||
/** | ||
* The names of counties inside the country or state | ||
*/ | ||
county: string[]; | ||
|
||
/** | ||
* The names of the compass directions. | ||
* First the 4 cardinal directions, then the 4 ordinal directions | ||
*/ | ||
direction: string[]; | ||
/** | ||
* The abbreviated names of the compass directions. | ||
* First the 4 cardinal directions, then the 4 ordinal directions | ||
*/ | ||
direction_abbr: string[]; | ||
|
||
/** | ||
* Common street prefixes | ||
*/ | ||
street_prefix: string[]; | ||
/** | ||
* Common street suffixes | ||
*/ | ||
street_suffix: string[]; | ||
|
||
/** | ||
* The address "inside" an address/e.g. an apartment or office. | ||
*/ | ||
secondary_address: string[]; | ||
|
||
/** | ||
* The ISO-3166-1 ALPHA-2 country codes | ||
*/ | ||
country_code: string[]; | ||
/** | ||
* The ISO-3166-1 ALPHA-3 country codes | ||
*/ | ||
country_code_alpha_3: string[]; | ||
|
||
// A list of timezones names. | ||
time_zone: string[]; | ||
} | ||
|
||
/** | ||
* Internal: A list of all keys for the AddressDefinitions. | ||
*/ | ||
export const ADDRESS = allOf<keyof AddressDefinitions>()( | ||
'postcode_by_state', | ||
'postcode', | ||
|
||
'city_name', | ||
'city_prefix', | ||
'city_suffix', | ||
|
||
'country', | ||
'state', | ||
'state_abbr', | ||
'county', | ||
|
||
'direction_abbr', | ||
'direction', | ||
|
||
'street_prefix', | ||
'street_suffix', | ||
|
||
'secondary_address', | ||
|
||
'country_code', | ||
'country_code_alpha_3', | ||
|
||
'time_zone' | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { allOf } from './utils'; | ||
|
||
/** | ||
* The possible definitions related to animals. | ||
*/ | ||
export interface AnimalDefinitions { | ||
bear: string[]; | ||
bird: string[]; | ||
cat: string[]; | ||
cetacean: string[]; | ||
cow: string[]; | ||
crocodilia: string[]; | ||
dog: string[]; | ||
fish: string[]; | ||
horse: string[]; | ||
insect: string[]; | ||
lion: string[]; | ||
rabbit: string[]; | ||
snake: string[]; | ||
type: string[]; | ||
} | ||
|
||
/** | ||
* Internal: A list of all keys for the AnimalDefinitions. | ||
*/ | ||
export const ANIMAL = allOf<keyof AnimalDefinitions>()( | ||
'dog', | ||
'cat', | ||
'snake', | ||
'bear', | ||
'lion', | ||
'cetacean', | ||
'insect', | ||
'crocodilia', | ||
'cow', | ||
'bird', | ||
'fish', | ||
'rabbit', | ||
'horse', | ||
'type' | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { allOf } from './utils'; | ||
|
||
/** | ||
* The possible definitions related to commerce. | ||
*/ | ||
export interface CommerceDefinitions { | ||
/** | ||
* Human readable color names | ||
*/ | ||
color: string[]; | ||
/** | ||
* Department names inside a shop. | ||
*/ | ||
department: string[]; | ||
/** | ||
* Product name generation definitions. | ||
*/ | ||
product_name: CommerceProductNameDefinitions; | ||
/** | ||
* Descriptions for products. | ||
*/ | ||
product_description: string[]; | ||
} | ||
|
||
/** | ||
* The possible definitions related to product name generation. | ||
*/ | ||
export interface CommerceProductNameDefinitions { | ||
/** | ||
* Adjectives describing a product (e.g. tasty). | ||
*/ | ||
adjective: string[]; | ||
/** | ||
* Materials describing a product (e.g. wood). | ||
*/ | ||
material: string[]; | ||
/** | ||
* Types of products (e.g. chair). | ||
*/ | ||
product: string[]; | ||
} | ||
|
||
/** | ||
* Internal: A list of all keys for the CommerceDefinitions. | ||
*/ | ||
export const COMMERCE = allOf<keyof CommerceDefinitions>()( | ||
'color', | ||
'department', | ||
'product_name', | ||
'product_description' | ||
); |
Oops, something went wrong.