monkey-front-core 0.0.478 → 0.0.480

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.
@@ -3,7 +3,7 @@ import { Component, Input, NgModule, Pipe, ViewEncapsulation, Injectable, EventE
3
3
  import * as i1 from 'monkey-style-guide';
4
4
  import { MonkeyButtonModule, MonkeyModalModule, MonkeyIconModule, MonkeyInputModule, MonkeyRadioButtonModule, MonkeyOptionModule, MonkeyUtils, MonkeyStyleGuideModule, MonkeyStyleGuideModalService, MonkeyStyleGuideSettingsService, MonkeyStyleGuideSnackbarService } from 'monkey-style-guide';
5
5
  import * as i2 from '@angular/common';
6
- import { CommonModule, formatNumber, CurrencyPipe } from '@angular/common';
6
+ import { CommonModule, formatNumber, CurrencyPipe, registerLocaleData } from '@angular/common';
7
7
  import * as i1$1 from '@ngx-translate/core';
8
8
  import { TranslateModule, TranslateService } from '@ngx-translate/core';
9
9
  import * as moment_ from 'moment';
@@ -23,6 +23,9 @@ import { __awaiter, __decorate } from 'tslib';
23
23
  import * as i2$3 from '@ngrx/store';
24
24
  import { createAction, props, INIT, createReducer, on, createFeatureSelector, createSelector, Store, StoreModule } from '@ngrx/store';
25
25
  import { createEntityAdapter } from '@ngrx/entity';
26
+ import esCL from '@angular/common/locales/es-CL';
27
+ import esMX from '@angular/common/locales/es-MX';
28
+ import ptBr from '@angular/common/locales/pt';
26
29
  import { datadogRum } from '@datadog/browser-rum';
27
30
  import * as i1$5 from '@angular/service-worker';
28
31
  import { ServiceWorkerModule } from '@angular/service-worker';
@@ -3443,143 +3446,148 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
3443
3446
  }], ctorParameters: function () { return []; } });
3444
3447
 
3445
3448
  class MonkeyEcxi18nConfigService extends MonkeyEcxCommonsService {
3446
- constructor(monkeyecxService, translateService, monkeyecxCookieStorageService, monkeyecxErrorConfigService) {
3447
- super(monkeyecxService);
3449
+ constructor(monkeyecxService, tokenStorage, translateService, monkeyecxErrorConfigService) {
3450
+ super(monkeyecxService, tokenStorage);
3448
3451
  this.translateService = translateService;
3449
- this.monkeyecxCookieStorageService = monkeyecxCookieStorageService;
3450
3452
  this.monkeyecxErrorConfigService = monkeyecxErrorConfigService;
3451
- this.translateService.addLangs(['pt-BR', 'en-US']);
3452
- this.translateService.setDefaultLang('pt-BR');
3453
- this.translateService.use('pt-BR');
3454
- }
3455
- apply(params, environment, change = false) {
3456
- this.applyInternal(environment, params, change);
3457
- this.applyExternal(params, environment, change);
3458
3453
  }
3459
- applyInternal(environment, params = {}, change = false) {
3454
+ loadAuth(environment, lang) {
3460
3455
  var _a;
3461
3456
  return __awaiter(this, void 0, void 0, function* () {
3462
- const { monkeyecxService, monkeyecxErrorConfigService, monkeyecxCookieStorageService } = this;
3463
- let lang = '';
3464
- let i18n = { lang: '' };
3465
3457
  try {
3466
- if (!change) {
3467
- const cookie = monkeyecxCookieStorageService.getCookie('monkey-app-locale');
3468
- if (cookie) {
3469
- i18n = JSON.parse(atob(cookie));
3470
- }
3471
- }
3472
- else {
3473
- i18n = {
3474
- lang: (_a = params === null || params === void 0 ? void 0 : params.i18n) === null || _a === void 0 ? void 0 : _a.lang
3475
- };
3476
- }
3458
+ const url = MonkeyEcxUtils.replaceVariables(environment.urli18nAssets, {
3459
+ name: 'auth',
3460
+ lang
3461
+ });
3462
+ const resp = yield ((_a = this.monkeyecxService) === null || _a === void 0 ? void 0 : _a.get(url).pipe(take(1)).toPromise());
3463
+ this.translateService.setTranslation(lang, resp.data, true);
3477
3464
  }
3478
3465
  catch (e) {
3479
- // not to do
3466
+ console.error(`loadAuth i18n ${lang} not found!`);
3467
+ this.monkeyecxErrorConfigService.apply('i18n');
3480
3468
  }
3481
- lang = (i18n === null || i18n === void 0 ? void 0 : i18n.lang) || `${(environment === null || environment === void 0 ? void 0 : environment.lang) || 'pt-BR'}`;
3469
+ });
3470
+ }
3471
+ loadAlerts(environment, lang) {
3472
+ var _a;
3473
+ return __awaiter(this, void 0, void 0, function* () {
3482
3474
  try {
3483
- const currenti18n = yield (monkeyecxService === null || monkeyecxService === void 0 ? void 0 : monkeyecxService.get(`${environment.localAssets}/i18n/${lang}.json`).pipe(take(1)).toPromise());
3484
- const { data } = currenti18n;
3485
- this.translateService.setTranslation('pt-BR', data, true);
3486
- this.translateService.setTranslation(lang, data, true);
3487
- this.translateService.use(lang);
3475
+ const url = MonkeyEcxUtils.replaceVariables(environment.urli18nAssets, {
3476
+ name: 'alerts',
3477
+ lang
3478
+ });
3479
+ const resp = yield ((_a = this.monkeyecxService) === null || _a === void 0 ? void 0 : _a.get(url).pipe(take(1)).toPromise());
3480
+ this.translateService.setTranslation(lang, resp.data, true);
3488
3481
  }
3489
- catch (err) {
3490
- console.error(`i18n ${lang} not found!`);
3491
- monkeyecxErrorConfigService.apply('i18n');
3492
- throwError(err);
3482
+ catch (e) {
3483
+ console.error(`loadAlerts i18n ${lang} not found!`);
3484
+ this.monkeyecxErrorConfigService.apply('i18n');
3493
3485
  }
3486
+ });
3487
+ }
3488
+ loadShared(environment, lang) {
3489
+ var _a;
3490
+ return __awaiter(this, void 0, void 0, function* () {
3494
3491
  try {
3495
- const pathName = ['alerts', 'auth', 'register', 'shared'];
3496
- const services = pathName === null || pathName === void 0 ? void 0 : pathName.map((name) => {
3497
- const url = MonkeyEcxUtils.replaceVariables(environment.urli18nAssets, {
3498
- name, lang
3499
- });
3500
- return monkeyecxService === null || monkeyecxService === void 0 ? void 0 : monkeyecxService.get(url).pipe(take(1)).toPromise();
3501
- });
3502
- const externali18nData = yield Promise.all(services);
3503
- externali18nData === null || externali18nData === void 0 ? void 0 : externali18nData.forEach((config) => {
3504
- const { data } = config;
3505
- this.translateService.setTranslation('pt-BR', data, true);
3506
- this.translateService.setTranslation(lang, data, true);
3492
+ const url = MonkeyEcxUtils.replaceVariables(environment.urli18nAssets, {
3493
+ name: 'shared',
3494
+ lang
3507
3495
  });
3496
+ const resp = yield ((_a = this.monkeyecxService) === null || _a === void 0 ? void 0 : _a.get(url).pipe(take(1)).toPromise());
3497
+ this.translateService.setTranslation(lang, resp.data, true);
3508
3498
  }
3509
- catch (err) {
3510
- // not to do
3499
+ catch (e) {
3500
+ console.error(`loadShared i18n ${lang} not found!`);
3501
+ this.monkeyecxErrorConfigService.apply('i18n');
3511
3502
  }
3512
3503
  });
3513
3504
  }
3514
- applyExternal(params, environment, change = false) {
3515
- var _a, _b;
3505
+ loadRegister(environment, lang) {
3506
+ var _a;
3516
3507
  return __awaiter(this, void 0, void 0, function* () {
3517
- const { monkeyecxCookieStorageService, monkeyecxErrorConfigService, monkeyecxService } = this;
3518
- let { i18n } = params;
3519
- const cookie = monkeyecxCookieStorageService.getCookie('monkey-app-locale');
3520
- if (cookie && !change) {
3521
- i18n = JSON.parse(atob(cookie));
3508
+ try {
3509
+ const url = MonkeyEcxUtils.replaceVariables(environment.urli18nAssets, {
3510
+ name: 'register',
3511
+ lang
3512
+ });
3513
+ const resp = yield ((_a = this.monkeyecxService) === null || _a === void 0 ? void 0 : _a.get(url).pipe(take(1)).toPromise());
3514
+ this.translateService.setTranslation(lang, resp.data, true);
3522
3515
  }
3523
- else {
3524
- monkeyecxCookieStorageService.setCookie('monkey-app-locale', btoa(JSON.stringify(i18n)), environment);
3516
+ catch (e) {
3517
+ console.error(`loadRegister i18n ${lang} not found!`);
3518
+ this.monkeyecxErrorConfigService.apply('i18n');
3525
3519
  }
3520
+ });
3521
+ }
3522
+ loadInternal(environment, lang) {
3523
+ var _a;
3524
+ return __awaiter(this, void 0, void 0, function* () {
3526
3525
  try {
3527
- const lang = `${(i18n === null || i18n === void 0 ? void 0 : i18n.lang) || 'pt-BR'}`;
3528
- const currentExternali18n = (_a = params === null || params === void 0 ? void 0 : params.externali18n) === null || _a === void 0 ? void 0 : _a[`${lang}`];
3529
- let data = {};
3530
- if (currentExternali18n) {
3531
- data = {
3532
- EXTERNAL: currentExternali18n
3533
- };
3534
- }
3535
- this.translateService.setTranslation('pt-BR', data, true);
3536
- this.translateService.setTranslation(`${lang}`, data, true);
3537
- this.translateService.use(`${lang}`);
3526
+ const url = `${environment.localAssets}/i18n/${lang}.json`;
3527
+ const resp = yield ((_a = this.monkeyecxService) === null || _a === void 0 ? void 0 : _a.get(url).pipe(take(1)).toPromise());
3528
+ this.translateService.setTranslation(lang, resp.data, true);
3538
3529
  }
3539
- catch (err) {
3540
- console.error(`i18n ${i18n === null || i18n === void 0 ? void 0 : i18n.lang} not found!`);
3541
- monkeyecxErrorConfigService.apply('i18n');
3542
- throwError(err);
3530
+ catch (e) {
3531
+ console.error(`loadInternal i18n ${lang} not found!`);
3532
+ this.monkeyecxErrorConfigService.apply('i18n');
3543
3533
  }
3534
+ });
3535
+ }
3536
+ apply(environment) {
3537
+ var _a, _b;
3538
+ return __awaiter(this, void 0, void 0, function* () {
3539
+ let lang = ((_a = environment === null || environment === void 0 ? void 0 : environment.locale) === null || _a === void 0 ? void 0 : _a.lang) || 'pt-BR';
3544
3540
  try {
3545
- const externali18nPaths = ((_b = params === null || params === void 0 ? void 0 : params.i18n) === null || _b === void 0 ? void 0 : _b.paths) || [];
3546
- const services = externali18nPaths === null || externali18nPaths === void 0 ? void 0 : externali18nPaths.map((url) => {
3547
- return monkeyecxService === null || monkeyecxService === void 0 ? void 0 : monkeyecxService.get(`${url}/${i18n === null || i18n === void 0 ? void 0 : i18n.lang}.json`).pipe(take(1)).toPromise();
3548
- });
3549
- if (!(services === null || services === void 0 ? void 0 : services.length))
3550
- return;
3551
- const externali18nData = yield Promise.all(services);
3552
- externali18nData === null || externali18nData === void 0 ? void 0 : externali18nData.forEach((config) => {
3553
- const { lang } = config;
3554
- const { data } = config;
3555
- this.translateService.setTranslation('pt-BR', data, true);
3556
- this.translateService.setTranslation(lang, data, true);
3557
- });
3541
+ const me = yield ((_b = this.tokenStorage) === null || _b === void 0 ? void 0 : _b.getMe());
3542
+ lang = (me === null || me === void 0 ? void 0 : me.locale) || lang;
3558
3543
  }
3559
- catch (err) {
3544
+ catch (e) {
3560
3545
  // not to do
3561
3546
  }
3547
+ if (lang === 'es-CL') {
3548
+ registerLocaleData(esCL);
3549
+ }
3550
+ else if (lang === 'es-MX') {
3551
+ registerLocaleData(esMX);
3552
+ }
3553
+ else {
3554
+ registerLocaleData(ptBr);
3555
+ }
3556
+ yield this.loadAuth(environment, lang);
3557
+ yield this.loadInternal(environment, lang);
3558
+ this.loadAlerts(environment, lang);
3559
+ this.loadShared(environment, lang);
3560
+ this.loadRegister(environment, lang);
3561
+ this.translateService.setDefaultLang(lang);
3562
+ this.translateService.use(lang);
3562
3563
  });
3563
3564
  }
3565
+ applyExternal(params, lang) {
3566
+ var _a;
3567
+ try {
3568
+ const currentExternali18n = (_a = params === null || params === void 0 ? void 0 : params.externali18n) === null || _a === void 0 ? void 0 : _a[`${lang}`];
3569
+ let data = {};
3570
+ if (currentExternali18n) {
3571
+ data = {
3572
+ EXTERNAL: currentExternali18n
3573
+ };
3574
+ }
3575
+ this.translateService.setTranslation(lang, data, true);
3576
+ }
3577
+ catch (e) {
3578
+ console.error(`loadExternal i18n ${lang} not found!`);
3579
+ this.monkeyecxErrorConfigService.apply('i18n');
3580
+ }
3581
+ }
3564
3582
  }
3565
- 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 });
3583
+ MonkeyEcxi18nConfigService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxi18nConfigService, deps: [{ token: MonkeyEcxService }, { token: MonkeyEcxTokenStorageService }, { token: i1$1.TranslateService }, { token: MonkeyEcxErrorConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
3566
3584
  MonkeyEcxi18nConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxi18nConfigService, providedIn: 'root' });
3567
- __decorate([
3568
- MonkeyEcxCoreService({
3569
- httpResponse: {
3570
- httpCodeIgnore: [404]
3571
- },
3572
- requestInProgress: {
3573
- showProgress: false
3574
- }
3575
- })
3576
- ], MonkeyEcxi18nConfigService.prototype, "applyInternal", null);
3577
3585
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxi18nConfigService, decorators: [{
3578
3586
  type: Injectable,
3579
3587
  args: [{
3580
3588
  providedIn: 'root'
3581
3589
  }]
3582
- }], ctorParameters: function () { return [{ type: MonkeyEcxService }, { type: i1$1.TranslateService }, { type: MonkeyEcxCookieStorageService }, { type: MonkeyEcxErrorConfigService }]; }, propDecorators: { applyInternal: [] } });
3590
+ }], ctorParameters: function () { return [{ type: MonkeyEcxService }, { type: MonkeyEcxTokenStorageService }, { type: i1$1.TranslateService }, { type: MonkeyEcxErrorConfigService }]; } });
3583
3591
 
3584
3592
  class MonkeyEcxLogsConfigService {
3585
3593
  apply(params, configBootstrap, environment, identifyCode) {
@@ -3911,23 +3919,21 @@ class MonkeyEcxConfigService extends MonkeyEcxCommonsService {
3911
3919
  }
3912
3920
  getSettings(monkeyecxCode, configBootstrap, callback, environment, identifyCode) {
3913
3921
  return __awaiter(this, void 0, void 0, function* () {
3914
- const { monkeyecxSecurityConsoleConfigService, monkeyecxServiceWorkerConfigService, monkeyecxMaintenanceConfigService, monkeyStyleGuideSettingsService, monkeyecxi18nConfigService, monkeyGTMConfigService, getWhiteLabel } = this;
3922
+ const { monkeyecxSecurityConsoleConfigService, monkeyecxServiceWorkerConfigService, monkeyecxMaintenanceConfigService, monkeyStyleGuideSettingsService, monkeyGTMConfigService, getWhiteLabel, monkeyecxi18nConfigService } = this;
3915
3923
  monkeyecxServiceWorkerConfigService.apply(configBootstrap);
3916
3924
  monkeyecxMaintenanceConfigService.apply(configBootstrap);
3917
3925
  monkeyecxSecurityConsoleConfigService.apply();
3918
3926
  monkeyGTMConfigService.apply(environment);
3919
- // await monkeyecxi18nConfigService.applyInternal(environment);
3920
3927
  const url = `${environment.urlAssets}/${monkeyecxCode.toLowerCase()}`;
3928
+ yield monkeyecxi18nConfigService.apply(environment);
3921
3929
  monkeyStyleGuideSettingsService.bootstrap(`${url}/monkey-style-guide-settings.json`, getWhiteLabel.bind(this, configBootstrap, callback, environment, identifyCode, url));
3922
3930
  });
3923
3931
  }
3924
3932
  getWhiteLabel(configBootstrap, callback, environment, identifyCode, url) {
3925
3933
  var _a;
3926
- const { monkeyecxService, configSubject$, monkeyecxLogsConfigService, monkeyecxErrorConfigService, monkeyEcxFeatureToggleService,
3927
- // monkeyecxi18nConfigService,
3928
- monkeyEcxAlertsConfigService } = this;
3934
+ const { monkeyecxService, configSubject$, monkeyecxLogsConfigService, monkeyecxErrorConfigService, monkeyEcxFeatureToggleService, monkeyecxi18nConfigService, monkeyEcxAlertsConfigService } = this;
3929
3935
  (_a = monkeyecxService === null || monkeyecxService === void 0 ? void 0 : monkeyecxService.get(`${url}/white-label.json`)) === null || _a === void 0 ? void 0 : _a.subscribe((config) => __awaiter(this, void 0, void 0, function* () {
3930
- // await monkeyecxi18nConfigService.applyExternal(config, environment);
3936
+ monkeyecxi18nConfigService.applyExternal(config, environment);
3931
3937
  monkeyecxLogsConfigService.apply(config, configBootstrap, environment, identifyCode);
3932
3938
  monkeyEcxFeatureToggleService.apply(configSubject$, environment);
3933
3939
  monkeyEcxAlertsConfigService.apply(config);