mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import Dictionary from "Common/Types/Dictionary";
|
|
import ComponentMetadata from "Common/Types/Workflow/Component";
|
|
import Components from "Common/Types/Workflow/Components";
|
|
import BaseModelComponentFactory from "Common/Types/Workflow/Components/BaseModel";
|
|
import Entities from "Common/Models/DatabaseModels/Index";
|
|
|
|
type LoadAllComponentMetadataFunction = () => Dictionary<ComponentMetadata>;
|
|
|
|
export const loadAllComponentMetadata: LoadAllComponentMetadataFunction =
|
|
(): Dictionary<ComponentMetadata> => {
|
|
const initComponents: Dictionary<ComponentMetadata> = {};
|
|
|
|
for (const componentMetadata of Components) {
|
|
initComponents[componentMetadata.id] = componentMetadata;
|
|
}
|
|
|
|
for (const model of Entities) {
|
|
const baseModelComponentMetadata: Array<ComponentMetadata> =
|
|
BaseModelComponentFactory.getComponents(new model());
|
|
|
|
for (const componentMetadata of baseModelComponentMetadata) {
|
|
initComponents[componentMetadata.id] = componentMetadata;
|
|
}
|
|
}
|
|
|
|
return initComponents;
|
|
};
|