monkey-front-core 0.0.442 → 0.0.444

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.
@@ -3307,14 +3307,36 @@ class MonkeyEcxi18nConfigService extends MonkeyEcxCommonsService {
3307
3307
  this.translateService.setDefaultLang('pt-BR');
3308
3308
  this.translateService.use('pt-BR');
3309
3309
  }
3310
- async apply(environment) {
3310
+ apply(params, environment, change = false) {
3311
+ this.applyInternal(environment);
3312
+ this.applyExternal(params, environment, change);
3313
+ }
3314
+ async applyInternal(environment) {
3311
3315
  const { monkeyecxService, monkeyecxErrorConfigService } = this;
3312
3316
  const lang = `${environment?.lang || 'pt-BR'}`;
3317
+ try {
3318
+ const currenti18n = await monkeyecxService
3319
+ ?.get(`${environment.localAssets}/i18n/${lang}.json`)
3320
+ .pipe(take(1))
3321
+ .toPromise();
3322
+ const { data } = currenti18n;
3323
+ this.translateService.setTranslation('pt-BR', data, true);
3324
+ this.translateService.setTranslation(lang, data, true);
3325
+ this.translateService.use(lang);
3326
+ }
3327
+ catch (err) {
3328
+ console.error(`i18n ${lang} not found!`);
3329
+ monkeyecxErrorConfigService.apply('i18n');
3330
+ throwError(err);
3331
+ }
3313
3332
  try {
3314
3333
  const pathName = ['alerts', 'auth', 'register', 'shared'];
3315
3334
  const services = pathName?.map((name) => {
3335
+ const url = MonkeyEcxUtils.replaceVariables(environment.urli18nAssets, {
3336
+ name, lang
3337
+ });
3316
3338
  return monkeyecxService
3317
- ?.get(`${environment.urlAssets}/data/i18n/${name}/${lang}.json`)
3339
+ ?.get(url)
3318
3340
  .pipe(take(1))
3319
3341
  .toPromise();
3320
3342
  });
@@ -3328,21 +3350,6 @@ class MonkeyEcxi18nConfigService extends MonkeyEcxCommonsService {
3328
3350
  catch (err) {
3329
3351
  // not to do
3330
3352
  }
3331
- try {
3332
- const currenti18n = await monkeyecxService
3333
- ?.get(`${environment.localAssets}/i18n/${lang}.json`)
3334
- .pipe(take(1))
3335
- .toPromise();
3336
- const { data } = currenti18n;
3337
- this.translateService.setTranslation('pt-BR', data, true);
3338
- this.translateService.setTranslation(lang, data, true);
3339
- this.translateService.use(lang);
3340
- }
3341
- catch (err) {
3342
- console.error(`i18n ${lang} not found!`);
3343
- monkeyecxErrorConfigService.apply('i18n');
3344
- throwError(err);
3345
- }
3346
3353
  }
3347
3354
  async applyExternal(params, environment, change = false) {
3348
3355
  const { monkeyecxCookieStorageService, monkeyecxErrorConfigService, monkeyecxService } = this;
@@ -3354,6 +3361,24 @@ class MonkeyEcxi18nConfigService extends MonkeyEcxCommonsService {
3354
3361
  else {
3355
3362
  monkeyecxCookieStorageService.setCookie('monkey-app-locale', btoa(JSON.stringify(i18n)), environment);
3356
3363
  }
3364
+ try {
3365
+ const lang = `${i18n?.lang || 'pt-BR'}`;
3366
+ const currentExternali18n = params?.externali18n?.[`${lang}`];
3367
+ let data = {};
3368
+ if (currentExternali18n) {
3369
+ data = {
3370
+ EXTERNAL: currentExternali18n
3371
+ };
3372
+ }
3373
+ this.translateService.setTranslation('pt-BR', data, true);
3374
+ this.translateService.setTranslation(`${lang}`, data, true);
3375
+ this.translateService.use(`${lang}`);
3376
+ }
3377
+ catch (err) {
3378
+ console.error(`i18n ${i18n?.lang} not found!`);
3379
+ monkeyecxErrorConfigService.apply('i18n');
3380
+ throwError(err);
3381
+ }
3357
3382
  try {
3358
3383
  const externali18nPaths = params?.i18n?.paths || [];
3359
3384
  const services = externali18nPaths?.map((url) => {
@@ -3372,24 +3397,6 @@ class MonkeyEcxi18nConfigService extends MonkeyEcxCommonsService {
3372
3397
  catch (err) {
3373
3398
  // not to do
3374
3399
  }
3375
- try {
3376
- const lang = `${i18n?.lang || 'pt-BR'}`;
3377
- const currentExternali18n = params?.externali18n?.[`${lang}`];
3378
- let data = {};
3379
- if (currentExternali18n) {
3380
- data = {
3381
- EXTERNAL: currentExternali18n
3382
- };
3383
- }
3384
- this.translateService.setTranslation('pt-BR', data, true);
3385
- this.translateService.setTranslation(lang, data, true);
3386
- this.translateService.use(lang);
3387
- }
3388
- catch (err) {
3389
- console.error(`i18n ${i18n?.lang} not found!`);
3390
- monkeyecxErrorConfigService.apply('i18n');
3391
- throwError(err);
3392
- }
3393
3400
  }
3394
3401
  }
3395
3402
  MonkeyEcxi18nConfigService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxi18nConfigService, deps: [{ token: MonkeyEcxService }, { token: i1$1.TranslateService }, { token: MonkeyEcxCookieStorageService }, { token: MonkeyEcxErrorConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -3403,13 +3410,13 @@ __decorate([
3403
3410
  showProgress: false
3404
3411
  }
3405
3412
  })
3406
- ], MonkeyEcxi18nConfigService.prototype, "apply", null);
3413
+ ], MonkeyEcxi18nConfigService.prototype, "applyInternal", null);
3407
3414
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxi18nConfigService, decorators: [{
3408
3415
  type: Injectable,
3409
3416
  args: [{
3410
3417
  providedIn: 'root'
3411
3418
  }]
3412
- }], ctorParameters: function () { return [{ type: MonkeyEcxService }, { type: i1$1.TranslateService }, { type: MonkeyEcxCookieStorageService }, { type: MonkeyEcxErrorConfigService }]; }, propDecorators: { apply: [] } });
3419
+ }], ctorParameters: function () { return [{ type: MonkeyEcxService }, { type: i1$1.TranslateService }, { type: MonkeyEcxCookieStorageService }, { type: MonkeyEcxErrorConfigService }]; }, propDecorators: { applyInternal: [] } });
3413
3420
 
3414
3421
  class MonkeyEcxLogsConfigService {
3415
3422
  apply(params, configBootstrap, environment, identifyCode) {
@@ -3731,29 +3738,26 @@ class MonkeyEcxConfigService extends MonkeyEcxCommonsService {
3731
3738
  this.configSubject$ = new BehaviorSubject({});
3732
3739
  this.configBootstrapSubject$ = new BehaviorSubject({});
3733
3740
  }
3734
- async internalValidations(...args) {
3735
- const { monkeyecxServiceWorkerConfigService, monkeyecxSecurityConsoleConfigService, monkeyecxMaintenanceConfigService } = this;
3736
- const configBootstrap = args[0];
3737
- const callback = args[1];
3738
- monkeyecxSecurityConsoleConfigService.apply();
3741
+ async getSettings(monkeyecxCode, configBootstrap, callback, environment, identifyCode) {
3742
+ const { monkeyecxSecurityConsoleConfigService, monkeyecxServiceWorkerConfigService, monkeyecxMaintenanceConfigService, monkeyStyleGuideSettingsService, monkeyecxi18nConfigService, monkeyGTMConfigService, getWhiteLabel } = this;
3739
3743
  monkeyecxServiceWorkerConfigService.apply(configBootstrap);
3740
3744
  monkeyecxMaintenanceConfigService.apply(configBootstrap);
3741
- callback(configBootstrap);
3742
- }
3743
- getWhiteLabelSettings(monkeyecxCode, configBootstrap, callback, environment, identifyCode) {
3744
- const { monkeyecxService, configSubject$, monkeyStyleGuideSettingsService, monkeyecxLogsConfigService, monkeyecxErrorConfigService, monkeyEcxFeatureToggleService, monkeyGTMConfigService, monkeyecxi18nConfigService, monkeyEcxAlertsConfigService, internalValidations } = this;
3745
+ monkeyecxSecurityConsoleConfigService.apply();
3746
+ monkeyGTMConfigService.apply(environment);
3747
+ await monkeyecxi18nConfigService.applyInternal(environment);
3745
3748
  const url = `${environment.urlAssets}/${monkeyecxCode.toLowerCase()}`;
3746
- monkeyecxi18nConfigService.apply(environment);
3747
- monkeyecxService
3748
- ?.get(`${url}/white-label.json`)
3749
- ?.subscribe((config) => {
3750
- monkeyecxi18nConfigService.applyExternal(config, environment);
3749
+ monkeyStyleGuideSettingsService.bootstrap(`${url}/monkey-style-guide-settings.json`, getWhiteLabel.bind(this, configBootstrap, callback, environment, identifyCode, url));
3750
+ }
3751
+ getWhiteLabel(configBootstrap, callback, environment, identifyCode, url) {
3752
+ const { monkeyecxService, configSubject$, monkeyecxLogsConfigService, monkeyecxErrorConfigService, monkeyEcxFeatureToggleService, monkeyecxi18nConfigService, monkeyEcxAlertsConfigService } = this;
3753
+ monkeyecxService?.get(`${url}/white-label.json`)?.subscribe(async (config) => {
3754
+ await monkeyecxi18nConfigService.applyExternal(config, environment);
3751
3755
  monkeyecxLogsConfigService.apply(config, configBootstrap, environment, identifyCode);
3752
3756
  monkeyEcxFeatureToggleService.apply(configSubject$, environment);
3753
- monkeyGTMConfigService.apply(environment);
3754
3757
  monkeyEcxAlertsConfigService.apply(config);
3755
- monkeyStyleGuideSettingsService.bootstrap(`${url}/monkey-style-guide-settings.json`, internalValidations.bind(this, configBootstrap, callback));
3756
3758
  configSubject$.next(config);
3759
+ if (callback)
3760
+ callback();
3757
3761
  }, (err) => {
3758
3762
  monkeyecxErrorConfigService.apply('theme');
3759
3763
  console.error('Program Configuration not found!');
@@ -3766,11 +3770,10 @@ class MonkeyEcxConfigService extends MonkeyEcxCommonsService {
3766
3770
  ?.get(`${environment.bootstrapAssets}`, {
3767
3771
  observe: 'response'
3768
3772
  })
3769
- ?.subscribe((resp) => {
3770
- const { headers, body } = resp;
3773
+ ?.subscribe(({ headers, body }) => {
3771
3774
  const monkeyCode = headers.get('monkey-code') || monkeyecxCode;
3772
3775
  if (monkeyCode) {
3773
- this.getWhiteLabelSettings(monkeyCode, body, callback, environment, identifyCode);
3776
+ this.getSettings(monkeyCode, body, callback, environment, identifyCode);
3774
3777
  configBootstrapSubject$.next(body);
3775
3778
  }
3776
3779
  else {