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

[CLI] Generate model #1221

Closed
3 tasks done
dhmlau opened this issue Apr 3, 2018 · 6 comments
Closed
3 tasks done

[CLI] Generate model #1221

dhmlau opened this issue Apr 3, 2018 · 6 comments
Assignees

Comments

@dhmlau
Copy link
Member

dhmlau commented Apr 3, 2018

Description / Feature proposal

CLI command to generate model TS file.

Outstanding questions

  • Do we ask the user to select the base class? If yes, what are the selections? or it will always be Entity.
  • What are the property types we support? Here is what we have in LB3:
    string
    number
    boolean
    object
    array
    date
    buffer

Acceptance Criteria

  • Make a CLI prompt for model and its properties
    • For properties, ask for their name, their types and their default values
  • The produced model should extend from Entity

User Experience

$ lb4 model
? Enter the model name: Customer
Let's add some Customer properties now. 

Enter an empty property name when done.
? Property name: customerId
? Property type:  (show a list of available types) string
? Required? (y/N) y
? Default value[leave blank for none]:

Let's add another Customer property.
Enter an empty property name when done.
? Property name: name
? Property type:  (show a list of available types) string
? Required? (y/N) y
? Default value[leave blank for none]:

At the end, src/models/customer.model.ts will be created.

@bajtos
Copy link
Member

bajtos commented Apr 24, 2018

Do we ask the user to select the base class? If yes, what are the selections? or it will always be Entity.

For DP3, I think it's ok to always use Entity as the base class.

What are the property types we support? Here is what we have in LB3:
string
number
boolean
object
array
date
buffer

I think that list is a good start and enough for DP3. However, the arrays should be typed. When the user selects "array", we should ask them to provide the type of array items (e.g. "string" or "number" - basically anything from the list above with the exception of arrays).

@bajtos bajtos removed their assignment Apr 24, 2018
@dhmlau
Copy link
Member Author

dhmlau commented Apr 27, 2018

related to #441

@shimks
Copy link
Contributor

shimks commented May 17, 2018

Rejecting because we do not have information on how the models will interact with the potential artifacts being created (e.g. JSON representations)

@bajtos
Copy link
Member

bajtos commented May 18, 2018

Rejecting because we do not have information on how the models will interact with the potential artifacts being created (e.g. JSON representations)

In the current design (at least for DP3 scope), models are defined code-first by using TypeScript classes and annotations, see e.g. examples/todo/src/models/todo.model.ts.

As I understand the goal of this story, we need a CLI command that will create a .model.ts files and a .repository.ts file based on user input.

A story to tell: as a user creating examples/todo application, I don't want to manually create model & repository files because I don't remember what are the conventions. Instead, I'd like to run a command like lb4 model that will prompt for necessary data and create the files for me.

The repository requires a datasource to be attached to. The CLI should scan datasources folder (see examples/todo/src/datasources).

Remember, we are not trying to build the ideal solution that won't need any further changes. Instead, we want to simplify the process of building examples/todo app by providing CLI tooling that produces artifacts following the current app design.

If we decide to change the app design guidelines, e.g. by moving datasource config from TypeScript to JSON, then such task would require an update of lb4 model command. That's out of scope of the task of creating the initial version of lb4 model though!

@dhmlau
Copy link
Member Author

dhmlau commented May 24, 2018

@virkt25 , assigning this to you, because you're doing this as part of the spike #441 already. thanks.

@dhmlau
Copy link
Member Author

dhmlau commented May 24, 2018

@virkt25 , if it's good for estimate, please move to the needs estimate column. thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants