contentful-ui-extensions-sdk 4.15.0 → 4.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,223 +1,263 @@
1
- import { ContentType, EditorInterface, SpaceMembership, Role, ContentTypeField, Metadata, Entry, Task, Asset, WorkflowDefinition } from './entities';
2
- import { EntryAPI } from './entry.types';
3
- import { SpaceAPI } from './space.types';
4
- import { WindowAPI } from './window.types';
5
- import { EntrySys, Link, SerializedJSONValue } from './utils';
6
- import { FieldAPI } from './field-locale.types';
7
- import { DialogsAPI } from './dialogs.types';
8
- import { AppConfigAPI } from './app.types';
9
- import { NavigatorAPI } from './navigator.types';
10
- import { EntryFieldInfo, FieldInfo } from './field.types';
11
- import { Adapter, KeyValueMap } from 'contentful-management/types';
12
- export interface UserAPI {
13
- sys: {
14
- id: string;
15
- type: string;
16
- };
17
- firstName: string;
18
- lastName: string;
19
- email: string;
20
- avatarUrl: string;
21
- spaceMembership: {
22
- sys: Pick<SpaceMembership['sys'], 'id' | 'type'>;
23
- admin: SpaceMembership['admin'];
24
- roles: Pick<Role, 'name' | 'description'>[];
25
- };
26
- }
27
- export interface LocalesAPI {
28
- /** The default locale code for the current space. */
29
- default: string;
30
- /** A list of locale codes of all locales available for editing in the current space. */
31
- available: string[];
32
- /** An object with keys of locale codes and values of corresponding human-readable locale names. */
33
- names: {
34
- [key: string]: string;
35
- };
36
- /** An object with keys of locale codes and values of corresponding fallback locale codes. If there's no fallback then the value is undefined. */
37
- fallbacks: {
38
- [key: string]: string | undefined;
39
- };
40
- /** An object with keys of locale codes and values of corresponding boolean value indicating if the locale is optional or not. */
41
- optional: {
42
- [key: string]: boolean;
43
- };
44
- /** An object with keys of locale codes and values of corresponding information indicating if the locale is right-to-left or left-to-right language. */
45
- direction: {
46
- [key: string]: 'ltr' | 'rtl';
47
- };
48
- }
49
- export interface NotifierAPI {
50
- /** Displays a success notification in the notification area of the Web App. */
51
- success: (message: string) => void;
52
- /** Displays an error notification in the notification area of the Web App. */
53
- error: (message: string) => void;
54
- /** Displays a warning notification in the notification area of the Web App. */
55
- warning: (message: string) => void;
56
- }
57
- export interface LocationAPI {
58
- /** Checks the location in which your app is running */
59
- is: (type: string) => boolean;
60
- }
61
- export interface ParametersAPI {
62
- installation: KeyValueMap;
63
- instance: KeyValueMap;
64
- invocation?: SerializedJSONValue;
65
- }
66
- export interface IdsAPI {
67
- user: string;
68
- extension?: string;
69
- organization: string;
70
- app?: string;
71
- space: string;
72
- environment: string;
73
- environmentAlias?: string;
74
- field: string;
75
- entry: string;
76
- contentType: string;
77
- }
78
- /** Content API */
79
- export interface ContentTypeAPI {
80
- sys: {
81
- id: string;
82
- type: 'ContentType';
83
- revision: number;
84
- space: Link<'Space', 'Link'>;
85
- environment: Link<'Environment', 'Link'>;
86
- createdAt?: string;
87
- updatedAt?: string;
88
- };
89
- fields: ContentTypeField[];
90
- name: string;
91
- displayField: string;
92
- description: string;
93
- }
94
- export interface EditorLocaleSettings {
95
- mode: 'multi' | 'single';
96
- focused?: string;
97
- active?: Array<string>;
98
- }
99
- export interface SharedEditorSDK {
100
- editor: {
101
- editorInterface: EditorInterface;
102
- onLocaleSettingsChanged: (callback: (localeSettings: EditorLocaleSettings) => void) => () => void;
103
- onShowDisabledFieldsChanged: (callback: (showDisabledFields: boolean) => any) => () => void;
104
- };
105
- /** Allows to read and update the value of any field of the current entry and to get the entry's metadata */
106
- entry: EntryAPI;
107
- /** Information about the content type of the entry. */
108
- contentType: ContentTypeAPI;
109
- }
110
- export type CrudAction = 'create' | 'read' | 'update' | 'delete';
111
- export type PublishableAction = 'publish' | 'unpublish';
112
- export type ArchiveableAction = 'archive' | 'unarchive';
113
- export type JSONPatchItem = {
114
- op: 'remove' | 'replace' | 'add';
115
- path: string;
116
- value?: any;
117
- };
118
- type PatchEntity = Entry | Task | Asset | WorkflowDefinition;
119
- export interface AccessAPI {
120
- can(action: 'read' | 'update', entity: 'EditorInterface' | EditorInterface): Promise<boolean>;
121
- can<T = Object>(action: CrudAction, entity: 'ContentType' | ContentType | 'Asset' | 'Entry' | T): Promise<boolean>;
122
- can<T = Object>(action: PublishableAction, entity: 'ContentType' | ContentType | 'Asset' | 'Entry' | T): Promise<boolean>;
123
- can<T = Object>(action: ArchiveableAction, entity: 'Asset' | 'Entry' | T): Promise<boolean>;
124
- can(action: 'update', entity: PatchEntity, patch: JSONPatchItem[]): Promise<boolean>;
125
- /** Whether the current user can edit app config */
126
- canEditAppConfig: () => Promise<boolean>;
127
- }
128
- type EntryScopedIds = 'field' | 'entry' | 'contentType';
129
- export interface BaseExtensionSDK {
130
- /** @deprecated since version 4.0.0 consider using the CMA instead
131
- * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
132
- */
133
- space: SpaceAPI;
134
- /** Information about the current user and roles */
135
- user: UserAPI;
136
- /** Information about the current locales */
137
- locales: LocalesAPI;
138
- /** Methods for opening UI dialogs: */
139
- dialogs: DialogsAPI;
140
- /** Methods for navigating between entities stored in a Contentful space. */
141
- navigator: NavigatorAPI;
142
- /** Methods for displaying notifications. */
143
- notifier: NotifierAPI;
144
- /** Exposes app configuration parameters */
145
- parameters: ParametersAPI;
146
- /** Exposes method to identify app's location */
147
- location: LocationAPI;
148
- /** Exposes methods for checking user's access level */
149
- access: AccessAPI;
150
- /** Exposes relevant ids, keys may be ommited based on location */
151
- ids: Omit<IdsAPI, EntryScopedIds>;
152
- /** Adapter to be injected in contentful-management client */
153
- cmaAdapter: Adapter;
154
- }
155
- export type EditorExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & SharedEditorSDK & {
156
- /** A set of IDs for the app */
157
- ids: Omit<IdsAPI, 'field'>;
158
- };
159
- export type SidebarExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & SharedEditorSDK & {
160
- /** A set of IDs for the app */
161
- ids: Omit<IdsAPI, 'field'>;
162
- /** Methods to update the size of the iframe the app is contained within. */
163
- window: WindowAPI;
164
- };
165
- export type FieldExtensionSDK = BaseExtensionSDK & SharedEditorSDK & {
166
- /** A set of IDs for the app */
167
- ids: IdsAPI;
168
- /** Gives you access to the value and metadata of the field the app is attached to. */
169
- field: FieldAPI;
170
- /** Methods to update the size of the iframe the app is contained within. */
171
- window: WindowAPI;
172
- };
173
- export type DialogExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & {
174
- /** A set of IDs for the app */
175
- ids: Omit<IdsAPI, EntryScopedIds>;
176
- /** Closes the dialog and resolves openCurrentApp promise with data */
177
- close: (data?: any) => void;
178
- /** Methods to update the size of the iframe the app is contained within. */
179
- window: WindowAPI;
180
- };
181
- export type PageExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & {
182
- /** A set of IDs actual for the app */
183
- ids: Omit<IdsAPI, EntryScopedIds>;
184
- };
185
- export type HomeExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & {
186
- ids: Omit<IdsAPI, EntryScopedIds>;
187
- };
188
- export type AppExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & {
189
- /** A set of IDs actual for the app */
190
- ids: Omit<IdsAPI, EntryScopedIds | 'extension' | 'app'> & {
191
- app: string;
192
- };
193
- app: AppConfigAPI;
194
- };
195
- export type KnownSDK = FieldExtensionSDK | SidebarExtensionSDK | DialogExtensionSDK | EditorExtensionSDK | PageExtensionSDK | AppExtensionSDK | HomeExtensionSDK;
196
- export interface Locations {
197
- LOCATION_ENTRY_FIELD: 'entry-field';
198
- LOCATION_ENTRY_FIELD_SIDEBAR: 'entry-field-sidebar';
199
- LOCATION_ENTRY_SIDEBAR: 'entry-sidebar';
200
- LOCATION_DIALOG: 'dialog';
201
- LOCATION_ENTRY_EDITOR: 'entry-editor';
202
- LOCATION_PAGE: 'page';
203
- LOCATION_HOME: 'home';
204
- LOCATION_APP_CONFIG: 'app-config';
205
- }
206
- export interface ConnectMessage {
207
- id: string;
208
- location: Location[keyof Location];
209
- parameters: ParametersAPI;
210
- locales: LocalesAPI;
211
- user: UserAPI;
212
- initialContentTypes: ContentType[];
213
- ids: IdsAPI;
214
- contentType: ContentTypeAPI;
215
- editorInterface?: EditorInterface;
216
- entry: {
217
- sys: EntrySys;
218
- metadata?: Metadata;
219
- };
220
- fieldInfo: EntryFieldInfo[];
221
- field?: FieldInfo;
222
- }
223
- export {};
1
+ import { ContentType, EditorInterface, SpaceMembership, Role, ContentTypeField, Metadata, Entry, Task, Asset, WorkflowDefinition } from './entities';
2
+ import { EntryAPI } from './entry.types';
3
+ import { SpaceAPI } from './space.types';
4
+ import { WindowAPI } from './window.types';
5
+ import { EntrySys, Link, SerializedJSONValue } from './utils';
6
+ import { FieldAPI } from './field-locale.types';
7
+ import { DialogsAPI } from './dialogs.types';
8
+ import { AppConfigAPI } from './app.types';
9
+ import { NavigatorAPI } from './navigator.types';
10
+ import { EntryFieldInfo, FieldInfo } from './field.types';
11
+ import { Adapter, KeyValueMap } from 'contentful-management/types';
12
+ export interface UserAPI {
13
+ sys: {
14
+ id: string;
15
+ type: string;
16
+ };
17
+ firstName: string;
18
+ lastName: string;
19
+ email: string;
20
+ avatarUrl: string;
21
+ spaceMembership: {
22
+ sys: Pick<SpaceMembership['sys'], 'id' | 'type'>;
23
+ admin: SpaceMembership['admin'];
24
+ roles: Pick<Role, 'name' | 'description'>[];
25
+ };
26
+ }
27
+ export interface LocalesAPI {
28
+ /** The default locale code for the current space. */
29
+ default: string;
30
+ /** A list of locale codes of all locales available for editing in the current space. */
31
+ available: string[];
32
+ /** An object with keys of locale codes and values of corresponding human-readable locale names. */
33
+ names: {
34
+ [key: string]: string;
35
+ };
36
+ /** An object with keys of locale codes and values of corresponding fallback locale codes. If there's no fallback then the value is undefined. */
37
+ fallbacks: {
38
+ [key: string]: string | undefined;
39
+ };
40
+ /** An object with keys of locale codes and values of corresponding boolean value indicating if the locale is optional or not. */
41
+ optional: {
42
+ [key: string]: boolean;
43
+ };
44
+ /** An object with keys of locale codes and values of corresponding information indicating if the locale is right-to-left or left-to-right language. */
45
+ direction: {
46
+ [key: string]: 'ltr' | 'rtl';
47
+ };
48
+ }
49
+ export interface NotifierAPI {
50
+ /** Displays a success notification in the notification area of the Web App. */
51
+ success: (message: string) => void;
52
+ /** Displays an error notification in the notification area of the Web App. */
53
+ error: (message: string) => void;
54
+ /** Displays a warning notification in the notification area of the Web App. */
55
+ warning: (message: string) => void;
56
+ }
57
+ export interface LocationAPI {
58
+ /** Checks the location in which your app is running */
59
+ is: (type: string) => boolean;
60
+ }
61
+ export interface ParametersAPI {
62
+ installation: KeyValueMap;
63
+ instance: KeyValueMap;
64
+ invocation?: SerializedJSONValue;
65
+ }
66
+ export interface IdsAPI {
67
+ user: string;
68
+ extension?: string;
69
+ organization: string;
70
+ app?: string;
71
+ space: string;
72
+ environment: string;
73
+ environmentAlias?: string;
74
+ field: string;
75
+ entry: string;
76
+ contentType: string;
77
+ }
78
+ /** Content API */
79
+ export interface ContentTypeAPI {
80
+ sys: {
81
+ id: string;
82
+ type: 'ContentType';
83
+ revision: number;
84
+ space: Link<'Space', 'Link'>;
85
+ environment: Link<'Environment', 'Link'>;
86
+ createdAt?: string;
87
+ updatedAt?: string;
88
+ };
89
+ fields: ContentTypeField[];
90
+ name: string;
91
+ displayField: string;
92
+ description: string;
93
+ }
94
+ export interface EditorLocaleSettings {
95
+ mode: 'multi' | 'single';
96
+ focused?: string;
97
+ active?: Array<string>;
98
+ }
99
+ export interface SharedEditorSDK {
100
+ editor: {
101
+ editorInterface: EditorInterface;
102
+ /**
103
+ * Returns the current locale settings
104
+ *
105
+ * The locale setting can change. To always work with the latest settings, use `onLocaleSettingsChanged`.
106
+ */
107
+ getLocaleSettings(): EditorLocaleSettings;
108
+ /**
109
+ * Subscribes to changes of the editor's locale settings
110
+ *
111
+ * @param callback Function that is called every time the locale settings change. Called immidiately with the current setting.
112
+ * @returns Function to unsubscribe. `callback` won't be called anymore.
113
+ */
114
+ onLocaleSettingsChanged: (callback: (localeSettings: EditorLocaleSettings) => void) => () => void;
115
+ /**
116
+ * Subscribes to changes of whether or not disabled fields are displayed
117
+ *
118
+ * @param callback Function that is called every time the setting whether or not disabled fields are displayed changes. Called immediately with the current state.
119
+ * @returns Function to unsubscribe. `callback` won't be called anymore.
120
+ * @deprecated Use {@link onShowHiddenFieldsChanged} instead
121
+ */
122
+ onShowDisabledFieldsChanged: (callback: (showDisabledFields: boolean) => void) => () => void;
123
+ /**
124
+ * Returns whether or not hidden fields are displayed
125
+ *
126
+ * This setting can change. To always work with the latest settings, use `onShowHiddenFieldsChanged`.
127
+ */
128
+ getShowHiddenFields(): boolean;
129
+ /**
130
+ * Subscribes to changes of whether or not hidden fields are displayed
131
+ *
132
+ * @param callback Function that is called every time the setting whether or not hidden fields are displayed changes. Called immediately with the current state.
133
+ * @returns Function to unsubscribe. `callback` won't be called anymore.
134
+ */
135
+ onShowHiddenFieldsChanged: (callback: (showHiddenFields: boolean) => void) => () => void;
136
+ };
137
+ /**
138
+ * Allows to read and update the value of any field of the current entry and to get the entry's metadata
139
+ */
140
+ entry: EntryAPI;
141
+ /**
142
+ * Information about the content type of the entry.
143
+ */
144
+ contentType: ContentTypeAPI;
145
+ }
146
+ export type CrudAction = 'create' | 'read' | 'update' | 'delete';
147
+ export type PublishableAction = 'publish' | 'unpublish';
148
+ export type ArchiveableAction = 'archive' | 'unarchive';
149
+ export type JSONPatchItem = {
150
+ op: 'remove' | 'replace' | 'add';
151
+ path: string;
152
+ value?: any;
153
+ };
154
+ type PatchEntity = Entry | Task | Asset | WorkflowDefinition;
155
+ export interface AccessAPI {
156
+ can(action: 'read' | 'update', entity: 'EditorInterface' | EditorInterface): Promise<boolean>;
157
+ can<T = Object>(action: CrudAction, entity: 'ContentType' | ContentType | 'Asset' | 'Entry' | T): Promise<boolean>;
158
+ can<T = Object>(action: PublishableAction, entity: 'ContentType' | ContentType | 'Asset' | 'Entry' | T): Promise<boolean>;
159
+ can<T = Object>(action: ArchiveableAction, entity: 'Asset' | 'Entry' | T): Promise<boolean>;
160
+ can(action: 'update', entity: PatchEntity, patch: JSONPatchItem[]): Promise<boolean>;
161
+ /** Whether the current user can edit app config */
162
+ canEditAppConfig: () => Promise<boolean>;
163
+ }
164
+ type EntryScopedIds = 'field' | 'entry' | 'contentType';
165
+ export interface BaseExtensionSDK {
166
+ /** @deprecated since version 4.0.0 consider using the CMA instead
167
+ * See https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library for more details
168
+ */
169
+ space: SpaceAPI;
170
+ /** Information about the current user and roles */
171
+ user: UserAPI;
172
+ /** Information about the current locales */
173
+ locales: LocalesAPI;
174
+ /** Methods for opening UI dialogs: */
175
+ dialogs: DialogsAPI;
176
+ /** Methods for navigating between entities stored in a Contentful space. */
177
+ navigator: NavigatorAPI;
178
+ /** Methods for displaying notifications. */
179
+ notifier: NotifierAPI;
180
+ /** Exposes app configuration parameters */
181
+ parameters: ParametersAPI;
182
+ /** Exposes method to identify app's location */
183
+ location: LocationAPI;
184
+ /** Exposes methods for checking user's access level */
185
+ access: AccessAPI;
186
+ /** Exposes relevant ids, keys may be ommited based on location */
187
+ ids: Omit<IdsAPI, EntryScopedIds>;
188
+ /** Adapter to be injected in contentful-management client */
189
+ cmaAdapter: Adapter;
190
+ }
191
+ export type EditorExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & SharedEditorSDK & {
192
+ /** A set of IDs for the app */
193
+ ids: Omit<IdsAPI, 'field'>;
194
+ };
195
+ export type SidebarExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & SharedEditorSDK & {
196
+ /** A set of IDs for the app */
197
+ ids: Omit<IdsAPI, 'field'>;
198
+ /** Methods to update the size of the iframe the app is contained within. */
199
+ window: WindowAPI;
200
+ };
201
+ export type FieldExtensionSDK = BaseExtensionSDK & SharedEditorSDK & {
202
+ /** A set of IDs for the app */
203
+ ids: IdsAPI;
204
+ /** Gives you access to the value and metadata of the field the app is attached to. */
205
+ field: FieldAPI;
206
+ /** Methods to update the size of the iframe the app is contained within. */
207
+ window: WindowAPI;
208
+ };
209
+ export type DialogExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & {
210
+ /** A set of IDs for the app */
211
+ ids: Omit<IdsAPI, EntryScopedIds>;
212
+ /** Closes the dialog and resolves openCurrentApp promise with data */
213
+ close: (data?: any) => void;
214
+ /** Methods to update the size of the iframe the app is contained within. */
215
+ window: WindowAPI;
216
+ };
217
+ export type PageExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & {
218
+ /** A set of IDs actual for the app */
219
+ ids: Omit<IdsAPI, EntryScopedIds>;
220
+ };
221
+ export type HomeExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & {
222
+ ids: Omit<IdsAPI, EntryScopedIds>;
223
+ };
224
+ export type AppExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & {
225
+ /** A set of IDs actual for the app */
226
+ ids: Omit<IdsAPI, EntryScopedIds | 'extension' | 'app'> & {
227
+ app: string;
228
+ };
229
+ app: AppConfigAPI;
230
+ };
231
+ export type KnownSDK = FieldExtensionSDK | SidebarExtensionSDK | DialogExtensionSDK | EditorExtensionSDK | PageExtensionSDK | AppExtensionSDK | HomeExtensionSDK;
232
+ export interface Locations {
233
+ LOCATION_ENTRY_FIELD: 'entry-field';
234
+ LOCATION_ENTRY_FIELD_SIDEBAR: 'entry-field-sidebar';
235
+ LOCATION_ENTRY_SIDEBAR: 'entry-sidebar';
236
+ LOCATION_DIALOG: 'dialog';
237
+ LOCATION_ENTRY_EDITOR: 'entry-editor';
238
+ LOCATION_PAGE: 'page';
239
+ LOCATION_HOME: 'home';
240
+ LOCATION_APP_CONFIG: 'app-config';
241
+ }
242
+ export interface ConnectMessage {
243
+ id: string;
244
+ location: Location[keyof Location];
245
+ parameters: ParametersAPI;
246
+ locales: LocalesAPI;
247
+ user: UserAPI;
248
+ initialContentTypes: ContentType[];
249
+ ids: IdsAPI;
250
+ contentType: ContentTypeAPI;
251
+ editorInterface?: EditorInterface;
252
+ editor?: {
253
+ localeSettings: EditorLocaleSettings;
254
+ showHiddenFields: boolean;
255
+ };
256
+ entry: {
257
+ sys: EntrySys;
258
+ metadata?: Metadata;
259
+ };
260
+ fieldInfo: EntryFieldInfo[];
261
+ field?: FieldInfo;
262
+ }
263
+ export {};
@@ -1,44 +1,44 @@
1
- import { ContentType, KeyValueMap } from './entities';
2
- interface AppStateEditorInterfaceItem {
3
- controls?: Array<{
4
- fieldId: string;
5
- settings?: Record<string, any>;
6
- }>;
7
- sidebar?: {
8
- position: number;
9
- settings?: Record<string, any>;
10
- };
11
- editors?: {
12
- position: number;
13
- settings?: Record<string, any>;
14
- };
15
- /**
16
- * @deprecated use `editors` instead
17
- */
18
- editor?: boolean;
19
- }
20
- export interface AppState {
21
- EditorInterface: Record<ContentType['sys']['id'], AppStateEditorInterfaceItem>;
22
- }
23
- export type OnConfigureHandlerReturn = {
24
- parameters?: KeyValueMap | null;
25
- targetState?: AppState | null;
26
- } | false;
27
- export type OnConfigureHandler = () => OnConfigureHandlerReturn | Promise<OnConfigureHandlerReturn>;
28
- export interface AppConfigAPI {
29
- /** Tells the web app that the app is loaded */
30
- setReady: () => Promise<void>;
31
- /** Returns true if an App is installed */
32
- isInstalled: () => Promise<boolean>;
33
- /** Returns current state of an App */
34
- getCurrentState: () => Promise<AppState | null>;
35
- /** Returns parameters of an App, null otherwise */
36
- getParameters: <T extends KeyValueMap = KeyValueMap>() => Promise<null | T>;
37
- /** Registers a handler to be called to produce parameters for an App */
38
- onConfigure: (handler: OnConfigureHandler) => void;
39
- /** Registers a handler to be called once configuration was finished */
40
- onConfigurationCompleted: (handler: (err: null | {
41
- message: string;
42
- }) => void) => void;
43
- }
44
- export {};
1
+ import { ContentType, KeyValueMap } from './entities';
2
+ interface AppStateEditorInterfaceItem {
3
+ controls?: Array<{
4
+ fieldId: string;
5
+ settings?: Record<string, any>;
6
+ }>;
7
+ sidebar?: {
8
+ position: number;
9
+ settings?: Record<string, any>;
10
+ };
11
+ editors?: {
12
+ position: number;
13
+ settings?: Record<string, any>;
14
+ };
15
+ /**
16
+ * @deprecated use `editors` instead
17
+ */
18
+ editor?: boolean;
19
+ }
20
+ export interface AppState {
21
+ EditorInterface: Record<ContentType['sys']['id'], AppStateEditorInterfaceItem>;
22
+ }
23
+ export type OnConfigureHandlerReturn = {
24
+ parameters?: KeyValueMap | null;
25
+ targetState?: AppState | null;
26
+ } | false;
27
+ export type OnConfigureHandler = () => OnConfigureHandlerReturn | Promise<OnConfigureHandlerReturn>;
28
+ export interface AppConfigAPI {
29
+ /** Tells the web app that the app is loaded */
30
+ setReady: () => Promise<void>;
31
+ /** Returns true if an App is installed */
32
+ isInstalled: () => Promise<boolean>;
33
+ /** Returns current state of an App */
34
+ getCurrentState: () => Promise<AppState | null>;
35
+ /** Returns parameters of an App, null otherwise */
36
+ getParameters: <T extends KeyValueMap = KeyValueMap>() => Promise<null | T>;
37
+ /** Registers a handler to be called to produce parameters for an App */
38
+ onConfigure: (handler: OnConfigureHandler) => void;
39
+ /** Registers a handler to be called once configuration was finished */
40
+ onConfigurationCompleted: (handler: (err: null | {
41
+ message: string;
42
+ }) => void) => void;
43
+ }
44
+ export {};