diff --git a/lib/app.ts b/lib/app.ts index 9a4fb03ec6..40d8c28fb4 100644 --- a/lib/app.ts +++ b/lib/app.ts @@ -53,7 +53,7 @@ const runHandler = (handler: Function, defaultResult: any, handlerArg?: any) => .catch(handleHandlerError) } -export default function createApp(channel: Channel): AppConfigAPI { +export default function createApp(channel: Channel): AppConfigAPI { const handlers: { [key: string]: any } = { [HOOK_STAGE_PRE_INSTALL]: null, [HOOK_STAGE_POST_INSTALL]: null, @@ -105,7 +105,7 @@ export default function createApp(channel: Channel): AppConfigAPI { getCurrentState() { return channel.call('callAppMethod', 'getCurrentState') as Promise }, - onConfigure(handler: OnConfigureHandler) { + onConfigure(handler: OnConfigureHandler) { setHandler(HOOK_STAGE_PRE_INSTALL, handler) }, onConfigurationCompleted(handler: (err: null | { message: string }) => void) { diff --git a/lib/types/api.types.ts b/lib/types/api.types.ts index e83402cb5b..f21f0608f0 100644 --- a/lib/types/api.types.ts +++ b/lib/types/api.types.ts @@ -312,7 +312,7 @@ export type ConfigAppSDK & { /** A set of IDs actual for the app */ ids: Omit & { app: string } - app: AppConfigAPI + app: AppConfigAPI } export type KnownAppSDK< diff --git a/lib/types/app.types.ts b/lib/types/app.types.ts index a4409bf0ac..91805d854f 100644 --- a/lib/types/app.types.ts +++ b/lib/types/app.types.ts @@ -10,12 +10,14 @@ export interface AppState { EditorInterface: Record } -export type OnConfigureHandlerReturn = - | { parameters?: KeyValueMap | null; targetState?: AppState | null } +export type OnConfigureHandlerReturn = + | { parameters?: InstallationParameters | null; targetState?: AppState | null } | false -export type OnConfigureHandler = () => OnConfigureHandlerReturn | Promise +export type OnConfigureHandler = () => + | OnConfigureHandlerReturn + | Promise> -export interface AppConfigAPI { +export interface AppConfigAPI { /** Tells the web app that the app is loaded */ setReady: () => Promise /** Returns true if an App is installed */ @@ -23,9 +25,9 @@ export interface AppConfigAPI { /** Returns current state of an App */ getCurrentState: () => Promise /** Returns parameters of an App, null otherwise */ - getParameters: () => Promise + getParameters: () => Promise /** Registers a handler to be called to produce parameters for an App */ - onConfigure: (handler: OnConfigureHandler) => void + onConfigure: (handler: OnConfigureHandler) => void /** Registers a handler to be called once configuration was finished */ onConfigurationCompleted: (handler: (err: null | { message: string }) => void) => void }