Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add book module #2949

Open
wants to merge 18 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/.vitepress/api-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const apiPages = [
items: [
{ text: 'Airline', link: '/api/airline.html' },
{ text: 'Animal', link: '/api/animal.html' },
{ text: 'Book', link: '/api/book.html' },
{ text: 'Color', link: '/api/color.html' },
{ text: 'Commerce', link: '/api/commerce.html' },
{ text: 'Company', link: '/api/company.html' },
Expand Down
1 change: 1 addition & 0 deletions scripts/generate-locales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type DefinitionType = {
const definitionsTypes: DefinitionType = {
airline: 'AirlineDefinition',
animal: 'AnimalDefinition',
book: 'BookDefinition',
color: 'ColorDefinition',
commerce: 'CommerceDefinition',
company: 'CompanyDefinition',
Expand Down
36 changes: 36 additions & 0 deletions src/definitions/book.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { LocaleEntry } from './definitions';

/**
* The possible definitions related to books.
*/
export type BookDefinition = LocaleEntry<{
/**
* The names of actual book authors.
*/
author: string[];

/**
* The formats of a book.
*/
format: string[];

/**
* The names of some book genres.
*/
genre: string[];

/**
* The names of actual book series.
*/
series: string[];

/**
* The names of actual book titles.
*/
title: string[];

/**
* The names of actual book publishers.
*/
publisher: string[];
}>;
2 changes: 2 additions & 0 deletions src/definitions/definitions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { AirlineDefinition } from './airline';
import type { AnimalDefinition } from './animal';
import type { BookDefinition } from './book';
import type { ColorDefinition } from './color';
import type { CommerceDefinition } from './commerce';
import type { CompanyDefinition } from './company';
Expand Down Expand Up @@ -34,6 +35,7 @@ export type LocaleDefinition = {
metadata?: MetadataDefinition;
airline?: AirlineDefinition;
animal?: AnimalDefinition;
book?: BookDefinition;
color?: ColorDefinition;
commerce?: CommerceDefinition;
company?: CompanyDefinition;
Expand Down
1 change: 1 addition & 0 deletions src/definitions/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export type { AirlineDefinition } from './airline';
export type { AnimalDefinition } from './animal';
export type { BookDefinition } from './book';
export type { ColorDefinition } from './color';
export type {
CommerceDefinition,
Expand Down
2 changes: 2 additions & 0 deletions src/faker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { LocaleProxy } from './locale-proxy';
import { createLocaleProxy } from './locale-proxy';
import { AirlineModule } from './modules/airline';
import { AnimalModule } from './modules/animal';
import { BookModule } from './modules/book';
import { ColorModule } from './modules/color';
import { CommerceModule } from './modules/commerce';
import { CompanyModule } from './modules/company';
Expand Down Expand Up @@ -63,6 +64,7 @@ export class Faker extends SimpleFaker {

readonly airline: AirlineModule = new AirlineModule(this);
readonly animal: AnimalModule = new AnimalModule(this);
readonly book: BookModule = new BookModule(this);
readonly color: ColorModule = new ColorModule(this);
readonly commerce: CommerceModule = new CommerceModule(this);
readonly company: CompanyModule = new CompanyModule(this);
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export type {
AirlineDefinition,
AnimalDefinition,
BookDefinition,
ColorDefinition,
CommerceDefinition,
CommerceProductNameDefinition,
Expand Down Expand Up @@ -39,6 +40,7 @@ export * from './locales';
export { Aircraft } from './modules/airline';
export type { AircraftType, AirlineModule } from './modules/airline';
export type { AnimalModule } from './modules/animal';
export type { BookModule } from './modules/book';
export { CssFunction, CssSpace } from './modules/color';
export type {
Casing,
Expand Down
102 changes: 102 additions & 0 deletions src/locales/en/book/author.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
export default [
'Adams, Clifford R. (Clifford Rose)',
'Alcott, Louisa May',
'Austen, Jane',
'Balzac, Honoré de',
'Barrie, J. M. (James Matthew)',
'Baum, L. Frank (Lyman Frank)',
matthewmayer marked this conversation as resolved.
Show resolved Hide resolved
'Bhide, Shivaram Parashuram',
'Brock, C. E. (Charles Edmund)',
'Brontë, Charlotte',
'Buckley, Theodore Alois',
'Burnett, Frances Hodgson',
'Burroughs, Edgar Rice',
'Burton, Richard Francis, Sir',
'Butler, Samuel',
'Carroll, Lewis',
'Cervantes Saavedra, Miguel de',
'Chambers, Robert W. (Robert William)',
'Chekhov, Anton Pavlovich',
'Chesterton, G. K. (Gilbert Keith)',
'Christie, Agatha',
'Conrad, Joseph',
'Dante Alighieri',
'Defoe, Daniel',
'Derbyshire, Charles E.',
'Dickens, Charles',
'Doré, Gustave',
'Dostoyevsky, Fyodor',
'Doyle, Arthur Conan',
'Dumas, Alexandre',
'Eliot, George',
'Eliot, T. S. (Thomas Stearns)',
'Fielding, Henry',
'Fitzgerald, F. Scott (Francis Scott)',
'Forster, E. M. (Edward Morgan)',
'Garnett, Constance',
'Gaskell, Elizabeth Cleghorn',
'Gilman, Charlotte Perkins',
'Goethe, Johann Wolfgang von',
'Grimm, Jacob',
'Grimm, Wilhelm',
'Hapgood, Isabel Florence',
'Hardy, Thomas',
'Hawthorne, Nathaniel',
'Homer',
'Hotten, John Camden',
'Howard, Robert E. (Robert Ervin)',
'Hugo, Victor',
'Ibsen, Henrik',
'Indrajit, Bhagavanlal',
'James, Henry',
'Jowett, Benjamin',
'Joyce, James',
'Kafka, Franz',
'Kipling, Rudyard',
'Lang, Andrew',
'Levy, Oscar',
'London, Jack',
'Lovecraft, H. P. (Howard Phillips)',
'Machiavelli, Niccolò',
'Marriott, W. K. (William Kenaz)',
'Marx, Karl',
'Maude, Aylmer',
'Maude, Louise',
'Maupassant, Guy de',
'Melville, Herman',
'Merrill, Frank T.',
'Milne, A. A. (Alan Alexander)',
'Montgomery, L. M. (Lucy Maud)',
'Morley, Henry',
'Nietzsche, Friedrich Wilhelm',
'Ormsby, John',
'Packard, Vance',
'Plato',
'Poe, Edgar Allan',
'Pope, Alexander',
'Potter, Beatrix',
'Rizal, José',
'Russell, Bertrand',
'Schopenhauer, Arthur',
'Scott, Walter',
'Shakespeare, William',
'Shaw, Bernard',
'Shelley, Mary Wollstonecraft',
'Smollett, T. (Tobias)',
'Stevenson, Robert Louis',
'Stoker, Bram',
'Swift, Jonathan',
'Thoreau, Henry David',
'Tolstoy, Leo',
'Twain, Mark',
'Vatsyayana',
'Verne, Jules',
'Von Arnim, Elizabeth',
'Wagner, Richard',
'Ward, Grady',
'Wells, H. G. (Herbert George)',
'Widger, David',
'Wilde, Oscar',
'Wodehouse, P. G. (Pelham Grenville)',
'Wyllie, David',
];
1 change: 1 addition & 0 deletions src/locales/en/book/format.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default ['Audiobook', 'Ebook', 'Hardcover', 'Paperback'];
32 changes: 32 additions & 0 deletions src/locales/en/book/genre.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export default [
matthewmayer marked this conversation as resolved.
Show resolved Hide resolved
'Biography/Autobiography',
matthewmayer marked this conversation as resolved.
Show resolved Hide resolved
'Classic',
'Comic/Graphic Novel',
matthewmayer marked this conversation as resolved.
Show resolved Hide resolved
'Crime/Detective',
'Essay',
'Fable',
'Fairy tale',
'Fanfiction',
'Fantasy',
'Fiction in verse',
matthewmayer marked this conversation as resolved.
Show resolved Hide resolved
'Fiction narrative',
matthewmayer marked this conversation as resolved.
Show resolved Hide resolved
'Folklore',
'Historical fiction',
'Horror',
'Humor',
'Legend',
matthewmayer marked this conversation as resolved.
Show resolved Hide resolved
'Metafiction',
'Mystery',
'Mythology',
'Mythopoeia',
matthewmayer marked this conversation as resolved.
Show resolved Hide resolved
'Narrative nonfiction',
'Realistic fiction',
'Reference book',
'Science fiction',
'Short story',
'Speech',
matthewmayer marked this conversation as resolved.
Show resolved Hide resolved
'Suspense/Thriller',
'Tall tale',
matthewmayer marked this conversation as resolved.
Show resolved Hide resolved
'Textbook',
'Western',
];
22 changes: 22 additions & 0 deletions src/locales/en/book/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* This file is automatically generated.
* Run 'pnpm run generate:locales' to update.
*/
import type { BookDefinition } from '../../..';
import author from './author';
import format from './format';
import genre from './genre';
import publisher from './publisher';
import series from './series';
import title from './title';

const book: BookDefinition = {
author,
format,
genre,
publisher,
series,
title,
};

export default book;
Loading