fix(tracker): use d2-api typed tracker API for v42 org unit params#392
fix(tracker): use d2-api typed tracker API for v42 org unit params#392ifoche wants to merge 2 commits intodevelopmentfrom
Conversation
Replace raw api.get("/tracker/trackedEntities", ...) calls with d2-api's
typed api.tracker.trackedEntities.get() method, which handles v42 parameter
naming (orgUnitMode, orgUnits with commas) internally.
- Upgrade d2-api to version with v42 tracker support (PR #184)
- Update d2-api imports from 2.41 to 2.42
- Refactor getTeisFromApi, getExistingTeis, getAllTrackedEntities
- Remove custom TrackedEntityGetRequest, TrackedEntitiesD2ApiResponse
- Replace string field selectors with typed object selectors
- Rename buildOrgUnitMode → buildOrgUnitParams
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
xurxodev
left a comment
There was a problem hiding this comment.
Thanks @ifoche
This changes are not compatible with 2.40. I'm not sure if this important or not
| Endpoint | Parameter | v2.40 | v2.41 | v2.42+ |
|---|---|---|---|---|
/tracker/trackedEntities |
org unit(s) | orgUnit (; separated) |
orgUnit (;) orgUnits (,) ✅ |
orgUnits (,) |
/tracker/trackedEntities |
org unit mode | ouMode |
ouMode orgUnitMode ✅ |
orgUnitMode |
/tracker/enrollments |
org unit(s) | orgUnit (; separated) |
orgUnit (;) orgUnits (,) ✅ |
orgUnits (,) |
/tracker/enrollments |
org unit mode | ouMode |
ouMode orgUnitMode ✅ |
orgUnitMode |
/tracker/events |
org unit mode | ouMode |
ouMode orgUnitMode ✅ |
orgUnitMode |
/tracker/ownership/transfer |
org unit | ou |
ou |
ou orgUnit ✅ |
Legend:
But the bigger blocker right now is that we can’t even run/verify it.
In local (and in GitHub Actions) the tests/compile fail with:
- Cannot find module '@eyeseetea/d2-api/2.42' from 'src/types/d2-api.ts'
So Jest can’t resolve the @eyeseetea/d2-api/2.42 entrypoint, which indicates that adding @eyeseetea/d2-api from a GitHub branch isn’t providing the expected published module paths (/2.42, and likely also /schemas) in the way our app imports it.
Therefore we can’t confirm the v41/v42 runtime behavior.
Normally we develop against a published beta of d2-api from npm because adding dependencies directly from a GitHub branch has caused issues in the past.
Arnau told me that this is the recommended approach now.
I think is necessary:
- publish a
d2-apibeta (including the v42 tracker OU params support), and - update this PR to depend on that beta version from npm (so local + GitHub Actions can compile/test)
Summary
api.get("/tracker/trackedEntities", ...)calls with d2-api's typedapi.tracker.trackedEntities.get()method, which handles v42 parameter naming (orgUnitMode,orgUnitswith commas) internallyTrackedEntityGetRequest,TrackedEntitiesD2ApiResponse, and backward-compat response typesContext
This is an alternative approach to PRs #386 and #387 for fixing the v42 tracker org unit parameter issue. Instead of fixing the parameter names locally in Bulk Load, this leverages d2-api's typed tracker API which handles the v42 naming internally.
Comparison with other PRs
Dependencies
Test plan
🤖 Generated with Claude Code