Skip to main content

App Module Configuration

The appModule is a fundamental module in Fusion, crucial for application loading. In the project portal, we have chosen not to use the default configuration provided by FusionCore and have opted for some shortcuts. This decision allows us to fully leverage the capabilities of the new Fusion framework.

note

The new Fusion CLI has also adopted some of the same shortcuts as us. This is because the development of App Management 2.0 has not yet begun.

this line in portal-framework-config.tsx file enables the app module utilizing our project portal apis client configuration

    enableAppModule(config, appConfigurator(portalConfig.portalClient.client));

this is the dev configuration for the portal client:

{
"client": {
"baseUri": "https://backend-fusion-project-portal-feature.radix.equinor.com",
"defaultScopes": [
"api://7bf96dd1-39fe-47dd-8286-329c730ac76b/access_as_user"
]
}
},

Our appConfigurator is located in the core project. This configures the module using the provided client configuration.

export const appConfigurator =
(client: Client): AppConfigBuilderCallback =>
async (builder) => {
const serviceDiscovery = await builder.requireInstance('serviceDiscovery');
const http = await builder.requireInstance('http');
const portal = await serviceDiscovery.createClient('portal');
const portalClient = await http.createClient('portal-client');
builder.setAppClient({
getAppManifest: (query) => {
return portalClient.json$(`/api/onboarded-apps/${query.appKey}`, {
selector: async (res) => manifestMapper(client.baseUri)(await res.json()),
});
},
getAppManifests: () =>
portalClient.json$(`/api/portal/fusion/apps`, {
selector: async (res) => (await res.json()).map(manifestMappers(client.baseUri)),
}),
getAppConfig: (query) => portal.json$(`/api/apps/${query.appKey}/config`),
});
};

In both manifestMapper and manifestMappers  we need to define the entry. this is uesd to load the applicaion modele and is not a part of the applicaiont manifet provided by fusion. in the manifestMapperwi also provide the isLegacy flag. This needs to be provided when onboarding a pllication to the porject portal.

    const manifestMapper =
(basePath: string) =>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(value: any): AppManifest => {
const { appKey, appInformation, isLegacy } = value;
return { ...appInformation, entry: `${basePath}/api/bundles/${appKey}`, isLegacy };
};
info

The app-configurator.ts file is currently in /client/packages/portal-core/src/framework/app-configurator.ts. It will be moved to the core project.