feat(#566): implement auto-inclusion of task and target and contact s…#784
feat(#566): implement auto-inclusion of task and target and contact s…#784inromualdo wants to merge 6 commits into
Conversation
|
@inromualdo sorry for the delay! Very interested in the feature you have added here! Before I get too far into reviewing the code, can you help me understand a bit better how this is expected to work? Here is how I think things go and maybe you can correct me if I get anything wrong:
There are some tradeoffs here between clarity and convenience. (There is more complexity when we are merging files behind the scenes and it adds another level of abstraction between what is seen in the config files and what is actually uploaded to the server. On the other hand, making configuration more reusable has clear benefits as well.) I think I see how this works for just dropping new files into the project directory. How will this work for config coming from re-usable NPM libs like https://github.com/medic/cht-stock-monitoring-workflow? Would I still have to manually copy files from that repo into my local config? |
There was a problem hiding this comment.
Okay, thanks for your patience @inromualdo! I have been doing a ton more thinking about this and digging through the existing code along with your changes here. I think this is a really exciting opportunity to step into a new era of CHT configuration. What you have here does a good job being passive and minimal in terms of the changes it envisions. Instead, I would like to propose we go all-in on this and expand our approach to just set a new standard! To summarize, I am proposing:
- We remove all remaining support for "non-declarative" configuration for tasks/targets/contact-summary.
- Add support for dynamically reading configuration from files in the
./contact-summary,./tasks, and./targetsdirectories (using directories to group the files instead of your current approach with the.contact-summary/tasks/targets.jsprefix).- Deprecate the
contact-summary.templated.js,tasks.js, andtargets.jsfiles, but retain support for reading config from them for backwards compatibility.
- Deprecate the
- Add support for not including contact-summary/tasks/targets configuration in a project (just default to empty config instead).
With this approach, a typical basic configuration structure would look something like:
app_settings/base_settings.json
contact-summary/base.js
targets/base.js
tasks/base.js
You can expand the contact-summary/tasks/targets configuration by adding additional files to the associated directory. Running the compile-app-settings action will pull everything together into the ./app_settings.json file.
What do you think? I am trying to actually reduce complexity by just standardizing along the intended go-forwards code paths. Do you think this will be useful/maintainable? Do you have any ideas on how to improve this (or achieve the same objective more cleanly)?
I don't think implementing what I am going for here would take a huge amount of additional effort. You have already done the most difficult design work of figuring out the details for merging the config. After poking around the code a bit, here is my thoughts on the implementation details, but we might be able to come up with a better approach....
- contact-summary:
- Remove support for "freeform" contact summary configuration (aka the
contact-summary.jsfile). Only keep support for "structured" (declarative) contact-summary config.- Going forwards, we will only support reading the declarative contact summary config from
contact-summary.templated.jsfile andcontact-summary/*.jsfiles.
- Going forwards, we will only support reading the declarative contact summary config from
- Move the contact-summary merge functionality out of
contact-summary/lib.jsintocontact-summary-emitter.jsso that it takes an array ofcontactSummariesinstead of the currentcontactSummaryparameter. - Remove the
contact-summary/lib.jsfile and replace it with a file generated at compile-time in thecompile-contact-summary.jslogic (similar tocht-cards-extensions-shim.js).- The generated file should only:
- Require the
contact-summary.templated.jsfile and all the variouscontact-summary/*.jsfiles, - Use the emitter to emit the contact summary config.
- Require the
- The logic should just treat the
contact-summary.templated.jslike the othercontact-summary/*.jsfiles, but it should be the "most preferred".- Also can log a message that
contact-summary.templated.jsis deprecated and should switch tocontact-summary/base.js
- Also can log a message that
- The generated file should only:
- Add support for not having any
contact-summary.templated.jsfile andcontact-summary/*.jsfiles (and just adding empty config into the app_settings)
- Remove support for "freeform" contact summary configuration (aka the
- tasks/targets:
- Remove support for
rules.nools.jsconfig (nools). Only keep support for declarative config.- Going forwards we will only support reading the declarative config from
tasks.js,targets.js,tasks/*.js, andtargets/*.jsfiles.
- Going forwards we will only support reading the declarative config from
- Remove the
nools/lib.jsand replace it with a file generated at compile-time in thecompile-tasks-and-targets.jslogic (similar to how the current*extensions-shim.jsfiles are being generated).- The generated file should only:
- Require the
tasks.js,targets.js,tasks/*.js, andtargets/*.jsfiles. - Use the emitters to emit the tasks and targets.
- Require the
- The logic should treat the
tasks.jsandtargets.jslike the othertasks/*.js, andtargets/*.jsfiles, but thetasks.jsandtargets.jsshould be "most preferred".- Also can log a message that
tasks.jsandtargets.jsare deprecated and should switch totasks/base.js, andtargets/base.js
- Also can log a message that
- The generated file should only:
- Add support for not having any
tasks.js,targets.js,tasks/*.js, andtargets/*.jsfiles (and just adding empty config into the app_settings)
- Remove support for
Description
Ability to compile and upload tasks and contact summary from reusable componnent. This PR auto include any file end by
.tasks.js,.targets.jsand.contact-summary.js#566
Code review items
License
The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.