data-point
data-point copied to clipboard
Deprecate entities, features and methods
Problem description:
Many of the entities, methods and features DataPoint has have become irrelevant or lead to bad practices.
Suggested solution:
Deprecate the following set of entities, methods, and features:
Entities:
- Entry - reality is that its just a Model, lets drop it to remove confusion
- Hash - Model and the reducer helpers are more than enough to cover all cases
- Collection - Model and the reducer helpers are more than enough to cover all cases
- Schema (dunno should we?) - A simple reducer function would do it (no need for a full blown entity) and would also remove a big dependency of the json schema lib. It would also let people choose their own flavour of validating schema. Providing documentation on how to do validation should sufice.
Methods
- omit - its only used by Hash (which should be removed), and when used on its own it would be better to use lodash or ramda, less code to maintain.
- dp.addValue - values are not being used, acc.locals proves to be more than enough, or maybe not?
- dp.addEntities - remove the ability to add them later to force people to use entity instances, and remove one more way of doing things.
Features:
- ComposeReducer - this is only used by entities that should be deprecated
- Extend Entity - this was just a plain bad bad idea
- DataPoint.values - do we need values? I think we should remove this 'other way' of accessing values.
@raingerber what do you think?
I think we should go even further. DataPoint "core" should largely just be the code for executing and debugging transformations. I think we should remove entities completely and just use reducers, but with the ability to create custom reducer types (https://github.com/ViacomInc/data-point/issues/249). Named entities were never a good idea, because they encourage users to write code that's hard to debug and reason about. The Model, Request, and Control entities are unique enough to make them useful, but we could implement them as reducers. As a middleground, we could also move the entity code to a separate opt-in package that extends the core engine.
I'm also fine with removing DataPoint.values, as well as most of the reducer helpers. The assign, map, filter, and find helpers only exist to support the Hash and Collection entities, which we agree should be removed. It's much more efficient to just use the native Array methods, because those transformations are usually synchronous, but DataPoint implements them using Promise.all.