diff --git a/cspell.json b/cspell.json index b484a24da7..366073da1e 100644 --- a/cspell.json +++ b/cspell.json @@ -130,7 +130,8 @@ "processwithstarteventform", "processstring", "typeahed", - "minmax" + "minmax", + "jsons" ], "dictionaries": [ "html", diff --git a/lib/extensions/src/lib/config/action.extensions.ts b/lib/extensions/src/lib/config/action.extensions.ts index e28d35a590..4f11e81eaa 100644 --- a/lib/extensions/src/lib/config/action.extensions.ts +++ b/lib/extensions/src/lib/config/action.extensions.ts @@ -48,5 +48,5 @@ export interface ContentActionRef extends ExtensionElement { export interface ActionRef { id: string; type: string; - payload?: string; + payload?: any; } diff --git a/lib/extensions/src/lib/config/extension.config.ts b/lib/extensions/src/lib/config/extension.config.ts index 0b3a2d2879..844aa0fa98 100644 --- a/lib/extensions/src/lib/config/extension.config.ts +++ b/lib/extensions/src/lib/config/extension.config.ts @@ -25,7 +25,7 @@ export interface ExtensionRef { $version: string; $vendor: string; $license: string; - $runtime: string; + $runtime?: string; $description?: string; $dependencies?: Array; diff --git a/lib/extensions/src/lib/services/extension.service.spec.ts b/lib/extensions/src/lib/services/extension.service.spec.ts index 029c4df1a0..f54ee94e85 100644 --- a/lib/extensions/src/lib/services/extension.service.spec.ts +++ b/lib/extensions/src/lib/services/extension.service.spec.ts @@ -43,7 +43,7 @@ describe('ExtensionService', () => { loader = new ExtensionLoaderService(null); componentRegister = new ComponentRegisterService(); ruleService = new RuleService(loader); - service = new ExtensionService(loader, componentRegister, ruleService); + service = new ExtensionService(loader, componentRegister, ruleService, []); }); it('should load and setup a config', async () => { @@ -56,6 +56,7 @@ describe('ExtensionService', () => { await service.load(); expect(loader.load).toHaveBeenCalled(); + expect(loader.load).toHaveBeenCalledWith('assets/app.extensions.json', 'assets/plugins', []); expect(service.setup).toHaveBeenCalledWith(blankConfig); }); diff --git a/lib/extensions/src/lib/services/extension.service.ts b/lib/extensions/src/lib/services/extension.service.ts index f25d52d479..e58ebd6fde 100644 --- a/lib/extensions/src/lib/services/extension.service.ts +++ b/lib/extensions/src/lib/services/extension.service.ts @@ -15,9 +15,9 @@ * limitations under the License. */ -import { Injectable, Type } from '@angular/core'; +import { Injectable, Type, InjectionToken, Inject } from '@angular/core'; import { RuleEvaluator, RuleRef, RuleContext } from '../config/rule.extensions'; -import { ExtensionConfig } from '../config/extension.config'; +import { ExtensionConfig, ExtensionRef } from '../config/extension.config'; import { ExtensionLoaderService } from './extension-loader.service'; import { RouteRef } from '../config/routing.extensions'; import { ActionRef } from '../config/action.extensions'; @@ -26,6 +26,19 @@ import { ComponentRegisterService } from './component-register.service'; import { RuleService } from './rule.service'; import { ExtensionElement } from '../config/extension-element'; +const EXTENSION_JSONS = new InjectionToken('extension-jsons', { + providedIn: 'root', + factory: () => [] +}); + +export function provideExtensionConfig(jsons: ExtensionRef[]) { + return { + provide: EXTENSION_JSONS, + useValue: jsons, + multi: true + }; +} + @Injectable({ providedIn: 'root' }) @@ -44,7 +57,8 @@ export class ExtensionService { constructor( protected loader: ExtensionLoaderService, protected componentRegister: ComponentRegisterService, - protected ruleService: RuleService + protected ruleService: RuleService, + @Inject(EXTENSION_JSONS) protected extensionJsons: ExtensionRef[] ) { } @@ -55,7 +69,8 @@ export class ExtensionService { async load(): Promise { const config = await this.loader.load( this.configPath, - this.pluginsPath + this.pluginsPath, + this.extensionJsons.flat() ); this.setup(config); return config; diff --git a/lib/tsconfig.json b/lib/tsconfig.json index c095887b48..0ab0d60db9 100644 --- a/lib/tsconfig.json +++ b/lib/tsconfig.json @@ -29,7 +29,7 @@ "@alfresco/adf-core": ["./core/"], "@alfresco/adf-insights": ["./analytics"] }, - "lib": ["es2018", "dom"], + "lib": ["es2018", "esnext.array", "dom"], "suppressImplicitAnyIndexErrors": true }, "exclude": [ diff --git a/tsconfig.json b/tsconfig.json index 50c3f60bc8..1021d24212 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -23,6 +23,7 @@ ], "lib": [ "es2018", + "esnext.array", "dom" ], "paths": {