diff --git a/cli/src/lib/generateManifests.js b/cli/src/lib/generateManifests.js index 21287b25..5685049e 100644 --- a/cli/src/lib/generateManifests.js +++ b/cli/src/lib/generateManifests.js @@ -120,6 +120,7 @@ module.exports = (paths, config, publicUrl) => { launch_path: shouldIncludeAppLaunchPath ? paths.launchPath : undefined, plugin_launch_path: includesPlugin ? paths.pluginLaunchPath : undefined, + plugin_type: includesPlugin ? config.pluginType : undefined, default_locale: 'en', activities: { dhis: { diff --git a/cli/src/lib/parseConfig.js b/cli/src/lib/parseConfig.js index d1b5a40d..a77f8318 100644 --- a/cli/src/lib/parseConfig.js +++ b/cli/src/lib/parseConfig.js @@ -48,6 +48,18 @@ const validateConfig = (config) => { ) } }) + + const { pluginType } = config + if (pluginType && !/^[A-Z0-9-_]+$/.test(pluginType)) { + throw new Error( + `Field ${chalk.bold( + 'pluginType' + )} must contain only the characters A-Z (uppercase), 0-9, -, or _. Got: ${chalk.bold( + `"${pluginType}"` + )}` + ) + } + return true } diff --git a/docs/config/d2-config-js-reference.md b/docs/config/d2-config-js-reference.md index dc80b93b..78752ede 100644 --- a/docs/config/d2-config-js-reference.md +++ b/docs/config/d2-config-js-reference.md @@ -24,6 +24,7 @@ The following configuration properties are supported: | **entryPoints.plugin** | _string_ | | The path to the application's plugin entrypoint (not used for libraries) | | **entryPoints.lib** | _string_ or _object_ | **./src/index** | The path to the library entrypoint(s) (not used for applications). Supports [conditional exports](https://nodejs.org/dist/latest-v16.x/docs/api/packages.html#packages_conditional_exports) | | **skipPluginLogic** | _boolean_ | **false** | By default, plugin entry points will be wrapped with logic to allow the passing of properties and resizing between the parent app and the child plugin. This logic will allow users to use the plugin inside an app when wrapped in `` component from app-runtime. If set to true, this logic will not be loaded. | +| **pluginType** | _string_ | | Gets added to the `plugin_type` field for this app in the `/api/apps` response -- an example is `pluginType: 'DASHBOARD'` for a plugin meant to be consumed by the Dashboard app. Must be contain only characters from the set A-Z (uppercase), 0-9, `-` and `_`; i.e., it's tested against the regex `/^[A-Z0-9-_]+$/`. | | **dataStoreNamespace** | _string_ | | The DataStore and UserDataStore namespace to reserve for this application. The reserved namespace **must** be suitably unique, as other apps will fail to install if they attempt to reserve the same namespace - see the [webapp manifest docs](https://docs.dhis2.org/en/develop/loading-apps.html) | | **customAuthorities** | _Array(string)_ | | An array of custom authorities to create when installing the app, these do not provide security protections in the DHIS2 REST API but can be assigned to user roles and used to modify the interface displayed to a user - see the [webapp manifest docs](https://docs.dhis2.org/en/develop/loading-apps.html) | | **minDHIS2Version** | _string_ | | The minimum DHIS2 version the App supports (eg. '2.35'). Required when uploading an app to the App Hub. The app's major version in the app's package.json needs to be increased when changing this property. | diff --git a/examples/pwa-app/d2.config.js b/examples/pwa-app/d2.config.js index a2de6f92..1a95dbe4 100644 --- a/examples/pwa-app/d2.config.js +++ b/examples/pwa-app/d2.config.js @@ -16,6 +16,8 @@ const config = { // Uncomment this to test plugin builds: // plugin: './src/components/VisualizationsList.js', }, + + // pluginType: 'DASHBOARD', skipPluginLogic: true, }