monkey-front-core 0.0.302 → 0.0.304

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.
@@ -19,14 +19,14 @@ import { NG_VALUE_ACCESSOR } from '@angular/forms';
19
19
  import { TemplatePortal } from '@angular/cdk/portal';
20
20
  import * as i1$4 from '@angular/cdk/overlay';
21
21
  import { OverlayModule } from '@angular/cdk/overlay';
22
+ import * as i2$3 from '@ngrx/store';
23
+ import { createAction, props, INIT, UPDATE, createReducer, on, createFeatureSelector, createSelector, StoreModule } from '@ngrx/store';
24
+ import { createEntityAdapter } from '@ngrx/entity';
22
25
  import { __decorate } from 'tslib';
23
26
  import { datadogRum } from '@datadog/browser-rum';
24
27
  import * as i1$5 from '@angular/service-worker';
25
28
  import { ServiceWorkerModule } from '@angular/service-worker';
26
29
  import { initialize } from 'launchdarkly-js-client-sdk';
27
- import * as i6 from '@ngrx/store';
28
- import { createAction, props, INIT, UPDATE, createReducer, on, createFeatureSelector, createSelector, StoreModule } from '@ngrx/store';
29
- import { createEntityAdapter } from '@ngrx/entity';
30
30
 
31
31
  class AlertsComponent {
32
32
  constructor(modalService) {
@@ -2431,6 +2431,158 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
2431
2431
  args: ['monkeyecxPopoverHeight']
2432
2432
  }] } });
2433
2433
 
2434
+ const clear = createAction('[MECX Core Storage] Clear All');
2435
+ const create = createAction('[MECX Core Storage] Create', props());
2436
+ const deleteOne = createAction('[MECX Core Storage] Delete One', props());
2437
+ const updateControl = createAction('[MECX Core Storage] Update Control', props());
2438
+ const updateOne = createAction('[MECX Core Storage] Update One', props());
2439
+
2440
+ var monkeyecxStorage_actions = /*#__PURE__*/Object.freeze({
2441
+ __proto__: null,
2442
+ clear: clear,
2443
+ create: create,
2444
+ deleteOne: deleteOne,
2445
+ updateControl: updateControl,
2446
+ updateOne: updateOne
2447
+ });
2448
+
2449
+ var index$3 = /*#__PURE__*/Object.freeze({
2450
+ __proto__: null,
2451
+ monkeyecxStorage: monkeyecxStorage_actions
2452
+ });
2453
+
2454
+ const seederReducer = (keys) => {
2455
+ return (reducer) => {
2456
+ return (state, action) => {
2457
+ const handledState = reducer(state, action);
2458
+ if (action.type === INIT || action.type === UPDATE) {
2459
+ const storageValue = localStorage.getItem('mecx-store');
2460
+ if (storageValue) {
2461
+ try {
2462
+ const handled = {
2463
+ ...handledState,
2464
+ ...JSON.parse(atob(storageValue))
2465
+ };
2466
+ return handled;
2467
+ }
2468
+ catch {
2469
+ localStorage.removeItem('mecx-store');
2470
+ }
2471
+ }
2472
+ }
2473
+ let data = handledState;
2474
+ try {
2475
+ keys.forEach((key) => {
2476
+ data = {
2477
+ ...data,
2478
+ [key]: handledState[key]
2479
+ };
2480
+ });
2481
+ localStorage.setItem('mecx-store', btoa(JSON.stringify(data)));
2482
+ }
2483
+ catch (e) {
2484
+ localStorage.removeItem('mecx-store');
2485
+ }
2486
+ return data || handledState;
2487
+ };
2488
+ };
2489
+ };
2490
+
2491
+ var monkeyecxSeeder_reducer = /*#__PURE__*/Object.freeze({
2492
+ __proto__: null,
2493
+ seederReducer: seederReducer
2494
+ });
2495
+
2496
+ const featureKey = 'mecx-core-storage';
2497
+ const adapter = createEntityAdapter({
2498
+ selectId: (item) => {
2499
+ return item.username;
2500
+ }
2501
+ });
2502
+ const initialState = adapter.getInitialState({
2503
+ control: {
2504
+ isLoading: false
2505
+ },
2506
+ error: null
2507
+ });
2508
+ const reducer = createReducer(initialState, on(clear, (state) => {
2509
+ return adapter.removeAll(state);
2510
+ }), on(create, (state, action) => {
2511
+ return adapter.upsertMany(action.data, {
2512
+ ...state
2513
+ });
2514
+ }), on(updateControl, (state, action) => {
2515
+ return {
2516
+ ...state,
2517
+ control: {
2518
+ ...state.control,
2519
+ ...action.data
2520
+ }
2521
+ };
2522
+ }), on(updateOne, (state, action) => {
2523
+ const { username } = action.data;
2524
+ return adapter.upsertOne({ ...action.data, username }, {
2525
+ ...state
2526
+ });
2527
+ }), on(deleteOne, (state, action) => {
2528
+ const { username } = action.data;
2529
+ return adapter.removeOne(username, state);
2530
+ }));
2531
+ const { selectAll: selectAll$1, selectEntities, selectIds, selectTotal } = adapter.getSelectors();
2532
+
2533
+ var monkeyecxStorage_reducer = /*#__PURE__*/Object.freeze({
2534
+ __proto__: null,
2535
+ featureKey: featureKey,
2536
+ adapter: adapter,
2537
+ initialState: initialState,
2538
+ reducer: reducer,
2539
+ selectAll: selectAll$1,
2540
+ selectEntities: selectEntities,
2541
+ selectIds: selectIds,
2542
+ selectTotal: selectTotal
2543
+ });
2544
+
2545
+ var index$2 = /*#__PURE__*/Object.freeze({
2546
+ __proto__: null,
2547
+ fromMonkeyecxSeeder: monkeyecxSeeder_reducer,
2548
+ fromMonkeyecxStorage: monkeyecxStorage_reducer
2549
+ });
2550
+
2551
+ const selectState = createFeatureSelector(featureKey);
2552
+ const selectAll = createSelector(selectState, selectAll$1);
2553
+ const select = (props) => {
2554
+ return createSelector(selectAll, (entities) => {
2555
+ return entities.filter((_) => {
2556
+ return _.username === props.username;
2557
+ });
2558
+ });
2559
+ };
2560
+ const selectControl = () => {
2561
+ return createSelector(selectState, (state) => {
2562
+ return state.control;
2563
+ });
2564
+ };
2565
+
2566
+ var monkeyecxStorage_selector = /*#__PURE__*/Object.freeze({
2567
+ __proto__: null,
2568
+ selectState: selectState,
2569
+ selectAll: selectAll,
2570
+ select: select,
2571
+ selectControl: selectControl
2572
+ });
2573
+
2574
+ var index$1 = /*#__PURE__*/Object.freeze({
2575
+ __proto__: null,
2576
+ monkeyecxStorage: monkeyecxStorage_selector
2577
+ });
2578
+
2579
+ var index = /*#__PURE__*/Object.freeze({
2580
+ __proto__: null,
2581
+ actions: index$3,
2582
+ reducers: index$2,
2583
+ selectors: index$1
2584
+ });
2585
+
2434
2586
  class MonkeyEcxRequestPagedHandling {
2435
2587
  constructor(url, pagedParams, links, samePage = false) {
2436
2588
  this.samePage = false;
@@ -3452,8 +3604,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
3452
3604
  }], ctorParameters: function () { return [{ type: MonkeyEcxService }, { type: MonkeyEcxi18nConfigService }, { type: MonkeyEcxLogsConfigService }, { type: i1.MonkeyStyleGuideSettingsService }, { type: MonkeyEcxServiceWorkerConfigService }, { type: MonkeyEcxSecurityConsoleConfigService }, { type: MonkeyEcxMaintenanceConfigService }, { type: MonkeyEcxErrorConfigService }, { type: MonkeyEcxFeatureToggleService }, { type: MonkeyEcxGTMConfigService }, { type: MonkeyEcxAlertsConfigService }]; }, propDecorators: { init: [] } });
3453
3605
 
3454
3606
  class MonkeyEcxTokenStorageService {
3455
- constructor(monkeyecxConfigService) {
3607
+ constructor(monkeyecxConfigService, store) {
3456
3608
  this.monkeyecxConfigService = monkeyecxConfigService;
3609
+ this.store = store;
3457
3610
  this.config = null;
3458
3611
  this.token = {
3459
3612
  username: '',
@@ -3470,8 +3623,8 @@ class MonkeyEcxTokenStorageService {
3470
3623
  role: '',
3471
3624
  ownerGovernmentId: '',
3472
3625
  _clearIgnore: {
3473
- ignore: ['username', 'program', 'accessType'],
3474
- },
3626
+ ignore: ['username', 'program', 'accessType']
3627
+ }
3475
3628
  };
3476
3629
  this.token$ = new BehaviorSubject(null);
3477
3630
  this.me$ = new BehaviorSubject(null);
@@ -3480,18 +3633,29 @@ class MonkeyEcxTokenStorageService {
3480
3633
  });
3481
3634
  }
3482
3635
  setAllTokens(token) {
3483
- const { token$ } = this;
3636
+ const { token$, store } = this;
3484
3637
  Object.entries(token).forEach(([key, value]) => {
3485
3638
  if (MonkeyEcxUtils.persistNullEmptyUndefined(value)) {
3486
3639
  localStorage.setItem(key, value);
3487
3640
  }
3488
3641
  });
3642
+ const username = token.username || localStorage.getItem('username');
3643
+ if (username) {
3644
+ store.dispatch(create({
3645
+ data: [
3646
+ {
3647
+ username,
3648
+ ...token
3649
+ }
3650
+ ]
3651
+ }));
3652
+ }
3489
3653
  token$.next(token);
3490
3654
  }
3491
3655
  getAllTokens() {
3492
3656
  const { token, config } = this;
3493
3657
  const handledToken = {
3494
- ...token,
3658
+ ...token
3495
3659
  };
3496
3660
  Object.entries(token || {}).forEach(([key, value]) => {
3497
3661
  handledToken[key] = localStorage.getItem(key);
@@ -3502,16 +3666,27 @@ class MonkeyEcxTokenStorageService {
3502
3666
  return handledToken;
3503
3667
  }
3504
3668
  setAllMe(me) {
3505
- const { me$ } = this;
3669
+ const { me$, store } = this;
3506
3670
  let previousMe = JSON.parse(localStorage?.getItem('me') || '{}');
3507
3671
  Object.entries(me).forEach(([key, value]) => {
3508
3672
  if (MonkeyEcxUtils.persistNullEmptyUndefined(value)) {
3509
3673
  previousMe = {
3510
3674
  ...previousMe,
3511
- [key]: value,
3675
+ [key]: value
3512
3676
  };
3513
3677
  }
3514
3678
  });
3679
+ const username = me.username || localStorage.getItem('username');
3680
+ if (username) {
3681
+ store.dispatch(create({
3682
+ data: [
3683
+ {
3684
+ username,
3685
+ me
3686
+ }
3687
+ ]
3688
+ }));
3689
+ }
3515
3690
  localStorage.setItem('me', JSON.stringify(previousMe));
3516
3691
  me$.next(previousMe);
3517
3692
  }
@@ -3538,7 +3713,7 @@ class MonkeyEcxTokenStorageService {
3538
3713
  this.setAllMe(me);
3539
3714
  }
3540
3715
  clear(force) {
3541
- const { token } = this;
3716
+ const { token, store } = this;
3542
3717
  try {
3543
3718
  Object.entries(token || {}).forEach(([key, value]) => {
3544
3719
  if ((token?._clearIgnore?.ignore || []).filter((val) => {
@@ -3549,6 +3724,10 @@ class MonkeyEcxTokenStorageService {
3549
3724
  }
3550
3725
  });
3551
3726
  localStorage.removeItem('me');
3727
+ const username = localStorage.getItem('username');
3728
+ if (username) {
3729
+ store.dispatch(deleteOne({ data: { username } }));
3730
+ }
3552
3731
  }
3553
3732
  catch (error) {
3554
3733
  return of(false);
@@ -3559,19 +3738,36 @@ class MonkeyEcxTokenStorageService {
3559
3738
  * @param fields (the name of fields you want to clear. ie: ['companyId', 'role', ...])
3560
3739
  */
3561
3740
  clearCredentials(fields = ['companyId', 'governmentId', 'companyType', 'programAdmin', 'role']) {
3741
+ const { store } = this;
3742
+ let obj = null;
3562
3743
  fields?.forEach((key) => {
3744
+ obj = {
3745
+ ...obj,
3746
+ [key]: null
3747
+ };
3563
3748
  localStorage.removeItem(key);
3564
3749
  });
3750
+ const username = localStorage.getItem('username');
3751
+ if (username) {
3752
+ store.dispatch(create({
3753
+ data: [
3754
+ {
3755
+ username,
3756
+ ...obj
3757
+ }
3758
+ ]
3759
+ }));
3760
+ }
3565
3761
  }
3566
3762
  }
3567
- MonkeyEcxTokenStorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxTokenStorageService, deps: [{ token: MonkeyEcxConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
3763
+ MonkeyEcxTokenStorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxTokenStorageService, deps: [{ token: MonkeyEcxConfigService }, { token: i2$3.Store }], target: i0.ɵɵFactoryTarget.Injectable });
3568
3764
  MonkeyEcxTokenStorageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxTokenStorageService, providedIn: 'root' });
3569
3765
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxTokenStorageService, decorators: [{
3570
3766
  type: Injectable,
3571
3767
  args: [{
3572
- providedIn: 'root',
3768
+ providedIn: 'root'
3573
3769
  }]
3574
- }], ctorParameters: function () { return [{ type: MonkeyEcxConfigService }]; } });
3770
+ }], ctorParameters: function () { return [{ type: MonkeyEcxConfigService }, { type: i2$3.Store }]; } });
3575
3771
 
3576
3772
  class MonkeyEcxSecurityDirective {
3577
3773
  constructor(elementRef, tokenStorageService, cdr) {
@@ -5375,163 +5571,11 @@ class MonkeyEcxSpecificationSearch {
5375
5571
  }
5376
5572
  }
5377
5573
 
5378
- const clear = createAction('[MECX Core Storage] Clear All');
5379
- const create = createAction('[MECX Core Storage] Create', props());
5380
- const updateControl = createAction('[MECX Core Storage] Update Control', props());
5381
- const updateOne = createAction('[MECX Core Storage] Update One', props());
5382
- const deleteOne = createAction('[MECX Core Storage] Delete One', props());
5383
-
5384
- var monkeyecxStorage_actions = /*#__PURE__*/Object.freeze({
5385
- __proto__: null,
5386
- clear: clear,
5387
- create: create,
5388
- updateControl: updateControl,
5389
- updateOne: updateOne,
5390
- deleteOne: deleteOne
5391
- });
5392
-
5393
- var index$3 = /*#__PURE__*/Object.freeze({
5394
- __proto__: null,
5395
- monkeyecxStorage: monkeyecxStorage_actions
5396
- });
5397
-
5398
- const seederReducer = (keys) => {
5399
- return (reducer) => {
5400
- return (state, action) => {
5401
- const handledState = reducer(state, action);
5402
- if (action.type === INIT || action.type === UPDATE) {
5403
- const storageValue = localStorage.getItem('state');
5404
- if (storageValue) {
5405
- try {
5406
- const handled = {
5407
- ...handledState,
5408
- ...JSON.parse(atob(storageValue))
5409
- };
5410
- return handled;
5411
- }
5412
- catch {
5413
- localStorage.removeItem('state');
5414
- }
5415
- }
5416
- }
5417
- let data = null;
5418
- try {
5419
- keys.forEach((key) => {
5420
- data = {
5421
- ...data,
5422
- [key]: handledState[key]
5423
- };
5424
- });
5425
- localStorage.setItem('state', btoa(JSON.stringify(data)));
5426
- }
5427
- catch (e) {
5428
- localStorage.removeItem('state');
5429
- }
5430
- return data || handledState;
5431
- };
5432
- };
5433
- };
5434
-
5435
- var monkeyecxSeeder_reducer = /*#__PURE__*/Object.freeze({
5436
- __proto__: null,
5437
- seederReducer: seederReducer
5438
- });
5439
-
5440
- const featureKey = 'mecx-core-storage';
5441
- const adapter = createEntityAdapter({
5442
- selectId: (item) => {
5443
- return item.username;
5444
- }
5445
- });
5446
- const initialState = adapter.getInitialState({
5447
- control: {
5448
- isLoading: false
5449
- },
5450
- error: null
5451
- });
5452
- const reducer = createReducer(initialState, on(clear, (state) => {
5453
- return adapter.removeAll(state);
5454
- }), on(create, (state, action) => {
5455
- return adapter.upsertMany(action.data, {
5456
- ...state
5457
- });
5458
- }), on(updateControl, (state, action) => {
5459
- return {
5460
- ...state,
5461
- control: {
5462
- ...state.control,
5463
- ...action.data
5464
- }
5465
- };
5466
- }), on(updateOne, (state, action) => {
5467
- const { username } = action.data;
5468
- return adapter.upsertOne({ ...action.data, username }, {
5469
- ...state
5470
- });
5471
- }), on(deleteOne, (state, action) => {
5472
- const { username } = action.data;
5473
- return adapter.removeOne(username, state);
5474
- }));
5475
- const { selectAll: selectAll$1, selectEntities, selectIds, selectTotal } = adapter.getSelectors();
5476
-
5477
- var monkeyecxStorage_reducer = /*#__PURE__*/Object.freeze({
5478
- __proto__: null,
5479
- featureKey: featureKey,
5480
- adapter: adapter,
5481
- initialState: initialState,
5482
- reducer: reducer,
5483
- selectAll: selectAll$1,
5484
- selectEntities: selectEntities,
5485
- selectIds: selectIds,
5486
- selectTotal: selectTotal
5487
- });
5488
-
5489
- var index$2 = /*#__PURE__*/Object.freeze({
5490
- __proto__: null,
5491
- fromMonkeyecxSeeder: monkeyecxSeeder_reducer,
5492
- fromMonkeyecxStorage: monkeyecxStorage_reducer
5493
- });
5494
-
5495
- const selectState = createFeatureSelector(featureKey);
5496
- const selectAll = createSelector(selectState, selectAll$1);
5497
- const select = (props) => {
5498
- return createSelector(selectAll, (entities) => {
5499
- return entities.filter((_) => {
5500
- return _.username === props.username;
5501
- });
5502
- });
5503
- };
5504
- const selectControl = () => {
5505
- return createSelector(selectState, (state) => {
5506
- return state.control;
5507
- });
5508
- };
5509
-
5510
- var monkeyecxStorage_selector = /*#__PURE__*/Object.freeze({
5511
- __proto__: null,
5512
- selectState: selectState,
5513
- selectAll: selectAll,
5514
- select: select,
5515
- selectControl: selectControl
5516
- });
5517
-
5518
- var index$1 = /*#__PURE__*/Object.freeze({
5519
- __proto__: null,
5520
- monkeyecxStorage: monkeyecxStorage_selector
5521
- });
5522
-
5523
- var index = /*#__PURE__*/Object.freeze({
5524
- __proto__: null,
5525
- actions: index$3,
5526
- reducers: index$2,
5527
- selectors: index$1
5528
- });
5529
-
5530
5574
  class MonkeyFrontCoreModule {
5531
5575
  }
5532
5576
  MonkeyFrontCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyFrontCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
5533
5577
  MonkeyFrontCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyFrontCoreModule, imports: [CommonModule,
5534
- HttpClientModule, i1$1.TranslateModule, MonkeyEcxConfigModule, MonkeyEcxHttpConfigInterceptorModule, MonkeyEcxErrorHandlingModule, MonkeyStyleGuideModule, i1$5.ServiceWorkerModule, ClosedToMaintenanceModule, i6.StoreFeatureModule, VersionChangedModule,
5578
+ HttpClientModule, i1$1.TranslateModule, MonkeyEcxConfigModule, MonkeyEcxHttpConfigInterceptorModule, MonkeyEcxErrorHandlingModule, MonkeyStyleGuideModule, i1$5.ServiceWorkerModule, ClosedToMaintenanceModule, i2$3.StoreFeatureModule, VersionChangedModule,
5535
5579
  AlertsModule,
5536
5580
  CurrencyConfigModule] });
5537
5581
  MonkeyFrontCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyFrontCoreModule, providers: [