faker-js / faker

Generate massive amounts of fake data in the browser and node.js
https://fakerjs.dev
Other
12.46k stars 897 forks source link

Random bundle id #1154

Open import-brain opened 2 years ago

import-brain commented 2 years ago

Clear and concise description of the problem

I wish there was a function where I could generate a random three-part app bundle id. I think this would fit well with the other functions in the system module, especially fileName(), because bundle IDs are used to identify applications, similarly to how file names identify files.

Suggested solution

In faker.system, the function should output values similar to the ones below:

Using the generally recommended "reverse domain name notation", where "com" is appended to the beginning of all bundle IDs

faker.system.bundleID() // com.apple.cocoa faker.system.bundleID() // com.mocha.flex

This function could be implemented by returning a string: "com." + faker.random.word().toLowerCase() + "." + faker.random.word().toLowerCase().

Alternative

No response

Additional context

I would be willing to submit a PR for this.

ST-DDT commented 2 years ago

Not sure about the name: maybe reverse domain name? Also this should not use random.word instead t should use internet.domainWord()

import-brain commented 2 years ago

Not sure about the name: maybe reverse domain name? Also this should not use random.word instead t should use internet.domainWord()

They are usually just called bundle IDs, lingo-wise. I've never heard of it referred to as a "reverse domain name", but "reverse domain name notation" is the way Apple recommends these bundle IDs be written.

Yeah, internet.domainWord() would be a better fit instead of random.word().

xDivisionByZerox commented 2 years ago

I have no problem with the name (maybe casing ID vs Id). But I'm not sure about the module. I didn't understood how this relates to any file system stuff. Wouldn't the Internet , Company (you know, because companies release most apps) or even Hacker module be more suited for a function like this? :/

import-brain commented 2 years ago

I have no problem with the name (maybe casing ID vs Id). But I'm not sure about the module. I didn't understood how this relates to any file system stuff. Wouldn't the Internet , Company (you know, because companies release most apps) or even Hacker module be more suited for a function like this? :/

A bundle ID is used as an app identifier in Apple systems, so I thought System would be a good fit. Definitely would be open to any of the modules you listed, though.

ST-DDT commented 2 years ago

For a start, we should add options to internetDomainName. Namely domainWords: number and reverse: boolean Then the bundleId would just be some kind of alias. From what I can tell the bundlenid is apple specific, so I would explicitly call it appleBundleId(). It looks pretty similar to other ids though e.g. maven package ids, java package names and probably a lot more. IMO, if we add these we should add them to the hacker module.

However before we add these "aliases", what is the expected usecase in a JS framework for the apple app bundle id?

import-brain commented 2 years ago

For a start, we should add options to internetDomainName. Namely domainWords: number and reverse: boolean Then the bundleId would just be some kind of alias. From what I can tell the bundlenid is apple specific, so I would explicitly call it appleBundleId(). It looks pretty similar to other ids though e.g. maven package ids, java package names and probably a lot more. IMO, if we add these we should add them to the hacker module.

However before we add these "aliases", what is the expected usecase in a JS framework for the apple app bundle id?

My bad if I'm missing something here, but why would domainWords be a number? Also, I think a reverse param for internet.domainName() would be pretty much completely unused, except for our bundle ID function.

A possible usecase would be generating random iOS bundle IDs for React Native.

ST-DDT commented 2 years ago

My bad if I'm missing something here, but why would domainWords be a number?

Maybe domainWordCount?

Also, I think a reverse param for internet.domainName() would be pretty much completely unused, except for our bundle ID function.

And everything else that uses the reverse domain name notation.

A possible usecase would be generating random iOS bundle IDs for React Native.

Is that your usecase? Otherwise, I think that you dont generate these ids unless you are trying to build an app store. (The own app bundle id is usually hardcoded) Or I missing something here?

import-brain commented 2 years ago

My bad if I'm missing something here, but why would domainWords be a number?

Maybe domainWordCount?

Also, I think a reverse param for internet.domainName() would be pretty much completely unused, except for our bundle ID function.

And everything else that uses the reverse domain name notation.

A possible usecase would be generating random iOS bundle IDs for React Native.

Is that your usecase? Otherwise, I think that you dont generate these ids unless you are trying to build an app store. (The own app bundle id is usually hardcoded) Or I missing something here?

On second thought, yeah, apple/android bundle ID and java package name generation functions can use the reverse param, my bad for saying it would be unused.

I want to make a website that displays app data from app stores. The website would require card components, which (hopefully) display the app's name, bundle ID, and average review rating. I want to render those cards in unit testing with faker-generated random bundle IDs to check that the cards are displaying data correctly.

Shinigami92 commented 2 years ago

@import-brain Are your target audience normal users or technical developers? If first => you should try to not confuse your customers with such technical bundle ids.

If you don't show the bundle id but only use it as a selector, then you may just use e.g. uuid or something unique 🤷 The bundle id could not be related to any other generated further data of your dataset you want to show in the card's content. Remember we are a fake generator lib not a real database 😉

import-brain commented 2 years ago

@import-brain Are your target audience normal users or technical developers? If first => you should try to not confuse your customers with such technical bundle ids.

If you don't show the bundle id but only use it as a selector, then you may just use e.g. uuid or something unique 🤷 The bundle id could not be related to any other generated further data of your dataset you want to show in the card's content. Remember we are a fake generator lib not a real database 😉

My audience is normal users, but I was hoping to include a very small section on the card displaying the bundle ID on the off chance a dev was looking through the cards and needed it.

You're right though, this function wouldn't have a wide use case and there are alternative unique things I could use.

ST-DDT commented 2 years ago

IMO since you have a need for it and it doesnt have much of an impact, we can add it. I think the hacker(developer) module would fit best. faker.hacker.appleBundleId However, we should consider marking them as alias using jsdocs tags. That way we give our users more ways to customize their output bejond the parameters of the alias. I could add support for it in our api docs.

import-brain commented 2 years ago

IMO since you have a need for it and it doesnt have much of an impact, we can add it. I think the hacker(developer) module would fit best. faker.hacker.appleBundleId However, we should consider marking them as alias using jsdocs tags. That way we give our users more ways to customize their output bejond the parameters of the alias. I could add support for it in our api docs.

Thank you for adding this.

Are you sure we should mark them using jsdoc alias tags? Would it be a lot of work to add support for them in our api docs? Wouldn't want to inconvenience you too much :)

ST-DDT commented 2 years ago

Are you sure we should mark them using jsdoc alias tags?

I think this increases awareness of the other methods. So if you spot appleBundleId and think, I want android stuff, then will see the references and have a clue how to implement your own variant. Thats at least my hope. What do you think?

Would it be a lot of work to add support for them in our api docs?

Currently new/unknown tags will be ignored, so there is no immideate action required. Also it should be fairly easy to integrate this, we can probalby reuse some of the @see logic.

import-brain commented 2 years ago

Are you sure we should mark them using jsdoc alias tags?

I think this increases awareness of the other methods. So if you spot appleBundleId and think, I want android stuff, then will see the references and have a clue how to implement your own variant. Thats at least my hope. What do you think?

Would it be a lot of work to add support for them in our api docs?

Currently new/unknown tags will be ignored, so there is no immideate action required. Also it should be fairly easy to integrate this, we can probalby reuse some of the @see logic.

Ah, the reason I questioned marking them with alias tags was that I was worried it would take a lot of time to implement them on the docs page.

You're right, it would definitely increase awareness and help users understand how methods are connected together. Great idea!

github-actions[bot] commented 1 year ago

Thank you for your feature proposal.

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