diff --git a/packages/app-runtime/src/AppConfig.ts b/packages/app-runtime/src/AppConfig.ts index b28beb5d4..acf4791cd 100644 --- a/packages/app-runtime/src/AppConfig.ts +++ b/packages/app-runtime/src/AppConfig.ts @@ -13,13 +13,14 @@ export interface AppConfig extends RuntimeConfig { export interface AppConfigOverwrite { transportLibrary?: Omit; accountsDbName?: string; - applicationId: string; + applicationId?: string; applePushEnvironment?: "Development" | "Production"; allowMultipleAccountsWithSameAddress?: boolean; databaseFolder?: string; + modules?: Record; } -export function createAppConfig(...configs: AppConfigOverwrite[]): AppConfig { +export function createAppConfig(...configs: (AppConfigOverwrite | AppConfig)[]): AppConfig { const appConfig: Omit & { transportLibrary: Omit; } = { diff --git a/packages/app-runtime/src/AppRuntime.ts b/packages/app-runtime/src/AppRuntime.ts index d71ec32ac..57085dd2c 100644 --- a/packages/app-runtime/src/AppRuntime.ts +++ b/packages/app-runtime/src/AppRuntime.ts @@ -203,7 +203,7 @@ export class AppRuntime extends Runtime { this._accountServices = new AccountServices(this._multiAccountController); } - public static async create(nativeBootstrapper: INativeBootstrapper, appConfig?: AppConfigOverwrite, eventBus?: EventBus): Promise { + public static async create(nativeBootstrapper: INativeBootstrapper, appConfig: AppConfigOverwrite | AppConfig = {}, eventBus?: EventBus): Promise { // TODO: JSSNMSHDD-2524 (validate app config) if (!nativeBootstrapper.isInitialized) { @@ -213,28 +213,7 @@ export class AppRuntime extends Runtime { } } - const applePushEnvironmentResult = nativeBootstrapper.nativeEnvironment.configAccess.get("applePushEnvironment"); - const applePushEnvironment = applePushEnvironmentResult.isError ? undefined : applePushEnvironmentResult.value; - - const applicationId = nativeBootstrapper.nativeEnvironment.configAccess.get("applicationId").value; - const transportConfig = nativeBootstrapper.nativeEnvironment.configAccess.get("transport").value; - const databaseFolder = nativeBootstrapper.nativeEnvironment.configAccess.get("databaseFolder").value; - - const mergedConfig = appConfig - ? createAppConfig( - { - transportLibrary: transportConfig, - applicationId: applicationId, - applePushEnvironment: applePushEnvironment - }, - appConfig - ) - : createAppConfig({ - transportLibrary: transportConfig, - applicationId: applicationId, - applePushEnvironment: applePushEnvironment, - databaseFolder: databaseFolder - }); + const mergedConfig = createAppConfig(appConfig); const runtime = new AppRuntime(nativeBootstrapper.nativeEnvironment, mergedConfig, eventBus); await runtime.init(); diff --git a/packages/app-runtime/src/natives/INativeConfigAccess.ts b/packages/app-runtime/src/natives/INativeConfigAccess.ts index 6f27113ae..d7def49f0 100644 --- a/packages/app-runtime/src/natives/INativeConfigAccess.ts +++ b/packages/app-runtime/src/natives/INativeConfigAccess.ts @@ -5,6 +5,4 @@ export interface INativeConfigAccess { set(key: string, value: any): Result; remove(key: string): Result; save(): Promise>; - initDefaultConfig(path: string): Promise>; - initRuntimeConfig(path: string): Promise>; } diff --git a/packages/app-runtime/test/lib/TestUtil.ts b/packages/app-runtime/test/lib/TestUtil.ts index 93b321d29..eb33b4a55 100644 --- a/packages/app-runtime/test/lib/TestUtil.ts +++ b/packages/app-runtime/test/lib/TestUtil.ts @@ -20,12 +20,12 @@ import { defaultsDeep } from "lodash"; import path from "path"; import { GenericContainer, Wait } from "testcontainers"; import { LogLevel } from "typescript-logging"; -import { AppConfig, AppRuntime, IUIBridge, LocalAccountDTO, LocalAccountSession, createAppConfig as runtime_createAppConfig } from "../../src"; +import { AppConfig, AppConfigOverwrite, AppRuntime, IUIBridge, LocalAccountDTO, LocalAccountSession, createAppConfig as runtime_createAppConfig } from "../../src"; import { FakeUIBridge } from "./FakeUIBridge"; import { FakeNativeBootstrapper } from "./natives/FakeNativeBootstrapper"; export class TestUtil { - public static async createRuntime(configOverride?: any, uiBridge: IUIBridge = new FakeUIBridge(), eventBus?: EventBus): Promise { + public static async createRuntime(configOverride?: AppConfigOverwrite, uiBridge: IUIBridge = new FakeUIBridge(), eventBus?: EventBus): Promise { configOverride = defaultsDeep(configOverride, { modules: { pushNotification: { enabled: false } @@ -42,7 +42,7 @@ export class TestUtil { return runtime; } - public static async createRuntimeWithoutInit(configOverride?: any): Promise { + public static async createRuntimeWithoutInit(configOverride?: AppConfigOverwrite): Promise { const config = this.createAppConfig(configOverride); const nativeBootstrapper = new FakeNativeBootstrapper(); diff --git a/packages/app-runtime/test/lib/natives/FakeNativeConfigAccess.ts b/packages/app-runtime/test/lib/natives/FakeNativeConfigAccess.ts index 000d28da4..61b8a9dfd 100644 --- a/packages/app-runtime/test/lib/natives/FakeNativeConfigAccess.ts +++ b/packages/app-runtime/test/lib/natives/FakeNativeConfigAccess.ts @@ -21,12 +21,4 @@ export class FakeNativeConfigAccess implements INativeConfigAccess { public save(): Promise> { return Promise.resolve(Result.ok(undefined)); } - - public initRuntimeConfig(/* logger: ILogger, fileAccess: INativeFileAccess*/): Promise> { - return Promise.resolve(Result.ok(undefined)); - } - - public initDefaultConfig(): Promise> { - return Promise.resolve(Result.ok(undefined)); - } }