Skip to content

[refactor] Clean Arch + Typescript#349

Merged
adrianq merged 37 commits intodevelopmentfrom
refactor/clean-arch-and-ts
Apr 21, 2026
Merged

[refactor] Clean Arch + Typescript#349
adrianq merged 37 commits intodevelopmentfrom
refactor/clean-arch-and-ts

Conversation

@tokland
Copy link
Copy Markdown
Contributor

@tokland tokland commented Apr 13, 2026

📌 References

This is the continuation of #345

📝 Implementation

  • Remove Legacy code (load/save old campaigns).
  • Remove Feedback-Tool (+ jquery, only used by this code)
  • Clean Arch:
    • models/campaign.ts: this file should eventually be domain/entities/Campaign.ts without any references to db: DbD2.
    • All calls from the React views should go through use cases in the composition root.
    • Target Population repository
    • GetTargetPopulationUseCase
    • SaveTargetPopulationUseCase
    • Target Population model (with db) -> entity (with no db)
  • Typescript:
    • src/components/steps/antigen-selection/AntigenSelectionStep.jsx
    • src/components/steps/organisation-units/OrganisationUnitsStep.jsx
    • src/components/steps/save/SaveStep.jsx
    • src/components/dashboard/Dashboard.jsx
    • src/components/campaign-wizard/CampaignWizard.jsx
    • src/components/shared/PageHeader.jsx
    • src/components/data-entry/DataEntry.jsx
    • src/components/wizard/ExitWizardButton.jsx
    • src/components/spinner/Spinner.jsx
    • src/components/app/Root.jsx
    • src/components/app/LandingPage.jsx
    • src/components/share/Share.jsx
    • src/utils/permissions.js
    • src/utils/validations.js
    • src/utils/styles.js
    • src/models/dashboard-items.js + remaining any in Dashboard.ts (first effort, still some any left)
    • src/models/dashboard-items.js + remaining any in Dashboard.ts (second effort)
    • Global: Review all usages of "any"
  • General:
    • Prune code (use ts-prune)
    • Refactor d2: D2 (provided by deprecated "d2" package, used with manual typing) by api: D2Api (d2-api, fully typed). Recent code already uses d2-api.
      • src/utils/dhis2.ts
      • src/models/datasets.ts
      • src/components/utils/page-visited.tsx
      • src/components/steps/save/SaveStep.tsx
      • src/components/steps/organisation-units/OrganisationUnitsStep.tsx
      • src/components/steps/general-info/GeneralInfoStep.tsx
      • src/components/steps/disaggregation/DisaggregationStep.tsx
      • src/components/steps/antigen-selection/AntigenSelectionStep.tsx
      • src/components/dashboard/Dashboard.tsx
      • src/components/campaign-wizard/CampaignWizard.tsx
      • src/components/data-entry/DataEntry.tsx (note: it will be refactored on v42 migration)
      • src/models/db-d2.ts
      • src/index.tsx
      • src/testing/d2-snap-mock.ts [infrastructure]
      • src/components/app/App.tsx
    • [complex, probably a standalone task] AntigensDisaggregation has become overly complex as requirements evolved. It should be simplified and refactored to better follow Clean Architecture, removing DHIS2-specific details (like COCs, we only know about categories and options). Part of the complexity comes from the agnostic treatment of data elements and disaggregations. Note that some of these disaggregations (dataElements: dose administered, at least, but probably all of them; categories: age group, doses) should be part of the domain, as it's something the domain knows about.

@bundlemon
Copy link
Copy Markdown

bundlemon Bot commented Apr 13, 2026

BundleMon

No change in files bundle size

Groups updated (1)
Status Path Size Limits
Build Folder
./**/*
1.88MB (-154.01KB -7.4%) +20%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@tokland tokland changed the base branch from development to refactor/clean2 April 13, 2026 11:41
tokland added 23 commits April 14, 2026 12:11
Move the OrganisationUnit type from models/db.types to a proper
domain entity (as a Struct class with a getFullOrgUnitName method).
Implement OrganisationUnitD2Repository using d2-api and expose it
through the composition root as a use case, replacing the ad-hoc
DbD2.getOrganisationUnitsFromIds and Campaign.getOrganisationUnitsWithName.
@adrianq adrianq changed the base branch from refactor/clean2 to development April 16, 2026 10:03
tokland added 9 commits April 16, 2026 13:18
Preparatory step for TypeScript migration. No runtime changes.
Add types to all functions and local types (AreaType, ItemConfig,
ConstructorOptions, etc). Export ModelDataDimensionItem and
D2DataDimensionItem from campaign-d2-visualizations. Fix latent
null-access bug on antigen.name in chartConstructor. Replace non-null
assertions with assert().
Clearer name: the flag indicates whether target population data has
been saved to the server, not whether values are "up to date".
@tokland tokland marked this pull request as ready for review April 20, 2026 08:26
@tokland tokland mentioned this pull request Apr 20, 2026
15 tasks
@adrianq adrianq merged commit 86497f7 into development Apr 21, 2026
6 checks passed
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.

2 participants