2023-01-17 21:39:29 +01:00
|
|
|
import Consola from 'consola';
|
|
|
|
|
|
2022-12-11 19:16:31 +01:00
|
|
|
import { ConfigType } from '../../types/config';
|
|
|
|
|
import { getConfig } from './getConfig';
|
|
|
|
|
|
|
|
|
|
export const getFrontendConfig = (name: string): ConfigType => {
|
|
|
|
|
const config = getConfig(name);
|
|
|
|
|
|
2023-01-17 21:39:29 +01:00
|
|
|
Consola.info(`Requested frontend content of configuration '${name}'`);
|
2023-03-18 18:29:22 +08:00
|
|
|
// If not, return the config
|
2023-04-03 15:57:11 +09:00
|
|
|
const someAppsWithoutProps = config.apps.filter(
|
2023-03-18 18:29:22 +08:00
|
|
|
(app) =>
|
|
|
|
|
app.integration?.properties.some(
|
|
|
|
|
(property) => property.value === null || property.value === undefined
|
|
|
|
|
) ?? false
|
|
|
|
|
);
|
2023-04-03 15:57:11 +09:00
|
|
|
if (someAppsWithoutProps.length > 0) {
|
2023-03-18 18:29:22 +08:00
|
|
|
Consola.warn(
|
2023-04-03 15:57:11 +09:00
|
|
|
`There are apps that have missing configuration options: [${someAppsWithoutProps
|
2023-03-18 18:29:22 +08:00
|
|
|
.map((app) => app.name)
|
|
|
|
|
.join(', ')}] please input the correct secrets once again for the concerned app(s), save them, exit edit mode and reload the page.`
|
|
|
|
|
);
|
|
|
|
|
}
|
2023-01-17 21:39:29 +01:00
|
|
|
|
2022-12-11 19:16:31 +01:00
|
|
|
return {
|
|
|
|
|
...config,
|
2022-12-23 17:17:57 +01:00
|
|
|
apps: config.apps.map((app) => ({
|
|
|
|
|
...app,
|
|
|
|
|
integration: {
|
2022-12-24 17:18:16 +09:00
|
|
|
...(app.integration ?? null),
|
2022-12-23 17:17:57 +01:00
|
|
|
type: app.integration?.type ?? null,
|
2022-12-24 17:18:16 +09:00
|
|
|
properties:
|
|
|
|
|
app.integration?.properties.map((property) => ({
|
|
|
|
|
...property,
|
2022-12-31 16:07:05 +01:00
|
|
|
value: property.type === 'private' ? null : property.value,
|
|
|
|
|
isDefined: property.value !== null,
|
2022-12-24 17:18:16 +09:00
|
|
|
})) ?? [],
|
2022-12-23 17:17:57 +01:00
|
|
|
},
|
2022-12-11 19:16:31 +01:00
|
|
|
})),
|
|
|
|
|
};
|
|
|
|
|
};
|