feat: move data engine to a standalone package without react dependency [LIBS-711]#1392
feat: move data engine to a standalone package without react dependency [LIBS-711]#1392
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)) |
|
KaiVandivier
left a comment
There was a problem hiding this comment.
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