@open-rlb/ng-app 3.1.63 → 3.1.64

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.
@@ -15,7 +15,7 @@ import { RLB_TRANSLATION_SERVICE, ToastService, RlbBootstrapModule, ModalDirecti
15
15
  import * as i1$5 from 'angular-auth-oidc-client';
16
16
  import { AbstractLoggerService, AuthModule, provideAuth, AuthInterceptor, AbstractSecurityStorage } from 'angular-auth-oidc-client';
17
17
  import * as i1 from 'ngx-cookie-service-ssr';
18
- import { of, tap, switchMap, from, map, catchError, filter, BehaviorSubject, share, lastValueFrom, zip, EMPTY, Observable, shareReplay, distinctUntilChanged, take } from 'rxjs';
18
+ import { of, from, map, catchError, tap, switchMap, filter, BehaviorSubject, share, lastValueFrom, zip, EMPTY, Observable, shareReplay, distinctUntilChanged, take } from 'rxjs';
19
19
  import { signalStore, withState, withMethods, patchState } from '@ngrx/signals';
20
20
  import { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';
21
21
  import * as i1$3 from '@ngx-translate/core';
@@ -395,18 +395,6 @@ const initialSidebarState = {
395
395
  searchText: null
396
396
  };
397
397
 
398
- const AclActions = createActionGroup({
399
- source: 'ACL',
400
- events: {
401
- 'Load ACL': emptyProps(),
402
- 'Load ACL Success': props(),
403
- 'Load ACL Failure': props(),
404
- 'Reset': emptyProps(),
405
- 'Finalized Apps Success': emptyProps(),
406
- 'Finalized Apps Failure': emptyProps()
407
- }
408
- });
409
-
410
398
  const aclFeatureKey = 'acl';
411
399
  const initialAclState = {
412
400
  resources: null,
@@ -421,19 +409,20 @@ class AdminApiService {
421
409
  this.config = config;
422
410
  this.aclConfig = aclConfig;
423
411
  }
424
- resourcesByUser$() {
412
+ resourcesByUser$(endpointKey, path) {
425
413
  if (!this.aclConfig) {
426
414
  console.error("ACL configuration is missing. Provide 'acl' in ProjectConfiguration.");
427
415
  return of([]);
428
416
  }
429
- const endpoint = this.config.endpoints?.[this.aclConfig.endpointKey];
417
+ const endpoint = this.config.endpoints?.[endpointKey];
430
418
  if (!endpoint) {
431
- throw new Error(`Endpoint '${this.aclConfig.endpointKey}' not found in configuration.`);
419
+ throw new Error(`Endpoint '${endpointKey}' not found in configuration.`);
420
+ }
421
+ if (!path) {
422
+ throw new Error(`Path '${path}' not found in configuration.`);
432
423
  }
433
- const url = `${endpoint.baseUrl}/${this.aclConfig.path}`;
434
- return this.httpClient.get(url).pipe(
435
- //this.errorManagementService.manageUI('error', 'dialog')
436
- );
424
+ const url = `${endpoint.baseUrl}/${path}`;
425
+ return this.httpClient.get(url).pipe();
437
426
  }
438
427
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: AdminApiService, deps: [{ token: i1$2.HttpClient }, { token: RLB_CFG, optional: true }, { token: RLB_CFG_ACL, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
439
428
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: AdminApiService, providedIn: 'root' }); }
@@ -455,7 +444,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
455
444
 
456
445
  const RLB_INIT_PROVIDER = new InjectionToken(`${RLB_CFG}:init.provider`);
457
446
 
458
- //import { ErrorManagementService } from "../../services/errors/error-management.service";
459
447
  const AclStore = signalStore({ providedIn: 'root' }, withState(initialAclState), withMethods((store, adminApi = inject(AdminApiService), baseStore = inject((Store)), rlbInitProvider = inject(RLB_INIT_PROVIDER, { optional: true }), aclConfiguration = inject(RLB_CFG_ACL, { optional: true })) => ({
460
448
  hasPermission: (busId, resId, action) => {
461
449
  const resources = store.resources();
@@ -464,25 +452,37 @@ const AclStore = signalStore({ providedIn: 'root' }, withState(initialAclState),
464
452
  return resources.some(company => company.resourceBusinessId === busId &&
465
453
  company.resources.some(res => {
466
454
  const matchRes = res.resourceId === resId;
467
- return action ? (matchRes && res.actions.includes(action)) : matchRes;
455
+ return action ? matchRes && res.actions.includes(action) : matchRes;
468
456
  }));
469
457
  },
470
458
  // Load Logic: Replaces both Effects. Get user res + call via bridge finalizeApps
471
- loadACL() {
459
+ // Accept the provider's ACL config
460
+ loadACL(providerAcl) {
461
+ // IF NO ACL CONFIGURATION -> BYPASS
462
+ if (!providerAcl) {
463
+ patchState(store, { resources: [], loaded: true, loading: false });
464
+ // Even if empty, we execute finalizeApps so the pipeline doesn't hang
465
+ if (rlbInitProvider) {
466
+ return from(rlbInitProvider.finalizeApps([], baseStore, aclConfiguration)).pipe(map(() => []), catchError(err => {
467
+ console.error('Finalization failed during bypass', err);
468
+ return of([]);
469
+ }));
470
+ }
471
+ return of([]);
472
+ }
473
+ // IF ACL CONFIG EXISTS -> FETCH RESOURCES
472
474
  patchState(store, { loading: true, loaded: false });
473
- return adminApi.resourcesByUser$().pipe(tap(resources => patchState(store, { resources, loaded: true, loading: false })), switchMap((resources) => {
475
+ return adminApi.resourcesByUser$(providerAcl.endpointKey, providerAcl.path).pipe(tap(resources => patchState(store, { resources, loaded: true, loading: false })), switchMap(resources => {
474
476
  if (!rlbInitProvider) {
475
- console.error("RlbInitProvider not found. Define RLB_INIT_PROVIDER");
476
477
  return of(resources);
477
478
  }
478
- // Pass resources directly to the finalizer to prevent race condition problem
479
- return from(rlbInitProvider.finalizeApps(resources, baseStore, aclConfiguration)).pipe(map(() => resources), catchError((err) => {
479
+ return from(rlbInitProvider.finalizeApps(resources, baseStore, aclConfiguration)).pipe(map(() => resources), catchError(err => {
480
480
  console.error('Finalization failed', err);
481
481
  return of(resources);
482
482
  }));
483
483
  }));
484
484
  },
485
- reset: () => patchState(store, initialAclState)
485
+ reset: () => patchState(store, initialAclState),
486
486
  })));
487
487
 
488
488
  class AbstractSupportService {
@@ -1551,22 +1551,25 @@ class AuthenticationService {
1551
1551
  }
1552
1552
  checkAuthMultiple(url) {
1553
1553
  return this.oidc.checkAuthMultiple(url).pipe(switchMap((responses) => {
1554
- const authenticatedConfig = responses.find(o => o.isAuthenticated);
1554
+ let authenticatedConfig = responses.find(o => o.isAuthenticated);
1555
+ // uncomment to bypass login
1556
+ // if (isDevMode()) {
1557
+ // //@ts-ignore
1558
+ // authenticatedConfig = { configId: 'chattoo' };
1559
+ // }
1555
1560
  if (authenticatedConfig && authenticatedConfig.configId) {
1556
1561
  this.store.dispatch(AuthActions.setCurrentProvider({
1557
1562
  currentProvider: authenticatedConfig.configId,
1558
1563
  }));
1559
1564
  }
1560
1565
  else {
1561
- // wrap login with this to bypass login flow
1562
- // if (!isDevMode()) {
1563
- //
1564
- // }
1565
1566
  this.login();
1566
1567
  return EMPTY;
1567
1568
  }
1568
- // SignalStore methods can trigger the API call
1569
- return this.aclStore.loadACL().pipe(tap(() => this.handleRedirect()), map(() => responses));
1569
+ // Find the active provider's configuration
1570
+ const activeProviderConfig = this.authConfig?.providers.find(p => p.configId === authenticatedConfig?.configId);
1571
+ // Pass the specific provider's ACL config to the store
1572
+ return this.aclStore.loadACL(activeProviderConfig?.acl).pipe(tap(() => this.handleRedirect()), map(() => responses));
1570
1573
  }));
1571
1574
  }
1572
1575
  login(targetUrl) {
@@ -3368,7 +3371,7 @@ const authsFeature = createFeature({
3368
3371
  }))
3369
3372
  });
3370
3373
  const authReducer = authsFeature.reducer;
3371
- const { selectAuthState, selectCurrentProvider, selectLoading: selectLoading$1 } = authsFeature;
3374
+ const { selectAuthState, selectCurrentProvider, selectLoading } = authsFeature;
3372
3375
 
3373
3376
  const navbarsFeature = createFeature({
3374
3377
  name: navbarsFeatureKey,
@@ -3483,78 +3486,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
3483
3486
  }]
3484
3487
  }], propDecorators: { data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: true }] }] } });
3485
3488
 
3486
- class AclEffects {
3487
- // TODO: It's legacy approach. We're moving forward to signalStore. All legacy boilerplate (effects.ts, reducers.ts, actions.ts) will be removed soon
3488
- // I've moved this logic into acl.store.ts -> loadACL() method
3489
- // finalizeAppsOnAclLoad$ = createEffect(() => {
3490
- // return this.actions$.pipe(
3491
- // ofType(AclActions.loadACLSuccess),
3492
- // switchMap(() => {
3493
- // if (!this.rlbInitProvider) {
3494
- // console.error("RlbInitProvider not found. Define RLB_INIT_PROVIDER");
3495
- // return of(AclActions.finalizedAppsFailure());
3496
- // }
3497
- // return from(
3498
- // this.rlbInitProvider.finalizeApps(this.store, this.aclConfiguration)
3499
- // ).pipe(
3500
- // map(() => AclActions.finalizedAppsSuccess()),
3501
- // catchError(() => of(AclActions.finalizedAppsFailure()))
3502
- // );
3503
- // }));
3504
- // });
3505
- constructor(actions$, adminApi, rlbInitProvider, aclConfiguration, store) {
3506
- this.actions$ = actions$;
3507
- this.adminApi = adminApi;
3508
- this.rlbInitProvider = rlbInitProvider;
3509
- this.aclConfiguration = aclConfiguration;
3510
- this.store = store;
3511
- this.loadAclOnAuth$ = createEffect(() => {
3512
- return this.actions$.pipe(
3513
- // Listen for the action dispatched in AuthenticationService.checkAuthMultiple
3514
- ofType(AuthActions.setCurrentProvider), map$1(() => AclActions.loadACL()));
3515
- });
3516
- this.fetchAcl$ = createEffect(() => {
3517
- return this.actions$.pipe(ofType(AclActions.loadACL), switchMap$1(() => this.adminApi.resourcesByUser$().pipe(map$1(resources => AclActions.loadACLSuccess({ resources })), catchError(error => of(AclActions.loadACLFailure({ error }))))));
3518
- });
3519
- }
3520
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: AclEffects, deps: [{ token: i1$8.Actions }, { token: AdminApiService }, { token: RLB_INIT_PROVIDER, optional: true }, { token: RLB_CFG_ACL, optional: true }, { token: i1$1.Store }], target: i0.ɵɵFactoryTarget.Injectable }); }
3521
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: AclEffects }); }
3522
- }
3523
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: AclEffects, decorators: [{
3524
- type: Injectable
3525
- }], ctorParameters: () => [{ type: i1$8.Actions }, { type: AdminApiService }, { type: undefined, decorators: [{
3526
- type: Optional
3527
- }, {
3528
- type: Inject,
3529
- args: [RLB_INIT_PROVIDER]
3530
- }] }, { type: undefined, decorators: [{
3531
- type: Optional
3532
- }, {
3533
- type: Inject,
3534
- args: [RLB_CFG_ACL]
3535
- }] }, { type: i1$1.Store }] });
3536
-
3537
- const aclFeature = createFeature({
3538
- name: aclFeatureKey,
3539
- reducer: createReducer(initialAclState, on(AclActions.loadACL, (state) => ({
3540
- ...state,
3541
- loading: true,
3542
- loaded: false
3543
- })), on(AclActions.loadACLSuccess, (state, { resources }) => ({
3544
- ...state,
3545
- resources,
3546
- loaded: true,
3547
- loading: false
3548
- })), on(AclActions.loadACLFailure, (state, { error }) => ({
3549
- ...state,
3550
- error,
3551
- loading: false,
3552
- loaded: true // We mark as loaded to unblock the UI even if the fetch fails
3553
- })), on(AclActions.reset, () => ({ ...initialAclState })))
3554
- });
3555
- const aclReducer = aclFeature.reducer;
3556
- const { selectAclState, selectResources, selectLoading, selectLoaded } = aclFeature;
3557
-
3558
3489
  const verifyDeactivate = (component, currentRoute, currentState, nextState) => {
3559
3490
  return component.verifyDeactivate();
3560
3491
  };
@@ -3565,12 +3496,10 @@ function provideRlbConfig(env) {
3565
3496
  RlbAppModule,
3566
3497
  provideStore(),
3567
3498
  provideState(authsFeature),
3568
- provideEffects(AuthEffects, AppContextEffects, AclEffects),
3499
+ provideEffects(AuthEffects, AppContextEffects),
3569
3500
  provideState(navbarsFeature),
3570
3501
  provideState(sidebarsFeature),
3571
3502
  provideState(appFeature),
3572
- provideState(aclFeature),
3573
- // provideEffects(AppContextEffects),
3574
3503
  provideRouter(getDefaultRoutes(env.pages)),
3575
3504
  provideRlbCodeBrowserOAuth(env.auth),
3576
3505
  provideRlbI18n(env.i18n),
@@ -3594,12 +3523,14 @@ function provideRlbConfig(env) {
3594
3523
  { provide: RLB_CFG_I18N, useValue: env.i18n },
3595
3524
  { provide: RLB_CFG_ACL, useValue: env.acl },
3596
3525
  {
3597
- provide: ModalRegistryOptions, useValue: {
3526
+ provide: ModalRegistryOptions,
3527
+ useValue: {
3598
3528
  modals: {
3599
- "modal-apps-component": ModalAppsComponent,
3529
+ 'modal-apps-component': ModalAppsComponent,
3600
3530
  'error-modal-component': ErrorModalComponent,
3601
- }
3602
- }, multi: true
3531
+ },
3532
+ },
3533
+ multi: true,
3603
3534
  },
3604
3535
  {
3605
3536
  provide: ToastRegistryOptions,
@@ -3614,12 +3545,16 @@ function provideRlbConfig(env) {
3614
3545
  }
3615
3546
  function provideApp(app) {
3616
3547
  const routesPaths = app.routes ? flattenRoutes(app.routes) : [];
3617
- const providers = [{
3618
- provide: RLB_APPS, useValue: {
3548
+ const providers = [
3549
+ {
3550
+ provide: RLB_APPS,
3551
+ useValue: {
3619
3552
  ...app.info,
3620
3553
  routes: routesPaths,
3621
- }, multi: true
3622
- },];
3554
+ },
3555
+ multi: true,
3556
+ },
3557
+ ];
3623
3558
  if (app.routes) {
3624
3559
  providers.push(provideRouter(app.routes));
3625
3560
  }
@@ -3640,5 +3575,5 @@ function flattenRoutes(routes, parentPath = '') {
3640
3575
  * Generated bundle index. Do not edit.
3641
3576
  */
3642
3577
 
3643
- export { AbstractMdService, AbstractSupportService, AclActions, AppBreadcrumbService, AppContainerComponent, AppContextActions, AppContextActionsInternal, AppLoggerService, AppStorageService, AppTemplateComponent, AppsService, AsMultiPipe, AsSinglePipe, AuthActions, AuthActionsInternal, AuthFeatureService, AuthenticationService, AutolinkPipe, BaseComponent, CmsComponent, CmsPipe, ContentComponent, CookiesService, ErrorManagementService, ErrorModalComponent, KeycloakProfileService, LanguageService, LeftComponentPipe, LocalCacheService, ModalAppsComponent, NavbarActions, NavbarActionsInternal, OauthPasswordService, ParseJwtService, PwaUpdaterService, RLB_APPS, RLB_APP_NAVCOMP, RLB_CFG, RLB_CFG_ACL, RLB_CFG_AUTH, RLB_CFG_CMS, RLB_CFG_ENV, RLB_CFG_I18N, RLB_CFG_PAGES, RLB_INIT_PROVIDER, RightComponentPipe, RlbAppModule, RlbRole, SidebarActions, SidebarActionsInternal, StrapiService, ToastComponent, TokenOauthInterceptor, TranslateBrowserLoader, TruncatePipe, UtilsService, aclFeatureKey, appContextFeatureKey, authsFeatureKey, getDefaultRoutes, initialAclState, initialAppContextState, initialAuthState, initialNavbarState, initialSidebarState, navbarsFeatureKey, oauthGuard, oauthPasswordGuard, permissionGuard, provideApp, provideRlbCodeBrowserOAuth, provideRlbConfig, provideRlbI18n, sidebarsFeatureKey, translateBrowserLoaderFactory, verifyDeactivate };
3578
+ export { AbstractMdService, AbstractSupportService, AppBreadcrumbService, AppContainerComponent, AppContextActions, AppContextActionsInternal, AppLoggerService, AppStorageService, AppTemplateComponent, AppsService, AsMultiPipe, AsSinglePipe, AuthActions, AuthActionsInternal, AuthFeatureService, AuthenticationService, AutolinkPipe, BaseComponent, CmsComponent, CmsPipe, ContentComponent, CookiesService, ErrorManagementService, ErrorModalComponent, KeycloakProfileService, LanguageService, LeftComponentPipe, LocalCacheService, ModalAppsComponent, NavbarActions, NavbarActionsInternal, OauthPasswordService, ParseJwtService, PwaUpdaterService, RLB_APPS, RLB_APP_NAVCOMP, RLB_CFG, RLB_CFG_ACL, RLB_CFG_AUTH, RLB_CFG_CMS, RLB_CFG_ENV, RLB_CFG_I18N, RLB_CFG_PAGES, RLB_INIT_PROVIDER, RightComponentPipe, RlbAppModule, RlbRole, SidebarActions, SidebarActionsInternal, StrapiService, ToastComponent, TokenOauthInterceptor, TranslateBrowserLoader, TruncatePipe, UtilsService, aclFeatureKey, appContextFeatureKey, authsFeatureKey, getDefaultRoutes, initialAclState, initialAppContextState, initialAuthState, initialNavbarState, initialSidebarState, navbarsFeatureKey, oauthGuard, oauthPasswordGuard, permissionGuard, provideApp, provideRlbCodeBrowserOAuth, provideRlbConfig, provideRlbI18n, sidebarsFeatureKey, translateBrowserLoaderFactory, verifyDeactivate };
3644
3579
  //# sourceMappingURL=open-rlb-ng-app.mjs.map