AAE-25392 Fixing types for setAuthGuards method (#10164)

* AAE-25392 Fixing types for setAuthGuards method

* AAE-25392 Fix type
This commit is contained in:
Ehsan Rezaei
2024-09-03 07:43:34 +02:00
committed by GitHub
parent beae4054f2
commit 4fd62acdec
@@ -35,7 +35,7 @@ import { BehaviorSubject, Observable } from 'rxjs';
*/ */
export function extensionJsonsFactory() { export function extensionJsonsFactory() {
return []; return [];
}; }
export const EXTENSION_JSONS = new InjectionToken<string[][]>('extension-jsons', { export const EXTENSION_JSONS = new InjectionToken<string[][]>('extension-jsons', {
providedIn: 'root', providedIn: 'root',
@@ -60,7 +60,7 @@ export function provideExtensionConfig(jsons: string[]) {
useValue: jsons, useValue: jsons,
multi: true multi: true
}; };
}; }
/** /**
* Provides the extension json raw values for the angular modules * Provides the extension json raw values for the angular modules
@@ -74,7 +74,7 @@ export function provideExtensionConfigValues(extensionConfigValue: ExtensionConf
useValue: extensionConfigValue, useValue: extensionConfigValue,
multi: true multi: true
}; };
}; }
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@@ -86,7 +86,7 @@ export class ExtensionService {
routes: Array<RouteRef> = []; routes: Array<RouteRef> = [];
actions: Array<ActionRef> = []; actions: Array<ActionRef> = [];
features: Array<any> = []; features: Array<any> = [];
authGuards: { [key: string]: Type<any> } = {}; authGuards: Record<string, unknown> = {};
setup$: Observable<ExtensionConfig>; setup$: Observable<ExtensionConfig>;
@@ -109,12 +109,7 @@ export class ExtensionService {
* @returns The loaded config data * @returns The loaded config data
*/ */
async load(): Promise<ExtensionConfig> { async load(): Promise<ExtensionConfig> {
const config = await this.loader.load( const config = await this.loader.load(this.configPath, this.pluginsPath, this.extensionJsons.flat(), this.extensionJsonValues.flat());
this.configPath,
this.pluginsPath,
this.extensionJsons.flat(),
this.extensionJsonValues.flat()
);
this.setup(config); this.setup(config);
return config; return config;
@@ -177,7 +172,7 @@ export class ExtensionService {
* *
* @param values The new auth guards to add * @param values The new auth guards to add
*/ */
setAuthGuards(values: { [key: string]: Type<any> }) { setAuthGuards(values: Record<string, unknown>) {
if (values) { if (values) {
this.authGuards = Object.assign({}, this.authGuards, values); this.authGuards = Object.assign({}, this.authGuards, values);
} }
@@ -208,10 +203,8 @@ export class ExtensionService {
* @param ids Array of ID value to look for * @param ids Array of ID value to look for
* @returns Array of auth guards or empty array if none were found * @returns Array of auth guards or empty array if none were found
*/ */
getAuthGuards(ids: string[]): Array<Type<any>> { getAuthGuards(ids: string[]): Array<unknown> {
return (ids || []) return (ids || []).map((id) => this.authGuards[id]).filter((guard) => guard);
.map((id) => this.authGuards[id])
.filter((guard) => guard);
} }
/** /**
@@ -272,12 +265,12 @@ export class ExtensionService {
* @param context Parameter object for the expression with details of app state * @param context Parameter object for the expression with details of app state
* @returns Result of evaluated expression, if found, or the literal value otherwise * @returns Result of evaluated expression, if found, or the literal value otherwise
*/ */
runExpression(value: string | any , context?: any) { runExpression(value: string | any, context?: any) {
if (typeof value === 'string' ) { if (typeof value === 'string') {
return this.evaluateExpression(value, context); return this.evaluateExpression(value, context);
} else { } else {
const duplicate = Object.assign({}, value); const duplicate = Object.assign({}, value);
Object.keys(duplicate).forEach( (key) => { Object.keys(duplicate).forEach((key) => {
duplicate[key] = this.evaluateExpression(duplicate[key], context); duplicate[key] = this.evaluateExpression(duplicate[key], context);
}); });
return duplicate; return duplicate;