Skip to content

Conversation

@amcgee
Copy link
Member

@amcgee amcgee commented Nov 25, 2024

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-runtime or app-service-data

Finally, a new DataEngine with config-initialized RestApiLink is bound to window.engine in the QueryPlayground example, which allows testing and experimenting with the engine in the browser console. See below:

Screenshot 2025-10-30 at 13 25 51

Checklist

  • Have written Documentation
  • Has tests coverage

@amcgee
Copy link
Member Author

amcgee commented Nov 25, 2024

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

@amcgee
Copy link
Member Author

amcgee commented Nov 25, 2024

Most of these SonarCloud code smells are probably legit but from older code... we should probably still address them here.

@amcgee
Copy link
Member Author

amcgee commented Nov 25, 2024

An alternative option here might be to export the engine as a separate library entrypoint to app-service-data...

@amcgee amcgee deleted the branch master November 26, 2024 16:41
@amcgee amcgee closed this Nov 26, 2024
@amcgee amcgee reopened this Nov 27, 2024
@sonarqubecloud
Copy link

Base automatically changed from alpha to master December 4, 2024 13:37
Comment on lines -248 to +249
const mockSpy = jest.fn(() => 42)
const mockSpy = jest.fn(() => Promise.resolve(42))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just flagging here

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 4, 2025

Copy link
Contributor

@KaiVandivier KaiVandivier left a 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!!! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants