faker icon indicating copy to clipboard operation
faker copied to clipboard

Add books module

Open ghost opened this issue 2 years ago • 26 comments
trafficstars

Clear and concise description of the problem

Add a faker.books module which allows for generating random titles, genres and publishers for books.

Suggested solution

We could add a faker.books module similar to the one provided by faker-ruby. The module could export the following methods:

  • title: returns a random book title
  • publisher: returns a random publisher
  • genre: returns a random genre
  • author: returns a random author

Alternative

I am not sure if author would be necessary since we already have faker.person.fullName.

Additional context

If the feature is accepted, I would like to work on it.

ghost avatar Aug 13 '23 07:08 ghost

Thank you for your feature proposal.

We marked it as "waiting for user interest" for now to gather some feedback from our community:

  • If you would like to see this feature be implemented, please react to the description with an up-vote (:+1:).
  • If you have a suggestion or want to point out some special cases that need to be considered, please leave a comment, so we are aware about them.

We would also like to hear about other community members' use cases for the feature to give us a better understanding of their potential implicit or explicit requirements.

We will start the implementation based on:

  • the number of votes (:+1:) and comments
  • the relevance for the ecosystem
  • availability of alternatives and workarounds
  • and the complexity of the requested feature

We do this because:

  • There are plenty of languages/countries out there and we would like to ensure that every method can cover all or almost all of them.
  • Every feature we add to faker has "costs" associated to it:
    • initial costs: design, implementation, reviews, documentation
    • running costs: awareness of the feature itself, more complex module structure, increased bundle size, more work during refactors

View more issues which are waiting for user interest

github-actions[bot] avatar Aug 13 '23 07:08 github-actions[bot]

What about ISBN which is currently located in the CommerceModule.

https://github.com/faker-js/faker/blob/24415ee993a9c6e3c8f0dffa544f492dcb29463c/src/modules/commerce/index.ts#L335-L353

Would that get relocated here as well?

xDivisionByZerox avatar Sep 24 '23 22:09 xDivisionByZerox

What is the status of this request? I could use something like this now

isaacfink avatar Jan 04 '24 13:01 isaacfink

What is the status of this request? I could use something like this now

This is currently waiting for user intrest so unfortunately this wont make it into the code in the next few months. Please upvote the issue to make it easier for us to measure the community's intrest in it.

Could you please also detail which properties you need for the books?

ST-DDT avatar Jan 04 '24 14:01 ST-DDT

It's waiting for 10 upvotes

Where faker doesn't provide the exact data you need you can generally get a good result by just using faker.helpers.arrayElement with an array of static data. Faker-Ruby has a book module so you could grab the data from there https://github.com/faker-ruby/faker/blob/main/lib/locales/en/book.yml

matthewmayer avatar Jan 04 '24 14:01 matthewmayer

Team Decision

This issue has gathered enough user interest to be considered for inclusion. Currently, v9.0 is already big enough so we would like to delay this until v9.1+.

ST-DDT avatar May 01 '24 14:05 ST-DDT

@inkedtree are you still interested in working on this? I would like to work on this as well :)

cieslarmichal avatar May 03 '24 12:05 cieslarmichal

Hi @cieslarmichal, We appreciate your willingness to contribute to this issue. Please keep in mind that we are currently doing major restructures in our codebase. This may result in numerous merge conflicts with any work you undertake. Consequently, we've scheduled this issue for v9.x (subsequent to 9.0). If you remain interested despite these considerations, I would be more than happy to assign this issue to you.

xDivisionByZerox avatar May 03 '24 12:05 xDivisionByZerox

Ok thanks, I will wait then, I would appreciate if you ping me when I can start working on this :)

cieslarmichal avatar May 03 '24 12:05 cieslarmichal

While the implementation cannot start right now, you could already make suggestions on how you want each method to behave and which methods to have exactly.

Like will book.title return a random elememt from a fixed list such as Harry Potter or will it use patterns like The {{word.noun}} of the {{animal.type}} or The adventures of {{person.firstName}} {{person.lastName}}

ST-DDT avatar May 03 '24 15:05 ST-DDT

I am actually developing book application so I know which methods could be useful, I would add methods as follows (open for more suggestions):

  • title (fixed list)
  • isbn (fixed list or generating valid isbns)
  • author (fixed list)
  • genre (fixed list)
  • publisher (fixed list)
  • translator (alias for person fullName)
  • format (paperback, hardcover or ebook)
  • pages (integer in range 50 - 1500)
  • releaseYear (integer in range 1940 - 2024)
  • series (fixed list like Harry Potter series)

cieslarmichal avatar May 04 '24 17:05 cieslarmichal

Generally sounds good to me!

Note isbn already appears in the faker.commerce module. We could probably make that a deprecated alias and move the implementation here

Id probably remove translator if it's just a random person name, doesn't add much (and if translator, why not illustrator, reviewer, etc)

Also not sure releaseYear is needed, too similar to faker.date.past() - which already has the ability to have a full release date, and to have the years be relative to current date.

Any methods we choose not to add to books for the MVP because there are too similar methods in other modules could still be referenced via see also and the module introduction. Eg if "author()" only has real authors we can cross reference faker.person.fullName() for people who want fake authors.

matthewmayer avatar May 05 '24 12:05 matthewmayer

Sounds good :) can't wait to start working on this!

cieslarmichal avatar May 05 '24 13:05 cieslarmichal

Is this comming any time soon? :)

sinanaltaii avatar Jun 01 '24 13:06 sinanaltaii

I am ready to implement that, but we are waiting for version v9 to be done (major refactor)

cieslarmichal avatar Jun 01 '24 13:06 cieslarmichal

@xDivisionByZerox do you have any planned date for v9 release?

cieslarmichal avatar Jun 03 '24 15:06 cieslarmichal

@xDivisionByZerox do you have any planned date for v9 release?

Sorry for the late reply. We sadly dont have a fixed release date planed. We will put some more focus on this topic on thursdays, tho. I understand that this might not be what you was hoping for. All I can do is thank you for your patience.

xDivisionByZerox avatar Jun 04 '24 19:06 xDivisionByZerox

Ok I will wait.

cieslarmichal avatar Jun 04 '24 20:06 cieslarmichal

@cieslarmichal In today's meeting we made a new announcement regarding v9 progress. This means that you can technically start with the implementation of the book module if you wish to do so. Please keep in mind that the module itself will not be included in the v9 release, but can be the first thing for v9.1.

xDivisionByZerox avatar Jun 13 '24 16:06 xDivisionByZerox

Hello, nice! One question: should I create my branch from default branch (next) and then make a pull request to it? Asking that because I can see there is a v9 branch and I am not sure about that situation with release.

I will start working on it this week :smile:

cieslarmichal avatar Jun 13 '24 20:06 cieslarmichal

'next' is perfectly fine. The v9 branch is the latest v9 release. In this case v9.0.0-alpha.1.

xDivisionByZerox avatar Jun 13 '24 21:06 xDivisionByZerox

Ok thanks :)

cieslarmichal avatar Jun 13 '24 21:06 cieslarmichal

I am starting to work on it, planning to add following methods to MVP:

  • title
  • author
  • genre
  • publisher
  • format
  • series

I will also add a note that isbn can be generated with commerce module.

cieslarmichal avatar Jun 14 '24 22:06 cieslarmichal

created a PR with changes https://github.com/faker-js/faker/pull/2949

cieslarmichal avatar Jun 15 '24 16:06 cieslarmichal

Just commenting here to get some more visibility

Should author() return

Shakespeare, William

Or

William Shakespeare

matthewmayer avatar Jun 16 '24 08:06 matthewmayer

I will probably go with William Shakespeare as it is more readable and natural in my opinion.

cieslarmichal avatar Jun 16 '24 09:06 cieslarmichal