datocms-plugin-sdk 0.3.24-alpha.3 → 0.3.27

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/src/types.ts ADDED
@@ -0,0 +1,1398 @@
1
+ import {
2
+ Account,
3
+ Field,
4
+ Item,
5
+ ModelBlock,
6
+ Plugin,
7
+ PluginAttributes,
8
+ Role,
9
+ Site,
10
+ SsoUser,
11
+ Upload,
12
+ User,
13
+ } from './SiteApiSchema';
14
+
15
+ export type Icon = string | { type: 'svg'; viewBox: string; content: string };
16
+
17
+ /** A tab to be displayed in the top-bar of the UI */
18
+ export type MainNavigationTab = {
19
+ /** Label to be shown. Must be unique. */
20
+ label: string;
21
+ /**
22
+ * Icon to be shown alongside the label. Can be a FontAwesome icon name (ie.
23
+ * `"address-book"`) or a custom SVG definition. To maintain visual
24
+ * consistency with the rest of the interface, try to use FontAwesome icons
25
+ * whenever possible.
26
+ */
27
+ icon: Icon;
28
+ /** ID of the page linked to the tab */
29
+ pointsTo: {
30
+ pageId: string;
31
+ };
32
+ /**
33
+ * Expresses where you want to place the tab in the top-bar. If not specified,
34
+ * the tab will be placed after the standard tabs provided by DatoCMS itself.
35
+ */
36
+ placement?: [
37
+ 'before' | 'after',
38
+ 'content' | 'mediaArea' | 'apiExplorer' | 'settings',
39
+ ];
40
+ /**
41
+ * If different plugins specify the same `placement` for their tabs, they will
42
+ * be displayed by ascending `rank`. If you want to specify an explicit value
43
+ * for `rank`, make sure to offer a way for final users to customize it inside
44
+ * the plugin's settings form, otherwise the hardcoded value you choose might
45
+ * clash with the one of another plugin! *
46
+ */
47
+ rank?: number;
48
+ };
49
+
50
+ /** An item contained in a Settings Area group */
51
+ export type SettingsAreaSidebarItem = {
52
+ /** Label to be shown. Must be unique. */
53
+ label: string;
54
+ /**
55
+ * Icon to be shown alongside the label. Can be a FontAwesome icon name (ie.
56
+ * `"address-book"`) or a custom SVG definition. To maintain visual
57
+ * consistency with the rest of the interface, try to use FontAwesome icons
58
+ * whenever possible.
59
+ */
60
+ icon: Icon;
61
+ /** ID of the page linked to the item */
62
+ pointsTo: {
63
+ pageId: string;
64
+ };
65
+ };
66
+
67
+ /**
68
+ * The sidebar in the Settings Area presents a number of pages grouped by topic.
69
+ * This object represents a new group to be added in the sideebar to the
70
+ * standard ones DatoCMS provides.
71
+ */
72
+ export type SettingsAreaSidebarItemGroup = {
73
+ /** Label to be shown. Must be unique. */
74
+ label: string;
75
+ /** The list of items it contains * */
76
+ items: SettingsAreaSidebarItem[];
77
+ /**
78
+ * Expresses where you want the group to be placed inside the sidebar. If not
79
+ * specified, the item will be placed after the standard items provided by
80
+ * DatoCMS itself.
81
+ */
82
+ placement?: [
83
+ 'before' | 'after',
84
+ (
85
+ | 'environment'
86
+ | 'project'
87
+ | 'permissions'
88
+ | 'webhooks'
89
+ | 'deployment'
90
+ | 'sso'
91
+ | 'auditLog'
92
+ | 'usage'
93
+ ),
94
+ ];
95
+ /**
96
+ * If different plugins specify the same `placement` for their sections, they
97
+ * will be displayed by ascending `rank`. If you want to specify an explicit
98
+ * value for `rank`, make sure to offer a way for final users to customize it
99
+ * inside the plugin's settings form, otherwise the hardcoded value you choose
100
+ * might clash with the one of another plugin! *
101
+ */
102
+ rank?: number;
103
+ };
104
+
105
+ /**
106
+ * The sidebar in the Content Area presents a number of user-defined menu-items.
107
+ * This object represents a new item to be added in the sidebar.
108
+ */
109
+ export type ContentAreaSidebarItem = {
110
+ /** Label to be shown. Must be unique. */
111
+ label: string;
112
+ /**
113
+ * Icon to be shown alongside the label. Can be a FontAwesome icon name (ie.
114
+ * `"address-book"`) or a custom SVG definition. To maintain visual
115
+ * consistency with the rest of the interface, try to use FontAwesome icons
116
+ * whenever possible.
117
+ */
118
+ icon: Icon;
119
+ /** ID of the page linked to the item */
120
+ pointsTo: {
121
+ pageId: string;
122
+ };
123
+ /**
124
+ * Expresses where you want the item to be placed inside the sidebar. If not
125
+ * specified, the item will be placed after the standard items provided by
126
+ * DatoCMS itself.
127
+ */
128
+ placement?: ['before' | 'after', 'menuItems' | 'settings'];
129
+ /**
130
+ * If different plugins specify the same `placement` for their panels, they
131
+ * will be displayed by ascending `rank`. If you want to specify an explicit
132
+ * value for `rank`, make sure to offer a way for final users to customize it
133
+ * inside the plugin's settings form, otherwise the hardcoded value you choose
134
+ * might clash with the one of another plugin! *
135
+ */
136
+ rank?: number;
137
+ };
138
+
139
+ export type FieldExtensionType = 'editor' | 'addon';
140
+
141
+ /**
142
+ * Field extensions extend the basic functionality of DatoCMS when it comes to
143
+ * presenting record's fields to the final user. Depending on the extension type
144
+ * (`editor` or `addon`) they will be shown in different places of the interface.
145
+ */
146
+ export type ManualFieldExtension = {
147
+ /**
148
+ * ID of field extension. Will be the first argument for the
149
+ * `renderFieldExtension` function
150
+ */
151
+ id: string;
152
+ /** Name to be shown when editing fields */
153
+ name: string;
154
+ /**
155
+ * Type of field extension. An `editor` extension replaces the default field
156
+ * editor that DatoCMS provides, while an `addon` extension is placed
157
+ * underneath the field editor to provide additional info/behaviour. You can
158
+ * setup multiple field addons for every field.
159
+ */
160
+ type: FieldExtensionType;
161
+ /**
162
+ * For `editor` extensions: moves the field to the sidebar of the record
163
+ * editing page, mimicking a sidebar panel
164
+ */
165
+ asSidebarPanel?: boolean | { startOpen: boolean };
166
+ /** The type of fields that the field extension in compatible with */
167
+ fieldTypes: NonNullable<PluginAttributes['field_types']>;
168
+ /**
169
+ * Whether this field extension needs some configuration options before being
170
+ * installed in a field or not. Will trigger the
171
+ * `renderManualFieldExtensionConfigScreen` and
172
+ * `validateManualFieldExtensionParameters` methods
173
+ */
174
+ configurable?: boolean | { initialHeight: number };
175
+ /** The initial height to set for the iframe that will render the field extension */
176
+ initialHeight?: number;
177
+ };
178
+
179
+ export type ItemFormSidebarPanelPlacement = [
180
+ 'before' | 'after',
181
+ 'info' | 'actions' | 'links' | 'history',
182
+ ];
183
+
184
+ /** A sidebar panel to be shown inside the record's editing page */
185
+ export type ItemFormSidebarPanel = {
186
+ /**
187
+ * ID of the panel. Will be the first argument for the
188
+ * `renderItemFormSidebarPanel` function
189
+ */
190
+ id: string;
191
+ /** Label to be shown on the collapsible sidebar panel handle */
192
+ label: string;
193
+ /**
194
+ * An arbitrary configuration object that will be passed as the `parameters`
195
+ * property of the second argument of the `renderItemFormSidebarPanel` function
196
+ */
197
+ parameters?: Record<string, unknown>;
198
+ /** Whether the sidebar panel will start open or collapsed */
199
+ startOpen?: boolean;
200
+ /**
201
+ * Expresses where you want the item to be placed inside the sidebar. If not
202
+ * specified, the item will be placed after the standard panels provided by
203
+ * DatoCMS itself.
204
+ */
205
+ placement?: ItemFormSidebarPanelPlacement;
206
+ /**
207
+ * If multiple sidebar panels specify the same `placement`, they will be
208
+ * sorted by ascending `rank`. If you want to specify an explicit value for
209
+ * `rank`, make sure to offer a way for final users to customize it inside the
210
+ * plugin's settings form, otherwise the hardcoded value you choose might
211
+ * clash with the one of another plugin! *
212
+ */
213
+ rank?: number;
214
+ /** The initial height to set for the iframe that will render the sidebar panel */
215
+ initialHeight?: number;
216
+ };
217
+
218
+ /** A field editor/sidebar forced on a field */
219
+ export type EditorOverride = {
220
+ /**
221
+ * ID of field extension. Will be the first argument for the
222
+ * `renderFieldExtension` function
223
+ */
224
+ id: string;
225
+ /** Moves the field to the sidebar of the record editing page, mimicking a sidebar panel */
226
+ asSidebarPanel?:
227
+ | boolean
228
+ | { startOpen?: boolean; placement?: ItemFormSidebarPanelPlacement };
229
+ /**
230
+ * An arbitrary configuration object that will be passed as the `parameters`
231
+ * property of the second argument of the `renderFieldExtension` function
232
+ */
233
+ parameters?: Record<string, unknown>;
234
+ /**
235
+ * If multiple plugins override a field, the one with the highest `rank` will
236
+ * win. If you want to specify an explicit value for `rank`, make sure to
237
+ * offer a way for final users to customize it inside the plugin's settings
238
+ * form, otherwise the hardcoded value you choose might clash with the one of
239
+ * another plugin! *
240
+ */
241
+ rank?: number;
242
+ /** The initial height to set for the iframe that will render the field extension */
243
+ initialHeight?: number;
244
+ };
245
+
246
+ /** A field addon extension forced on a field */
247
+ export type AddonOverride = {
248
+ /**
249
+ * ID of field extension. Will be the first argument for the
250
+ * `renderFieldExtension` function
251
+ */
252
+ id: string;
253
+ /**
254
+ * An arbitrary configuration object that will be passed as the `parameters`
255
+ * property of the second argument of the `renderFieldExtension` function
256
+ */
257
+ parameters?: Record<string, unknown>;
258
+ /**
259
+ * If multiple addons are present for a field, they will be sorted by
260
+ * ascending `rank`. If you want to specify an explicit value for `rank`, make
261
+ * sure to offer a way for final users to customize it inside the plugin's
262
+ * settings form, otherwise the hardcoded value you choose might clash with
263
+ * the one of another plugin! *
264
+ */
265
+ rank?: number;
266
+ /** The initial height to set for the iframe that will render the field extension */
267
+ initialHeight?: number;
268
+ };
269
+
270
+ /** An object expressing some field extensions you want to force on a particular field */
271
+ export type FieldExtensionOverride = {
272
+ /** Force a field editor/sidebar extension on a field */
273
+ editor?: EditorOverride;
274
+ /** One or more field sidebar extensions to forcefully add to a field */
275
+ addons?: AddonOverride[];
276
+ };
277
+
278
+ /** An object containing the theme colors for the current DatoCMS project */
279
+ export type Theme = {
280
+ primaryColor: string;
281
+ accentColor: string;
282
+ semiTransparentAccentColor: string;
283
+ lightColor: string;
284
+ darkColor: string;
285
+ };
286
+
287
+ /** Focal point of an image asset */
288
+ export type FocalPoint = {
289
+ /** Horizontal position expressed as float between 0 and 1 */
290
+ x: number;
291
+ /** Vertical position expressed as float between 0 and 1 */
292
+ y: number;
293
+ };
294
+
295
+ /** The structure contained in a "single asset" field */
296
+ export type FileFieldValue = {
297
+ /** ID of the asset */
298
+ // eslint-disable-next-line camelcase
299
+ upload_id: string;
300
+ /** Alternate text for the asset */
301
+ alt: string | null;
302
+ /** Title for the asset */
303
+ title: string | null;
304
+ /** Focal point of an asset */
305
+ // eslint-disable-next-line camelcase
306
+ focal_point: FocalPoint | null;
307
+ /** Object with arbitrary metadata related to the asset */
308
+ // eslint-disable-next-line camelcase
309
+ custom_data: Record<string, string>;
310
+ };
311
+
312
+ /** A modal to present to the user */
313
+ export type Modal = {
314
+ /** ID of the modal. Will be the first argument for the `renderModal` function */
315
+ id: string;
316
+ /** Title for the modal. Ignored by `fullWidth` modals */
317
+ title?: string;
318
+ /** Whether to present a close button for the modal or not */
319
+ closeDisabled?: boolean;
320
+ /** Width of the modal. Can be a number, or one of the predefined sizes */
321
+ width?: 's' | 'm' | 'l' | 'xl' | 'fullWidth' | number;
322
+ /**
323
+ * An arbitrary configuration object that will be passed as the `parameters`
324
+ * property of the second argument of the `renderModal` function
325
+ */
326
+ parameters?: Record<string, unknown>;
327
+ /** The initial height to set for the iframe that will render the modal content */
328
+ initialHeight?: number;
329
+ };
330
+
331
+ /** An additional asset source */
332
+ export type AssetSource = {
333
+ /**
334
+ * ID of the asset source. Will be the first argument for the
335
+ * `renderAssetSource` function
336
+ */
337
+ id: string;
338
+ /** Name of the asset that will be shown to the user */
339
+ name: string;
340
+ /**
341
+ * Icon to be shown alongside the name. Can be a FontAwesome icon name (ie.
342
+ * `"address-book"`) or a custom SVG definition. To maintain visual
343
+ * consistency with the rest of the interface, try to use FontAwesome icons
344
+ * whenever possible.
345
+ */
346
+ icon: Icon;
347
+ /**
348
+ * Configuration options for the modal that will be opened to select a media
349
+ * file from this source
350
+ */
351
+ modal?: {
352
+ /** Width of the modal. Can be a number, or one of the predefined sizes */
353
+ width?: 's' | 'm' | 'l' | 'xl' | number;
354
+ /** The initial height to set for the iframe that will render the modal content */
355
+ initialHeight?: number;
356
+ };
357
+ };
358
+
359
+ /** A toast notification to present to the user */
360
+ export type Toast<CtaValue = unknown> = {
361
+ /** Message of the notification */
362
+ message: string;
363
+ /** Type of notification. Will present the toast in a different color accent. */
364
+ type: 'notice' | 'alert' | 'warning';
365
+ /** An optional button to show inside the toast */
366
+ cta?: {
367
+ /** Label for the button */
368
+ label: string;
369
+ /**
370
+ * The value to be returned by the `customToast` promise if the button is
371
+ * clicked by the user
372
+ */
373
+ value: CtaValue;
374
+ };
375
+ /** Whether the toast is to be automatically closed if the user changes page */
376
+ dismissOnPageChange?: boolean;
377
+ /**
378
+ * Whether the toast is to be automatically closed after some time (`true`
379
+ * will use the default DatoCMS time interval)
380
+ */
381
+ dismissAfterTimeout?: boolean | number;
382
+ };
383
+
384
+ /** A choice presented in a `openConfirm` panel */
385
+ export type ConfirmChoice = {
386
+ /** The label to be shown for the choice */
387
+ label: string;
388
+ /**
389
+ * The value to be returned by the `openConfirm` promise if the button is
390
+ * clicked by the user
391
+ */
392
+ value: unknown;
393
+ /** The intent of the button. Will present the button in a different color accent. */
394
+ intent?: 'positive' | 'negative';
395
+ };
396
+
397
+ /** Options for the `openConfirm` function */
398
+ export type ConfirmOptions = {
399
+ /** The title to be shown inside the confirmation panel */
400
+ title: string;
401
+ /** The main message to be shown inside the confirmation panel */
402
+ content: string;
403
+ /** The different options the user can choose from */
404
+ choices: ConfirmChoice[];
405
+ /** The cancel option to present to the user */
406
+ cancel: ConfirmChoice;
407
+ };
408
+
409
+ /** Generic properties available in all the hooks */
410
+ export type CommonProperties = {
411
+ /** The current DatoCMS project */
412
+ site: Site;
413
+ /** The ID of the current environment */
414
+ environment: string;
415
+ /** All the models of the current DatoCMS project, indexed by ID */
416
+ itemTypes: Partial<Record<string, ModelBlock>>;
417
+ /**
418
+ * The current DatoCMS user. It can either be the owner or one of the
419
+ * collaborators (regular or SSO).
420
+ */
421
+ currentUser: User | SsoUser | Account;
422
+ /** The role for the current DatoCMS user */
423
+ currentRole: Role;
424
+ /**
425
+ * The access token to perform API calls on behalf of the current user. Only
426
+ * available if `currentUserAccessToken` additional permission is granted
427
+ */
428
+ currentUserAccessToken: string | undefined;
429
+ /** The current plugin */
430
+ plugin: Plugin;
431
+ /**
432
+ * UI preferences of the current user (right now, only the preferred locale is
433
+ * available)
434
+ */
435
+ ui: {
436
+ /** Preferred locale */
437
+ locale: string;
438
+ };
439
+ };
440
+
441
+ export type InitAdditionalProperties = {
442
+ mode: 'init';
443
+ };
444
+
445
+ export type InitProperties = CommonProperties & InitAdditionalProperties;
446
+
447
+ export type InitMethods = {
448
+ getSettings: () => Promise<InitProperties>;
449
+ };
450
+
451
+ export type InitPropertiesAndMethods = InitMethods & InitProperties;
452
+
453
+ /** Additional properties available in all `renderXXX` hooks */
454
+ export type RenderAdditionalProperties = {
455
+ /**
456
+ * All the fields currently loaded for the current DatoCMS project, indexed by
457
+ * ID. It will always contain the current model fields and all the fields of
458
+ * the blocks it might contain via Modular Content/Structured Text fields. If
459
+ * some fields you need are not present, use the `loadItemTypeFields` function
460
+ * to load them.
461
+ */
462
+ fields: Partial<Record<string, Field>>;
463
+ /** An object containing the theme colors for the current DatoCMS project */
464
+ theme: Theme;
465
+ /**
466
+ * All the regular users currently loaded for the current DatoCMS project,
467
+ * indexed by ID. It will always contain the current user. If some users you
468
+ * need are not present, use the `loadUsers` function to load them.
469
+ */
470
+ users: Partial<Record<string, User>>;
471
+ /**
472
+ * All the SSO users currently loaded for the current DatoCMS project, indexed
473
+ * by ID. It will always contain the current user. If some users you need are
474
+ * not present, use the `loadSsoUsers` function to load them.
475
+ */
476
+ ssoUsers: Partial<Record<string, SsoUser>>;
477
+ /** The project owner */
478
+ account: Account;
479
+ /** The padding in px that must be applied to the body */
480
+ bodyPadding: [number, number, number, number];
481
+ };
482
+
483
+ export type RenderProperties = CommonProperties & RenderAdditionalProperties;
484
+
485
+ export type FieldAppearanceChange =
486
+ | {
487
+ operation: 'removeEditor';
488
+ }
489
+ | {
490
+ operation: 'updateEditor';
491
+ newFieldExtensionId?: string;
492
+ newParameters?: Record<string, unknown>;
493
+ }
494
+ | {
495
+ operation: 'setEditor';
496
+ fieldExtensionId: string;
497
+ parameters: Record<string, unknown>;
498
+ }
499
+ | {
500
+ operation: 'removeAddon';
501
+ index: number;
502
+ }
503
+ | {
504
+ operation: 'updateAddon';
505
+ index: number;
506
+ newFieldExtensionId?: string;
507
+ newParameters?: Record<string, unknown>;
508
+ }
509
+ | {
510
+ operation: 'insertAddon';
511
+ index: number;
512
+ fieldExtensionId: string;
513
+ parameters: Record<string, unknown>;
514
+ };
515
+
516
+ /**
517
+ * These methods can be used to update both plugin parameters and manual field
518
+ * extensions configuration.
519
+ */
520
+ export type UpdateParametersMethods = {
521
+ /**
522
+ * Updates the plugin parameters.
523
+ *
524
+ * Always check `ctx.currentRole.meta.final_permissions.can_edit_schema`
525
+ * before calling this, as the user might not have the permission to perform
526
+ * the operation.
527
+ *
528
+ * @example
529
+ *
530
+ * ```js
531
+ * await ctx.updatePluginParameters({ debugMode: true });
532
+ * await ctx.notice('Plugin parameters successfully updated!');
533
+ * ```
534
+ */
535
+ updatePluginParameters: (params: Record<string, unknown>) => Promise<void>;
536
+ /**
537
+ * Performs changes in the appearance of a field. You can install/remove a
538
+ * manual field extension, or tweak their parameters. If multiple changes are
539
+ * passed, they will be applied sequencially.
540
+ *
541
+ * Always check `ctx.currentRole.meta.final_permissions.can_edit_schema`
542
+ * before calling this, as the user might not have the permission to perform
543
+ * the operation.
544
+ *
545
+ * @example
546
+ *
547
+ * ```js
548
+ * const fields = await ctx.loadFieldsUsingPlugin();
549
+ *
550
+ * if (fields.length === 0) {
551
+ * ctx.alert('No field is using this plugin as a manual extension!');
552
+ * return;
553
+ * }
554
+ *
555
+ * for (const field of fields) {
556
+ * const { appearance } = field.attributes;
557
+ * const operations = [];
558
+ *
559
+ * if (appearance.editor === ctx.plugin.id) {
560
+ * operations.push({
561
+ * operation: 'updateEditor',
562
+ * newParameters: {
563
+ * ...appearance.parameters,
564
+ * foo: 'bar',
565
+ * },
566
+ * });
567
+ * }
568
+ *
569
+ * appearance.addons.forEach((addon, i) => {
570
+ * if (addon.id !== ctx.plugin.id) {
571
+ * return;
572
+ * }
573
+ *
574
+ * operations.push({
575
+ * operation: 'updateAddon',
576
+ * index: i,
577
+ * newParameters: { ...addon.parameters, foo: 'bar' },
578
+ * });
579
+ * });
580
+ *
581
+ * await ctx.updateFieldAppearance(field.id, operations);
582
+ * ctx.notice(`Successfully edited field ${field.attributes.api_key}`);
583
+ * }
584
+ * ```
585
+ */
586
+ updateFieldAppearance: (
587
+ fieldId: string,
588
+ changes: FieldAppearanceChange[],
589
+ ) => Promise<void>;
590
+ };
591
+
592
+ /**
593
+ * These methods can be used to asyncronously load additional information your
594
+ * plugin needs to work
595
+ */
596
+ export type LoadDataMethods = {
597
+ /**
598
+ * Loads all the fields for a specific model (or block). Fields will be
599
+ * returned and will also be available in the the `fields` property.
600
+ *
601
+ * @example
602
+ *
603
+ * ```js
604
+ * const itemTypeId = prompt('Please insert a model ID:');
605
+ *
606
+ * const fields = await ctx.loadItemTypeFields(itemTypeId);
607
+ *
608
+ * ctx.notice(
609
+ * `Success! ${fields
610
+ * .map((field) => field.attributes.api_key)
611
+ * .join(', ')}`,
612
+ * );
613
+ * ```
614
+ */
615
+ loadItemTypeFields: (itemTypeId: string) => Promise<Field[]>;
616
+ /**
617
+ * Loads all the fields in the project that are currently using the plugin for
618
+ * one of its manual field extensions.
619
+ *
620
+ * @example
621
+ *
622
+ * ```js
623
+ * const fields = await ctx.loadFieldsUsingPlugin();
624
+ *
625
+ * ctx.notice(
626
+ * `Success! ${fields
627
+ * .map((field) => field.attributes.api_key)
628
+ * .join(', ')}`,
629
+ * );
630
+ * ```
631
+ */
632
+ loadFieldsUsingPlugin: () => Promise<Field[]>;
633
+ /**
634
+ * Loads all regular users. Users will be returned and will also be available
635
+ * in the the `users` property.
636
+ *
637
+ * @example
638
+ *
639
+ * ```js
640
+ * const users = await ctx.loadUsers();
641
+ *
642
+ * ctx.notice(`Success! ${users.map((user) => user.id).join(', ')}`);
643
+ * ```
644
+ */
645
+ loadUsers: () => Promise<User[]>;
646
+ /**
647
+ * Loads all SSO users. Users will be returned and will also be available in
648
+ * the the `ssoUsers` property.
649
+ *
650
+ * @example
651
+ *
652
+ * ```js
653
+ * const users = await ctx.loadSsoUsers();
654
+ *
655
+ * ctx.notice(`Success! ${users.map((user) => user.id).join(', ')}`);
656
+ * ```
657
+ */
658
+ loadSsoUsers: () => Promise<SsoUser[]>;
659
+ };
660
+
661
+ /** These methods let you open the standard DatoCMS dialogs needed to interact with records */
662
+ export type ItemDialogMethods = {
663
+ /**
664
+ * Opens a dialog for creating a new record. It returns a promise resolved
665
+ * with the newly created record or `null` if the user closes the dialog
666
+ * without creating anything.
667
+ *
668
+ * @example
669
+ *
670
+ * ```js
671
+ * const itemTypeId = prompt('Please insert a model ID:');
672
+ *
673
+ * const item = await ctx.createNewItem(itemTypeId);
674
+ *
675
+ * if (item) {
676
+ * ctx.notice(`Success! ${item.id}`);
677
+ * } else {
678
+ * ctx.alert('Closed!');
679
+ * }
680
+ * ```
681
+ */
682
+ createNewItem: (itemTypeId: string) => Promise<Item | null>;
683
+ /**
684
+ * Opens a dialog for selecting one (or multiple) record(s) from a list of
685
+ * existing records of type `itemTypeId`. It returns a promise resolved with
686
+ * the selected record(s), or `null` if the user closes the dialog without
687
+ * choosing any record.
688
+ *
689
+ * @example
690
+ *
691
+ * ```js
692
+ * const itemTypeId = prompt('Please insert a model ID:');
693
+ *
694
+ * const items = await ctx.selectItem(itemTypeId, { multiple: true });
695
+ *
696
+ * if (items) {
697
+ * ctx.notice(`Success! ${items.map((i) => i.id).join(', ')}`);
698
+ * } else {
699
+ * ctx.alert('Closed!');
700
+ * }
701
+ * ```
702
+ */
703
+ selectItem: {
704
+ (itemTypeId: string, options: { multiple: true }): Promise<Item[] | null>;
705
+ (itemTypeId: string, options?: { multiple: false }): Promise<Item | null>;
706
+ };
707
+ /**
708
+ * Opens a dialog for editing an existing record. It returns a promise
709
+ * resolved with the edited record, or `null` if the user closes the dialog
710
+ * without persisting any change.
711
+ *
712
+ * @example
713
+ *
714
+ * ```js
715
+ * const itemId = prompt('Please insert a record ID:');
716
+ *
717
+ * const item = await ctx.editItem(itemId);
718
+ *
719
+ * if (item) {
720
+ * ctx.notice(`Success! ${item.id}`);
721
+ * } else {
722
+ * ctx.alert('Closed!');
723
+ * }
724
+ * ```
725
+ */
726
+ editItem: (itemId: string) => Promise<Item | null>;
727
+ };
728
+
729
+ /** These methods can be used to show UI-consistent toast notifications to the end-user */
730
+ export type ToastMethods = {
731
+ /**
732
+ * Triggers an "error" toast displaying the selected message
733
+ *
734
+ * @example
735
+ *
736
+ * ```js
737
+ * const message = prompt(
738
+ * 'Please insert a message:',
739
+ * 'This is an alert message!',
740
+ * );
741
+ *
742
+ * await ctx.alert(message);
743
+ * ```
744
+ */
745
+ alert: (message: string) => Promise<void>;
746
+ /**
747
+ * Triggers a "success" toast displaying the selected message
748
+ *
749
+ * @example
750
+ *
751
+ * ```js
752
+ * const message = prompt(
753
+ * 'Please insert a message:',
754
+ * 'This is a notice message!',
755
+ * );
756
+ *
757
+ * await ctx.notice(message);
758
+ * ```
759
+ */
760
+ notice: (message: string) => Promise<void>;
761
+ /**
762
+ * Triggers a custom toast displaying the selected message (and optionally a CTA)
763
+ *
764
+ * @example
765
+ *
766
+ * ```js
767
+ * const result = await ctx.customToast({
768
+ * type: 'warning',
769
+ * message: 'Just a sample warning notification!',
770
+ * dismissOnPageChange: true,
771
+ * dismissAfterTimeout: 5000,
772
+ * cta: {
773
+ * label: 'Execute call-to-action',
774
+ * value: 'cta',
775
+ * },
776
+ * });
777
+ *
778
+ * if (result === 'cta') {
779
+ * ctx.notice(`Clicked CTA!`);
780
+ * }
781
+ * ```
782
+ */
783
+ customToast: <CtaValue = unknown>(
784
+ toast: Toast<CtaValue>,
785
+ ) => Promise<CtaValue | null>;
786
+ };
787
+
788
+ /**
789
+ * These methods let you open the standard DatoCMS dialogs needed to interact
790
+ * with Media Area assets
791
+ */
792
+ export type UploadDialogMethods = {
793
+ /**
794
+ * Opens a dialog for selecting one (or multiple) existing asset(s). It
795
+ * returns a promise resolved with the selected asset(s), or `null` if the
796
+ * user closes the dialog without selecting any upload.
797
+ *
798
+ * @example
799
+ *
800
+ * ```js
801
+ * const item = await ctx.selectUpload({ multiple: false });
802
+ *
803
+ * if (item) {
804
+ * ctx.notice(`Success! ${item.id}`);
805
+ * } else {
806
+ * ctx.alert('Closed!');
807
+ * }
808
+ * ```
809
+ */
810
+ selectUpload: {
811
+ (options: { multiple: true }): Promise<Upload[] | null>;
812
+ (options?: { multiple: false }): Promise<Upload | null>;
813
+ };
814
+
815
+ /**
816
+ * Opens a dialog for editing a Media Area asset. It returns a promise resolved with:
817
+ *
818
+ * - The updated asset, if the user persists some changes to the asset itself
819
+ * - `null`, if the user closes the dialog without persisting any change
820
+ * - An asset structure with an additional `deleted` property set to true, if
821
+ * the user deletes the asset
822
+ *
823
+ * @example
824
+ *
825
+ * ```js
826
+ * const uploadId = prompt('Please insert an asset ID:');
827
+ *
828
+ * const item = await ctx.editUpload(uploadId);
829
+ *
830
+ * if (item) {
831
+ * ctx.notice(`Success! ${item.id}`);
832
+ * } else {
833
+ * ctx.alert('Closed!');
834
+ * }
835
+ * ```
836
+ */
837
+ editUpload: (
838
+ uploadId: string,
839
+ ) => Promise<(Upload & { deleted?: true }) | null>;
840
+ /**
841
+ * Opens a dialog for editing a "single asset" field structure. It returns a
842
+ * promise resolved with the updated structure, or `null` if the user closes
843
+ * the dialog without persisting any change.
844
+ *
845
+ * @example
846
+ *
847
+ * ```js
848
+ * const uploadId = prompt('Please insert an asset ID:');
849
+ *
850
+ * const result = await ctx.editUploadMetadata({
851
+ * upload_id: uploadId,
852
+ * alt: null,
853
+ * title: null,
854
+ * custom_data: {},
855
+ * focal_point: null,
856
+ * });
857
+ *
858
+ * if (result) {
859
+ * ctx.notice(`Success! ${JSON.stringify(result)}`);
860
+ * } else {
861
+ * ctx.alert('Closed!');
862
+ * }
863
+ * ```
864
+ */
865
+ editUploadMetadata: (
866
+ /** The "single asset" field structure */
867
+ fileFieldValue: FileFieldValue,
868
+ /** Shows metadata information for a specific locale */
869
+ locale?: string,
870
+ ) => Promise<FileFieldValue | null>;
871
+ };
872
+
873
+ /** These methods can be used to open custom dialogs/confirmation panels */
874
+ export type CustomDialogMethods = {
875
+ /**
876
+ * Opens a custom modal. Returns a promise resolved with what the modal itself
877
+ * returns calling the `resolve()` function
878
+ *
879
+ * @example
880
+ *
881
+ * ```js
882
+ * const result = await ctx.openModal({
883
+ * id: 'regular',
884
+ * title: 'Custom title!',
885
+ * width: 'l',
886
+ * parameters: { foo: 'bar' },
887
+ * });
888
+ *
889
+ * if (result) {
890
+ * ctx.notice(`Success! ${JSON.stringify(result)}`);
891
+ * } else {
892
+ * ctx.alert('Closed!');
893
+ * }
894
+ * ```
895
+ */
896
+ openModal: (modal: Modal) => Promise<unknown>;
897
+ /**
898
+ * Opens a UI-consistent confirmation dialog. Returns a promise resolved with
899
+ * the value of the choice made by the user
900
+ *
901
+ * @example
902
+ *
903
+ * ```js
904
+ * const result = await ctx.openConfirm({
905
+ * title: 'Custom title',
906
+ * content:
907
+ * 'Lorem Ipsum is simply dummy text of the printing and typesetting industry',
908
+ * choices: [
909
+ * {
910
+ * label: 'Positive',
911
+ * value: 'positive',
912
+ * intent: 'positive',
913
+ * },
914
+ * {
915
+ * label: 'Negative',
916
+ * value: 'negative',
917
+ * intent: 'negative',
918
+ * },
919
+ * ],
920
+ * cancel: {
921
+ * label: 'Cancel',
922
+ * value: false,
923
+ * },
924
+ * });
925
+ *
926
+ * if (result) {
927
+ * ctx.notice(`Success! ${result}`);
928
+ * } else {
929
+ * ctx.alert('Cancelled!');
930
+ * }
931
+ * ```
932
+ */
933
+ openConfirm: (options: ConfirmOptions) => Promise<unknown>;
934
+ };
935
+
936
+ /** These methods can be used to take the user to different pages */
937
+ export type NavigateMethods = {
938
+ /**
939
+ * Moves the user to another URL internal to the backend
940
+ *
941
+ * @example
942
+ *
943
+ * ```js
944
+ * await ctx.navigateTo('/');
945
+ * ```
946
+ */
947
+ navigateTo: (path: string) => Promise<void>;
948
+ };
949
+
950
+ /** These methods can be used to set various properties of the containing iframe */
951
+ export type IframeMethods = {
952
+ /** Sets the height for the iframe */
953
+ setHeight: (number: number) => Promise<void>;
954
+ };
955
+
956
+ export type RenderMethods = LoadDataMethods &
957
+ UpdateParametersMethods &
958
+ ToastMethods &
959
+ ItemDialogMethods &
960
+ UploadDialogMethods &
961
+ CustomDialogMethods &
962
+ NavigateMethods;
963
+
964
+ /**
965
+ * These information describe the current state of the form that's being shown
966
+ * to the end-user to edit a record
967
+ */
968
+ export type ItemFormAdditionalProperties = {
969
+ /** The currently active locale for the record */
970
+ locale: string;
971
+ /** If an already persisted record is being edited, returns the full record entity */
972
+ item: Item | null;
973
+ /** The model for the record being edited */
974
+ itemType: ModelBlock;
975
+ /** The complete internal form state */
976
+ formValues: Record<string, unknown>;
977
+ /** The current status of the record being edited */
978
+ itemStatus: 'new' | 'draft' | 'updated' | 'published';
979
+ /** Whether the form is currently submitting itself or not */
980
+ isSubmitting: boolean;
981
+ /** Whether the form has some non-persisted changes or not */
982
+ isFormDirty: boolean;
983
+ };
984
+
985
+ export type ItemFormProperties = RenderProperties &
986
+ ItemFormAdditionalProperties;
987
+
988
+ /**
989
+ * These methods can be used to interact with the form that's being shown to the
990
+ * end-user to edit a record
991
+ */
992
+ export type ItemFormAdditionalMethods = {
993
+ /**
994
+ * Hides/shows a specific field in the form
995
+ *
996
+ * @example
997
+ *
998
+ * ```js
999
+ * const fieldPath = prompt(
1000
+ * 'Please insert the path of a field in the form',
1001
+ * ctx.fieldPath,
1002
+ * );
1003
+ *
1004
+ * await ctx.toggleField(fieldPath, true);
1005
+ * ```
1006
+ */
1007
+ toggleField: (path: string, show: boolean) => Promise<void>;
1008
+ /**
1009
+ * Disables/re-enables a specific field in the form
1010
+ *
1011
+ * @example
1012
+ *
1013
+ * ```js
1014
+ * const fieldPath = prompt(
1015
+ * 'Please insert the path of a field in the form',
1016
+ * ctx.fieldPath,
1017
+ * );
1018
+ *
1019
+ * await ctx.disableField(fieldPath, true);
1020
+ * ```
1021
+ */
1022
+ disableField: (path: string, disable: boolean) => Promise<void>;
1023
+ /**
1024
+ * Smoothly navigates to a specific field in the form. If the field is
1025
+ * localized it will switch language tab and then navigate to the chosen field.
1026
+ *
1027
+ * @example
1028
+ *
1029
+ * ```js
1030
+ * const fieldPath = prompt(
1031
+ * 'Please insert the path of a field in the form',
1032
+ * ctx.fieldPath,
1033
+ * );
1034
+ *
1035
+ * await ctx.scrollToField(fieldPath);
1036
+ * ```
1037
+ */
1038
+ scrollToField: (path: string, locale?: string) => Promise<void>;
1039
+ /**
1040
+ * Changes a specific path of the `formValues` object
1041
+ *
1042
+ * @example
1043
+ *
1044
+ * ```js
1045
+ * const fieldPath = prompt(
1046
+ * 'Please insert the path of a field in the form',
1047
+ * ctx.fieldPath,
1048
+ * );
1049
+ *
1050
+ * await ctx.setFieldValue(fieldPath, 'new value');
1051
+ * ```
1052
+ */
1053
+ setFieldValue: (path: string, value: unknown) => Promise<void>;
1054
+ /**
1055
+ * Triggers a submit form for current record
1056
+ *
1057
+ * @example
1058
+ *
1059
+ * ```js
1060
+ * await ctx.saveCurrentItem();
1061
+ * ```
1062
+ */
1063
+ saveCurrentItem: () => Promise<void>;
1064
+ };
1065
+
1066
+ export type ItemFormMethods = RenderMethods &
1067
+ IframeMethods &
1068
+ ItemFormAdditionalMethods;
1069
+
1070
+ /** Information regarding the specific sidebar panel that you need to render */
1071
+ export type RenderSidebarPanelAdditionalProperties = {
1072
+ mode: 'renderItemFormSidebarPanel';
1073
+ /** The ID of the sidebar panel that needs to be rendered */
1074
+ sidebarPaneId: string;
1075
+ /**
1076
+ * The arbitrary `parameters` of the panel declared in the
1077
+ * `itemFormSidebarPanels` function
1078
+ */
1079
+ parameters: Record<string, unknown>;
1080
+ };
1081
+
1082
+ export type RenderSidebarPanelProperties = ItemFormProperties &
1083
+ RenderSidebarPanelAdditionalProperties;
1084
+
1085
+ export type RenderSidebarPanelAdditionalMethods = {
1086
+ getSettings: () => Promise<RenderSidebarPanelProperties>;
1087
+ };
1088
+
1089
+ export type RenderSidebarPanelMethods = ItemFormMethods &
1090
+ RenderSidebarPanelAdditionalMethods;
1091
+
1092
+ export type RenderSidebarPanePropertiesAndMethods = RenderSidebarPanelMethods &
1093
+ RenderSidebarPanelProperties;
1094
+
1095
+ /**
1096
+ * Information regarding the state of a specific field where you need to render
1097
+ * the field extension
1098
+ */
1099
+ export type RenderFieldExtensionAdditionalProperties = {
1100
+ mode: 'renderFieldExtension';
1101
+ /** The ID of the field extension that needs to be rendered */
1102
+ fieldExtensionId: string;
1103
+ /** The arbitrary `parameters` of the field extension */
1104
+ parameters: Record<string, unknown>;
1105
+ /** The placeholder for the field */
1106
+ placeholder: string;
1107
+ /** Whether the field is currently disabled or not */
1108
+ disabled: boolean;
1109
+ /** The path in the `formValues` object where to find the current value for the field */
1110
+ fieldPath: string;
1111
+ /** The field where the field extension is installed to */
1112
+ field: Field;
1113
+ /**
1114
+ * If the field extension is installed in a field of a block, returns the top
1115
+ * level Modular Content/Structured Text field containing the block itself
1116
+ */
1117
+ parentField: Field | undefined;
1118
+ };
1119
+
1120
+ export type RenderFieldExtensionProperties = ItemFormProperties &
1121
+ RenderFieldExtensionAdditionalProperties;
1122
+
1123
+ export type RenderFieldExtensionAdditionalMethods = {
1124
+ getSettings: () => Promise<RenderFieldExtensionProperties>;
1125
+ };
1126
+
1127
+ export type RenderFieldExtensionMethods = ItemFormMethods &
1128
+ RenderFieldExtensionAdditionalMethods;
1129
+
1130
+ export type RenderFieldExtensionPropertiesAndMethods = RenderFieldExtensionMethods &
1131
+ RenderFieldExtensionProperties;
1132
+
1133
+ /** Information regarding the specific custom modal that you need to render */
1134
+ export type RenderModalAdditionalProperties = {
1135
+ mode: 'renderModal';
1136
+ /** The ID of the modal that needs to be rendered */
1137
+ modalId: string;
1138
+ /** The arbitrary `parameters` of the modal declared in the `openModal` function */
1139
+ parameters: Record<string, unknown>;
1140
+ };
1141
+
1142
+ export type RenderModalProperties = RenderProperties &
1143
+ RenderModalAdditionalProperties;
1144
+
1145
+ /** These methods can be used to close the modal */
1146
+ export type RenderModalAdditionalMethods = {
1147
+ getSettings: () => Promise<RenderModalProperties>;
1148
+ /**
1149
+ * A function to be called by the plugin to close the modal. The `openModal`
1150
+ * call will be resolved with the passed return value
1151
+ *
1152
+ * @example
1153
+ *
1154
+ * ```js
1155
+ * const returnValue = prompt(
1156
+ * 'Please specify the value to return to the caller:',
1157
+ * 'success',
1158
+ * );
1159
+ *
1160
+ * await ctx.resolve(returnValue);
1161
+ * ```
1162
+ */
1163
+ resolve: (returnValue: unknown) => Promise<void>;
1164
+ };
1165
+
1166
+ export type RenderModalMethods = RenderMethods &
1167
+ IframeMethods &
1168
+ RenderModalAdditionalMethods;
1169
+
1170
+ export type RenderModalPropertiesAndMethods = RenderModalMethods &
1171
+ RenderModalProperties;
1172
+
1173
+ /** Information regarding the specific asset source browser that you need to render */
1174
+ export type RenderAssetSourceAdditionalProperties = {
1175
+ mode: 'renderAssetSource';
1176
+ /** The ID of the assetSource that needs to be rendered */
1177
+ assetSourceId: string;
1178
+ };
1179
+
1180
+ export type RenderAssetSourceProperties = RenderProperties &
1181
+ RenderAssetSourceAdditionalProperties;
1182
+
1183
+ export type NewUploadResourceAsUrl = {
1184
+ /**
1185
+ * URL for the resource. The URL must respond with a
1186
+ * `Access-Control-Allow-Origin` header — for instance `*`, which will allow
1187
+ * all hosts — allowing the image to be read by DatoCMS
1188
+ */
1189
+ url: string;
1190
+ /**
1191
+ * Optional filename to be used to generate the final DatoCMS URL. If not
1192
+ * passed, the URL will be used
1193
+ */
1194
+ filename?: string;
1195
+ };
1196
+
1197
+ export type NewUploadResourceAsBase64 = {
1198
+ /**
1199
+ * Base64 encoded data URI for the resource.
1200
+ *
1201
+ * Format:
1202
+ *
1203
+ * `data:[<mime type>][;charset=<charset>];base64,<encoded data>`
1204
+ */
1205
+ base64: string;
1206
+ /** Filename to be used to generate the final DatoCMS URL */
1207
+ filename: string;
1208
+ };
1209
+
1210
+ export type NewUpload = {
1211
+ /** The actual resource that will be uploaded */
1212
+ resource: NewUploadResourceAsUrl | NewUploadResourceAsBase64;
1213
+ /** Copyright to apply to the asset */
1214
+ copyright?: string;
1215
+ /** Author to apply to the asset */
1216
+ author?: string;
1217
+ /** Notes to apply to the asset */
1218
+ notes?: string;
1219
+ /** Tags to apply to the asset */
1220
+ tags?: string[];
1221
+ /**
1222
+ * An hash containing, for each locale of the project, the default metadata to
1223
+ * apply to the asset
1224
+ */
1225
+ default_field_metadata?: {
1226
+ [k: string]: {
1227
+ /** Alternate text for the asset */
1228
+ alt: string | null;
1229
+ /** Title for the asset */
1230
+ title: string | null;
1231
+ /** Object with arbitrary metadata */
1232
+ custom_data: {
1233
+ [k: string]: unknown;
1234
+ };
1235
+ /** Focal point (only for image assets) */
1236
+ focal_point?: {
1237
+ /** Horizontal position expressed as float between 0 and 1 */
1238
+ x: number;
1239
+ /** Vertical position expressed as float between 0 and 1 */
1240
+ y: number;
1241
+ } | null;
1242
+ };
1243
+ };
1244
+ };
1245
+
1246
+ /** Use these methods to confirm */
1247
+ export type RenderAssetSourceAdditionalMethods = {
1248
+ getSettings: () => Promise<RenderAssetSourceProperties>;
1249
+ /**
1250
+ * Function to be called when the user selects the asset: it will trigger the
1251
+ * creation of a new `Upload` that will be added in the Media Area.
1252
+ *
1253
+ * @example
1254
+ *
1255
+ * ```js
1256
+ * await ctx.select({
1257
+ * resource: {
1258
+ * url:
1259
+ * 'https://images.unsplash.com/photo-1416339306562-f3d12fefd36f',
1260
+ * filename: 'man-drinking-coffee.jpg',
1261
+ * },
1262
+ * copyright: 'Royalty free (Unsplash)',
1263
+ * author: 'Jeff Sheldon',
1264
+ * notes: 'A man drinking a coffee',
1265
+ * tags: ['man', 'coffee'],
1266
+ * });
1267
+ * ```
1268
+ */
1269
+ select: (newUpload: NewUpload) => void;
1270
+ };
1271
+
1272
+ export type RenderAssetSourceMethods = RenderMethods &
1273
+ IframeMethods &
1274
+ RenderAssetSourceAdditionalMethods;
1275
+
1276
+ export type RenderAssetSourcePropertiesAndMethods = RenderAssetSourceMethods &
1277
+ RenderAssetSourceProperties;
1278
+
1279
+ /** Information regarding the specific page that you need to render */
1280
+ export type RenderPageAdditionalProperties = {
1281
+ mode: 'renderPage';
1282
+ /** The ID of the page that needs to be rendered */
1283
+ pageId: string;
1284
+ };
1285
+
1286
+ export type RenderPageProperties = RenderProperties &
1287
+ RenderPageAdditionalProperties;
1288
+
1289
+ export type RenderPageAdditionalMethods = {
1290
+ getSettings: () => Promise<RenderPageProperties>;
1291
+ };
1292
+
1293
+ export type RenderPageMethods = RenderMethods & RenderPageAdditionalMethods;
1294
+
1295
+ export type RenderPagePropertiesAndMethods = RenderPageMethods &
1296
+ RenderPageProperties;
1297
+
1298
+ export type PendingField = {
1299
+ id?: string;
1300
+ type: 'field';
1301
+ attributes: {
1302
+ api_key: Field['attributes']['api_key'];
1303
+ appearance: Field['attributes']['appearance'];
1304
+ default_value: Field['attributes']['default_value'];
1305
+ field_type: Field['attributes']['field_type'];
1306
+ hint: Field['attributes']['hint'];
1307
+ label: Field['attributes']['label'];
1308
+ localized: Field['attributes']['localized'];
1309
+ validators: Field['attributes']['validators'];
1310
+ };
1311
+ };
1312
+
1313
+ /**
1314
+ * Information regarding the specific form that you need to render to let the
1315
+ * end-user edit the configuration object of a field extension
1316
+ */
1317
+ export type RenderManualFieldExtensionConfigScreenAdditionalProperties = {
1318
+ mode: 'renderManualFieldExtensionConfigScreen';
1319
+ /** The ID of the field extension for which we need to render the parameters form */
1320
+ fieldExtensionId: string;
1321
+ /**
1322
+ * The current value of the parameters (you can change the value with the
1323
+ * `setParameters` function)
1324
+ */
1325
+ parameters: Record<string, unknown>;
1326
+ /**
1327
+ * The current validation errors for the parameters (you can set them
1328
+ * implementing the `validateManualFieldExtensionParameters` function)
1329
+ */
1330
+ errors: Record<string, unknown>;
1331
+
1332
+ /** The field entity that is being edited in the form */
1333
+ pendingField: PendingField;
1334
+
1335
+ /** The model for the field being edited */
1336
+ itemType: ModelBlock;
1337
+ };
1338
+
1339
+ export type RenderManualFieldExtensionConfigScreenProperties = RenderProperties &
1340
+ RenderManualFieldExtensionConfigScreenAdditionalProperties;
1341
+
1342
+ /**
1343
+ * These methods can be used to update the configuration object of a specific
1344
+ * field extension
1345
+ */
1346
+ export type RenderManualFieldExtensionConfigScreenAdditionalMethods = {
1347
+ getSettings: () => Promise<RenderManualFieldExtensionConfigScreenProperties>;
1348
+ /**
1349
+ * Sets a new value for the parameters
1350
+ *
1351
+ * @example
1352
+ *
1353
+ * ```js
1354
+ * await ctx.setParameters({ color: '#ff0000' });
1355
+ * ```
1356
+ */
1357
+ setParameters: (params: Record<string, unknown>) => Promise<void>;
1358
+ };
1359
+
1360
+ export type RenderManualFieldExtensionConfigScreenMethods = RenderMethods &
1361
+ IframeMethods &
1362
+ RenderManualFieldExtensionConfigScreenAdditionalMethods;
1363
+
1364
+ export type RenderManualFieldExtensionConfigScreenPropertiesAndMethods = RenderManualFieldExtensionConfigScreenMethods &
1365
+ RenderManualFieldExtensionConfigScreenProperties;
1366
+
1367
+ export type RenderConfigScreenAdditionalProperties = {
1368
+ mode: 'renderConfigScreen';
1369
+ };
1370
+
1371
+ export type RenderConfigScreenProperties = RenderProperties &
1372
+ RenderConfigScreenAdditionalProperties;
1373
+
1374
+ /** These methods can be used to update the configuration object of your plugin */
1375
+ export type RenderConfigScreenAdditionalMethods = {
1376
+ getSettings: () => Promise<RenderConfigScreenProperties>;
1377
+ };
1378
+
1379
+ export type RenderConfigScreenMethods = RenderMethods &
1380
+ IframeMethods &
1381
+ RenderConfigScreenAdditionalMethods;
1382
+
1383
+ export type RenderConfigScreenPropertiesAndMethods = RenderConfigScreenMethods &
1384
+ RenderConfigScreenProperties;
1385
+
1386
+ export type OnBootAdditionalProperties = {
1387
+ mode: 'onBoot';
1388
+ };
1389
+
1390
+ export type OnBootProperties = RenderProperties & OnBootAdditionalProperties;
1391
+
1392
+ export type OnBootAdditionalMethods = {
1393
+ getSettings: () => Promise<OnBootProperties>;
1394
+ };
1395
+
1396
+ export type OnBootMethods = RenderMethods & OnBootAdditionalMethods;
1397
+
1398
+ export type OnBootPropertiesAndMethods = OnBootMethods & OnBootProperties;