feat(#11192): support extension libs in messages#11244
Draft
belwalshubham wants to merge 5 commits into
Draft
Conversation
belwalshubham
force-pushed
the
11192-extension-libs-messages
branch
from
July 12, 2026 14:43
aeba59b to
54db099
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds project-defined
extension-libsas synchronous Mustache section helpers for translations and outgoing messages.This allows configurers to transform message values without adding a new built-in helper to CHT Core, for example:
Closes #11192.
Architecture
flowchart LR Couch[("CouchDB<br/>extension-libs")] Loader["Extension-libs loader<br/>decode + atomic registry replacement"] Couch --> Loader Loader --> Webapp["Webapp cache"] Loader --> API["API config cache"] Loader --> Sentinel["Sentinel config cache"] Loader --> Admin["Admin preview load"] Webapp --> Translation["Webapp translations"] Webapp --> Report["Report detail messages"] API --> Export["Message export rendering"] Sentinel --> Transitions["Transitions and scheduled SMS"] Admin --> Preview["Message queue preview"] Translation --> MessageUtils["message-utils<br/>template(opts) / generate(opts)"] Report --> MessageUtils Export --> MessageUtils Transitions --> MessageUtils Preview --> MessageUtils MessageUtils --> Output["Consistent rendered message"]Changes
@medic/extension-libsfor loading and decoding theextension-libsCouchDB document.message-utils.generateandmessage-utils.templateto accept an options object containingextensionLibs..jssuffix.Security
Extension-libs are trusted application configuration uploaded by authorized administrators. This change does not present extension-lib execution as sandboxed.
Verification
Manual end-to-end evidence
The following screenshot records the manually executed live CouchDB flow. It uses a real
extension-libsdocument and attachments, the production@medic/extension-libsloader, and the productionmessage-utilsrendering path.Manual steps verified:
cht_11192_e2edatabase on CouchDB 3.5.2.to_devanagari.jsas an attachment on theextension-libsdocument.message-utils.generateand confirmedID १२३४५.uppercase.js.message-utils.templateand confirmedHello ADA.This screenshot is evidence of the loader/reload/rendering end-to-end path. The Admin, API, Sentinel, and Webapp integrations are additionally covered by their regression suites listed below.
npm run build-devnpm run lintCOUCH_URL=http://medic:password@localhost:5984/medic npm run unit-api— 1,636 passingnpm run unit-admin— 435 passingTZ=UTC COUCH_URL=http://medic:password@localhost:5984/medic npm run unit-sentinel— 231 passingnpm test --workspace=@medic/extension-libs— 6 passing, 100% coveragenpm test --workspace=@medic/message-utils— 112 passing, 100% statements/linesto_devanagari.jsas an attachment;ID १२३४५throughmessage-utils.generate;uppercase.js;Hello ADAthroughmessage-utils.template;Notes for reviewers
message-utils.