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

Merged
merged 21 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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 './internal/locale-proxy';
import { createLocaleProxy } from './internal/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 @@ -36,6 +37,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
229 changes: 229 additions & 0 deletions src/locales/en/book/author.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
export default [
'A.A. Milne',
'Agatha Christie',
'Alan Moore and Dave Gibbons',
'Albert Camus',
'Aldous Huxley',
'Alexander Pope',
'Alexandre Dumas',
'Alice Walker',
'Andrew Lang',
'Anne Frank',
'Anthony Burgess',
'Anthony Trollope',
'Antoine de Saint-Exupéry',
'Anton Chekhov',
'Anton Pavlovich Chekhov',
'Arthur Conan Doyle',
'Arthur Schopenhauer',
'Aylmer Maude',
'Ayn Rand',
'Beatrix Potter',
'Benjamin Disraeli',
'Benjamin Jowett',
'Bernard Shaw',
'Bertrand Russell',
'Bhagavanlal Indrajit',
'Boris Pasternak',
'Bram Stoker',
'Brian Evenson',
'C.E. Brock',
'C.S. Lewis',
'Carson McCallers',
'Charles Dickens',
'Charles E. Derbyshire',
'Charlotte Brontë',
'Charlotte Perkins Gilman',
'Chinua Achebe',
'Clifford R. Adams',
'Constance Garnett',
'Cormac McCarthy',
'D.H. Lawrence',
'Dan Brown',
'Daniel Defoe',
'Dante Alighieri',
'Dashiell Hammett',
'David Widger',
'David Wyllie',
'Dean Koontz',
'Don DeLillo',
'E.M. Forster',
'Edgar Allan Poe',
'Edgar Rice Burroughs',
'Elizabeth Cleghorn Gaskell',
'Elizabeth Von Arnim',
'Emily Brontë',
'Erich Remarque',
'Ernest Hemingway',
'Evelyn Waugh',
'F. Scott Fitzgerald',
'Ford Madox Ford',
'Frances Hodgson Burnett',
'Frank Herbert',
'Frank T. Merrill',
'Franz Kafka',
'Friedrich Wilhelm Nietzsche',
'Fyodor Dostoyevsky',
'G.K. Chesterton',
'Gabriel Garcia Marquez',
'Geoffrey Chaucer',
'George Eliot',
'George Grossmith',
'George Orwell',
'George R. R. Martin',
'George Saunders',
'Grady Ward',
'Graham Greene',
'Gustave Doré',
'Gustave Flaubert',
'Guy de Maupassant',
'Günter Grass',
'H.G. Wells',
'H.P. Lovecraft',
'Harper Lee',
'Harriet Beecher Stowe',
'Haruki Murakami',
'Henrik Ibsen',
'Henry David Thoreau',
'Henry Fielding',
'Henry James',
'Henry Miller',
'Henry Morley',
'Herman Melville',
'Hermann Broch',
'Homer',
'Honoré de Balzac',
'Ian McEwan',
'Isabel Florence Hapgood',
'Italo Calvino',
'J.D. Salinger',
'J.K. Rowling',
'J.M. Barrie',
'J.R.R. Tolkien',
'Jack Kerouac',
'Jack London',
'Jacob Grimm',
'Jacqueline Crooks',
'James Baldwin',
'James Dickey',
'James Ellroy',
'James Joyce',
'James Patterson',
'Jane Austen',
'Johann Wolfgang von Goethe',
'John Bunyan',
'John Camden Hotten',
'John Dos Passos',
'John Green',
'John Grisham',
'John Kennedy Toole',
'John Milton',
'John Ormsby',
'John Steinbeck',
'John Updike',
'Jonathan Franzen',
'Jonathan Swift',
'Joseph Conrad',
'Joseph Heller',
'José Rizal',
'Judy Blume',
'Jules Verne',
'Junot Diaz',
'Karl Marx',
'Kazuo Ishiguro',
'Ken Follett',
'Ken Kesey',
'Kenneth Grahame',
'Khaled Hosseini',
'Kingsley Amis',
'Kurt Vonnegut',
'L. Frank Baum',
'L.M. Montgomery',
'Laurence Sterne',
'Leo Tolstoy',
'Lewis Carroll',
'Louisa May Alcott',
'Louise Maude',
'Malcolm Lowry',
'Marcel Proust',
'Margaret Atwood',
'Margaret Mitchell',
'Marilynne Robinson',
'Mark Twain',
'Martin Amis',
'Mary Shelley',
'Michael Chabon',
'Miguel de Cervantes',
'Mikhail Bulgakov',
'Muriel Spark',
'Nancy Mitford',
'Nathanael West',
'Nathaniel Hawthorne',
'Neil Gaiman',
'Niccolo Machiavelli',
'Norman Mailer',
'Oscar Levy',
'Oscar Wilde',
'P.G. Wodehouse',
'Paulo Coelho',
'Peter Carey',
'Philip Pullman',
'Philip Roth',
'Plato',
'R.L. Stine',
'Rachel Kushner',
'Ralph Ellison',
'Ray Bradbury',
'Raymond Chandler',
'Richard Wagner',
'Richard Wright',
'Richard Yates',
'Roald Dahl',
'Robert Graves',
'Robert Louis Stevenson',
'Robert Penn Warren',
'Rudyard Kipling',
'Salman Rushdie',
'Samuel Beckett',
'Samuel Butler',
'Samuel Richardson',
'Saul Bellow',
'Shivaram Parashuram Bhide',
'Sir Arthur Conan Doyle',
'Sir Richard Francis Burton',
'Stendhal',
'Stephen Hawking',
'Stephen King',
'Sun Tzu',
'Suzanne Collins',
'T. Smollett',
'T.S. Eliot',
'Theodore Alois Buckley',
'Theodore Dreiser',
'Thomas Hardy',
'Thomas Love Peacock',
'Thomas Mann',
'Toni Morrison',
'Truman Capote',
'V.S. Naipaul',
'Vance Packard',
'Vatsyayana',
'Victor Hugo',
'Virgil',
'Virginia Woolf',
'Vladimir Nabokov',
'Voltaire',
'W.G. Sebald',
'W.K. Marriott',
'Walker Percy',
'Walt Whitman',
'Walter Scott',
'Wilhelm Grimm',
'Wilkie Collins',
'William Faulkner',
'William Gibson',
'William Golding',
'William Makepeace Thackeray',
'William Shakespeare',
'Zadie Smith',
];
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'];
27 changes: 27 additions & 0 deletions src/locales/en/book/genre.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export default [
matthewmayer marked this conversation as resolved.
Show resolved Hide resolved
'Adventure',
'Biography',
'Business',
"Children's Literature",
'Classic',
'Comedy',
'Comic',
'Detective',
'Drama',
'Fantasy',
'Graphic Novel',
'Historical Fiction',
'Horror',
'Memoir',
'Mystery',
'Mythology',
'Philosophy',
'Poetry',
'Psychology',
'Religion',
'Romance',
'Science Fiction',
'Thriller',
'Western',
'Young Adult',
];
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