-
Notifications
You must be signed in to change notification settings - Fork 31
/
app.types.ts
35 lines (31 loc) · 1.38 KB
/
app.types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { ContentType, KeyValueMap } from './entities'
interface AppStateEditorInterfaceItem {
controls?: Array<{ fieldId: string; settings?: Record<string, any> }>
sidebar?: { position: number; settings?: Record<string, any> }
editors?: { position: number; settings?: Record<string, any> }
/**
* @deprecated use `editors` instead
*/
editor?: boolean
}
export interface AppState {
EditorInterface: Record<ContentType['sys']['id'], AppStateEditorInterfaceItem>
}
export type OnConfigureHandlerReturn =
| { parameters?: KeyValueMap | null; targetState?: AppState | null }
| false
export type OnConfigureHandler = () => OnConfigureHandlerReturn | Promise<OnConfigureHandlerReturn>
export interface AppConfigAPI {
/** Tells the web app that the app is loaded */
setReady: () => Promise<void>
/** Returns true if an App is installed */
isInstalled: () => Promise<boolean>
/** Returns current state of an App */
getCurrentState: () => Promise<AppState | null>
/** Returns parameters of an App, null otherwise */
getParameters: <T extends KeyValueMap = KeyValueMap>() => Promise<null | T>
/** Registers a handler to be called to produce parameters for an App */
onConfigure: (handler: OnConfigureHandler) => void
/** Registers a handler to be called once configuration was finished */
onConfigurationCompleted: (handler: (err: null | { message: string }) => void) => void
}