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 13 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
127 changes: 127 additions & 0 deletions src/locales/en/book/author.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
export default [
'A. A. Milne',
'Agatha Christie',
'Alexander Pope',
'Alexandre Dumas',
'Alice Walker',
'Andrew Lang',
'Anton Pavlovich Chekhov',
'Arthur Conan Doyle',
'Arthur Schopenhauer',
'Aylmer Maude',
'Beatrix Potter',
'Benjamin Jowett',
'Bernard Shaw',
'Bertrand Russell',
'Bhagavanlal Indrajit',
'Bram Stoker',
'Brian Evenson',
'C. E. Brock',
'Charles Dickens',
'Charles E. Derbyshire',
'Charlotte Brontë',
'Charlotte Perkins Gilman',
'Clifford R. Adams',
'Constance Garnett',
'Dan Brown',
'Daniel Defoe',
'Dante Alighieri',
'David Widger',
'David Wyllie',
'Dean Koontz',
'E. M. Forster',
'Edgar Allan Poe',
'Edgar Rice Burroughs',
'Elizabeth Cleghorn Gaskell',
'Elizabeth Von Arnim',
'F. Scott Fitzgerald',
'Frances Hodgson Burnett',
'Frank T. Merrill',
'Franz Kafka',
'Friedrich Wilhelm Nietzsche',
'Fyodor Dostoyevsky',
'G. K. Chesterton',
'George Eliot',
'George R. R. Martin',
'George Saunders',
'Grady Ward',
'Gustave Doré',
'Guy de Maupassant',
'H. G. Wells',
'H. P. Lovecraft',
'Haruki Murakami',
'Henrik Ibsen',
'Henry David Thoreau',
'Henry Fielding',
'Henry James',
'Henry Morley',
'Herman Melville',
'Homer',
'Honoré de Balzac',
'Ian McEwan',
'Isabel Florence Hapgood',
'J. K. Rowling',
'J. M. Barrie',
'Jack London',
'Jacob Grimm',
'Jacqueline Crooks',
'James Joyce',
'James Patterson',
'Jane Austen',
'Johann Wolfgang von Goethe',
'John Camden Hotten',
'John Green',
'John Grisham',
'John Ormsby',
'Jonathan Franzen',
'Jonathan Swift',
'Joseph Conrad',
'José Rizal',
'Jules Verne',
'Karl Marx',
'Kazuo Ishiguro',
'Khaled Hosseini',
'L. Frank Baum',
'L. M. Montgomery',
'Leo Tolstoy',
'Lewis Carroll',
'Louisa May Alcott',
'Louise Maude',
'Margaret Atwood',
'Mark Twain',
'Mary Wollstonecraft Shelley',
'Michael Chabon',
'Miguel de Cervantes Saavedra',
'Nathaniel Hawthorne',
'Neil Gaiman',
'Niccolò Machiavelli',
'Oscar Levy',
'Oscar Wilde',
'P. G. Wodehouse',
'Plato',
'R. L. Stine',
'Rachel Kushner',
'Richard Wagner',
'Robert E. Howard',
'Robert Louis Stevenson',
'Robert W. Chambers',
'Rudyard Kipling',
'Samuel Butler',
'Shivaram Parashuram Bhide',
'Sir Richard Francis Burton',
'Stephen King',
'Suzanne Collins',
'T. S. Eliot',
'T. Smollett',
'Theodore Alois Buckley',
'Thomas Hardy',
'Toni Morrison',
'Vance Packard',
'Vatsyayana',
'Victor Hugo',
'W. K. Marriott',
'Walter Scott',
'Wilhelm Grimm',
'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