UNPKG

@o3r/configuration

Version:

This module contains configuration-related features such as CMS compatibility, Configuration override, store and debugging. It enables your application runtime configuration and comes with an integrated ng builder to help you generate configurations suppo

68 lines (62 loc) 3.54 kB
import * as i0 from '@angular/core'; import { Injectable, NgModule } from '@angular/core'; import * as i1 from '@ngrx/store'; import { computeItemIdentifier } from '@o3r/core'; import { setConfigOverride, ConfigurationStoreModule } from '@o3r/configuration'; /** ActionUpdateConfigurationBlock */ const RULES_ENGINE_CONFIGURATION_UPDATE_ACTION_TYPE = 'UPDATE_CONFIG'; /** * Service to handle async Configuration actions */ class ConfigurationRulesEngineActionHandler { constructor(store) { this.store = store; /** @inheritdoc */ this.supportingActions = [RULES_ENGINE_CONFIGURATION_UPDATE_ACTION_TYPE]; } /** @inheritdoc */ executeActions(actions) { const configOverrideMap = actions .filter((action) => action.library && action.component && action.property && typeof action.value !== 'undefined') .reduce((acc, ov) => { const configName = computeItemIdentifier(ov.component, ov.library); acc[configName] ||= { overrides: {} }; acc[configName].overrides[ov.property] = ov.value; return acc; }, {}); const configOverrides = Object.entries(configOverrideMap) .reduce((acc, [key, value]) => { acc[key] = value.overrides; return acc; }, {}); this.store.dispatch(setConfigOverride({ state: { configOverrides } })); } /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: ConfigurationRulesEngineActionHandler, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Injectable }); } /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: ConfigurationRulesEngineActionHandler }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: ConfigurationRulesEngineActionHandler, decorators: [{ type: Injectable }], ctorParameters: () => [{ type: i1.Store }] }); class ConfigurationRulesEngineActionModule { /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: ConfigurationRulesEngineActionModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); } /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.1", ngImport: i0, type: ConfigurationRulesEngineActionModule, imports: [ConfigurationStoreModule] }); } /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: ConfigurationRulesEngineActionModule, providers: [ ConfigurationRulesEngineActionHandler ], imports: [ConfigurationStoreModule] }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: ConfigurationRulesEngineActionModule, decorators: [{ type: NgModule, args: [{ imports: [ ConfigurationStoreModule ], providers: [ ConfigurationRulesEngineActionHandler ] }] }] }); /** * Generated bundle index. Do not edit. */ export { ConfigurationRulesEngineActionHandler, ConfigurationRulesEngineActionModule, RULES_ENGINE_CONFIGURATION_UPDATE_ACTION_TYPE }; //# sourceMappingURL=o3r-configuration-rules-engine.mjs.map