-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
This story is extracted from #4099, where we researched existing LoopBack 3 components and various techniques they use.
Now we need to write documentation for extension authors to show how to solve the following use cases in LoopBack 4:
-
Contribute custom entities (Application, Installation) to be persisted via CRUD, exposed via REST and possibly further customized by the app. Customization options include which datasource to use, the base path where REST API is exposed (e.g.
/api/appsand/api/devices), additional fields (e.g.Application.tenantId) and changes in persistence behavior (e.g. via Operation Hooks) -
Add a custom Operation Hook to given models, with a config option to enable/disable this feature. The list of models can be provided explicitly in the component configuration or obtained dynamically via introspection (e.g. all models having a "belongsTo" relation with the Group model). This may require How can extensions introspect application artifacts #5426 How can extensions introspect application artifacts.
-
Add new relations, e.g. between an app-provided entity
Userand a component-provided entityFile. In this variant, the relation is added on small fixed number of models. -
A model mixing adding new relations (
hasMany ModelEvents), installing Operation Hooks (to generate model events/audit log entries), adding new Repository APIs (for working with related model events).(The mixin-based design may be difficult to accomplish in LB4, we may want to use introspection and a model setting instead. The trickier part is how to apply changes to models added after the component was mounted.)
-
For all models with a flag enabled in model settings, setup a custom
afterRemotehook to modify the HTTP response (e.g. add additional headers).
In most cases, the new content will be useful to authors building new LB4 components too, therefore we should structure the content in two parts:
- A guide explaining how to build a component contributing a service, this should go to Extending LoopBack
- A guide explaining how to migrate LB3 components, this guide should go to Migrating components and extensions and focus on aspects unique to extensions migrating from LB3 and refer to content in Extending LoopBack wherever possible & appropriate.