export function loadConfig(configsDef, { application, config }) {
    if (configsDef) {
        for (const [name, def] of Object.entries(configsDef)) {
            let value = application[name];
            if (value === undefined || value === null) {
                let source = config;
                if (!source) {
                    switch (def.scope) {
                        case 'blueprint': {
                            // TODO Convert type to BaseGenerator
                            source = this.blueprintStorage.getAll();
                            break;
                        }
                    }
                }
                if (source) {
                    value = application[name] = source[name] ?? undefined;
                    if (value === undefined && def.default !== undefined) {
                        application[name] = typeof def.default === 'function' ? def.default.call(this, source) : def.default;
                    }
                }
            }
        }
    }
}
