-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Staging goals:
- Be able to load LB 3.x artifacts including models/datasources
- Support LB next artifacts, such as model/datasource/repository/api-spec/...
Story
As a LoopBack developer, I'd like to declare my artifacts as JSON or YAML files so that I can continue enjoying the declarative experience.
Acceptance Criteria
- On application boot:
- Read each of the directories in
srcfor their corresponding artifacts (models, datasources, controllers, etc) - For each artifact:
- Parse the artifact as an object
- Semantically validate that the object meets the requirements of the artifact type it specifies
- Wire up the artifact to the application context using the appropriate artifact prefix
- Read each of the directories in
Example
Given a src directory:
src/
datasources/
foo.datasource.json
we'll want to parse the datasource artifact, which contains:
{
"host": "127.0.0.1",
"port": 3001,
// etc
}Once we've loaded the file, we'll want to ensure that it has all of the properties required for it to be a datasource (in this case, a "host" property might be required), and then bind it to the context.
const datasource = validateDatasource(dsObj);
app.bind(`datasources.${name}`).to(datasource);Rules
- If more than one artifact exists with a different extension (foo.model.json and foo.model.yaml)
- prefer JSON over YAML
- if there is a TS file and JSON/YAML, merge the JSON/YAML definition into the parsed TS class
foo.model.json
Questions to Answer
- How will we merge programmatic models (TypeScript classes) with declarative forms?
- What artifacts will we support for declarative use?
- models
- datasources
- ACL
- middleware
- remoting
- boot scripts
- repositories
- If we're supporting them in declarative form, what is the schema for that?
- What will the schema be for each of these artifacts?