Add a new action: src/fn/upload-ui-extensions.js. Can follow similar patterns as to what is in upload-extension-libs.js.
- Validation:
- Each extension must include a
.js and a .properties.json file.
- In the
.properties.json (maybe can use joi to do this?):
- The
type must be set and must be either app_main_tab or app_drawer_tab.
- The
title must be set and must be a string
- The
icon must be set and must be a string
- If
roles is set, it must be a string[]
- If
config is set, it must be a Record<string, unknown>
- Each UI Extension gets its own document in the
medic database:
type - ui-extension
_id - ui-extension:${fileName} (not including the file extension)
- Include all the contents of the
.properties.json as fields in the doc.
- Include the contents of the
.js file as an attachment called extension.js
- We should support only uploading specific extensions following the same pattern as the
upload-*-forms actions.
- E.g. when you execute
cht upload-app-forms -- delivery it will only upload the delivery form and not all app forms.
- We can get the
-- ... data via the environment.extraArgs property. I believe this is just a string array of everything including and after -- (delimited by spaces). So, we might need to drop the initial -- entry (as is done in the args-form-filter lib).
- If any specific extension names are provided, we should only upload those.
It may make sense to extract at least some of this logic into a lib for better code management and easier unit testing....
Add a new action:
src/fn/upload-ui-extensions.js. Can follow similar patterns as to what is in upload-extension-libs.js..jsand a.properties.jsonfile..properties.json(maybe can usejoito do this?):typemust be set and must be eitherapp_main_taborapp_drawer_tab.titlemust be set and must be astringiconmust be set and must be astringrolesis set, it must be astring[]configis set, it must be aRecord<string, unknown>medicdatabase:type-ui-extension_id-ui-extension:${fileName}(not including the file extension).properties.jsonas fields in the doc..jsfile as an attachment calledextension.jsupload-*-formsactions.cht upload-app-forms -- deliveryit will only upload thedeliveryform and not all app forms.-- ...data via theenvironment.extraArgsproperty. I believe this is just a string array of everything including and after--(delimited by spaces). So, we might need to drop the initial--entry (as is done in the args-form-filter lib).It may make sense to extract at least some of this logic into a lib for better code management and easier unit testing....