@o3r/configuration 10.0.0-next.8 → 11.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +11 -11
  2. package/core/configurable.d.ts +1 -25
  3. package/core/configurable.d.ts.map +1 -1
  4. package/core/configuration.d.ts +1 -3
  5. package/core/configuration.d.ts.map +1 -1
  6. package/devkit/configuration-devtools.console.service.d.ts +9 -8
  7. package/devkit/configuration-devtools.console.service.d.ts.map +1 -1
  8. package/devkit/configuration-devtools.interface.d.ts +12 -5
  9. package/devkit/configuration-devtools.interface.d.ts.map +1 -1
  10. package/devkit/configuration-devtools.message.service.d.ts +5 -7
  11. package/devkit/configuration-devtools.message.service.d.ts.map +1 -1
  12. package/devkit/configuration-devtools.module.d.ts +0 -1
  13. package/devkit/configuration-devtools.module.d.ts.map +1 -1
  14. package/devkit/configuration-devtools.service.d.ts +2 -6
  15. package/devkit/configuration-devtools.service.d.ts.map +1 -1
  16. package/devkit/configuration-devtools.token.d.ts.map +1 -1
  17. package/esm2022/core/configurable.mjs +1 -1
  18. package/esm2022/core/configuration.mjs +4 -6
  19. package/esm2022/devkit/configuration-devtools.console.service.mjs +18 -13
  20. package/esm2022/devkit/configuration-devtools.interface.mjs +1 -2
  21. package/esm2022/devkit/configuration-devtools.message.service.mjs +6 -8
  22. package/esm2022/devkit/configuration-devtools.module.mjs +5 -6
  23. package/esm2022/devkit/configuration-devtools.service.mjs +6 -10
  24. package/esm2022/devkit/configuration-devtools.token.mjs +3 -2
  25. package/esm2022/rules-engine/configuration.handler-action.mjs +40 -0
  26. package/esm2022/rules-engine/configuration.interfaces.mjs +3 -0
  27. package/esm2022/rules-engine/configuration.rules-engine.module.mjs +23 -0
  28. package/esm2022/rules-engine/o3r-configuration-rules-engine.mjs +5 -0
  29. package/esm2022/rules-engine/public_api.mjs +4 -0
  30. package/esm2022/services/configuration/configuration.base.module.mjs +4 -4
  31. package/esm2022/services/configuration/configuration.base.service.mjs +15 -36
  32. package/esm2022/stores/config-override/config-override.module.mjs +4 -4
  33. package/esm2022/stores/config-override/config-override.selectors.mjs +1 -2
  34. package/esm2022/stores/config-override/config-override.sync.mjs +1 -2
  35. package/esm2022/stores/configuration/configuration.helpers.mjs +3 -4
  36. package/esm2022/stores/configuration/configuration.module.mjs +4 -4
  37. package/esm2022/stores/configuration/configuration.selectors.mjs +6 -3
  38. package/esm2022/stores/configuration/configuration.state.mjs +5 -1
  39. package/esm2022/tools/configuration.observer.mjs +1 -1
  40. package/fesm2022/o3r-configuration-rules-engine.mjs +67 -0
  41. package/fesm2022/o3r-configuration-rules-engine.mjs.map +1 -0
  42. package/fesm2022/o3r-configuration.mjs +72 -93
  43. package/fesm2022/o3r-configuration.mjs.map +1 -1
  44. package/package.json +22 -16
  45. package/rules-engine/configuration.handler-action.d.ts +19 -0
  46. package/rules-engine/configuration.handler-action.d.ts.map +1 -0
  47. package/rules-engine/configuration.interfaces.d.ts +13 -0
  48. package/rules-engine/configuration.interfaces.d.ts.map +1 -0
  49. package/rules-engine/configuration.rules-engine.module.d.ts +8 -0
  50. package/rules-engine/configuration.rules-engine.module.d.ts.map +1 -0
  51. package/rules-engine/index.d.ts +6 -0
  52. package/rules-engine/o3r-configuration-rules-engine.d.ts.map +1 -0
  53. package/rules-engine/public_api.d.ts +4 -0
  54. package/rules-engine/public_api.d.ts.map +1 -0
  55. package/schemas/configuration.metadata.schema.json +3 -2
  56. package/schemas/rules-engine.config-action.schema.json +34 -0
  57. package/schematics/configuration-to-component/index.d.ts.map +1 -1
  58. package/schematics/configuration-to-component/index.js +3 -3
  59. package/schematics/configuration-to-component/index.js.map +1 -1
  60. package/schematics/configuration-to-component/schema.json +1 -1
  61. package/schematics/configuration-to-component/templates/__name__.config.ts.template +2 -2
  62. package/schematics/ng-add/helpers/devtools-registration.d.ts +11 -0
  63. package/schematics/ng-add/helpers/devtools-registration.d.ts.map +1 -0
  64. package/schematics/ng-add/helpers/devtools-registration.js +35 -0
  65. package/schematics/ng-add/helpers/devtools-registration.js.map +1 -0
  66. package/schematics/ng-add/index.d.ts.map +1 -1
  67. package/schematics/ng-add/index.js +7 -4
  68. package/schematics/ng-add/index.js.map +1 -1
  69. package/schematics/ng-add/schema.json +1 -1
  70. package/services/configuration/configuration.base.service.d.ts +2 -9
  71. package/services/configuration/configuration.base.service.d.ts.map +1 -1
  72. package/stores/config-override/config-override.selectors.d.ts +0 -1
  73. package/stores/config-override/config-override.selectors.d.ts.map +1 -1
  74. package/stores/config-override/config-override.sync.d.ts +0 -1
  75. package/stores/config-override/config-override.sync.d.ts.map +1 -1
  76. package/stores/configuration/configuration.helpers.d.ts +0 -1
  77. package/stores/configuration/configuration.helpers.d.ts.map +1 -1
  78. package/stores/configuration/configuration.selectors.d.ts +8 -2
  79. package/stores/configuration/configuration.selectors.d.ts.map +1 -1
  80. package/stores/configuration/configuration.state.d.ts +6 -2
  81. package/stores/configuration/configuration.state.d.ts.map +1 -1
  82. package/tools/configuration.observer.d.ts +2 -2
  83. package/tools/configuration.observer.d.ts.map +1 -1
  84. package/schematics/package.json +0 -3
@@ -1,26 +1,25 @@
1
- import { deepFill, sendOtterMessage, filterMessageContent, otterComponentInfoPropertyName } from '@o3r/core';
1
+ import { computeItemIdentifier, deepFill, sendOtterMessage, filterMessageContent, otterComponentInfoPropertyName } from '@o3r/core';
2
2
  import { map, distinctUntilChanged, shareReplay, filter, take, switchMap } from 'rxjs/operators';
3
3
  import * as i0 from '@angular/core';
4
4
  import { InjectionToken, NgModule, Injectable, Optional, Inject } from '@angular/core';
5
- import { firstValueFrom, Subscription, fromEvent, combineLatest, BehaviorSubject } from 'rxjs';
5
+ import { firstValueFrom, Subscription, fromEvent, of, combineLatest, BehaviorSubject } from 'rxjs';
6
6
  import * as i1 from '@ngrx/store';
7
- import { createAction, props, on, createReducer, StoreModule, createFeatureSelector, createSelector, select } from '@ngrx/store';
7
+ import { props, createAction, on, createReducer, StoreModule, createFeatureSelector, createSelector, select } from '@ngrx/store';
8
8
  import { createEntityAdapter } from '@ngrx/entity';
9
9
  import * as i2 from '@o3r/logger';
10
10
  import { LoggerModule } from '@o3r/logger';
11
11
 
12
12
  /**
13
13
  * Get the configuration name
14
- *
14
+ * @deprecated use {@link computeItemIdentifier} from @o3r/core. Will be removed in v12
15
15
  * @param componentName Name of the component to get the configuration
16
16
  * @param libraryName Name of the library the component is coming from
17
17
  */
18
18
  function computeConfigurationName(componentName, libraryName) {
19
- return (libraryName ? libraryName + '#' : '') + componentName;
19
+ return computeItemIdentifier(componentName, libraryName);
20
20
  }
21
21
  /**
22
22
  * Get the component and library's names based on the configuration name
23
- *
24
23
  * @param configurationName Name of the component as found in the store
25
24
  * @returns Object containing library and component name.
26
25
  */
@@ -35,7 +34,6 @@ function parseConfigurationName(configurationName) {
35
34
  }
36
35
  /**
37
36
  * Operator to get the configuration from store for a given component and merge it with the global config
38
- *
39
37
  * @param defaultValue Default value of the configuration
40
38
  */
41
39
  function getConfiguration(defaultValue) {
@@ -46,7 +44,6 @@ function getConfiguration(defaultValue) {
46
44
 
47
45
  /**
48
46
  * Determine if the given message is a Configuration message
49
- *
50
47
  * @param message message to check
51
48
  */
52
49
  const isConfigurationMessage = (message) => {
@@ -98,13 +95,13 @@ class ConfigOverrideStoreModule {
98
95
  ]
99
96
  };
100
97
  }
101
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: ConfigOverrideStoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
102
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.0", ngImport: i0, type: ConfigOverrideStoreModule, imports: [i1.StoreFeatureModule] }); }
103
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: ConfigOverrideStoreModule, providers: [
98
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ConfigOverrideStoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
99
+ /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.8", ngImport: i0, type: ConfigOverrideStoreModule, imports: [i1.StoreFeatureModule] }); }
100
+ /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ConfigOverrideStoreModule, providers: [
104
101
  { provide: CONFIG_OVERRIDE_REDUCER_TOKEN, useFactory: getDefaultConfigOverrideReducer }
105
102
  ], imports: [StoreModule.forFeature(CONFIG_OVERRIDE_STORE_NAME, CONFIG_OVERRIDE_REDUCER_TOKEN)] }); }
106
103
  }
107
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: ConfigOverrideStoreModule, decorators: [{
104
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ConfigOverrideStoreModule, decorators: [{
108
105
  type: NgModule,
109
106
  args: [{
110
107
  imports: [
@@ -122,7 +119,6 @@ const selectConfigOverrideState = createFeatureSelector(CONFIG_OVERRIDE_STORE_NA
122
119
  const selectConfigOverride = createSelector(selectConfigOverrideState, (state) => state?.configOverrides || {});
123
120
  /**
124
121
  * Get the override for given component identifier
125
- *
126
122
  * @param componentId
127
123
  * @returns
128
124
  */
@@ -130,7 +126,6 @@ const selectComponentOverrideConfig = (componentId) => createSelector(selectConf
130
126
 
131
127
  /**
132
128
  * Deserializer
133
- *
134
129
  * @param rawObject
135
130
  */
136
131
  const configOverrideStorageDeserializer = (rawObject) => {
@@ -177,12 +172,11 @@ const clearConfigurationEntities = createAction(ACTION_CLEAR_ENTITIES);
177
172
 
178
173
  /**
179
174
  * compute the configuration into SetEntitiesPayload
180
- *
181
175
  * @param customConfigObject array of configurations
182
176
  */
183
177
  function computeConfiguration(customConfigObject) {
184
178
  const entities = customConfigObject.reduce((acc, conf) => {
185
- const id = computeConfigurationName(conf.name, conf.library);
179
+ const id = computeItemIdentifier(conf.name, conf.library);
186
180
  acc[id] = { ...conf.config, id };
187
181
  return acc;
188
182
  }, {});
@@ -219,6 +213,10 @@ const configurationReducer = createReducer(configurationInitialState, ...configu
219
213
  * Name of the Configuration Store
220
214
  */
221
215
  const CONFIGURATION_STORE_NAME = 'configuration';
216
+ /**
217
+ * ID of the global configuration
218
+ */
219
+ const globalConfigurationId = 'global';
222
220
 
223
221
  /** Token of the Configuration reducer */
224
222
  const CONFIGURATION_REDUCER_TOKEN = new InjectionToken('Feature Configuration Reducer');
@@ -235,13 +233,13 @@ class ConfigurationStoreModule {
235
233
  ]
236
234
  };
237
235
  }
238
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: ConfigurationStoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
239
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.0", ngImport: i0, type: ConfigurationStoreModule, imports: [i1.StoreFeatureModule] }); }
240
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: ConfigurationStoreModule, providers: [
236
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ConfigurationStoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
237
+ /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.8", ngImport: i0, type: ConfigurationStoreModule, imports: [i1.StoreFeatureModule] }); }
238
+ /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ConfigurationStoreModule, providers: [
241
239
  { provide: CONFIGURATION_REDUCER_TOKEN, useFactory: getDefaultConfigurationReducer }
242
240
  ], imports: [StoreModule.forFeature(CONFIGURATION_STORE_NAME, CONFIGURATION_REDUCER_TOKEN)] }); }
243
241
  }
244
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: ConfigurationStoreModule, decorators: [{
242
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ConfigurationStoreModule, decorators: [{
245
243
  type: NgModule,
246
244
  args: [{
247
245
  imports: [
@@ -270,11 +268,14 @@ const selectConfigurationEntities = createSelector(selectConfigurationState, (st
270
268
  const selectConfigurationTotal = createSelector(selectConfigurationState, (state) => state ? selectTotal(state) : 0);
271
269
  /**
272
270
  * Select the configuration for component with id
273
- *
274
271
  * @param props property of the selector
275
272
  * @param props.id id of the component
276
273
  */
277
274
  const selectConfigurationForComponent = (props) => createSelector(selectConfigurationEntities, (entities) => (entities?.[props.id] || {}));
275
+ /**
276
+ * Select the global configuration
277
+ */
278
+ const selectGlobalConfiguration = createSelector(selectConfigurationForComponent({ id: globalConfigurationId }), (config) => config);
278
279
 
279
280
  const configurationStorageSync = {
280
281
  deserialize: (rawObject) => {
@@ -289,7 +290,8 @@ const configurationStorageSync = {
289
290
  const OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS = {
290
291
  defaultLibraryName: '@o3r/components',
291
292
  defaultJsonFilename: 'partial-static-config.json',
292
- isActivatedOnBootstrap: false
293
+ isActivatedOnBootstrap: false,
294
+ isActivatedOnBootstrapWhenCMSContext: true
293
295
  };
294
296
  // eslint-disable-next-line max-len
295
297
  const OTTER_CONFIGURATION_DEVTOOLS_OPTIONS = new InjectionToken('Otter Configuration Devtools options');
@@ -314,7 +316,6 @@ class OtterConfigurationDevtools {
314
316
  }
315
317
  /**
316
318
  * Get configuration name based on input information
317
- *
318
319
  * @param selector Selector for a component configuration. It can be a string in the form library#componentName (i.e: @refx/shared-components#HeaderContComponent)
319
320
  * or an object with the component and library names (i.e: {library:"@refx/shared-components", componentName:'HeaderContComponent'})
320
321
  * @param isFallbackName Determine if the name requested is a fallback name
@@ -339,7 +340,6 @@ class OtterConfigurationDevtools {
339
340
  }
340
341
  /**
341
342
  * Set a specified value of a component configuration
342
- *
343
343
  * @param selector Selector for a component configuration
344
344
  * @param configProperty Name of the configuration property to set
345
345
  * @param configValue Value of the configuration property to set
@@ -353,7 +353,6 @@ class OtterConfigurationDevtools {
353
353
  }
354
354
  /**
355
355
  * Get the configuration for a specific component
356
- *
357
356
  * @param selector Selector for a component configuration. It can be a string in the form library#configurationName (i.e: @refx/shared-components#HeaderPresConfig)
358
357
  * or an object with the configuration and library names (i.e: {library:"@refx/shared-components", componentName:'HeaderPresConfig'})
359
358
  */
@@ -372,25 +371,24 @@ class OtterConfigurationDevtools {
372
371
  }
373
372
  /**
374
373
  * Load a json configuration
375
- *
376
374
  * @param configurations configurations to load
377
375
  */
378
376
  loadConfiguration(configurations) {
379
377
  this.store.dispatch(upsertConfigurationEntities(computeConfiguration(typeof configurations === 'string' ? JSON.parse(configurations) : configurations)));
380
378
  this.appRef.tick();
381
379
  }
382
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: OtterConfigurationDevtools, deps: [{ token: i1.Store }, { token: i0.ApplicationRef }, { token: OTTER_CONFIGURATION_DEVTOOLS_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
383
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: OtterConfigurationDevtools, providedIn: 'root' }); }
380
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: OtterConfigurationDevtools, deps: [{ token: i1.Store }, { token: i0.ApplicationRef }, { token: OTTER_CONFIGURATION_DEVTOOLS_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
381
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: OtterConfigurationDevtools, providedIn: 'root' }); }
384
382
  }
385
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: OtterConfigurationDevtools, decorators: [{
383
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: OtterConfigurationDevtools, decorators: [{
386
384
  type: Injectable,
387
385
  args: [{ providedIn: 'root' }]
388
- }], ctorParameters: function () { return [{ type: i1.Store }, { type: i0.ApplicationRef }, { type: undefined, decorators: [{
386
+ }], ctorParameters: () => [{ type: i1.Store }, { type: i0.ApplicationRef }, { type: undefined, decorators: [{
389
387
  type: Optional
390
388
  }, {
391
389
  type: Inject,
392
390
  args: [OTTER_CONFIGURATION_DEVTOOLS_OPTIONS]
393
- }] }]; } });
391
+ }] }] });
394
392
 
395
393
  /* eslint-disable no-console */
396
394
  class ConfigurationDevtoolsConsoleService {
@@ -400,7 +398,9 @@ class ConfigurationDevtoolsConsoleService {
400
398
  this.configurationDevtools = configurationDevtools;
401
399
  this.options = options;
402
400
  this.options = { ...OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS, ...options };
403
- if (this.options.isActivatedOnBootstrap) {
401
+ if (this.options.isActivatedOnBootstrap
402
+ || (this.options.isActivatedOnBootstrapWhenCMSContext
403
+ && document.body.dataset.cmscontext === 'true')) {
404
404
  this.activate();
405
405
  }
406
406
  }
@@ -421,7 +421,6 @@ class ConfigurationDevtoolsConsoleService {
421
421
  }
422
422
  /**
423
423
  * Set a specified value of a component configuration
424
- *
425
424
  * @param selector Selector for a component configuration
426
425
  * @param configProperty Name of the configuration property to set
427
426
  * @param configValue Value of the configuration property to set
@@ -440,7 +439,6 @@ class ConfigurationDevtoolsConsoleService {
440
439
  }
441
440
  /**
442
441
  * Display the list of configurations loaded in the store and the library they originate from
443
- *
444
442
  * @returns array with the configurations and libraries for example: ["RefxComponentsCommonRuntimeConfig from @refx/shared-common"]
445
443
  */
446
444
  async displayComponentsWithConfiguration() {
@@ -449,7 +447,6 @@ class ConfigurationDevtoolsConsoleService {
449
447
  }
450
448
  /**
451
449
  * Display the configuration for a specific component
452
- *
453
450
  * @param selector Selector for a component configuration. It can be a string in the form library#configurationName (i.e: '@refx/shared-components#HeaderContConfig')
454
451
  * or an object with the configuration and library names (i.e: {library:"@refx/shared-components", componentName:'HeaderContConfig'}).
455
452
  * Note the object input componentName expects a configuration name not a component name.
@@ -461,7 +458,6 @@ class ConfigurationDevtoolsConsoleService {
461
458
  }
462
459
  /**
463
460
  * Download the JSON file of the whole configuration
464
- *
465
461
  * @param fileName Name of the file to download
466
462
  */
467
463
  async saveConfiguration(fileName = this.options.defaultJsonFilename) {
@@ -481,7 +477,7 @@ class ConfigurationDevtoolsConsoleService {
481
477
  async displayConfigurationBookmark() {
482
478
  const content = await this.configurationDevtools.getConfiguration();
483
479
  console.log('BOOKMARK');
484
- console.log(`javascript:window._OTTER_DEVTOOLS_.loadConfiguration('${JSON.stringify(content).replace(/[']/g, '\\\'')}')`);
480
+ console.log(`javascript:window._OTTER_DEVTOOLS_.updateConfigurations('${JSON.stringify(content).replace(/[']/g, '\\\'')}')`);
485
481
  }
486
482
  /**
487
483
  * Copy the whole configuration to the clipboard
@@ -492,26 +488,33 @@ class ConfigurationDevtoolsConsoleService {
492
488
  }
493
489
  /**
494
490
  * Load a json configuration
495
- *
496
491
  * @param configurations configurations to load
492
+ * @deprecated please use `updateConfigurations` instead, will be removed in Otter v12.
497
493
  */
498
494
  loadConfiguration(configurations) {
499
495
  this.configurationDevtools.loadConfiguration(configurations);
500
496
  }
501
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: ConfigurationDevtoolsConsoleService, deps: [{ token: OtterConfigurationDevtools }, { token: OTTER_CONFIGURATION_DEVTOOLS_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
502
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: ConfigurationDevtoolsConsoleService, providedIn: 'root' }); }
497
+ /**
498
+ * Replace N configurations in one shot
499
+ * @param configurations array of configurations to update
500
+ */
501
+ updateConfigurations(configurations) {
502
+ this.configurationDevtools.loadConfiguration(configurations);
503
+ }
504
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ConfigurationDevtoolsConsoleService, deps: [{ token: OtterConfigurationDevtools }, { token: OTTER_CONFIGURATION_DEVTOOLS_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
505
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ConfigurationDevtoolsConsoleService, providedIn: 'root' }); }
503
506
  }
504
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: ConfigurationDevtoolsConsoleService, decorators: [{
507
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ConfigurationDevtoolsConsoleService, decorators: [{
505
508
  type: Injectable,
506
509
  args: [{
507
510
  providedIn: 'root'
508
511
  }]
509
- }], ctorParameters: function () { return [{ type: OtterConfigurationDevtools }, { type: undefined, decorators: [{
512
+ }], ctorParameters: () => [{ type: OtterConfigurationDevtools }, { type: undefined, decorators: [{
510
513
  type: Optional
511
514
  }, {
512
515
  type: Inject,
513
516
  args: [OTTER_CONFIGURATION_DEVTOOLS_OPTIONS]
514
- }] }]; } });
517
+ }] }] });
515
518
 
516
519
  class ConfigurationDevtoolsMessageService {
517
520
  constructor(store, logger, configurationDevtools, options) {
@@ -532,7 +535,6 @@ class ConfigurationDevtoolsMessageService {
532
535
  }
533
536
  /**
534
537
  * Function to trigger a re-send a requested messages to the Otter Chrome DevTools extension
535
- *
536
538
  * @param only restricted list of messages to re-send
537
539
  */
538
540
  handleReEmitRequest(only) {
@@ -542,7 +544,6 @@ class ConfigurationDevtoolsMessageService {
542
544
  }
543
545
  /**
544
546
  * Function to handle the incoming messages from Otter Chrome DevTools extension
545
- *
546
547
  * @param event Event coming from the Otter Chrome DevTools extension
547
548
  * @param message
548
549
  */
@@ -590,25 +591,24 @@ class ConfigurationDevtoolsMessageService {
590
591
  ngOnDestroy() {
591
592
  this.subscriptions.unsubscribe();
592
593
  }
593
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: ConfigurationDevtoolsMessageService, deps: [{ token: i1.Store }, { token: i2.LoggerService }, { token: OtterConfigurationDevtools }, { token: OTTER_CONFIGURATION_DEVTOOLS_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
594
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: ConfigurationDevtoolsMessageService, providedIn: 'root' }); }
594
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ConfigurationDevtoolsMessageService, deps: [{ token: i1.Store }, { token: i2.LoggerService }, { token: OtterConfigurationDevtools }, { token: OTTER_CONFIGURATION_DEVTOOLS_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
595
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ConfigurationDevtoolsMessageService, providedIn: 'root' }); }
595
596
  }
596
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: ConfigurationDevtoolsMessageService, decorators: [{
597
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ConfigurationDevtoolsMessageService, decorators: [{
597
598
  type: Injectable,
598
599
  args: [{
599
600
  providedIn: 'root'
600
601
  }]
601
- }], ctorParameters: function () { return [{ type: i1.Store }, { type: i2.LoggerService }, { type: OtterConfigurationDevtools }, { type: undefined, decorators: [{
602
+ }], ctorParameters: () => [{ type: i1.Store }, { type: i2.LoggerService }, { type: OtterConfigurationDevtools }, { type: undefined, decorators: [{
602
603
  type: Optional
603
604
  }, {
604
605
  type: Inject,
605
606
  args: [OTTER_CONFIGURATION_DEVTOOLS_OPTIONS]
606
- }] }]; } });
607
+ }] }] });
607
608
 
608
609
  class ConfigurationDevtoolsModule {
609
610
  /**
610
611
  * Initialize Otter Devtools
611
- *
612
612
  * @param options
613
613
  */
614
614
  static instrument(options) {
@@ -622,10 +622,10 @@ class ConfigurationDevtoolsModule {
622
622
  ]
623
623
  };
624
624
  }
625
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: ConfigurationDevtoolsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
626
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.0", ngImport: i0, type: ConfigurationDevtoolsModule, imports: [StoreModule,
625
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ConfigurationDevtoolsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
626
+ /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.8", ngImport: i0, type: ConfigurationDevtoolsModule, imports: [StoreModule,
627
627
  ConfigurationStoreModule] }); }
628
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: ConfigurationDevtoolsModule, providers: [
628
+ /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ConfigurationDevtoolsModule, providers: [
629
629
  { provide: OTTER_CONFIGURATION_DEVTOOLS_OPTIONS, useValue: OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS },
630
630
  ConfigurationDevtoolsMessageService,
631
631
  ConfigurationDevtoolsConsoleService,
@@ -633,7 +633,7 @@ class ConfigurationDevtoolsModule {
633
633
  ], imports: [StoreModule,
634
634
  ConfigurationStoreModule] }); }
635
635
  }
636
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: ConfigurationDevtoolsModule, decorators: [{
636
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ConfigurationDevtoolsModule, decorators: [{
637
637
  type: NgModule,
638
638
  args: [{
639
639
  imports: [
@@ -650,17 +650,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImpor
650
650
  }] });
651
651
 
652
652
  class ConfigurationBaseServiceModule {
653
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: ConfigurationBaseServiceModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
654
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.0", ngImport: i0, type: ConfigurationBaseServiceModule, imports: [ConfigurationStoreModule, LoggerModule] }); }
655
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: ConfigurationBaseServiceModule, imports: [ConfigurationStoreModule, LoggerModule] }); }
653
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ConfigurationBaseServiceModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
654
+ /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.8", ngImport: i0, type: ConfigurationBaseServiceModule, imports: [ConfigurationStoreModule, LoggerModule] }); }
655
+ /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ConfigurationBaseServiceModule, imports: [ConfigurationStoreModule, LoggerModule] }); }
656
656
  }
657
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: ConfigurationBaseServiceModule, decorators: [{
657
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ConfigurationBaseServiceModule, decorators: [{
658
658
  type: NgModule,
659
659
  args: [{
660
660
  imports: [ConfigurationStoreModule, LoggerModule]
661
661
  }]
662
662
  }] });
663
663
 
664
+ const jsonStringifyDiff = (obj1, obj2) => JSON.stringify(obj1) === JSON.stringify(obj2);
664
665
  /**
665
666
  * Configuration service
666
667
  */
@@ -671,25 +672,22 @@ class ConfigurationBaseService {
671
672
  }
672
673
  /**
673
674
  * Update a specific component config or add it to the store if does not exist
674
- *
675
675
  * @param configuration to edit/add
676
676
  * @param configurationId Configuration ID
677
677
  */
678
- upsertConfiguration(configuration, configurationId = 'global') {
678
+ upsertConfiguration(configuration, configurationId = globalConfigurationId) {
679
679
  this.store.dispatch(upsertConfigurationEntity({ id: configurationId, configuration }));
680
680
  }
681
681
  /**
682
682
  * Update a specific component config
683
- *
684
683
  * @param configuration Partial config to edit
685
684
  * @param configurationId Configuration ID
686
685
  */
687
- updateConfiguration(configuration, configurationId = 'global') {
686
+ updateConfiguration(configuration, configurationId = globalConfigurationId) {
688
687
  this.store.dispatch(updateConfigurationEntity({ id: configurationId, configuration }));
689
688
  }
690
689
  /**
691
690
  * This function will get the configuration stored in the data attribute of the html's body tag
692
- *
693
691
  * @param configTagName Value used to identify the data attribute where the config is pushed in the index.html
694
692
  */
695
693
  getConfigFromBodyTag(configTagName = 'staticconfig') {
@@ -701,7 +699,6 @@ class ConfigurationBaseService {
701
699
  }
702
700
  /**
703
701
  * Transform the custom configuration in store configuration model
704
- *
705
702
  * @param customConfigObject Configuration object (extracted from body tag for static config or downloaded in case of dynamic config)
706
703
  */
707
704
  computeConfiguration(customConfigObject) {
@@ -709,12 +706,11 @@ class ConfigurationBaseService {
709
706
  }
710
707
  /**
711
708
  * Complete a stored configuration by adding the missing fields
712
- *
713
709
  * @param extension Configuration extension to be included in the store
714
710
  * @param configurationId Configuration ID to extend
715
711
  * @param forceUpdate Force update the configuration in the store
716
712
  */
717
- extendConfiguration(extension, configurationId = 'global', forceUpdate = false) {
713
+ extendConfiguration(extension, configurationId = globalConfigurationId, forceUpdate = false) {
718
714
  if (this.extendedConfiguration[configurationId] && !forceUpdate) {
719
715
  return;
720
716
  }
@@ -723,7 +719,6 @@ class ConfigurationBaseService {
723
719
  }
724
720
  /**
725
721
  * Operator to get the configuration from store for a given component and merge it with the global config
726
- *
727
722
  * @param id Id of the component
728
723
  * @param defaultValue Default value of the configuration
729
724
  */
@@ -738,39 +733,23 @@ class ConfigurationBaseService {
738
733
  }
739
734
  /**
740
735
  * Get an observable of the configuration from store for a given component and merge it with the global config + the config overrides from the rules engine
741
- *
742
736
  * @param id Id of the component
743
737
  */
744
738
  getConfig(id) {
745
- return combineLatest([
746
- this.store.pipe(select(selectConfigurationEntities), map((storedConfigs) => {
747
- const globalConfigId = 'global';
748
- const componentConfig = storedConfigs[id];
749
- const globalConfig = storedConfigs[globalConfigId];
750
- if (id !== globalConfigId && globalConfig) {
751
- return {
752
- ...globalConfig,
753
- ...(componentConfig || {})
754
- };
755
- }
756
- return componentConfig || null;
757
- }), distinctUntilChanged((prev, current) => JSON.stringify(prev) === JSON.stringify(current))), this.store.pipe(select(selectComponentOverrideConfig(id)))
758
- ]).pipe(map(([storeConfig, storeOverrideConfig]) => {
759
- return {
760
- ...storeConfig,
761
- ...storeOverrideConfig
762
- };
763
- }));
739
+ const globalConfig$ = this.store.pipe(select(selectGlobalConfiguration));
740
+ const componentConfig$ = id !== globalConfigurationId ? this.store.pipe(select(selectConfigurationForComponent({ id }))) : of({});
741
+ const overrideConfig$ = this.store.pipe(select(selectComponentOverrideConfig(id)));
742
+ return combineLatest([globalConfig$, componentConfig$, overrideConfig$]).pipe(map(([globalConfig, componentConfig, overrideConfig]) => ({ ...globalConfig, ...componentConfig, ...overrideConfig })), distinctUntilChanged(jsonStringifyDiff));
764
743
  }
765
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: ConfigurationBaseService, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Injectable }); }
766
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: ConfigurationBaseService, providedIn: ConfigurationBaseServiceModule }); }
744
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ConfigurationBaseService, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Injectable }); }
745
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ConfigurationBaseService, providedIn: ConfigurationBaseServiceModule }); }
767
746
  }
768
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImport: i0, type: ConfigurationBaseService, decorators: [{
747
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ConfigurationBaseService, decorators: [{
769
748
  type: Injectable,
770
749
  args: [{
771
750
  providedIn: ConfigurationBaseServiceModule
772
751
  }]
773
- }], ctorParameters: function () { return [{ type: i1.Store }]; } });
752
+ }], ctorParameters: () => [{ type: i1.Store }] });
774
753
 
775
754
  /**
776
755
  * Decorator to identify the configuration observer
@@ -834,5 +813,5 @@ class ConfigurationObserver {
834
813
  * Generated bundle index. Do not edit.
835
814
  */
836
815
 
837
- export { CONFIGURATION_REDUCER_TOKEN, CONFIGURATION_STORE_NAME, CONFIG_OVERRIDE_REDUCER_TOKEN, CONFIG_OVERRIDE_STORE_NAME, ConfigObserver, ConfigOverrideStoreModule, ConfigurationBaseService, ConfigurationBaseServiceModule, ConfigurationDevtoolsConsoleService, ConfigurationDevtoolsMessageService, ConfigurationDevtoolsModule, ConfigurationObserver, ConfigurationStoreModule, OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS, OTTER_CONFIGURATION_DEVTOOLS_OPTIONS, OtterConfigurationDevtools, clearConfigurationEntities, computeConfiguration, computeConfigurationName, configOverrideInitialState, configOverrideReducer, configOverrideReducerFeatures, configOverrideStorageDeserializer, configOverrideStorageSync, configurationAdapter, configurationInitialState, configurationReducer, configurationReducerFeatures, configurationStorageSync, getConfiguration, getDefaultConfigOverrideReducer, getDefaultConfigurationReducer, isConfigurationMessage, parseConfigurationName, selectAllConfiguration, selectComponentOverrideConfig, selectConfigOverride, selectConfigOverrideState, selectConfigurationEntities, selectConfigurationForComponent, selectConfigurationIds, selectConfigurationState, selectConfigurationTotal, setConfigOverride, setConfigurationEntities, updateConfigurationEntities, updateConfigurationEntity, upsertConfigurationEntities, upsertConfigurationEntity };
816
+ export { CONFIGURATION_REDUCER_TOKEN, CONFIGURATION_STORE_NAME, CONFIG_OVERRIDE_REDUCER_TOKEN, CONFIG_OVERRIDE_STORE_NAME, ConfigObserver, ConfigOverrideStoreModule, ConfigurationBaseService, ConfigurationBaseServiceModule, ConfigurationDevtoolsConsoleService, ConfigurationDevtoolsMessageService, ConfigurationDevtoolsModule, ConfigurationObserver, ConfigurationStoreModule, OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS, OTTER_CONFIGURATION_DEVTOOLS_OPTIONS, OtterConfigurationDevtools, clearConfigurationEntities, computeConfiguration, computeConfigurationName, configOverrideInitialState, configOverrideReducer, configOverrideReducerFeatures, configOverrideStorageDeserializer, configOverrideStorageSync, configurationAdapter, configurationInitialState, configurationReducer, configurationReducerFeatures, configurationStorageSync, getConfiguration, getDefaultConfigOverrideReducer, getDefaultConfigurationReducer, globalConfigurationId, isConfigurationMessage, parseConfigurationName, selectAllConfiguration, selectComponentOverrideConfig, selectConfigOverride, selectConfigOverrideState, selectConfigurationEntities, selectConfigurationForComponent, selectConfigurationIds, selectConfigurationState, selectConfigurationTotal, selectGlobalConfiguration, setConfigOverride, setConfigurationEntities, updateConfigurationEntities, updateConfigurationEntity, upsertConfigurationEntities, upsertConfigurationEntity };
838
817
  //# sourceMappingURL=o3r-configuration.mjs.map