datocms-plugin-sdk 0.3.2 → 0.3.3

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