monkey-front-core 0.0.194 → 0.0.197
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.
- package/esm2020/lib/core/directives/monkeyecx-feature-by-program-directive.mjs +2 -2
- package/esm2020/lib/core/interceptors/monkeyecx-http-config-header.interceptor.mjs +54 -11
- package/esm2020/lib/core/services/auth/monkeyecx-authentication.service.mjs +5 -1
- package/esm2020/lib/core/services/commons/monkeyecx-commons.service.mjs +4 -4
- package/fesm2015/monkey-front-core.mjs +73 -26
- package/fesm2015/monkey-front-core.mjs.map +1 -1
- package/fesm2020/monkey-front-core.mjs +60 -14
- package/fesm2020/monkey-front-core.mjs.map +1 -1
- package/lib/core/interceptors/monkeyecx-http-config-header.interceptor.d.ts +7 -3
- package/lib/core/services/auth/monkeyecx-authentication.service.d.ts +3 -2
- package/monkey-front-core-0.0.197.tgz +0 -0
- package/package.json +1 -1
- package/monkey-front-core-0.0.194.tgz +0 -0
|
@@ -10,7 +10,7 @@ import * as moment_ from 'moment';
|
|
|
10
10
|
import * as i1$2 from 'ngx-cookie-service';
|
|
11
11
|
import * as i1$3 from '@angular/router';
|
|
12
12
|
import { NavigationStart, NavigationEnd, NavigationError, NavigationCancel } from '@angular/router';
|
|
13
|
-
import { BehaviorSubject, Subscription, throwError, interval, concat, of, Subject } from 'rxjs';
|
|
13
|
+
import { BehaviorSubject, Subscription, throwError, interval, concat, of, Subject, from } from 'rxjs';
|
|
14
14
|
import { filter, take, takeWhile, map, catchError, first, takeUntil, mergeMap, finalize } from 'rxjs/operators';
|
|
15
15
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
16
16
|
import { TemplatePortal } from '@angular/cdk/portal';
|
|
@@ -2220,10 +2220,10 @@ class MonkeyEcxCommonsService {
|
|
|
2220
2220
|
const { config, feature } = args;
|
|
2221
2221
|
try {
|
|
2222
2222
|
if (!MonkeyEcxUtils.persistNullEmptyUndefined(feature) ||
|
|
2223
|
-
!MonkeyEcxUtils.persistNullEmptyUndefined(config?.program?.settings
|
|
2224
|
-
return
|
|
2223
|
+
!MonkeyEcxUtils.persistNullEmptyUndefined(config?.program?.settings)) {
|
|
2224
|
+
return true;
|
|
2225
2225
|
}
|
|
2226
|
-
return !config?.program?.settings[feature];
|
|
2226
|
+
return !config?.program?.settings?.[feature];
|
|
2227
2227
|
}
|
|
2228
2228
|
catch (e) {
|
|
2229
2229
|
// not to do
|
|
@@ -3467,6 +3467,10 @@ class MonkeyEcxAuthenticationService {
|
|
|
3467
3467
|
console.error('isCompanyAuthorized needs to be declared!');
|
|
3468
3468
|
return false;
|
|
3469
3469
|
};
|
|
3470
|
+
this.isTokenMandatory = (url) => {
|
|
3471
|
+
console.error('isTokenMandatory needs to be declared!');
|
|
3472
|
+
return false;
|
|
3473
|
+
};
|
|
3470
3474
|
this.getRequestWithHeaders = (request) => {
|
|
3471
3475
|
console.error('getRequestWithHeaders needs to be declared!');
|
|
3472
3476
|
return null;
|
|
@@ -4483,7 +4487,7 @@ class MonkeyEcxFeatureByProgramDirective {
|
|
|
4483
4487
|
const { feature, config } = this;
|
|
4484
4488
|
let display = 'none';
|
|
4485
4489
|
if (!MonkeyEcxUtils.persistNullEmptyUndefined(feature) ||
|
|
4486
|
-
!MonkeyEcxUtils.persistNullEmptyUndefined(config?.program?.settings
|
|
4490
|
+
!MonkeyEcxUtils.persistNullEmptyUndefined(config?.program?.settings)) {
|
|
4487
4491
|
return;
|
|
4488
4492
|
}
|
|
4489
4493
|
const disabled = config?.program?.settings?.[feature];
|
|
@@ -4670,13 +4674,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
4670
4674
|
}], ctorParameters: function () { return [{ type: MonkeyEcxAuthenticationService }, { type: MonkeyEcxErrorHandlingService }]; } });
|
|
4671
4675
|
|
|
4672
4676
|
class MonkeyEcxHttpConfigHeaderInterceptor {
|
|
4673
|
-
constructor(
|
|
4674
|
-
this.
|
|
4675
|
-
this.
|
|
4677
|
+
constructor(authService, errorHandlingService, config) {
|
|
4678
|
+
this.authService = authService;
|
|
4679
|
+
this.errorHandlingService = errorHandlingService;
|
|
4680
|
+
this.config = config;
|
|
4676
4681
|
// not to do
|
|
4677
4682
|
}
|
|
4678
|
-
|
|
4679
|
-
|
|
4683
|
+
async handle(request, next) {
|
|
4684
|
+
const { url } = request;
|
|
4685
|
+
if (this.authService.isTokenMandatory(url)) {
|
|
4686
|
+
try {
|
|
4687
|
+
const config = await this.config
|
|
4688
|
+
.config()
|
|
4689
|
+
.pipe(take(1))
|
|
4690
|
+
.toPromise();
|
|
4691
|
+
if (!config) {
|
|
4692
|
+
await this.onValidateConfig();
|
|
4693
|
+
}
|
|
4694
|
+
}
|
|
4695
|
+
catch (error) {
|
|
4696
|
+
// not to do
|
|
4697
|
+
}
|
|
4698
|
+
}
|
|
4699
|
+
return this.authService
|
|
4700
|
+
.getRequestWithHeadersOb(request)
|
|
4701
|
+
.pipe(take(1), map((event) => {
|
|
4680
4702
|
return event;
|
|
4681
4703
|
}), mergeMap((resp) => {
|
|
4682
4704
|
request = request.clone({
|
|
@@ -4684,16 +4706,40 @@ class MonkeyEcxHttpConfigHeaderInterceptor {
|
|
|
4684
4706
|
});
|
|
4685
4707
|
return next.handle(request);
|
|
4686
4708
|
}), catchError((error) => {
|
|
4687
|
-
this.
|
|
4709
|
+
this.errorHandlingService.handleError(error);
|
|
4688
4710
|
return throwError(error);
|
|
4689
|
-
}))
|
|
4711
|
+
}))
|
|
4712
|
+
.toPromise();
|
|
4713
|
+
}
|
|
4714
|
+
onValidateConfig() {
|
|
4715
|
+
return new Promise((resolve) => {
|
|
4716
|
+
let count = 0;
|
|
4717
|
+
const interval = setInterval(async () => {
|
|
4718
|
+
count += 1;
|
|
4719
|
+
if (count > 20) {
|
|
4720
|
+
clearInterval(interval);
|
|
4721
|
+
resolve(null);
|
|
4722
|
+
}
|
|
4723
|
+
const config = await this.config
|
|
4724
|
+
.config()
|
|
4725
|
+
.pipe(take(1))
|
|
4726
|
+
.toPromise();
|
|
4727
|
+
if (config) {
|
|
4728
|
+
clearInterval(interval);
|
|
4729
|
+
resolve(null);
|
|
4730
|
+
}
|
|
4731
|
+
}, 200);
|
|
4732
|
+
});
|
|
4733
|
+
}
|
|
4734
|
+
intercept(request, next) {
|
|
4735
|
+
return from(this.handle(request, next));
|
|
4690
4736
|
}
|
|
4691
4737
|
}
|
|
4692
|
-
MonkeyEcxHttpConfigHeaderInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxHttpConfigHeaderInterceptor, deps: [{ token: MonkeyEcxAuthenticationService }, { token: MonkeyEcxErrorHandlingService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4738
|
+
MonkeyEcxHttpConfigHeaderInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxHttpConfigHeaderInterceptor, deps: [{ token: MonkeyEcxAuthenticationService }, { token: MonkeyEcxErrorHandlingService }, { token: MonkeyEcxConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4693
4739
|
MonkeyEcxHttpConfigHeaderInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxHttpConfigHeaderInterceptor });
|
|
4694
4740
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: MonkeyEcxHttpConfigHeaderInterceptor, decorators: [{
|
|
4695
4741
|
type: Injectable
|
|
4696
|
-
}], ctorParameters: function () { return [{ type: MonkeyEcxAuthenticationService }, { type: MonkeyEcxErrorHandlingService }]; } });
|
|
4742
|
+
}], ctorParameters: function () { return [{ type: MonkeyEcxAuthenticationService }, { type: MonkeyEcxErrorHandlingService }, { type: MonkeyEcxConfigService }]; } });
|
|
4697
4743
|
|
|
4698
4744
|
/* eslint-disable max-len */
|
|
4699
4745
|
class MonkeyEcxHttpConfigQueueInterceptor {
|