aboutsummaryrefslogtreecommitdiff
path: root/src/definitions
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2022-05-05 00:09:25 +0200
committerGitHub <[email protected]>2022-05-05 00:09:25 +0200
commit984fbb445ff3be3658535bf98916ce5f38943fbf (patch)
treeafab5f5137ee3069690944d11285d6d5a4e2fe35 /src/definitions
parentf1dba1bb0b90dc5e1e3ee096f937a1d4df6acf03 (diff)
downloadfaker-984fbb445ff3be3658535bf98916ce5f38943fbf.tar.xz
faker-984fbb445ff3be3658535bf98916ce5f38943fbf.zip
fix(generate:locale): make the definition types extendible (#915)
Co-authored-by: Piotr Kuczynski <[email protected]>
Diffstat (limited to 'src/definitions')
-rw-r--r--src/definitions/address.ts8
-rw-r--r--src/definitions/animal.ts6
-rw-r--r--src/definitions/commerce.ts6
-rw-r--r--src/definitions/company.ts6
-rw-r--r--src/definitions/database.ts6
-rw-r--r--src/definitions/date.ts6
-rw-r--r--src/definitions/definitions.ts16
-rw-r--r--src/definitions/finance.ts6
-rw-r--r--src/definitions/hacker.ts6
-rw-r--r--src/definitions/index.ts2
-rw-r--r--src/definitions/internet.ts5
-rw-r--r--src/definitions/lorem.ts6
-rw-r--r--src/definitions/music.ts6
-rw-r--r--src/definitions/name.ts6
-rw-r--r--src/definitions/phone_number.ts6
-rw-r--r--src/definitions/system.ts6
-rw-r--r--src/definitions/vehicle.ts6
-rw-r--r--src/definitions/word.ts6
18 files changed, 72 insertions, 43 deletions
diff --git a/src/definitions/address.ts b/src/definitions/address.ts
index 6552f39a..a7300e5f 100644
--- a/src/definitions/address.ts
+++ b/src/definitions/address.ts
@@ -1,7 +1,9 @@
+import type { LocaleEntry } from './definitions';
+
/**
* The possible definitions related to addresses.
*/
-export interface AddressDefinitions {
+export type AddressDefinitions = LocaleEntry<{
/**
* Postcodes patterns by state
*/
@@ -14,7 +16,7 @@ export interface AddressDefinitions {
/**
* Names of actual cities
*/
- city_name?: string[];
+ city_name: string[];
/**
* Common city prefixes
*/
@@ -96,4 +98,4 @@ export interface AddressDefinitions {
// A list of timezones names.
time_zone: string[];
-}
+}>;
diff --git a/src/definitions/animal.ts b/src/definitions/animal.ts
index d056e402..58e493e5 100644
--- a/src/definitions/animal.ts
+++ b/src/definitions/animal.ts
@@ -1,7 +1,9 @@
+import type { LocaleEntry } from './definitions';
+
/**
* The possible definitions related to animals.
*/
-export interface AnimalDefinitions {
+export type AnimalDefinitions = LocaleEntry<{
bear: string[];
bird: string[];
cat: string[];
@@ -16,4 +18,4 @@ export interface AnimalDefinitions {
rabbit: string[];
snake: string[];
type: string[];
-}
+}>;
diff --git a/src/definitions/commerce.ts b/src/definitions/commerce.ts
index eb106463..65aef4ba 100644
--- a/src/definitions/commerce.ts
+++ b/src/definitions/commerce.ts
@@ -1,7 +1,9 @@
+import type { LocaleEntry } from './definitions';
+
/**
* The possible definitions related to commerce.
*/
-export interface CommerceDefinitions {
+export type CommerceDefinitions = LocaleEntry<{
/**
* Human readable color names
*/
@@ -18,7 +20,7 @@ export interface CommerceDefinitions {
* Descriptions for products.
*/
product_description: string[];
-}
+}>;
/**
* The possible definitions related to product name generation.
diff --git a/src/definitions/company.ts b/src/definitions/company.ts
index 89999ced..5b98bcc5 100644
--- a/src/definitions/company.ts
+++ b/src/definitions/company.ts
@@ -1,7 +1,9 @@
+import type { LocaleEntry } from './definitions';
+
/**
* The possible definitions related to companies.
*/
-export interface CompanyDefinitions {
+export type CompanyDefinitions = LocaleEntry<{
/**
* Business/products related adjectives.
*/
@@ -30,4 +32,4 @@ export interface CompanyDefinitions {
* Company suffixes
*/
suffix: string[];
-}
+}>;
diff --git a/src/definitions/database.ts b/src/definitions/database.ts
index 47ab603d..776f5361 100644
--- a/src/definitions/database.ts
+++ b/src/definitions/database.ts
@@ -1,7 +1,9 @@
+import type { LocaleEntry } from './definitions';
+
/**
* The possible definitions related to databases.
*/
-export interface DatabaseDefinitions {
+export type DatabaseDefinitions = LocaleEntry<{
/**
* Database Engine
*/
@@ -18,4 +20,4 @@ export interface DatabaseDefinitions {
* Column types
*/
type: string[];
-}
+}>;
diff --git a/src/definitions/date.ts b/src/definitions/date.ts
index a6d74722..2f014f55 100644
--- a/src/definitions/date.ts
+++ b/src/definitions/date.ts
@@ -1,7 +1,9 @@
+import type { LocaleEntry } from './definitions';
+
/**
* The possible definitions related to dates.
*/
-export interface DateDefinitions {
+export type DateDefinitions = LocaleEntry<{
/**
* The translations for months (January - December).
*/
@@ -10,7 +12,7 @@ export interface DateDefinitions {
* The translations for weekdays (Sunday - Saturday).
*/
weekday: DateEntryDefinition;
-}
+}>;
/**
* The possible definitions related to date entries.
diff --git a/src/definitions/definitions.ts b/src/definitions/definitions.ts
index a338cc83..fae443ba 100644
--- a/src/definitions/definitions.ts
+++ b/src/definitions/definitions.ts
@@ -15,10 +15,15 @@ import type { SystemDefinitions } from './system';
import type { VehicleDefinitions } from './vehicle';
import type { WordDefinitions } from './word';
+export type LocaleEntry<T> = Partial<T> &
+ // Unsupported & custom modules
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ Record<string, any>;
+
/**
* The definitions as used by the Faker modules.
*/
-interface Definitions {
+export interface Definitions {
address: AddressDefinitions;
animal: AnimalDefinitions;
commerce: CommerceDefinitions;
@@ -48,11 +53,4 @@ export type LocaleDefinition = {
*/
title: string;
separator?: string;
-} & {
- // Known modules
- [module in keyof Definitions]?: Partial<Definitions[module]>;
-} & {
- // Unsupported & custom modules
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- [group: string]: any;
-};
+} & LocaleEntry<Definitions>;
diff --git a/src/definitions/finance.ts b/src/definitions/finance.ts
index e5f4553b..d2c26283 100644
--- a/src/definitions/finance.ts
+++ b/src/definitions/finance.ts
@@ -1,7 +1,9 @@
+import type { LocaleEntry } from './definitions';
+
/**
* The possible definitions related to finances.
*/
-export interface FinanceDefinitions {
+export type FinanceDefinitions = LocaleEntry<{
/**
* The types of accounts/purposes of an account (e.g. `Savings` account).
*/
@@ -21,7 +23,7 @@ export interface FinanceDefinitions {
* Types of transactions (e.g. `deposit`).
*/
transaction_type: string[];
-}
+}>;
/**
* The possible definitions related to currency entries.
diff --git a/src/definitions/hacker.ts b/src/definitions/hacker.ts
index 8a23c88a..e6790839 100644
--- a/src/definitions/hacker.ts
+++ b/src/definitions/hacker.ts
@@ -1,7 +1,9 @@
+import type { LocaleEntry } from './definitions';
+
/**
* The possible definitions related to computers.
*/
-export interface HackerDefinitions {
+export type HackerDefinitions = LocaleEntry<{
/**
* Generic computer related abbreviations (e.g. `RAM`, `EXE`).
*/
@@ -30,4 +32,4 @@ export interface HackerDefinitions {
* Some computer related verbs (e.g. `hack`).
*/
verb: string[];
-}
+}>;
diff --git a/src/definitions/index.ts b/src/definitions/index.ts
index 70555b0e..bcfcab0f 100644
--- a/src/definitions/index.ts
+++ b/src/definitions/index.ts
@@ -7,7 +7,7 @@ export type {
export type { CompanyDefinitions } from './company';
export type { DatabaseDefinitions } from './database';
export type { DateDefinitions, DateEntryDefinition } from './date';
-export type { LocaleDefinition } from './definitions';
+export type { Definitions, LocaleDefinition } from './definitions';
export type {
FinanceCurrencyEntryDefinitions,
FinanceDefinitions,
diff --git a/src/definitions/internet.ts b/src/definitions/internet.ts
index e81871f6..96a79a76 100644
--- a/src/definitions/internet.ts
+++ b/src/definitions/internet.ts
@@ -1,9 +1,10 @@
import type { EmojiType } from '../modules/internet';
+import type { LocaleEntry } from './definitions';
/**
* The possible definitions related to internet stuff.
*/
-export interface InternetDefinitions {
+export type InternetDefinitions = LocaleEntry<{
/**
* Common top level and similar domains (e.g `de`, `co.uk`).
*/
@@ -20,4 +21,4 @@ export interface InternetDefinitions {
* List of all fully-qualified emojis.
*/
emoji: Record<EmojiType, string[]>;
-}
+}>;
diff --git a/src/definitions/lorem.ts b/src/definitions/lorem.ts
index 202a527f..4d851b30 100644
--- a/src/definitions/lorem.ts
+++ b/src/definitions/lorem.ts
@@ -1,9 +1,11 @@
+import type { LocaleEntry } from './definitions';
+
/**
* The possible definitions related to lorem texts.
*/
-export interface LoremDefinitions {
+export type LoremDefinitions = LocaleEntry<{
/**
* Lorem words used to generate dummy texts.
*/
words: string[];
-}
+}>;
diff --git a/src/definitions/music.ts b/src/definitions/music.ts
index eaa340ae..3e2842d5 100644
--- a/src/definitions/music.ts
+++ b/src/definitions/music.ts
@@ -1,9 +1,11 @@
+import type { LocaleEntry } from './definitions';
+
/**
* The possible definitions related to music.
*/
-export interface MusicDefinitions {
+export type MusicDefinitions = LocaleEntry<{
/**
* The names of some music genres.
*/
genre: string[];
-}
+}>;
diff --git a/src/definitions/name.ts b/src/definitions/name.ts
index a5156410..9098a66a 100644
--- a/src/definitions/name.ts
+++ b/src/definitions/name.ts
@@ -1,7 +1,9 @@
+import type { LocaleEntry } from './definitions';
+
/**
* The possible definitions related to people's names.
*/
-export interface NameDefinitions {
+export type NameDefinitions = LocaleEntry<{
gender: string[];
binary_gender: string[];
@@ -29,7 +31,7 @@ export interface NameDefinitions {
name: string[];
title: NameTitleDefinitions;
-}
+}>;
/**
* The possible definitions related to people's titles.
diff --git a/src/definitions/phone_number.ts b/src/definitions/phone_number.ts
index 1fb69ad2..3f805ea7 100644
--- a/src/definitions/phone_number.ts
+++ b/src/definitions/phone_number.ts
@@ -1,7 +1,9 @@
+import type { LocaleEntry } from './definitions';
+
/**
* The possible definitions related to phone numbers.
*/
-export interface PhoneNumberDefinitions {
+export type PhoneNumberDefinitions = LocaleEntry<{
/**
* Some patterns used to generate phone numbers.
* `#` will be replaced by a random digit (0-9).
@@ -11,4 +13,4 @@ export interface PhoneNumberDefinitions {
* @see Helpers.replaceSymbolWithNumber(format)
*/
formats: string[];
-}
+}>;
diff --git a/src/definitions/system.ts b/src/definitions/system.ts
index c3e25232..c6aa16c7 100644
--- a/src/definitions/system.ts
+++ b/src/definitions/system.ts
@@ -1,7 +1,9 @@
+import type { LocaleEntry } from './definitions';
+
/**
* The possible definitions related to files and the system.
*/
-export interface SystemDefinitions {
+export type SystemDefinitions = LocaleEntry<{
/**
* Returns some common file paths.
*/
@@ -10,7 +12,7 @@ export interface SystemDefinitions {
* The mime type definitions with some additional information.
*/
mimeTypes: { [mimeType: string]: SystemMimeTypeEntryDefinitions };
-}
+}>;
/**
* The mime type entry details.
diff --git a/src/definitions/vehicle.ts b/src/definitions/vehicle.ts
index 71c35851..8904a9eb 100644
--- a/src/definitions/vehicle.ts
+++ b/src/definitions/vehicle.ts
@@ -1,7 +1,9 @@
+import type { LocaleEntry } from './definitions';
+
/**
* The possible definitions related to vehicles.
*/
-export interface VehicleDefinitions {
+export type VehicleDefinitions = LocaleEntry<{
/**
* Some types of bicycles.
*/
@@ -22,4 +24,4 @@ export interface VehicleDefinitions {
* Some types of vehicles (e.g. `Minivan`).
*/
type: string[];
-}
+}>;
diff --git a/src/definitions/word.ts b/src/definitions/word.ts
index 3e502215..c705de82 100644
--- a/src/definitions/word.ts
+++ b/src/definitions/word.ts
@@ -1,7 +1,9 @@
+import type { LocaleEntry } from './definitions';
+
/**
* The possible definitions related to words.
*/
-export interface WordDefinitions {
+export type WordDefinitions = LocaleEntry<{
adjective: string[];
adverb: string[];
conjunction: string[];
@@ -9,4 +11,4 @@ export interface WordDefinitions {
noun: string[];
preposition: string[];
verb: string[];
-}
+}>;