datocms-plugin-sdk 0.3.5 → 0.3.20
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.
- package/dist/esm/SiteApiSchema.d.ts +167 -83
- package/dist/esm/types.d.ts +467 -307
- package/dist/types/SiteApiSchema.d.ts +167 -83
- package/dist/types/types.d.ts +467 -307
- package/package.json +2 -2
- package/types.json +1006 -564
package/dist/types/types.d.ts
CHANGED
|
@@ -10,15 +10,19 @@ export declare type MainNavigationTab = {
|
|
|
10
10
|
pageId: string;
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
|
-
* Expresses where you want to place the tab in the top-bar. If not specified,
|
|
14
|
-
* will be placed after the standard tabs provided by DatoCMS itself.
|
|
13
|
+
* Expresses where you want to place the tab in the top-bar. If not specified,
|
|
14
|
+
* the tab will be placed after the standard tabs provided by DatoCMS itself.
|
|
15
15
|
*/
|
|
16
|
-
placement?: [
|
|
16
|
+
placement?: [
|
|
17
|
+
'before' | 'after',
|
|
18
|
+
'content' | 'mediaArea' | 'apiExplorer' | 'settings'
|
|
19
|
+
];
|
|
17
20
|
/**
|
|
18
|
-
* If different plugins specify the same `placement` for their tabs, they will
|
|
19
|
-
* displayed by ascending `rank`. If you want to specify an explicit value
|
|
20
|
-
* make sure to offer a way for final users to customize it inside
|
|
21
|
-
* form, otherwise the hardcoded value you choose might
|
|
21
|
+
* If different plugins specify the same `placement` for their tabs, they will
|
|
22
|
+
* be displayed by ascending `rank`. If you want to specify an explicit value
|
|
23
|
+
* for `rank`, make sure to offer a way for final users to customize it inside
|
|
24
|
+
* the plugin's settings form, otherwise the hardcoded value you choose might
|
|
25
|
+
* clash with the one of another plugin! *
|
|
22
26
|
*/
|
|
23
27
|
rank?: number;
|
|
24
28
|
};
|
|
@@ -34,8 +38,9 @@ export declare type SettingsAreaSidebarItem = {
|
|
|
34
38
|
};
|
|
35
39
|
};
|
|
36
40
|
/**
|
|
37
|
-
* The sidebar in the Settings Area presents a number of pages grouped by topic.
|
|
38
|
-
* object represents a new group to be added in the sideebar to the
|
|
41
|
+
* The sidebar in the Settings Area presents a number of pages grouped by topic.
|
|
42
|
+
* This object represents a new group to be added in the sideebar to the
|
|
43
|
+
* standard ones DatoCMS provides.
|
|
39
44
|
*/
|
|
40
45
|
export declare type SettingsAreaSidebarItemGroup = {
|
|
41
46
|
/** Label to be shown. Must be unique. */
|
|
@@ -43,24 +48,26 @@ export declare type SettingsAreaSidebarItemGroup = {
|
|
|
43
48
|
/** The list of items it contains * */
|
|
44
49
|
items: SettingsAreaSidebarItem[];
|
|
45
50
|
/**
|
|
46
|
-
* Expresses where you want the group to be placed inside the sidebar. If not
|
|
47
|
-
* the item will be placed after the standard items provided by
|
|
51
|
+
* Expresses where you want the group to be placed inside the sidebar. If not
|
|
52
|
+
* specified, the item will be placed after the standard items provided by
|
|
53
|
+
* DatoCMS itself.
|
|
48
54
|
*/
|
|
49
55
|
placement?: [
|
|
50
56
|
'before' | 'after',
|
|
51
57
|
('environment' | 'project' | 'permissions' | 'webhooks' | 'deployment' | 'sso' | 'auditLog' | 'usage')
|
|
52
58
|
];
|
|
53
59
|
/**
|
|
54
|
-
* If different plugins specify the same `placement` for their sections, they
|
|
55
|
-
* displayed by ascending `rank`. If you want to specify an explicit
|
|
56
|
-
* make sure to offer a way for final users to customize it
|
|
57
|
-
* form, otherwise the hardcoded value you choose
|
|
60
|
+
* If different plugins specify the same `placement` for their sections, they
|
|
61
|
+
* will be displayed by ascending `rank`. If you want to specify an explicit
|
|
62
|
+
* value for `rank`, make sure to offer a way for final users to customize it
|
|
63
|
+
* inside the plugin's settings form, otherwise the hardcoded value you choose
|
|
64
|
+
* might clash with the one of another plugin! *
|
|
58
65
|
*/
|
|
59
66
|
rank?: number;
|
|
60
67
|
};
|
|
61
68
|
/**
|
|
62
|
-
* The sidebar in the Content Area presents a number of user-defined menu-items.
|
|
63
|
-
* object represents a new item to be added in the sidebar.
|
|
69
|
+
* The sidebar in the Content Area presents a number of user-defined menu-items.
|
|
70
|
+
* This object represents a new item to be added in the sidebar.
|
|
64
71
|
*/
|
|
65
72
|
export declare type ContentAreaSidebarItem = {
|
|
66
73
|
/** Label to be shown. Must be unique. */
|
|
@@ -72,38 +79,44 @@ export declare type ContentAreaSidebarItem = {
|
|
|
72
79
|
pageId: string;
|
|
73
80
|
};
|
|
74
81
|
/**
|
|
75
|
-
* Expresses where you want the item to be placed inside the sidebar. If not
|
|
76
|
-
* the item will be placed after the standard items provided by
|
|
82
|
+
* Expresses where you want the item to be placed inside the sidebar. If not
|
|
83
|
+
* specified, the item will be placed after the standard items provided by
|
|
84
|
+
* DatoCMS itself.
|
|
77
85
|
*/
|
|
78
86
|
placement?: ['before' | 'after', 'menuItems' | 'settings'];
|
|
79
87
|
/**
|
|
80
|
-
* If different plugins specify the same `placement` for their panels, they
|
|
81
|
-
* displayed by ascending `rank`. If you want to specify an explicit
|
|
82
|
-
* make sure to offer a way for final users to customize it
|
|
83
|
-
* form, otherwise the hardcoded value you choose
|
|
88
|
+
* If different plugins specify the same `placement` for their panels, they
|
|
89
|
+
* will be displayed by ascending `rank`. If you want to specify an explicit
|
|
90
|
+
* value for `rank`, make sure to offer a way for final users to customize it
|
|
91
|
+
* inside the plugin's settings form, otherwise the hardcoded value you choose
|
|
92
|
+
* might clash with the one of another plugin! *
|
|
84
93
|
*/
|
|
85
94
|
rank?: number;
|
|
86
95
|
};
|
|
87
96
|
export declare type FieldExtensionType = 'editor' | 'addon';
|
|
88
97
|
/**
|
|
89
|
-
* Field extensions extend the basic functionality of DatoCMS when it comes to
|
|
90
|
-
* record's fields to the final user. Depending on the extension type
|
|
91
|
-
* `addon`) they will be shown in different places of the interface.
|
|
98
|
+
* Field extensions extend the basic functionality of DatoCMS when it comes to
|
|
99
|
+
* presenting record's fields to the final user. Depending on the extension type
|
|
100
|
+
* (`editor` or `addon`) they will be shown in different places of the interface.
|
|
92
101
|
*/
|
|
93
102
|
export declare type ManualFieldExtension = {
|
|
94
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* ID of field extension. Will be the first argument for the
|
|
105
|
+
* `renderFieldExtension` function
|
|
106
|
+
*/
|
|
95
107
|
id: string;
|
|
96
108
|
/** Name to be shown when editing fields */
|
|
97
109
|
name: string;
|
|
98
110
|
/**
|
|
99
|
-
* Type of field extension. An `editor` extension replaces the default field
|
|
100
|
-
* DatoCMS provides, while an `addon` extension is placed
|
|
101
|
-
* provide additional info/behaviour. You can
|
|
111
|
+
* Type of field extension. An `editor` extension replaces the default field
|
|
112
|
+
* editor that DatoCMS provides, while an `addon` extension is placed
|
|
113
|
+
* underneath the field editor to provide additional info/behaviour. You can
|
|
114
|
+
* setup multiple field addons for every field.
|
|
102
115
|
*/
|
|
103
116
|
type: FieldExtensionType;
|
|
104
117
|
/**
|
|
105
|
-
* For `editor` extensions: moves the field to the sidebar of the record
|
|
106
|
-
* mimicking a sidebar panel
|
|
118
|
+
* For `editor` extensions: moves the field to the sidebar of the record
|
|
119
|
+
* editing page, mimicking a sidebar panel
|
|
107
120
|
*/
|
|
108
121
|
asSidebarPanel?: boolean | {
|
|
109
122
|
startOpen: boolean;
|
|
@@ -111,8 +124,9 @@ export declare type ManualFieldExtension = {
|
|
|
111
124
|
/** The type of fields that the field extension in compatible with */
|
|
112
125
|
fieldTypes: NonNullable<PluginAttributes['field_types']>;
|
|
113
126
|
/**
|
|
114
|
-
* Whether this field extension needs some configuration options before being
|
|
115
|
-
* in a field or not. Will trigger the
|
|
127
|
+
* Whether this field extension needs some configuration options before being
|
|
128
|
+
* installed in a field or not. Will trigger the
|
|
129
|
+
* `renderManualFieldExtensionConfigScreen` and
|
|
116
130
|
* `validateManualFieldExtensionParameters` methods
|
|
117
131
|
*/
|
|
118
132
|
configurable?: boolean | {
|
|
@@ -127,27 +141,32 @@ export declare type ItemFormSidebarPanelPlacement = [
|
|
|
127
141
|
];
|
|
128
142
|
/** A sidebar panel to be shown inside the record's editing page */
|
|
129
143
|
export declare type ItemFormSidebarPanel = {
|
|
130
|
-
/**
|
|
144
|
+
/**
|
|
145
|
+
* ID of the panel. Will be the first argument for the
|
|
146
|
+
* `renderItemFormSidebarPanel` function
|
|
147
|
+
*/
|
|
131
148
|
id: string;
|
|
132
149
|
/** Label to be shown on the collapsible sidebar panel handle */
|
|
133
150
|
label: string;
|
|
134
151
|
/**
|
|
135
|
-
* An arbitrary configuration object that will be passed as the `parameters`
|
|
136
|
-
* the second argument of the `renderItemFormSidebarPanel` function
|
|
152
|
+
* An arbitrary configuration object that will be passed as the `parameters`
|
|
153
|
+
* property of the second argument of the `renderItemFormSidebarPanel` function
|
|
137
154
|
*/
|
|
138
155
|
parameters?: Record<string, unknown>;
|
|
139
156
|
/** Whether the sidebar panel will start open or collapsed */
|
|
140
157
|
startOpen?: boolean;
|
|
141
158
|
/**
|
|
142
|
-
* Expresses where you want the item to be placed inside the sidebar. If not
|
|
143
|
-
* the item will be placed after the standard panels provided by
|
|
159
|
+
* Expresses where you want the item to be placed inside the sidebar. If not
|
|
160
|
+
* specified, the item will be placed after the standard panels provided by
|
|
161
|
+
* DatoCMS itself.
|
|
144
162
|
*/
|
|
145
163
|
placement?: ItemFormSidebarPanelPlacement;
|
|
146
164
|
/**
|
|
147
|
-
* If multiple sidebar panels specify the same `placement`, they will be
|
|
148
|
-
* ascending `rank`. If you want to specify an explicit value for
|
|
149
|
-
* offer a way for final users to customize it inside the
|
|
150
|
-
* otherwise the hardcoded value you choose might
|
|
165
|
+
* If multiple sidebar panels specify the same `placement`, they will be
|
|
166
|
+
* sorted by ascending `rank`. If you want to specify an explicit value for
|
|
167
|
+
* `rank`, make sure to offer a way for final users to customize it inside the
|
|
168
|
+
* plugin's settings form, otherwise the hardcoded value you choose might
|
|
169
|
+
* clash with the one of another plugin! *
|
|
151
170
|
*/
|
|
152
171
|
rank?: number;
|
|
153
172
|
/** The initial height to set for the iframe that will render the sidebar panel */
|
|
@@ -155,7 +174,10 @@ export declare type ItemFormSidebarPanel = {
|
|
|
155
174
|
};
|
|
156
175
|
/** A field editor/sidebar forced on a field */
|
|
157
176
|
export declare type EditorOverride = {
|
|
158
|
-
/**
|
|
177
|
+
/**
|
|
178
|
+
* ID of field extension. Will be the first argument for the
|
|
179
|
+
* `renderFieldExtension` function
|
|
180
|
+
*/
|
|
159
181
|
id: string;
|
|
160
182
|
/** Moves the field to the sidebar of the record editing page, mimicking a sidebar panel */
|
|
161
183
|
asSidebarPanel?: boolean | {
|
|
@@ -163,15 +185,16 @@ export declare type EditorOverride = {
|
|
|
163
185
|
placement?: ItemFormSidebarPanelPlacement;
|
|
164
186
|
};
|
|
165
187
|
/**
|
|
166
|
-
* An arbitrary configuration object that will be passed as the `parameters`
|
|
167
|
-
* the second argument of the `renderFieldExtension` function
|
|
188
|
+
* An arbitrary configuration object that will be passed as the `parameters`
|
|
189
|
+
* property of the second argument of the `renderFieldExtension` function
|
|
168
190
|
*/
|
|
169
191
|
parameters?: Record<string, unknown>;
|
|
170
192
|
/**
|
|
171
|
-
* If multiple plugins override a field, the one with the highest `rank` will
|
|
172
|
-
* you want to specify an explicit value for `rank`, make sure to
|
|
173
|
-
* users to customize it inside the plugin's settings
|
|
174
|
-
* value you choose might clash with the one of
|
|
193
|
+
* If multiple plugins override a field, the one with the highest `rank` will
|
|
194
|
+
* win. If you want to specify an explicit value for `rank`, make sure to
|
|
195
|
+
* offer a way for final users to customize it inside the plugin's settings
|
|
196
|
+
* form, otherwise the hardcoded value you choose might clash with the one of
|
|
197
|
+
* another plugin! *
|
|
175
198
|
*/
|
|
176
199
|
rank?: number;
|
|
177
200
|
/** The initial height to set for the iframe that will render the field extension */
|
|
@@ -179,18 +202,22 @@ export declare type EditorOverride = {
|
|
|
179
202
|
};
|
|
180
203
|
/** A field addon extension forced on a field */
|
|
181
204
|
export declare type AddonOverride = {
|
|
182
|
-
/**
|
|
205
|
+
/**
|
|
206
|
+
* ID of field extension. Will be the first argument for the
|
|
207
|
+
* `renderFieldExtension` function
|
|
208
|
+
*/
|
|
183
209
|
id: string;
|
|
184
210
|
/**
|
|
185
|
-
* An arbitrary configuration object that will be passed as the `parameters`
|
|
186
|
-
* the second argument of the `renderFieldExtension` function
|
|
211
|
+
* An arbitrary configuration object that will be passed as the `parameters`
|
|
212
|
+
* property of the second argument of the `renderFieldExtension` function
|
|
187
213
|
*/
|
|
188
214
|
parameters?: Record<string, unknown>;
|
|
189
215
|
/**
|
|
190
|
-
* If multiple addons are present for a field, they will be sorted by
|
|
191
|
-
* If you want to specify an explicit value for `rank`, make
|
|
192
|
-
* final users to customize it inside the plugin's
|
|
193
|
-
* hardcoded value you choose might clash with
|
|
216
|
+
* If multiple addons are present for a field, they will be sorted by
|
|
217
|
+
* ascending `rank`. If you want to specify an explicit value for `rank`, make
|
|
218
|
+
* sure to offer a way for final users to customize it inside the plugin's
|
|
219
|
+
* settings form, otherwise the hardcoded value you choose might clash with
|
|
220
|
+
* the one of another plugin! *
|
|
194
221
|
*/
|
|
195
222
|
rank?: number;
|
|
196
223
|
/** The initial height to set for the iframe that will render the field extension */
|
|
@@ -242,8 +269,8 @@ export declare type Modal = {
|
|
|
242
269
|
/** Width of the modal. Can be a number, or one of the predefined sizes */
|
|
243
270
|
width?: 's' | 'm' | 'l' | 'xl' | 'fullWidth' | number;
|
|
244
271
|
/**
|
|
245
|
-
* An arbitrary configuration object that will be passed as the `parameters`
|
|
246
|
-
* the second argument of the `renderModal` function
|
|
272
|
+
* An arbitrary configuration object that will be passed as the `parameters`
|
|
273
|
+
* property of the second argument of the `renderModal` function
|
|
247
274
|
*/
|
|
248
275
|
parameters?: Record<string, unknown>;
|
|
249
276
|
/** The initial height to set for the iframe that will render the modal content */
|
|
@@ -259,14 +286,17 @@ export declare type Toast<CtaValue = unknown> = {
|
|
|
259
286
|
cta?: {
|
|
260
287
|
/** Label for the button */
|
|
261
288
|
label: string;
|
|
262
|
-
/**
|
|
289
|
+
/**
|
|
290
|
+
* The value to be returned by the `customToast` promise if the button is
|
|
291
|
+
* clicked by the user
|
|
292
|
+
*/
|
|
263
293
|
value: CtaValue;
|
|
264
294
|
};
|
|
265
295
|
/** Whether the toast is to be automatically closed if the user changes page */
|
|
266
296
|
dismissOnPageChange?: boolean;
|
|
267
297
|
/**
|
|
268
|
-
* Whether the toast is to be automatically closed after some time (`true`
|
|
269
|
-
* default DatoCMS time interval)
|
|
298
|
+
* Whether the toast is to be automatically closed after some time (`true`
|
|
299
|
+
* will use the default DatoCMS time interval)
|
|
270
300
|
*/
|
|
271
301
|
dismissAfterTimeout?: boolean | number;
|
|
272
302
|
};
|
|
@@ -274,7 +304,10 @@ export declare type Toast<CtaValue = unknown> = {
|
|
|
274
304
|
export declare type ConfirmChoice = {
|
|
275
305
|
/** The label to be shown for the choice */
|
|
276
306
|
label: string;
|
|
277
|
-
/**
|
|
307
|
+
/**
|
|
308
|
+
* The value to be returned by the `openConfirm` promise if the button is
|
|
309
|
+
* clicked by the user
|
|
310
|
+
*/
|
|
278
311
|
value: unknown;
|
|
279
312
|
/** The intent of the button. Will present the button in a different color accent. */
|
|
280
313
|
intent?: 'positive' | 'negative';
|
|
@@ -299,20 +332,23 @@ export declare type CommonProperties = {
|
|
|
299
332
|
/** All the models of the current DatoCMS project, indexed by ID */
|
|
300
333
|
itemTypes: Partial<Record<string, ModelBlock>>;
|
|
301
334
|
/**
|
|
302
|
-
* The current DatoCMS user. It can either be the owner or one of the
|
|
303
|
-
* (regular or SSO).
|
|
335
|
+
* The current DatoCMS user. It can either be the owner or one of the
|
|
336
|
+
* collaborators (regular or SSO).
|
|
304
337
|
*/
|
|
305
338
|
currentUser: User | SsoUser | Account;
|
|
306
339
|
/** The role for the current DatoCMS user */
|
|
307
340
|
currentRole: Role;
|
|
308
341
|
/**
|
|
309
|
-
* The access token to perform API calls on behalf of the current user. Only
|
|
310
|
-
* if `
|
|
342
|
+
* The access token to perform API calls on behalf of the current user. Only
|
|
343
|
+
* available if `currentUserAccessToken` additional permission is granted
|
|
311
344
|
*/
|
|
312
|
-
|
|
345
|
+
currentUserAccessToken: string | undefined;
|
|
313
346
|
/** The current plugin */
|
|
314
347
|
plugin: Plugin;
|
|
315
|
-
/**
|
|
348
|
+
/**
|
|
349
|
+
* UI preferences of the current user (right now, only the preferred locale is
|
|
350
|
+
* available)
|
|
351
|
+
*/
|
|
316
352
|
ui: {
|
|
317
353
|
/** Preferred locale */
|
|
318
354
|
locale: string;
|
|
@@ -329,24 +365,25 @@ export declare type InitPropertiesAndMethods = InitMethods & InitProperties;
|
|
|
329
365
|
/** Additional properties available in all `renderXXX` hooks */
|
|
330
366
|
export declare type RenderAdditionalProperties = {
|
|
331
367
|
/**
|
|
332
|
-
* All the fields currently loaded for the current DatoCMS project, indexed by
|
|
333
|
-
* will always contain the current model fields and all the fields of
|
|
334
|
-
* might contain via Modular Content/Structured Text fields. If
|
|
335
|
-
* not present, use the `loadItemTypeFields` function
|
|
368
|
+
* All the fields currently loaded for the current DatoCMS project, indexed by
|
|
369
|
+
* ID. It will always contain the current model fields and all the fields of
|
|
370
|
+
* the blocks it might contain via Modular Content/Structured Text fields. If
|
|
371
|
+
* some fields you need are not present, use the `loadItemTypeFields` function
|
|
372
|
+
* to load them.
|
|
336
373
|
*/
|
|
337
374
|
fields: Partial<Record<string, Field>>;
|
|
338
375
|
/** An object containing the theme colors for the current DatoCMS project */
|
|
339
376
|
theme: Theme;
|
|
340
377
|
/**
|
|
341
|
-
* All the regular users currently loaded for the current DatoCMS project,
|
|
342
|
-
* ID. It will always contain the current user. If some users you
|
|
343
|
-
* use the `loadUsers` function to load them.
|
|
378
|
+
* All the regular users currently loaded for the current DatoCMS project,
|
|
379
|
+
* indexed by ID. It will always contain the current user. If some users you
|
|
380
|
+
* need are not present, use the `loadUsers` function to load them.
|
|
344
381
|
*/
|
|
345
382
|
users: Partial<Record<string, User>>;
|
|
346
383
|
/**
|
|
347
|
-
* All the SSO users currently loaded for the current DatoCMS project, indexed
|
|
348
|
-
* will always contain the current user. If some users you need are
|
|
349
|
-
* `loadSsoUsers` function to load them.
|
|
384
|
+
* All the SSO users currently loaded for the current DatoCMS project, indexed
|
|
385
|
+
* by ID. It will always contain the current user. If some users you need are
|
|
386
|
+
* not present, use the `loadSsoUsers` function to load them.
|
|
350
387
|
*/
|
|
351
388
|
ssoUsers: Partial<Record<string, SsoUser>>;
|
|
352
389
|
/** The project owner */
|
|
@@ -380,151 +417,186 @@ export declare type FieldAppearanceChange = {
|
|
|
380
417
|
parameters: Record<string, unknown>;
|
|
381
418
|
};
|
|
382
419
|
/**
|
|
383
|
-
* These methods can be used to update both plugin parameters and manual field
|
|
384
|
-
* configuration.
|
|
420
|
+
* These methods can be used to update both plugin parameters and manual field
|
|
421
|
+
* extensions configuration.
|
|
385
422
|
*/
|
|
386
423
|
export declare type UpdateParametersMethods = {
|
|
387
424
|
/**
|
|
388
425
|
* Updates the plugin parameters.
|
|
389
426
|
*
|
|
390
|
-
* Always check `ctx.currentRole.meta.final_permissions.can_edit_schema`
|
|
391
|
-
* this, as the user might not have the permission to perform
|
|
427
|
+
* Always check `ctx.currentRole.meta.final_permissions.can_edit_schema`
|
|
428
|
+
* before calling this, as the user might not have the permission to perform
|
|
429
|
+
* the operation.
|
|
392
430
|
*
|
|
393
431
|
* @example
|
|
394
|
-
*
|
|
395
|
-
*
|
|
432
|
+
*
|
|
433
|
+
* ```js
|
|
434
|
+
* await ctx.updatePluginParameters({ debugMode: true });
|
|
435
|
+
* await ctx.notice('Plugin parameters successfully updated!');
|
|
436
|
+
* ```
|
|
396
437
|
*/
|
|
397
438
|
updatePluginParameters: (params: Record<string, unknown>) => Promise<void>;
|
|
398
439
|
/**
|
|
399
|
-
* Performs changes in the appearance of a field. You can install/remove a
|
|
400
|
-
* extension, or tweak their parameters. If multiple changes are
|
|
401
|
-
* applied sequencially.
|
|
440
|
+
* Performs changes in the appearance of a field. You can install/remove a
|
|
441
|
+
* manual field extension, or tweak their parameters. If multiple changes are
|
|
442
|
+
* passed, they will be applied sequencially.
|
|
402
443
|
*
|
|
403
|
-
* Always check `ctx.currentRole.meta.final_permissions.can_edit_schema`
|
|
404
|
-
* this, as the user might not have the permission to perform
|
|
444
|
+
* Always check `ctx.currentRole.meta.final_permissions.can_edit_schema`
|
|
445
|
+
* before calling this, as the user might not have the permission to perform
|
|
446
|
+
* the operation.
|
|
405
447
|
*
|
|
406
448
|
* @example
|
|
407
|
-
* const fields = await ctx.loadFieldsUsingPlugin();
|
|
408
449
|
*
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
450
|
+
* ```js
|
|
451
|
+
* const fields = await ctx.loadFieldsUsingPlugin();
|
|
452
|
+
*
|
|
453
|
+
* if (fields.length === 0) {
|
|
454
|
+
* ctx.alert('No field is using this plugin as a manual extension!');
|
|
455
|
+
* return;
|
|
456
|
+
* }
|
|
457
|
+
*
|
|
458
|
+
* for (const field of fields) {
|
|
459
|
+
* const { appearance } = field.attributes;
|
|
460
|
+
* const operations = [];
|
|
461
|
+
*
|
|
462
|
+
* if (appearance.editor === ctx.plugin.id) {
|
|
463
|
+
* operations.push({
|
|
464
|
+
* operation: 'updateEditor',
|
|
465
|
+
* newParameters: {
|
|
466
|
+
* ...appearance.parameters,
|
|
467
|
+
* foo: 'bar',
|
|
468
|
+
* },
|
|
469
|
+
* });
|
|
412
470
|
* }
|
|
413
471
|
*
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
*
|
|
418
|
-
* if (appearance.editor === ctx.plugin.id) {
|
|
419
|
-
* operations.push({
|
|
420
|
-
* operation: 'updateEditor',
|
|
421
|
-
* newParameters: {
|
|
422
|
-
* ...appearance.parameters,
|
|
423
|
-
* foo: 'bar',
|
|
424
|
-
* },
|
|
425
|
-
* });
|
|
472
|
+
* appearance.addons.forEach((addon, i) => {
|
|
473
|
+
* if (addon.id !== ctx.plugin.id) {
|
|
474
|
+
* return;
|
|
426
475
|
* }
|
|
427
476
|
*
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
*
|
|
431
|
-
* }
|
|
432
|
-
*
|
|
433
|
-
* operations.push({
|
|
434
|
-
* operation: 'updateAddon',
|
|
435
|
-
* index: i,
|
|
436
|
-
* newParameters: { ...addon.parameters, foo: 'bar' },
|
|
437
|
-
* });
|
|
477
|
+
* operations.push({
|
|
478
|
+
* operation: 'updateAddon',
|
|
479
|
+
* index: i,
|
|
480
|
+
* newParameters: { ...addon.parameters, foo: 'bar' },
|
|
438
481
|
* });
|
|
482
|
+
* });
|
|
439
483
|
*
|
|
440
|
-
*
|
|
441
|
-
*
|
|
442
|
-
*
|
|
484
|
+
* await ctx.updateFieldAppearance(field.id, operations);
|
|
485
|
+
* ctx.notice(`Successfully edited field ${field.attributes.api_key}`);
|
|
486
|
+
* }
|
|
487
|
+
* ```
|
|
443
488
|
*/
|
|
444
489
|
updateFieldAppearance: (fieldId: string, changes: FieldAppearanceChange[]) => Promise<void>;
|
|
445
490
|
};
|
|
446
|
-
/**
|
|
491
|
+
/**
|
|
492
|
+
* These methods can be used to asyncronously load additional information your
|
|
493
|
+
* plugin needs to work
|
|
494
|
+
*/
|
|
447
495
|
export declare type LoadDataMethods = {
|
|
448
496
|
/**
|
|
449
|
-
* Loads all the fields for a specific model (or block). Fields will be
|
|
450
|
-
* will also be available in the the `fields` property.
|
|
497
|
+
* Loads all the fields for a specific model (or block). Fields will be
|
|
498
|
+
* returned and will also be available in the the `fields` property.
|
|
451
499
|
*
|
|
452
500
|
* @example
|
|
453
|
-
* const itemTypeId = prompt('Please insert a model ID:');
|
|
454
501
|
*
|
|
455
|
-
*
|
|
502
|
+
* ```js
|
|
503
|
+
* const itemTypeId = prompt('Please insert a model ID:');
|
|
504
|
+
*
|
|
505
|
+
* const fields = await ctx.loadItemTypeFields(itemTypeId);
|
|
456
506
|
*
|
|
457
|
-
*
|
|
458
|
-
*
|
|
459
|
-
*
|
|
507
|
+
* ctx.notice(
|
|
508
|
+
* `Success! ${fields
|
|
509
|
+
* .map((field) => field.attributes.api_key)
|
|
510
|
+
* .join(', ')}`,
|
|
511
|
+
* );
|
|
512
|
+
* ```
|
|
460
513
|
*/
|
|
461
514
|
loadItemTypeFields: (itemTypeId: string) => Promise<Field[]>;
|
|
462
515
|
/**
|
|
463
|
-
* Loads all the fields in the project that are currently using the plugin for
|
|
464
|
-
* its manual field extensions.
|
|
516
|
+
* Loads all the fields in the project that are currently using the plugin for
|
|
517
|
+
* one of its manual field extensions.
|
|
465
518
|
*
|
|
466
519
|
* @example
|
|
467
|
-
* const fields = await ctx.loadFieldsUsingPlugin();
|
|
468
520
|
*
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
*
|
|
521
|
+
* ```js
|
|
522
|
+
* const fields = await ctx.loadFieldsUsingPlugin();
|
|
523
|
+
*
|
|
524
|
+
* ctx.notice(
|
|
525
|
+
* `Success! ${fields
|
|
526
|
+
* .map((field) => field.attributes.api_key)
|
|
527
|
+
* .join(', ')}`,
|
|
528
|
+
* );
|
|
529
|
+
* ```
|
|
472
530
|
*/
|
|
473
531
|
loadFieldsUsingPlugin: () => Promise<Field[]>;
|
|
474
532
|
/**
|
|
475
|
-
* Loads all regular users. Users will be returned and will also be available
|
|
476
|
-
* `users` property.
|
|
533
|
+
* Loads all regular users. Users will be returned and will also be available
|
|
534
|
+
* in the the `users` property.
|
|
477
535
|
*
|
|
478
536
|
* @example
|
|
479
|
-
* const users = await ctx.loadUsers();
|
|
480
537
|
*
|
|
481
|
-
*
|
|
538
|
+
* ```js
|
|
539
|
+
* const users = await ctx.loadUsers();
|
|
540
|
+
*
|
|
541
|
+
* ctx.notice(`Success! ${users.map((user) => user.id).join(', ')}`);
|
|
542
|
+
* ```
|
|
482
543
|
*/
|
|
483
544
|
loadUsers: () => Promise<User[]>;
|
|
484
545
|
/**
|
|
485
|
-
* Loads all SSO users. Users will be returned and will also be available in
|
|
486
|
-
* `ssoUsers` property.
|
|
546
|
+
* Loads all SSO users. Users will be returned and will also be available in
|
|
547
|
+
* the the `ssoUsers` property.
|
|
487
548
|
*
|
|
488
549
|
* @example
|
|
489
|
-
* const users = await ctx.loadSsoUsers();
|
|
490
550
|
*
|
|
491
|
-
*
|
|
551
|
+
* ```js
|
|
552
|
+
* const users = await ctx.loadSsoUsers();
|
|
553
|
+
*
|
|
554
|
+
* ctx.notice(`Success! ${users.map((user) => user.id).join(', ')}`);
|
|
555
|
+
* ```
|
|
492
556
|
*/
|
|
493
557
|
loadSsoUsers: () => Promise<SsoUser[]>;
|
|
494
558
|
};
|
|
495
559
|
/** These methods let you open the standard DatoCMS dialogs needed to interact with records */
|
|
496
560
|
export declare type ItemDialogMethods = {
|
|
497
561
|
/**
|
|
498
|
-
* Opens a dialog for creating a new record. It returns a promise resolved
|
|
499
|
-
* newly created record or `null` if the user closes the dialog
|
|
562
|
+
* Opens a dialog for creating a new record. It returns a promise resolved
|
|
563
|
+
* with the newly created record or `null` if the user closes the dialog
|
|
564
|
+
* without creating anything.
|
|
500
565
|
*
|
|
501
566
|
* @example
|
|
502
|
-
* const itemTypeId = prompt('Please insert a model ID:');
|
|
503
567
|
*
|
|
504
|
-
*
|
|
568
|
+
* ```js
|
|
569
|
+
* const itemTypeId = prompt('Please insert a model ID:');
|
|
505
570
|
*
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
*
|
|
509
|
-
*
|
|
510
|
-
*
|
|
571
|
+
* const item = await ctx.createNewItem(itemTypeId);
|
|
572
|
+
*
|
|
573
|
+
* if (item) {
|
|
574
|
+
* ctx.notice(`Success! ${item.id}`);
|
|
575
|
+
* } else {
|
|
576
|
+
* ctx.alert('Closed!');
|
|
577
|
+
* }
|
|
578
|
+
* ```
|
|
511
579
|
*/
|
|
512
580
|
createNewItem: (itemTypeId: string) => Promise<Item | null>;
|
|
513
581
|
/**
|
|
514
|
-
* Opens a dialog for selecting one (or multiple) record(s) from a list of
|
|
515
|
-
* records of type `itemTypeId`. It returns a promise resolved with
|
|
516
|
-
* record(s), or `null` if the user closes the dialog without
|
|
582
|
+
* Opens a dialog for selecting one (or multiple) record(s) from a list of
|
|
583
|
+
* existing records of type `itemTypeId`. It returns a promise resolved with
|
|
584
|
+
* the selected record(s), or `null` if the user closes the dialog without
|
|
585
|
+
* choosing any record.
|
|
517
586
|
*
|
|
518
587
|
* @example
|
|
519
|
-
* const itemTypeId = prompt('Please insert a model ID:');
|
|
520
588
|
*
|
|
521
|
-
*
|
|
589
|
+
* ```js
|
|
590
|
+
* const itemTypeId = prompt('Please insert a model ID:');
|
|
522
591
|
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
*
|
|
592
|
+
* const items = await ctx.selectItem(itemTypeId, { multiple: true });
|
|
593
|
+
*
|
|
594
|
+
* if (items) {
|
|
595
|
+
* ctx.notice(`Success! ${items.map((i) => i.id).join(', ')}`);
|
|
596
|
+
* } else {
|
|
597
|
+
* ctx.alert('Closed!');
|
|
598
|
+
* }
|
|
599
|
+
* ```
|
|
528
600
|
*/
|
|
529
601
|
selectItem: {
|
|
530
602
|
(itemTypeId: string, options: {
|
|
@@ -535,19 +607,23 @@ export declare type ItemDialogMethods = {
|
|
|
535
607
|
}): Promise<Item | null>;
|
|
536
608
|
};
|
|
537
609
|
/**
|
|
538
|
-
* Opens a dialog for editing an existing record. It returns a promise
|
|
539
|
-
* edited record, or `null` if the user closes the dialog
|
|
610
|
+
* Opens a dialog for editing an existing record. It returns a promise
|
|
611
|
+
* resolved with the edited record, or `null` if the user closes the dialog
|
|
612
|
+
* without persisting any change.
|
|
540
613
|
*
|
|
541
614
|
* @example
|
|
542
|
-
* const itemId = prompt('Please insert a record ID:');
|
|
543
615
|
*
|
|
544
|
-
*
|
|
616
|
+
* ```js
|
|
617
|
+
* const itemId = prompt('Please insert a record ID:');
|
|
545
618
|
*
|
|
546
|
-
*
|
|
547
|
-
*
|
|
548
|
-
*
|
|
549
|
-
*
|
|
550
|
-
*
|
|
619
|
+
* const item = await ctx.editItem(itemId);
|
|
620
|
+
*
|
|
621
|
+
* if (item) {
|
|
622
|
+
* ctx.notice(`Success! ${item.id}`);
|
|
623
|
+
* } else {
|
|
624
|
+
* ctx.alert('Closed!');
|
|
625
|
+
* }
|
|
626
|
+
* ```
|
|
551
627
|
*/
|
|
552
628
|
editItem: (itemId: string) => Promise<Item | null>;
|
|
553
629
|
};
|
|
@@ -557,56 +633,77 @@ export declare type ToastMethods = {
|
|
|
557
633
|
* Triggers an "error" toast displaying the selected message
|
|
558
634
|
*
|
|
559
635
|
* @example
|
|
560
|
-
* const message = prompt('Please insert a message:', 'This is an alert message!');
|
|
561
636
|
*
|
|
562
|
-
*
|
|
637
|
+
* ```js
|
|
638
|
+
* const message = prompt(
|
|
639
|
+
* 'Please insert a message:',
|
|
640
|
+
* 'This is an alert message!',
|
|
641
|
+
* );
|
|
642
|
+
*
|
|
643
|
+
* await ctx.alert(message);
|
|
644
|
+
* ```
|
|
563
645
|
*/
|
|
564
646
|
alert: (message: string) => Promise<void>;
|
|
565
647
|
/**
|
|
566
648
|
* Triggers a "success" toast displaying the selected message
|
|
567
649
|
*
|
|
568
650
|
* @example
|
|
569
|
-
* const message = prompt('Please insert a message:', 'This is a notice message!');
|
|
570
651
|
*
|
|
571
|
-
*
|
|
652
|
+
* ```js
|
|
653
|
+
* const message = prompt(
|
|
654
|
+
* 'Please insert a message:',
|
|
655
|
+
* 'This is a notice message!',
|
|
656
|
+
* );
|
|
657
|
+
*
|
|
658
|
+
* await ctx.notice(message);
|
|
659
|
+
* ```
|
|
572
660
|
*/
|
|
573
661
|
notice: (message: string) => Promise<void>;
|
|
574
662
|
/**
|
|
575
663
|
* Triggers a custom toast displaying the selected message (and optionally a CTA)
|
|
576
664
|
*
|
|
577
665
|
* @example
|
|
578
|
-
* const result = await ctx.customToast({
|
|
579
|
-
* type: 'warning',
|
|
580
|
-
* message: 'Just a sample warning notification!',
|
|
581
|
-
* dismissOnPageChange: true,
|
|
582
|
-
* dismissAfterTimeout: 5000,
|
|
583
|
-
* cta: {
|
|
584
|
-
* label: 'Execute call-to-action',
|
|
585
|
-
* value: 'cta',
|
|
586
|
-
* },
|
|
587
|
-
* });
|
|
588
666
|
*
|
|
589
|
-
*
|
|
590
|
-
*
|
|
591
|
-
*
|
|
667
|
+
* ```js
|
|
668
|
+
* const result = await ctx.customToast({
|
|
669
|
+
* type: 'warning',
|
|
670
|
+
* message: 'Just a sample warning notification!',
|
|
671
|
+
* dismissOnPageChange: true,
|
|
672
|
+
* dismissAfterTimeout: 5000,
|
|
673
|
+
* cta: {
|
|
674
|
+
* label: 'Execute call-to-action',
|
|
675
|
+
* value: 'cta',
|
|
676
|
+
* },
|
|
677
|
+
* });
|
|
678
|
+
*
|
|
679
|
+
* if (result === 'cta') {
|
|
680
|
+
* ctx.notice(`Clicked CTA!`);
|
|
681
|
+
* }
|
|
682
|
+
* ```
|
|
592
683
|
*/
|
|
593
684
|
customToast: <CtaValue = unknown>(toast: Toast<CtaValue>) => Promise<CtaValue | null>;
|
|
594
685
|
};
|
|
595
|
-
/**
|
|
686
|
+
/**
|
|
687
|
+
* These methods let you open the standard DatoCMS dialogs needed to interact
|
|
688
|
+
* with Media Area assets
|
|
689
|
+
*/
|
|
596
690
|
export declare type UploadDialogMethods = {
|
|
597
691
|
/**
|
|
598
|
-
* Opens a dialog for selecting one (or multiple) existing asset(s). It
|
|
599
|
-
* promise resolved with the selected asset(s), or `null` if the
|
|
600
|
-
* without selecting any upload.
|
|
692
|
+
* Opens a dialog for selecting one (or multiple) existing asset(s). It
|
|
693
|
+
* returns a promise resolved with the selected asset(s), or `null` if the
|
|
694
|
+
* user closes the dialog without selecting any upload.
|
|
601
695
|
*
|
|
602
696
|
* @example
|
|
603
|
-
* const item = await ctx.selectUpload({ multiple: false });
|
|
604
697
|
*
|
|
605
|
-
*
|
|
606
|
-
*
|
|
607
|
-
*
|
|
608
|
-
*
|
|
609
|
-
* }
|
|
698
|
+
* ```js
|
|
699
|
+
* const item = await ctx.selectUpload({ multiple: false });
|
|
700
|
+
*
|
|
701
|
+
* if (item) {
|
|
702
|
+
* ctx.notice(`Success! ${item.id}`);
|
|
703
|
+
* } else {
|
|
704
|
+
* ctx.alert('Closed!');
|
|
705
|
+
* }
|
|
706
|
+
* ```
|
|
610
707
|
*/
|
|
611
708
|
selectUpload: {
|
|
612
709
|
(options: {
|
|
@@ -621,44 +718,50 @@ export declare type UploadDialogMethods = {
|
|
|
621
718
|
*
|
|
622
719
|
* - The updated asset, if the user persists some changes to the asset itself
|
|
623
720
|
* - `null`, if the user closes the dialog without persisting any change
|
|
624
|
-
* - An asset structure with an additional `deleted` property set to true, if
|
|
625
|
-
* deletes the asset
|
|
721
|
+
* - An asset structure with an additional `deleted` property set to true, if
|
|
722
|
+
* the user deletes the asset
|
|
626
723
|
*
|
|
627
724
|
* @example
|
|
628
|
-
* const uploadId = prompt('Please insert an asset ID:');
|
|
629
725
|
*
|
|
630
|
-
*
|
|
726
|
+
* ```js
|
|
727
|
+
* const uploadId = prompt('Please insert an asset ID:');
|
|
631
728
|
*
|
|
632
|
-
*
|
|
633
|
-
*
|
|
634
|
-
*
|
|
635
|
-
*
|
|
636
|
-
*
|
|
729
|
+
* const item = await ctx.editUpload(uploadId);
|
|
730
|
+
*
|
|
731
|
+
* if (item) {
|
|
732
|
+
* ctx.notice(`Success! ${item.id}`);
|
|
733
|
+
* } else {
|
|
734
|
+
* ctx.alert('Closed!');
|
|
735
|
+
* }
|
|
736
|
+
* ```
|
|
637
737
|
*/
|
|
638
738
|
editUpload: (uploadId: string) => Promise<(Upload & {
|
|
639
739
|
deleted?: true;
|
|
640
740
|
}) | null>;
|
|
641
741
|
/**
|
|
642
|
-
* Opens a dialog for editing a "single asset" field structure. It returns a
|
|
643
|
-
* resolved with the updated structure, or `null` if the user closes
|
|
644
|
-
* persisting any change.
|
|
742
|
+
* Opens a dialog for editing a "single asset" field structure. It returns a
|
|
743
|
+
* promise resolved with the updated structure, or `null` if the user closes
|
|
744
|
+
* the dialog without persisting any change.
|
|
645
745
|
*
|
|
646
746
|
* @example
|
|
647
|
-
* const uploadId = prompt('Please insert an asset ID:');
|
|
648
|
-
*
|
|
649
|
-
* const result = await ctx.editUploadMetadata({
|
|
650
|
-
* upload_id: uploadId,
|
|
651
|
-
* alt: null,
|
|
652
|
-
* title: null,
|
|
653
|
-
* custom_data: {},
|
|
654
|
-
* focal_point: null,
|
|
655
|
-
* });
|
|
656
747
|
*
|
|
657
|
-
*
|
|
658
|
-
*
|
|
659
|
-
*
|
|
660
|
-
*
|
|
661
|
-
*
|
|
748
|
+
* ```js
|
|
749
|
+
* const uploadId = prompt('Please insert an asset ID:');
|
|
750
|
+
*
|
|
751
|
+
* const result = await ctx.editUploadMetadata({
|
|
752
|
+
* upload_id: uploadId,
|
|
753
|
+
* alt: null,
|
|
754
|
+
* title: null,
|
|
755
|
+
* custom_data: {},
|
|
756
|
+
* focal_point: null,
|
|
757
|
+
* });
|
|
758
|
+
*
|
|
759
|
+
* if (result) {
|
|
760
|
+
* ctx.notice(`Success! ${JSON.stringify(result)}`);
|
|
761
|
+
* } else {
|
|
762
|
+
* ctx.alert('Closed!');
|
|
763
|
+
* }
|
|
764
|
+
* ```
|
|
662
765
|
*/
|
|
663
766
|
editUploadMetadata: (
|
|
664
767
|
/** The "single asset" field structure */
|
|
@@ -669,56 +772,62 @@ export declare type UploadDialogMethods = {
|
|
|
669
772
|
/** These methods can be used to open custom dialogs/confirmation panels */
|
|
670
773
|
export declare type CustomDialogMethods = {
|
|
671
774
|
/**
|
|
672
|
-
* Opens a custom modal. Returns a promise resolved with what the modal itself
|
|
673
|
-
* calling the `resolve()` function
|
|
775
|
+
* Opens a custom modal. Returns a promise resolved with what the modal itself
|
|
776
|
+
* returns calling the `resolve()` function
|
|
674
777
|
*
|
|
675
778
|
* @example
|
|
676
|
-
* const result = await ctx.openModal({
|
|
677
|
-
* id: 'regular',
|
|
678
|
-
* title: 'Custom title!',
|
|
679
|
-
* width: 'l',
|
|
680
|
-
* parameters: { foo: 'bar' },
|
|
681
|
-
* });
|
|
682
779
|
*
|
|
683
|
-
*
|
|
684
|
-
*
|
|
685
|
-
*
|
|
686
|
-
*
|
|
687
|
-
*
|
|
780
|
+
* ```js
|
|
781
|
+
* const result = await ctx.openModal({
|
|
782
|
+
* id: 'regular',
|
|
783
|
+
* title: 'Custom title!',
|
|
784
|
+
* width: 'l',
|
|
785
|
+
* parameters: { foo: 'bar' },
|
|
786
|
+
* });
|
|
787
|
+
*
|
|
788
|
+
* if (result) {
|
|
789
|
+
* ctx.notice(`Success! ${JSON.stringify(result)}`);
|
|
790
|
+
* } else {
|
|
791
|
+
* ctx.alert('Closed!');
|
|
792
|
+
* }
|
|
793
|
+
* ```
|
|
688
794
|
*/
|
|
689
795
|
openModal: (modal: Modal) => Promise<unknown>;
|
|
690
796
|
/**
|
|
691
|
-
* Opens a UI-consistent confirmation dialog. Returns a promise resolved with
|
|
692
|
-
* of the choice made by the user
|
|
797
|
+
* Opens a UI-consistent confirmation dialog. Returns a promise resolved with
|
|
798
|
+
* the value of the choice made by the user
|
|
693
799
|
*
|
|
694
800
|
* @example
|
|
695
|
-
*
|
|
696
|
-
*
|
|
697
|
-
*
|
|
698
|
-
*
|
|
699
|
-
*
|
|
700
|
-
*
|
|
701
|
-
*
|
|
702
|
-
*
|
|
703
|
-
*
|
|
704
|
-
*
|
|
705
|
-
*
|
|
706
|
-
* label: 'Negative',
|
|
707
|
-
* value: 'negative',
|
|
708
|
-
* intent: 'negative',
|
|
709
|
-
* },
|
|
710
|
-
* ],
|
|
711
|
-
* cancel: {
|
|
712
|
-
* label: 'Cancel',
|
|
713
|
-
* value: false,
|
|
801
|
+
*
|
|
802
|
+
* ```js
|
|
803
|
+
* const result = await ctx.openConfirm({
|
|
804
|
+
* title: 'Custom title',
|
|
805
|
+
* content:
|
|
806
|
+
* 'Lorem Ipsum is simply dummy text of the printing and typesetting industry',
|
|
807
|
+
* choices: [
|
|
808
|
+
* {
|
|
809
|
+
* label: 'Positive',
|
|
810
|
+
* value: 'positive',
|
|
811
|
+
* intent: 'positive',
|
|
714
812
|
* },
|
|
715
|
-
*
|
|
813
|
+
* {
|
|
814
|
+
* label: 'Negative',
|
|
815
|
+
* value: 'negative',
|
|
816
|
+
* intent: 'negative',
|
|
817
|
+
* },
|
|
818
|
+
* ],
|
|
819
|
+
* cancel: {
|
|
820
|
+
* label: 'Cancel',
|
|
821
|
+
* value: false,
|
|
822
|
+
* },
|
|
823
|
+
* });
|
|
716
824
|
*
|
|
717
|
-
*
|
|
718
|
-
*
|
|
719
|
-
*
|
|
720
|
-
*
|
|
721
|
-
*
|
|
825
|
+
* if (result) {
|
|
826
|
+
* ctx.notice(`Success! ${result}`);
|
|
827
|
+
* } else {
|
|
828
|
+
* ctx.alert('Cancelled!');
|
|
829
|
+
* }
|
|
830
|
+
* ```
|
|
722
831
|
*/
|
|
723
832
|
openConfirm: (options: ConfirmOptions) => Promise<unknown>;
|
|
724
833
|
};
|
|
@@ -728,7 +837,10 @@ export declare type NavigateMethods = {
|
|
|
728
837
|
* Moves the user to another URL internal to the backend
|
|
729
838
|
*
|
|
730
839
|
* @example
|
|
731
|
-
*
|
|
840
|
+
*
|
|
841
|
+
* ```js
|
|
842
|
+
* await ctx.navigateTo('/');
|
|
843
|
+
* ```
|
|
732
844
|
*/
|
|
733
845
|
navigateTo: (path: string) => Promise<void>;
|
|
734
846
|
};
|
|
@@ -739,8 +851,8 @@ export declare type IframeMethods = {
|
|
|
739
851
|
};
|
|
740
852
|
export declare type RenderMethods = LoadDataMethods & UpdateParametersMethods & ToastMethods & CustomDialogMethods & NavigateMethods;
|
|
741
853
|
/**
|
|
742
|
-
* These information describe the current state of the form that's being shown
|
|
743
|
-
* end-user to edit a record
|
|
854
|
+
* These information describe the current state of the form that's being shown
|
|
855
|
+
* to the end-user to edit a record
|
|
744
856
|
*/
|
|
745
857
|
export declare type ItemFormAdditionalProperties = {
|
|
746
858
|
/** The currently active locale for the record */
|
|
@@ -760,64 +872,79 @@ export declare type ItemFormAdditionalProperties = {
|
|
|
760
872
|
};
|
|
761
873
|
export declare type ItemFormProperties = RenderProperties & ItemFormAdditionalProperties;
|
|
762
874
|
/**
|
|
763
|
-
* These methods can be used to interact with the form that's being shown to the
|
|
764
|
-
* to edit a record
|
|
875
|
+
* These methods can be used to interact with the form that's being shown to the
|
|
876
|
+
* end-user to edit a record
|
|
765
877
|
*/
|
|
766
878
|
export declare type ItemFormAdditionalMethods = {
|
|
767
879
|
/**
|
|
768
880
|
* Hides/shows a specific field in the form
|
|
769
881
|
*
|
|
770
882
|
* @example
|
|
771
|
-
* const fieldPath = prompt(
|
|
772
|
-
* 'Please insert the path of a field in the form',
|
|
773
|
-
* ctx.fieldPath,
|
|
774
|
-
* );
|
|
775
883
|
*
|
|
776
|
-
*
|
|
884
|
+
* ```js
|
|
885
|
+
* const fieldPath = prompt(
|
|
886
|
+
* 'Please insert the path of a field in the form',
|
|
887
|
+
* ctx.fieldPath,
|
|
888
|
+
* );
|
|
889
|
+
*
|
|
890
|
+
* await ctx.toggleField(fieldPath, true);
|
|
891
|
+
* ```
|
|
777
892
|
*/
|
|
778
893
|
toggleField: (path: string, show: boolean) => Promise<void>;
|
|
779
894
|
/**
|
|
780
895
|
* Disables/re-enables a specific field in the form
|
|
781
896
|
*
|
|
782
897
|
* @example
|
|
783
|
-
* const fieldPath = prompt(
|
|
784
|
-
* 'Please insert the path of a field in the form',
|
|
785
|
-
* ctx.fieldPath,
|
|
786
|
-
* );
|
|
787
898
|
*
|
|
788
|
-
*
|
|
899
|
+
* ```js
|
|
900
|
+
* const fieldPath = prompt(
|
|
901
|
+
* 'Please insert the path of a field in the form',
|
|
902
|
+
* ctx.fieldPath,
|
|
903
|
+
* );
|
|
904
|
+
*
|
|
905
|
+
* await ctx.disableField(fieldPath, true);
|
|
906
|
+
* ```
|
|
789
907
|
*/
|
|
790
908
|
disableField: (path: string, disable: boolean) => Promise<void>;
|
|
791
909
|
/**
|
|
792
|
-
* Smoothly navigates to a specific field in the form. If the field is
|
|
793
|
-
* switch language tab and then navigate to the chosen field.
|
|
910
|
+
* Smoothly navigates to a specific field in the form. If the field is
|
|
911
|
+
* localized it will switch language tab and then navigate to the chosen field.
|
|
794
912
|
*
|
|
795
913
|
* @example
|
|
796
|
-
* const fieldPath = prompt(
|
|
797
|
-
* 'Please insert the path of a field in the form',
|
|
798
|
-
* ctx.fieldPath,
|
|
799
|
-
* );
|
|
800
914
|
*
|
|
801
|
-
*
|
|
915
|
+
* ```js
|
|
916
|
+
* const fieldPath = prompt(
|
|
917
|
+
* 'Please insert the path of a field in the form',
|
|
918
|
+
* ctx.fieldPath,
|
|
919
|
+
* );
|
|
920
|
+
*
|
|
921
|
+
* await ctx.scrollToField(fieldPath);
|
|
922
|
+
* ```
|
|
802
923
|
*/
|
|
803
924
|
scrollToField: (path: string, locale?: string) => Promise<void>;
|
|
804
925
|
/**
|
|
805
926
|
* Changes a specific path of the `formValues` object
|
|
806
927
|
*
|
|
807
928
|
* @example
|
|
808
|
-
* const fieldPath = prompt(
|
|
809
|
-
* 'Please insert the path of a field in the form',
|
|
810
|
-
* ctx.fieldPath,
|
|
811
|
-
* );
|
|
812
929
|
*
|
|
813
|
-
*
|
|
930
|
+
* ```js
|
|
931
|
+
* const fieldPath = prompt(
|
|
932
|
+
* 'Please insert the path of a field in the form',
|
|
933
|
+
* ctx.fieldPath,
|
|
934
|
+
* );
|
|
935
|
+
*
|
|
936
|
+
* await ctx.setFieldValue(fieldPath, 'new value');
|
|
937
|
+
* ```
|
|
814
938
|
*/
|
|
815
939
|
setFieldValue: (path: string, value: unknown) => Promise<void>;
|
|
816
940
|
/**
|
|
817
941
|
* Triggers a submit form for current record
|
|
818
942
|
*
|
|
819
943
|
* @example
|
|
820
|
-
*
|
|
944
|
+
*
|
|
945
|
+
* ```js
|
|
946
|
+
* await ctx.saveCurrentItem();
|
|
947
|
+
* ```
|
|
821
948
|
*/
|
|
822
949
|
saveCurrentItem: () => Promise<void>;
|
|
823
950
|
};
|
|
@@ -827,7 +954,10 @@ export declare type RenderSidebarPanelAdditionalProperties = {
|
|
|
827
954
|
mode: 'renderItemFormSidebarPanel';
|
|
828
955
|
/** The ID of the sidebar panel that needs to be rendered */
|
|
829
956
|
sidebarPaneId: string;
|
|
830
|
-
/**
|
|
957
|
+
/**
|
|
958
|
+
* The arbitrary `parameters` of the panel declared in the
|
|
959
|
+
* `itemFormSidebarPanels` function
|
|
960
|
+
*/
|
|
831
961
|
parameters: Record<string, unknown>;
|
|
832
962
|
};
|
|
833
963
|
export declare type RenderSidebarPanelProperties = ItemFormProperties & RenderSidebarPanelAdditionalProperties;
|
|
@@ -836,7 +966,10 @@ export declare type RenderSidebarPanelAdditionalMethods = {
|
|
|
836
966
|
};
|
|
837
967
|
export declare type RenderSidebarPanelMethods = ItemFormMethods & RenderSidebarPanelAdditionalMethods;
|
|
838
968
|
export declare type RenderSidebarPanePropertiesAndMethods = RenderSidebarPanelMethods & RenderSidebarPanelProperties;
|
|
839
|
-
/**
|
|
969
|
+
/**
|
|
970
|
+
* Information regarding the state of a specific field where you need to render
|
|
971
|
+
* the field extension
|
|
972
|
+
*/
|
|
840
973
|
export declare type RenderFieldExtensionAdditionalProperties = {
|
|
841
974
|
mode: 'renderFieldExtension';
|
|
842
975
|
/** The ID of the field extension that needs to be rendered */
|
|
@@ -852,8 +985,8 @@ export declare type RenderFieldExtensionAdditionalProperties = {
|
|
|
852
985
|
/** The field where the field extension is installed to */
|
|
853
986
|
field: Field;
|
|
854
987
|
/**
|
|
855
|
-
* If the field extension is installed in a field of a block, returns the top
|
|
856
|
-
* Modular Content/Structured Text field containing the block itself
|
|
988
|
+
* If the field extension is installed in a field of a block, returns the top
|
|
989
|
+
* level Modular Content/Structured Text field containing the block itself
|
|
857
990
|
*/
|
|
858
991
|
parentField: Field | undefined;
|
|
859
992
|
};
|
|
@@ -876,16 +1009,19 @@ export declare type RenderModalProperties = RenderProperties & RenderModalAdditi
|
|
|
876
1009
|
export declare type RenderModalAdditionalMethods = {
|
|
877
1010
|
getSettings: () => Promise<RenderModalProperties>;
|
|
878
1011
|
/**
|
|
879
|
-
* A function to be called by the plugin to close the modal. The `openModal`
|
|
880
|
-
* be resolved with the passed return value
|
|
1012
|
+
* A function to be called by the plugin to close the modal. The `openModal`
|
|
1013
|
+
* call will be resolved with the passed return value
|
|
881
1014
|
*
|
|
882
1015
|
* @example
|
|
883
|
-
* const returnValue = prompt(
|
|
884
|
-
* 'Please specify the value to return to the caller:',
|
|
885
|
-
* 'success',
|
|
886
|
-
* );
|
|
887
1016
|
*
|
|
888
|
-
*
|
|
1017
|
+
* ```js
|
|
1018
|
+
* const returnValue = prompt(
|
|
1019
|
+
* 'Please specify the value to return to the caller:',
|
|
1020
|
+
* 'success',
|
|
1021
|
+
* );
|
|
1022
|
+
*
|
|
1023
|
+
* await ctx.resolve(returnValue);
|
|
1024
|
+
* ```
|
|
889
1025
|
*/
|
|
890
1026
|
resolve: (returnValue: unknown) => Promise<void>;
|
|
891
1027
|
};
|
|
@@ -903,9 +1039,23 @@ export declare type RenderPageAdditionalMethods = {
|
|
|
903
1039
|
};
|
|
904
1040
|
export declare type RenderPageMethods = RenderMethods & RenderPageAdditionalMethods;
|
|
905
1041
|
export declare type RenderPagePropertiesAndMethods = RenderPageMethods & RenderPageProperties;
|
|
1042
|
+
export declare type PendingField = {
|
|
1043
|
+
id?: string;
|
|
1044
|
+
type: 'field';
|
|
1045
|
+
attributes: {
|
|
1046
|
+
api_key: Field['attributes']['api_key'];
|
|
1047
|
+
appearance: Field['attributes']['appearance'];
|
|
1048
|
+
default_value: Field['attributes']['default_value'];
|
|
1049
|
+
field_type: Field['attributes']['field_type'];
|
|
1050
|
+
hint: Field['attributes']['hint'];
|
|
1051
|
+
label: Field['attributes']['label'];
|
|
1052
|
+
localized: Field['attributes']['localized'];
|
|
1053
|
+
validators: Field['attributes']['validators'];
|
|
1054
|
+
};
|
|
1055
|
+
};
|
|
906
1056
|
/**
|
|
907
|
-
* Information regarding the specific form that you need to render to let the
|
|
908
|
-
* edit the configuration object of a field extension
|
|
1057
|
+
* Information regarding the specific form that you need to render to let the
|
|
1058
|
+
* end-user edit the configuration object of a field extension
|
|
909
1059
|
*/
|
|
910
1060
|
export declare type RenderManualFieldExtensionConfigScreenAdditionalProperties = {
|
|
911
1061
|
mode: 'renderManualFieldExtensionConfigScreen';
|
|
@@ -917,20 +1067,30 @@ export declare type RenderManualFieldExtensionConfigScreenAdditionalProperties =
|
|
|
917
1067
|
*/
|
|
918
1068
|
parameters: Record<string, unknown>;
|
|
919
1069
|
/**
|
|
920
|
-
* The current validation errors for the parameters (you can set them
|
|
921
|
-
* `validateManualFieldExtensionParameters` function)
|
|
1070
|
+
* The current validation errors for the parameters (you can set them
|
|
1071
|
+
* implementing the `validateManualFieldExtensionParameters` function)
|
|
922
1072
|
*/
|
|
923
1073
|
errors: Record<string, unknown>;
|
|
1074
|
+
/** The field entity that is being edited in the form */
|
|
1075
|
+
pendingField: PendingField;
|
|
1076
|
+
/** The model for the field being edited */
|
|
1077
|
+
itemType: ModelBlock;
|
|
924
1078
|
};
|
|
925
1079
|
export declare type RenderManualFieldExtensionConfigScreenProperties = RenderProperties & RenderManualFieldExtensionConfigScreenAdditionalProperties;
|
|
926
|
-
/**
|
|
1080
|
+
/**
|
|
1081
|
+
* These methods can be used to update the configuration object of a specific
|
|
1082
|
+
* field extension
|
|
1083
|
+
*/
|
|
927
1084
|
export declare type RenderManualFieldExtensionConfigScreenAdditionalMethods = {
|
|
928
1085
|
getSettings: () => Promise<RenderManualFieldExtensionConfigScreenProperties>;
|
|
929
1086
|
/**
|
|
930
1087
|
* Sets a new value for the parameters
|
|
931
1088
|
*
|
|
932
1089
|
* @example
|
|
933
|
-
*
|
|
1090
|
+
*
|
|
1091
|
+
* ```js
|
|
1092
|
+
* await ctx.setParameters({ color: '#ff0000' });
|
|
1093
|
+
* ```
|
|
934
1094
|
*/
|
|
935
1095
|
setParameters: (params: Record<string, unknown>) => Promise<void>;
|
|
936
1096
|
};
|