import { InjectionToken } from '@angular/core'; import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot } from '@angular/router'; import { Observable } from 'rxjs'; import { MtnaLogger } from '@mtna/lib-ui'; import { Catalog } from '@mtna/pojo-consumer-ui'; import { RdsDataProductDialogService } from '../../data-product-selection-dialog/data-product-dialog.service'; import { RdsApiService } from './rds-api.service'; export declare const RDS_ROOT_CATALOG: InjectionToken>; /** * Protect routes that require a data product to be selected. * If a data product is not selected, the guard will automatically select it * if there is only one option, otherwise it will open the data product selection dialog. * * Requires the app to provide the `RDS_ROOT_CATALOG` injection token. In your AppModule: * @example * * export function getRootCatalog(store: Store): Observable { * return store.pipe(select(fromRoot.getDataProductRootCatalog)); * } * * NgModule({ * ... * providers: [ * { * provide: RDS_ROOT_CATALOG, * useFactory: getRootCatalog, * deps: [Store] * } * ], * ... * }) * export class AppModule {} * */ export declare class RdsDataProductGuard implements CanActivate { protected dataProductDialog: RdsDataProductDialogService; protected rdsApiService: RdsApiService; private getRootCatalog; protected logger: MtnaLogger; /** Whether the catalog has been set and actually exists in the root catalog */ protected get catalogSetAndExists(): boolean; private _catalogSetAndExists; /** Whether the data product has been set and actually exists in the selected catalog */ protected get dataProductSetAndExists(): boolean; private _dataProductSetAndExists; constructor(dataProductDialog: RdsDataProductDialogService, rdsApiService: RdsApiService, getRootCatalog: Observable, logger: MtnaLogger); canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable; /** * Determine if the catalog and data product have been set on the api service and exists in the root catalog * @param rootCatalog root catalog for a given RDS environment */ protected determineSetAndExists(rootCatalog: Catalog): void; /** * Selects the initial catalog. * This method will check if there is only only catalog available and select it, * or if there are multiple options it will open the data product selection dialog for the user to choose. * * @param rootCatalog RDS root catalog * @returns Observable whether the selection has changed */ private selectInitialCatalog; /** * Selects the initial data product. * If there is only one data product in the provided catalog, select it. * If there are multiple data products, open the dialog and let the user choose. * * @param catalog Selected catalog * @param rootCatalog RDS root catalog * @returns Observable whether the selection has changed */ private selectInitialDataProduct; }