@codex-ts/core-lib 1.0.15 → 1.0.16
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.
|
@@ -4,8 +4,11 @@ import * as i1 from '@angular/common/http';
|
|
|
4
4
|
import { HttpClient, HttpClientModule, HttpParams } from '@angular/common/http';
|
|
5
5
|
import * as i1$2 from '@angular/common';
|
|
6
6
|
import { isPlatformBrowser, CommonModule, formatDate } from '@angular/common';
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
7
|
+
import * as i1$3 from '@angular/router';
|
|
8
|
+
import { Router } from '@angular/router';
|
|
9
|
+
import { toObservable } from '@angular/core/rxjs-interop';
|
|
10
|
+
import { map, BehaviorSubject, finalize, Observable, forkJoin, throwError, of, isObservable, Subject, take as take$1, tap as tap$1, catchError as catchError$1, takeUntil as takeUntil$1, ReplaySubject, distinctUntilChanged as distinctUntilChanged$1 } from 'rxjs';
|
|
11
|
+
import { retry, timeout, catchError, take, map as map$1, finalize as finalize$1, switchMap, takeUntil, mergeMap, tap, debounceTime, distinctUntilChanged } from 'rxjs/operators';
|
|
9
12
|
import * as i4 from 'primeng/api';
|
|
10
13
|
import * as i1$1 from '@angular/forms';
|
|
11
14
|
import { FormGroup, ReactiveFormsModule } from '@angular/forms';
|
|
@@ -29,7 +32,6 @@ import * as i3$4 from 'primeng/inputtextarea';
|
|
|
29
32
|
import { Textarea } from 'primeng/inputtextarea';
|
|
30
33
|
import * as i2$1 from 'primeng/tooltip';
|
|
31
34
|
import { TooltipModule } from 'primeng/tooltip';
|
|
32
|
-
import * as i1$3 from '@angular/router';
|
|
33
35
|
|
|
34
36
|
class AppConstants {
|
|
35
37
|
static FORM = {
|
|
@@ -265,6 +267,35 @@ function provideKeycloak(config) {
|
|
|
265
267
|
];
|
|
266
268
|
}
|
|
267
269
|
|
|
270
|
+
class KeycloakAuthGuard {
|
|
271
|
+
keycloakService = inject(KeycloakService);
|
|
272
|
+
router = inject(Router);
|
|
273
|
+
canActivate(route, state) {
|
|
274
|
+
return toObservable(this.keycloakService.isAuthenticated$).pipe(map(authenticated => {
|
|
275
|
+
if (!authenticated) {
|
|
276
|
+
this.keycloakService.login({
|
|
277
|
+
redirectUri: window.location.origin + state.url
|
|
278
|
+
});
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
const requiredRoles = route.data['roles'];
|
|
282
|
+
if (requiredRoles && !this.hasRequiredRoles(requiredRoles)) {
|
|
283
|
+
return this.router.createUrlTree(['/unauthorized']);
|
|
284
|
+
}
|
|
285
|
+
return true;
|
|
286
|
+
}));
|
|
287
|
+
}
|
|
288
|
+
hasRequiredRoles(requiredRoles) {
|
|
289
|
+
return requiredRoles.every(role => this.keycloakService.getRoles().includes(role));
|
|
290
|
+
}
|
|
291
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: KeycloakAuthGuard, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
292
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: KeycloakAuthGuard, providedIn: 'root' });
|
|
293
|
+
}
|
|
294
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: KeycloakAuthGuard, decorators: [{
|
|
295
|
+
type: Injectable,
|
|
296
|
+
args: [{ providedIn: 'root' }]
|
|
297
|
+
}] });
|
|
298
|
+
|
|
268
299
|
/**
|
|
269
300
|
* A general-purpose HTTP utility service that provides enhanced HTTP operations
|
|
270
301
|
* beyond the standard Angular HttpClient. This service includes features such as:
|
|
@@ -1017,7 +1048,7 @@ class FormService {
|
|
|
1017
1048
|
return of(void 0);
|
|
1018
1049
|
}
|
|
1019
1050
|
this.formState.loading = true;
|
|
1020
|
-
return this.entityService.getById(uuid).pipe(take(1), map(data => {
|
|
1051
|
+
return this.entityService.getById(uuid).pipe(take(1), map$1(data => {
|
|
1021
1052
|
this.updateFormState(data);
|
|
1022
1053
|
}), finalize$1(() => this.formState.loading = false));
|
|
1023
1054
|
}
|
|
@@ -1037,7 +1068,7 @@ class FormService {
|
|
|
1037
1068
|
}
|
|
1038
1069
|
this.formState.loading = true;
|
|
1039
1070
|
const operation$ = this.getSubmitOperation();
|
|
1040
|
-
return operation$.pipe(finalize$1(() => this.formState.loading = false), map(result => {
|
|
1071
|
+
return operation$.pipe(finalize$1(() => this.formState.loading = false), map$1(result => {
|
|
1041
1072
|
this.notificationService.showSuccess(`${this.entityName} ${AppMessages.FORM.SUCCESS.SAVE}`);
|
|
1042
1073
|
return result;
|
|
1043
1074
|
}));
|
|
@@ -1776,7 +1807,7 @@ class BaseFormComponent extends BasePageComponent {
|
|
|
1776
1807
|
});
|
|
1777
1808
|
}
|
|
1778
1809
|
initializeForm() {
|
|
1779
|
-
return this.route.queryParams.pipe(take(1), map(params => {
|
|
1810
|
+
return this.route.queryParams.pipe(take(1), map$1(params => {
|
|
1780
1811
|
this.initializeFormMode(params[AppConstants.FORM.MODE]);
|
|
1781
1812
|
this.setupFormState();
|
|
1782
1813
|
this.initializeFormSubscriptions();
|
|
@@ -1797,7 +1828,7 @@ class BaseFormComponent extends BasePageComponent {
|
|
|
1797
1828
|
throw new Error(`UUID is required for ${this.state.mode} mode`);
|
|
1798
1829
|
}
|
|
1799
1830
|
return this.getEntityOperations().getById(uuid)
|
|
1800
|
-
.pipe(tap(data => this.updateFormState(data)), map(() => void 0));
|
|
1831
|
+
.pipe(tap(data => this.updateFormState(data)), map$1(() => void 0));
|
|
1801
1832
|
}));
|
|
1802
1833
|
}
|
|
1803
1834
|
getRouterState() {
|
|
@@ -2376,7 +2407,7 @@ class BaseTabbedFormComponent extends BasePageComponent {
|
|
|
2376
2407
|
activeTab: tabs[0]?.value || ''
|
|
2377
2408
|
};
|
|
2378
2409
|
// Then initialize form
|
|
2379
|
-
this.route.queryParams.pipe(take$1(1), tap$1(() => this.state = { ...this.state, loading: true }), tap$1(params => this.initializeForm(params)), map
|
|
2410
|
+
this.route.queryParams.pipe(take$1(1), tap$1(() => this.state = { ...this.state, loading: true }), tap$1(params => this.initializeForm(params)), map(() => void 0), catchError$1(error => {
|
|
2380
2411
|
console.error('Error initializing form:', error);
|
|
2381
2412
|
this.showError(AppMessages.FORM.ERROR.INIT);
|
|
2382
2413
|
return of(void 0);
|
|
@@ -2432,7 +2463,7 @@ class BaseTabbedFormComponent extends BasePageComponent {
|
|
|
2432
2463
|
}
|
|
2433
2464
|
}
|
|
2434
2465
|
loadFromUuid() {
|
|
2435
|
-
this.route.queryParams.pipe(take$1(1), map
|
|
2466
|
+
this.route.queryParams.pipe(take$1(1), map((params) => {
|
|
2436
2467
|
const uuid = params[AppConstants.FORM.UUID];
|
|
2437
2468
|
if (!uuid) {
|
|
2438
2469
|
throw new Error(`UUID is required for ${this.state.mode} mode when no formData is provided`);
|
|
@@ -2820,7 +2851,7 @@ class BaseTaskDetailsComponent extends BasePageComponent {
|
|
|
2820
2851
|
this.formlyConfigService = formlyConfigService;
|
|
2821
2852
|
}
|
|
2822
2853
|
initializeServices() {
|
|
2823
|
-
return of(void 0).pipe(map(() => {
|
|
2854
|
+
return of(void 0).pipe(map$1(() => {
|
|
2824
2855
|
this.formService = new FormService(this.getEntityService(), this.formlyConfigService, this.notificationService, this.getEntityName(), this.getJsonFields(), this.getDropdownOptions());
|
|
2825
2856
|
this.state = this.formService.getState();
|
|
2826
2857
|
this.loading = this.state.loading;
|
|
@@ -2835,7 +2866,7 @@ class BaseTaskDetailsComponent extends BasePageComponent {
|
|
|
2835
2866
|
});
|
|
2836
2867
|
}
|
|
2837
2868
|
initializeFromRoute() {
|
|
2838
|
-
return this.route.queryParams.pipe(map(params => {
|
|
2869
|
+
return this.route.queryParams.pipe(map$1(params => {
|
|
2839
2870
|
const mode = params[AppConstants.FORM.MODE];
|
|
2840
2871
|
if (mode) {
|
|
2841
2872
|
this.formService.setMode(mode);
|
|
@@ -3089,5 +3120,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImpor
|
|
|
3089
3120
|
* Generated bundle index. Do not edit.
|
|
3090
3121
|
*/
|
|
3091
3122
|
|
|
3092
|
-
export { AppConstants, AppMessages, BaseCrudService, BaseFormComponent, BaseListPageComponent, BaseListTabbedFormComponent, BasePageComponent, BaseTabbedFormComponent, BaseTaskDashboardComponent, BaseTaskDetailsComponent, BaseTaskService, ComponentContext, CoreFormlyModule, FormService, FormlyConfigService, HttpUtilityService, IndianDatePipe, KEYCLOAK_CONFIG, KeycloakService, NotificationService, TabbedFormType, TaskRole, UtilsService, provideKeycloak };
|
|
3123
|
+
export { AppConstants, AppMessages, BaseCrudService, BaseFormComponent, BaseListPageComponent, BaseListTabbedFormComponent, BasePageComponent, BaseTabbedFormComponent, BaseTaskDashboardComponent, BaseTaskDetailsComponent, BaseTaskService, ComponentContext, CoreFormlyModule, FormService, FormlyConfigService, HttpUtilityService, IndianDatePipe, KEYCLOAK_CONFIG, KeycloakAuthGuard, KeycloakService, NotificationService, TabbedFormType, TaskRole, UtilsService, provideKeycloak };
|
|
3093
3124
|
//# sourceMappingURL=codex-ts-core-lib.mjs.map
|