-
Notifications
You must be signed in to change notification settings - Fork 16
feat: move data engine to a standalone package without react dependency [LIBS-711] #1392
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
base: master
Are you sure you want to change the base?
Conversation
|
Leaving this as draft for an initial review, still need to write documentation for how to use this in non-React and React server component contexts |
|
Most of these SonarCloud code smells are probably legit but from older code... we should probably still address them here. |
|
An alternative option here might be to export the engine as a separate library entrypoint to |
|
| const mockSpy = jest.fn(() => 42) | ||
| const mockSpy = jest.fn(() => Promise.resolve(42)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just flagging here
|
KaiVandivier
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remaining: tests and docs
Otherwise awesome!!! 🙌



Implements LIBS-711
Key features
Externalizes the data engine as a new standalone package (
@dhis2/data-engine, we could consider a different name) so that it can be used in non-React contexts. This new package has zero external dependencies and should encapsulate all most DHIS2-specific business logic/authentication/etc.Additionally, add support for a
fetch-like interface to DataEngine - i.e.engine.fetch('/me', { method: 'PATCH', body: { 'employer': 'DHIS2' }}). Add syntax sugar methods for each method as well, i.e.engine.get('me')This is a non-breaking change for consumers of
app-runtimeorapp-service-dataFinally, a new
DataEnginewith config-initializedRestApiLinkis bound towindow.enginein the QueryPlayground example, which allows testing and experimenting with the engine in the browser console. See below:Checklist