The PR superseeds the existing deepMerge algorithm used to merge
settings of parent and child models with a new algorithm that allows
to specify the way each setting is merged or mixed-in.
This configuration of this algorithm uses a merge policy specification.
The `getMergePolicy()` helper of BaseModelClass can be used to ease
model merge configuration.
Next is presented the expected merge behaviour for each option.
NOTE: This applies to top-level settings properties
- Any
- `{replace: true}` (default): child replaces the value from parent
- assignin `null` on child setting deletes the inherited setting
- Arrays
- `{replace: false}`: unique elements of parent and child cumulate
- `{rank: true}` adds the model inheritance rank to array
elements of type Object {} as internal property `__rank`
- Object {}:
- `{replace: false}`: deep merges parent and child objects
- `{patch: true}`: child replaces inner properties from parent
The recommended merge policy is returned by getMergePolicy()
when calling the method with option `{configureModelMerge: true}`.
The legacy built-in merge policy is returned by `getMergePolicy()`
when avoiding option `configureModelMerge`.
NOTE: it also delivers ACLs ranking in addition to the legacy
behaviour as well as fixes for settings `description` and `relations`
`getMergePolicy()` can be customized using model's setting
`configureModelMerge` as follows:
```
{
// ..
options: {
configureModelMerge: {
// merge options
}
}
// ..
}
```
`getMergePolicy()` method can also be extended programmatically as
follows:
```
myModel.getMergePolicy = function(options) {
const origin = myModel.base.getMergePolicy(options);
return Object.assign({}, origin, {
// new/overriding options
});
};
```
Fix the bug in `ModelClass.extend` where the `base` option used
in the new class was inherited from ModelClass. As a result
the extended model was incorrectly based on ModelClass's parent.
Modify `modelBuilder.define` to normalize the property name storing
the name of the base model to `settings.base`.
- Add a ModelDefinition class to encapsulate the model schema handling
- Add a Connector class as the base class for connector implementations
- Optimize attachTo and mixin
- Rename some properties/methods