datocms-plugin-sdk 0.3.1 → 0.3.2

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # `datocms-plugin-sdk`
2
2
 
3
- A set of Typescript types and helpers to work with DatoCMS Structured Text fields.
3
+ Typescript SDK to build DatoCMS plugins. You can read all about the SDK in [our documentation](https://www.datocms.com/docs/plugin-sdk).
4
4
 
5
5
  ## Installation
6
6
 
@@ -442,8 +442,9 @@ export declare type UpdateParametersMethods = {
442
442
  * the operation.
443
443
  *
444
444
  * @example
445
- * const fieldId = 234;
446
- * ctx.updateFieldAppearance(234, [
445
+ * const fieldId = prompt('Please insert a field ID:');
446
+ *
447
+ * ctx.updateFieldAppearance(fieldId, [
447
448
  * {
448
449
  * operation: 'updateEditor',
449
450
  * newFieldExtensionParameters: { foo: 'bar' },
@@ -467,8 +468,11 @@ export declare type LoadDataMethods = {
467
468
  * returned and will also be available in the the `fields` property.
468
469
  *
469
470
  * @example
470
- * const fields = await sdk.loadItemTypeFields('810907');
471
- * sdk.notice(
471
+ * const fieldId = prompt('Please insert a field ID:');
472
+ *
473
+ * const fields = await ctx.loadItemTypeFields(fieldId);
474
+ *
475
+ * ctx.notice(
472
476
  * `Success! ${fields
473
477
  * .map((field) => field.attributes.api_key)
474
478
  * .join(', ')}`,
@@ -480,8 +484,9 @@ export declare type LoadDataMethods = {
480
484
  * one of its manual field extensions.
481
485
  *
482
486
  * @example
483
- * const fields = await sdk.loadFieldsUsingPlugin();
484
- * sdk.notice(
487
+ * const fields = await ctx.loadFieldsUsingPlugin();
488
+ *
489
+ * ctx.notice(
485
490
  * `Success! ${fields
486
491
  * .map((field) => field.attributes.api_key)
487
492
  * .join(', ')}`,
@@ -493,8 +498,9 @@ export declare type LoadDataMethods = {
493
498
  * in the the `users` property.
494
499
  *
495
500
  * @example
496
- * const users = await sdk.loadUsers();
497
- * sdk.notice(`Success! ${users.map((user) => i.id).join(', ')}`);
501
+ * const users = await ctx.loadUsers();
502
+ *
503
+ * ctx.notice(`Success! ${users.map((user) => i.id).join(', ')}`);
498
504
  */
499
505
  loadUsers: () => Promise<User[]>;
500
506
  /**
@@ -502,8 +508,9 @@ export declare type LoadDataMethods = {
502
508
  * the the `ssoUsers` property.
503
509
  *
504
510
  * @example
505
- * const users = await sdk.loadSsoUsers();
506
- * sdk.notice(`Success! ${users.map((user) => i.id).join(', ')}`);
511
+ * const users = await ctx.loadSsoUsers();
512
+ *
513
+ * ctx.notice(`Success! ${users.map((user) => i.id).join(', ')}`);
507
514
  */
508
515
  loadSsoUsers: () => Promise<SsoUser[]>;
509
516
  };
@@ -515,11 +522,14 @@ export declare type ItemDialogMethods = {
515
522
  * without creating anything.
516
523
  *
517
524
  * @example
518
- * const item = await sdk.createNewItem('810907');
525
+ * const itemTypeId = prompt('Please insert a model ID:');
526
+ *
527
+ * const item = await ctx.createNewItem(itemTypeId);
528
+ *
519
529
  * if (item) {
520
- * sdk.notice(`Success! ${item.id}`);
530
+ * ctx.notice(`Success! ${item.id}`);
521
531
  * } else {
522
- * sdk.alert('Closed!');
532
+ * ctx.alert('Closed!');
523
533
  * }
524
534
  */
525
535
  createNewItem: (itemTypeId: string) => Promise<Item | null>;
@@ -530,7 +540,10 @@ export declare type ItemDialogMethods = {
530
540
  * choosing any record.
531
541
  *
532
542
  * @example
533
- * const items = await ctx.selectItem('810907', { multiple: true });
543
+ * const itemTypeId = prompt('Please insert a model ID:');
544
+ *
545
+ * const items = await ctx.selectItem(itemTypeId, { multiple: true });
546
+ *
534
547
  * if (items) {
535
548
  * ctx.notice(`Success! ${items.map((i) => i.id).join(', ')}`);
536
549
  * } else {
@@ -551,12 +564,14 @@ export declare type ItemDialogMethods = {
551
564
  * without persisting any change.
552
565
  *
553
566
  * @example
554
- * const item = await sdk.editItem('50479504');
567
+ * const itemId = prompt('Please insert a record ID:');
568
+ *
569
+ * const item = await ctx.editItem(itemId);
555
570
  *
556
571
  * if (item) {
557
- * sdk.notice(`Success! ${item.id}`);
572
+ * ctx.notice(`Success! ${item.id}`);
558
573
  * } else {
559
- * sdk.alert('Closed!');
574
+ * ctx.alert('Closed!');
560
575
  * }
561
576
  */
562
577
  editItem: (itemId: string) => Promise<Item | null>;
@@ -567,25 +582,35 @@ export declare type ToastMethods = {
567
582
  * Triggers an "error" toast displaying the selected message
568
583
  *
569
584
  * @example
570
- * sdk.alert('Alert!');
585
+ * const message = prompt(
586
+ * 'Please insert a message:',
587
+ * 'This is an alert message!',
588
+ * );
589
+ *
590
+ * ctx.alert(message);
571
591
  */
572
592
  alert: (message: string) => void;
573
593
  /**
574
594
  * Triggers a "success" toast displaying the selected message
575
595
  *
576
596
  * @example
577
- * sdk.notice('Notice!');
597
+ * const message = prompt(
598
+ * 'Please insert a message:',
599
+ * 'This is a notice message!',
600
+ * );
601
+ *
602
+ * ctx.notice(message);
578
603
  */
579
604
  notice: (message: string) => void;
580
605
  /**
581
606
  * Triggers a custom toast displaying the selected message (and optionally a CTA)
582
607
  *
583
608
  * @example
584
- * const result = await sdk.customToast({
609
+ * const result = await ctx.customToast({
585
610
  * type: 'warning',
586
611
  * message: 'Just a sample warning notification!',
587
612
  * dismissOnPageChange: true,
588
- * dismissAfterTimeout: 22000,
613
+ * dismissAfterTimeout: 5000,
589
614
  * cta: {
590
615
  * label: 'Execute call-to-action',
591
616
  * value: 'cta',
@@ -593,7 +618,7 @@ export declare type ToastMethods = {
593
618
  * });
594
619
  *
595
620
  * if (result === 'cta') {
596
- * sdk.notice(`Clicked CTA!`);
621
+ * ctx.notice(`Clicked CTA!`);
597
622
  * }
598
623
  */
599
624
  customToast: <CtaValue = unknown>(toast: Toast<CtaValue>) => Promise<CtaValue | null>;
@@ -609,12 +634,12 @@ export declare type UploadDialogMethods = {
609
634
  * user closes the dialog without selecting any upload.
610
635
  *
611
636
  * @example
612
- * const item = await sdk.selectUpload({ multiple: false });
637
+ * const item = await ctx.selectUpload({ multiple: false });
613
638
  *
614
639
  * if (item) {
615
- * sdk.notice(`Success! ${item.id}`);
640
+ * ctx.notice(`Success! ${item.id}`);
616
641
  * } else {
617
- * sdk.alert('Closed!');
642
+ * ctx.alert('Closed!');
618
643
  * }
619
644
  */
620
645
  selectUpload: {
@@ -634,12 +659,14 @@ export declare type UploadDialogMethods = {
634
659
  * the user deletes the asset
635
660
  *
636
661
  * @example
637
- * const item = await sdk.editUpload('21717537');
662
+ * const uploadId = prompt('Please insert an asset ID:');
663
+ *
664
+ * const item = await ctx.editUpload(uploadId);
638
665
  *
639
666
  * if (item) {
640
- * sdk.notice(`Success! ${item.id}`);
667
+ * ctx.notice(`Success! ${item.id}`);
641
668
  * } else {
642
- * sdk.alert('Closed!');
669
+ * ctx.alert('Closed!');
643
670
  * }
644
671
  */
645
672
  editUpload: (uploadId: string) => Promise<(Upload & {
@@ -651,8 +678,10 @@ export declare type UploadDialogMethods = {
651
678
  * the dialog without persisting any change.
652
679
  *
653
680
  * @example
654
- * const result = await sdk.editUploadMetadata({
655
- * upload_id: '21717537',
681
+ * const uploadId = prompt('Please insert an asset ID:');
682
+ *
683
+ * const result = await ctx.editUploadMetadata({
684
+ * upload_id: uploadId,
656
685
  * alt: null,
657
686
  * title: null,
658
687
  * custom_data: {},
@@ -660,9 +689,9 @@ export declare type UploadDialogMethods = {
660
689
  * });
661
690
  *
662
691
  * if (result) {
663
- * sdk.notice(`Success! ${JSON.stringify(result)}`);
692
+ * ctx.notice(`Success! ${JSON.stringify(result)}`);
664
693
  * } else {
665
- * sdk.alert('Closed!');
694
+ * ctx.alert('Closed!');
666
695
  * }
667
696
  */
668
697
  editUploadMetadata: (
@@ -678,16 +707,17 @@ export declare type CustomDialogMethods = {
678
707
  * returns calling the `resolve()` function
679
708
  *
680
709
  * @example
681
- * const result = await sdk.openModal({
710
+ * const result = await ctx.openModal({
682
711
  * id: 'regular',
683
712
  * title: 'Custom title!',
684
713
  * width: 'l',
685
714
  * parameters: { foo: 'bar' },
686
715
  * });
716
+ *
687
717
  * if (result) {
688
- * sdk.notice(`Success! ${JSON.stringify(result)}`);
718
+ * ctx.notice(`Success! ${JSON.stringify(result)}`);
689
719
  * } else {
690
- * sdk.alert('Closed!');
720
+ * ctx.alert('Closed!');
691
721
  * }
692
722
  */
693
723
  openModal: (modal: Modal) => Promise<unknown>;
@@ -696,7 +726,7 @@ export declare type CustomDialogMethods = {
696
726
  * the value of the choice made by the user
697
727
  *
698
728
  * @example
699
- * const result = await sdk.openConfirm({
729
+ * const result = await ctx.openConfirm({
700
730
  * title: 'Custom title',
701
731
  * content:
702
732
  * 'Lorem Ipsum is simply dummy text of the printing and typesetting industry',
@@ -717,10 +747,11 @@ export declare type CustomDialogMethods = {
717
747
  * value: false,
718
748
  * },
719
749
  * });
750
+ *
720
751
  * if (result) {
721
- * sdk.notice(`Success! ${result}`);
752
+ * ctx.notice(`Success! ${result}`);
722
753
  * } else {
723
- * sdk.alert('Cancelled!');
754
+ * ctx.alert('Cancelled!');
724
755
  * }
725
756
  */
726
757
  openConfirm: (options: ConfirmOptions) => Promise<unknown>;
@@ -731,7 +762,7 @@ export declare type NavigateMethods = {
731
762
  * Moves the user to another URL internal to the backend
732
763
  *
733
764
  * @example
734
- * sdk.navigateTo('/');
765
+ * ctx.navigateTo('/');
735
766
  */
736
767
  navigateTo: (path: string) => void;
737
768
  };
@@ -771,14 +802,23 @@ export declare type ItemFormAdditionalMethods = {
771
802
  * Hides/shows a specific field in the form
772
803
  *
773
804
  * @example
774
- * sdk.toggleField(sdk.fieldPath, true);
805
+ * const fieldPath = prompt(
806
+ * 'Please insert the path of a field in the form',
807
+ * ctx.fieldPath,
808
+ * );
809
+ *
810
+ * ctx.toggleField(fieldPath, true);
775
811
  */
776
812
  toggleField: (path: string, show: boolean) => void;
777
813
  /**
778
814
  * Disables/re-enables a specific field in the form
779
815
  *
780
816
  * @example
781
- * sdk.disableField(sdk.fieldPath, true);
817
+ * const fieldPath = prompt(
818
+ * 'Please insert the path of a field in the form',
819
+ * ctx.fieldPath,
820
+ * );
821
+ * ctx.disableField(fieldPath, true);
782
822
  */
783
823
  disableField: (path: string, disable: boolean) => void;
784
824
  /**
@@ -786,21 +826,29 @@ export declare type ItemFormAdditionalMethods = {
786
826
  * localized it will switch language tab and then navigate to the chosen field.
787
827
  *
788
828
  * @example
789
- * sdk.scrollToField(sdk.fieldPath);
829
+ * const fieldPath = prompt(
830
+ * 'Please insert the path of a field in the form',
831
+ * ctx.fieldPath,
832
+ * );
833
+ * ctx.scrollToField(fieldPath);
790
834
  */
791
835
  scrollToField: (path: string, locale?: string) => void;
792
836
  /**
793
837
  * Changes a specific path of the `formValues` object
794
838
  *
795
839
  * @example
796
- * sdk.setFieldValue(sdk.fieldPath, 'new value');
840
+ * const fieldPath = prompt(
841
+ * 'Please insert the path of a field in the form',
842
+ * ctx.fieldPath,
843
+ * );
844
+ * ctx.setFieldValue(fieldPath, 'new value');
797
845
  */
798
846
  setFieldValue: (path: string, value: unknown) => void;
799
847
  /**
800
848
  * Triggers a submit form for current record
801
849
  *
802
850
  * @example
803
- * await sdk.saveCurrentItem();
851
+ * await ctx.saveCurrentItem();
804
852
  */
805
853
  saveCurrentItem: () => Promise<void>;
806
854
  };
@@ -867,6 +915,14 @@ export declare type RenderModalAdditionalMethods = {
867
915
  /**
868
916
  * A function to be called by the plugin to close the modal. The `openModal`
869
917
  * call will be resolved with the passed return value
918
+ *
919
+ * @example
920
+ * const returnValue = prompt(
921
+ * 'Please specify the value to return to the caller:',
922
+ * 'success',
923
+ * );
924
+ *
925
+ * ctx.resolve(returnValue);
870
926
  */
871
927
  resolve: (returnValue: unknown) => void;
872
928
  };
@@ -442,8 +442,9 @@ export declare type UpdateParametersMethods = {
442
442
  * the operation.
443
443
  *
444
444
  * @example
445
- * const fieldId = 234;
446
- * ctx.updateFieldAppearance(234, [
445
+ * const fieldId = prompt('Please insert a field ID:');
446
+ *
447
+ * ctx.updateFieldAppearance(fieldId, [
447
448
  * {
448
449
  * operation: 'updateEditor',
449
450
  * newFieldExtensionParameters: { foo: 'bar' },
@@ -467,8 +468,11 @@ export declare type LoadDataMethods = {
467
468
  * returned and will also be available in the the `fields` property.
468
469
  *
469
470
  * @example
470
- * const fields = await sdk.loadItemTypeFields('810907');
471
- * sdk.notice(
471
+ * const fieldId = prompt('Please insert a field ID:');
472
+ *
473
+ * const fields = await ctx.loadItemTypeFields(fieldId);
474
+ *
475
+ * ctx.notice(
472
476
  * `Success! ${fields
473
477
  * .map((field) => field.attributes.api_key)
474
478
  * .join(', ')}`,
@@ -480,8 +484,9 @@ export declare type LoadDataMethods = {
480
484
  * one of its manual field extensions.
481
485
  *
482
486
  * @example
483
- * const fields = await sdk.loadFieldsUsingPlugin();
484
- * sdk.notice(
487
+ * const fields = await ctx.loadFieldsUsingPlugin();
488
+ *
489
+ * ctx.notice(
485
490
  * `Success! ${fields
486
491
  * .map((field) => field.attributes.api_key)
487
492
  * .join(', ')}`,
@@ -493,8 +498,9 @@ export declare type LoadDataMethods = {
493
498
  * in the the `users` property.
494
499
  *
495
500
  * @example
496
- * const users = await sdk.loadUsers();
497
- * sdk.notice(`Success! ${users.map((user) => i.id).join(', ')}`);
501
+ * const users = await ctx.loadUsers();
502
+ *
503
+ * ctx.notice(`Success! ${users.map((user) => i.id).join(', ')}`);
498
504
  */
499
505
  loadUsers: () => Promise<User[]>;
500
506
  /**
@@ -502,8 +508,9 @@ export declare type LoadDataMethods = {
502
508
  * the the `ssoUsers` property.
503
509
  *
504
510
  * @example
505
- * const users = await sdk.loadSsoUsers();
506
- * sdk.notice(`Success! ${users.map((user) => i.id).join(', ')}`);
511
+ * const users = await ctx.loadSsoUsers();
512
+ *
513
+ * ctx.notice(`Success! ${users.map((user) => i.id).join(', ')}`);
507
514
  */
508
515
  loadSsoUsers: () => Promise<SsoUser[]>;
509
516
  };
@@ -515,11 +522,14 @@ export declare type ItemDialogMethods = {
515
522
  * without creating anything.
516
523
  *
517
524
  * @example
518
- * const item = await sdk.createNewItem('810907');
525
+ * const itemTypeId = prompt('Please insert a model ID:');
526
+ *
527
+ * const item = await ctx.createNewItem(itemTypeId);
528
+ *
519
529
  * if (item) {
520
- * sdk.notice(`Success! ${item.id}`);
530
+ * ctx.notice(`Success! ${item.id}`);
521
531
  * } else {
522
- * sdk.alert('Closed!');
532
+ * ctx.alert('Closed!');
523
533
  * }
524
534
  */
525
535
  createNewItem: (itemTypeId: string) => Promise<Item | null>;
@@ -530,7 +540,10 @@ export declare type ItemDialogMethods = {
530
540
  * choosing any record.
531
541
  *
532
542
  * @example
533
- * const items = await ctx.selectItem('810907', { multiple: true });
543
+ * const itemTypeId = prompt('Please insert a model ID:');
544
+ *
545
+ * const items = await ctx.selectItem(itemTypeId, { multiple: true });
546
+ *
534
547
  * if (items) {
535
548
  * ctx.notice(`Success! ${items.map((i) => i.id).join(', ')}`);
536
549
  * } else {
@@ -551,12 +564,14 @@ export declare type ItemDialogMethods = {
551
564
  * without persisting any change.
552
565
  *
553
566
  * @example
554
- * const item = await sdk.editItem('50479504');
567
+ * const itemId = prompt('Please insert a record ID:');
568
+ *
569
+ * const item = await ctx.editItem(itemId);
555
570
  *
556
571
  * if (item) {
557
- * sdk.notice(`Success! ${item.id}`);
572
+ * ctx.notice(`Success! ${item.id}`);
558
573
  * } else {
559
- * sdk.alert('Closed!');
574
+ * ctx.alert('Closed!');
560
575
  * }
561
576
  */
562
577
  editItem: (itemId: string) => Promise<Item | null>;
@@ -567,25 +582,35 @@ export declare type ToastMethods = {
567
582
  * Triggers an "error" toast displaying the selected message
568
583
  *
569
584
  * @example
570
- * sdk.alert('Alert!');
585
+ * const message = prompt(
586
+ * 'Please insert a message:',
587
+ * 'This is an alert message!',
588
+ * );
589
+ *
590
+ * ctx.alert(message);
571
591
  */
572
592
  alert: (message: string) => void;
573
593
  /**
574
594
  * Triggers a "success" toast displaying the selected message
575
595
  *
576
596
  * @example
577
- * sdk.notice('Notice!');
597
+ * const message = prompt(
598
+ * 'Please insert a message:',
599
+ * 'This is a notice message!',
600
+ * );
601
+ *
602
+ * ctx.notice(message);
578
603
  */
579
604
  notice: (message: string) => void;
580
605
  /**
581
606
  * Triggers a custom toast displaying the selected message (and optionally a CTA)
582
607
  *
583
608
  * @example
584
- * const result = await sdk.customToast({
609
+ * const result = await ctx.customToast({
585
610
  * type: 'warning',
586
611
  * message: 'Just a sample warning notification!',
587
612
  * dismissOnPageChange: true,
588
- * dismissAfterTimeout: 22000,
613
+ * dismissAfterTimeout: 5000,
589
614
  * cta: {
590
615
  * label: 'Execute call-to-action',
591
616
  * value: 'cta',
@@ -593,7 +618,7 @@ export declare type ToastMethods = {
593
618
  * });
594
619
  *
595
620
  * if (result === 'cta') {
596
- * sdk.notice(`Clicked CTA!`);
621
+ * ctx.notice(`Clicked CTA!`);
597
622
  * }
598
623
  */
599
624
  customToast: <CtaValue = unknown>(toast: Toast<CtaValue>) => Promise<CtaValue | null>;
@@ -609,12 +634,12 @@ export declare type UploadDialogMethods = {
609
634
  * user closes the dialog without selecting any upload.
610
635
  *
611
636
  * @example
612
- * const item = await sdk.selectUpload({ multiple: false });
637
+ * const item = await ctx.selectUpload({ multiple: false });
613
638
  *
614
639
  * if (item) {
615
- * sdk.notice(`Success! ${item.id}`);
640
+ * ctx.notice(`Success! ${item.id}`);
616
641
  * } else {
617
- * sdk.alert('Closed!');
642
+ * ctx.alert('Closed!');
618
643
  * }
619
644
  */
620
645
  selectUpload: {
@@ -634,12 +659,14 @@ export declare type UploadDialogMethods = {
634
659
  * the user deletes the asset
635
660
  *
636
661
  * @example
637
- * const item = await sdk.editUpload('21717537');
662
+ * const uploadId = prompt('Please insert an asset ID:');
663
+ *
664
+ * const item = await ctx.editUpload(uploadId);
638
665
  *
639
666
  * if (item) {
640
- * sdk.notice(`Success! ${item.id}`);
667
+ * ctx.notice(`Success! ${item.id}`);
641
668
  * } else {
642
- * sdk.alert('Closed!');
669
+ * ctx.alert('Closed!');
643
670
  * }
644
671
  */
645
672
  editUpload: (uploadId: string) => Promise<(Upload & {
@@ -651,8 +678,10 @@ export declare type UploadDialogMethods = {
651
678
  * the dialog without persisting any change.
652
679
  *
653
680
  * @example
654
- * const result = await sdk.editUploadMetadata({
655
- * upload_id: '21717537',
681
+ * const uploadId = prompt('Please insert an asset ID:');
682
+ *
683
+ * const result = await ctx.editUploadMetadata({
684
+ * upload_id: uploadId,
656
685
  * alt: null,
657
686
  * title: null,
658
687
  * custom_data: {},
@@ -660,9 +689,9 @@ export declare type UploadDialogMethods = {
660
689
  * });
661
690
  *
662
691
  * if (result) {
663
- * sdk.notice(`Success! ${JSON.stringify(result)}`);
692
+ * ctx.notice(`Success! ${JSON.stringify(result)}`);
664
693
  * } else {
665
- * sdk.alert('Closed!');
694
+ * ctx.alert('Closed!');
666
695
  * }
667
696
  */
668
697
  editUploadMetadata: (
@@ -678,16 +707,17 @@ export declare type CustomDialogMethods = {
678
707
  * returns calling the `resolve()` function
679
708
  *
680
709
  * @example
681
- * const result = await sdk.openModal({
710
+ * const result = await ctx.openModal({
682
711
  * id: 'regular',
683
712
  * title: 'Custom title!',
684
713
  * width: 'l',
685
714
  * parameters: { foo: 'bar' },
686
715
  * });
716
+ *
687
717
  * if (result) {
688
- * sdk.notice(`Success! ${JSON.stringify(result)}`);
718
+ * ctx.notice(`Success! ${JSON.stringify(result)}`);
689
719
  * } else {
690
- * sdk.alert('Closed!');
720
+ * ctx.alert('Closed!');
691
721
  * }
692
722
  */
693
723
  openModal: (modal: Modal) => Promise<unknown>;
@@ -696,7 +726,7 @@ export declare type CustomDialogMethods = {
696
726
  * the value of the choice made by the user
697
727
  *
698
728
  * @example
699
- * const result = await sdk.openConfirm({
729
+ * const result = await ctx.openConfirm({
700
730
  * title: 'Custom title',
701
731
  * content:
702
732
  * 'Lorem Ipsum is simply dummy text of the printing and typesetting industry',
@@ -717,10 +747,11 @@ export declare type CustomDialogMethods = {
717
747
  * value: false,
718
748
  * },
719
749
  * });
750
+ *
720
751
  * if (result) {
721
- * sdk.notice(`Success! ${result}`);
752
+ * ctx.notice(`Success! ${result}`);
722
753
  * } else {
723
- * sdk.alert('Cancelled!');
754
+ * ctx.alert('Cancelled!');
724
755
  * }
725
756
  */
726
757
  openConfirm: (options: ConfirmOptions) => Promise<unknown>;
@@ -731,7 +762,7 @@ export declare type NavigateMethods = {
731
762
  * Moves the user to another URL internal to the backend
732
763
  *
733
764
  * @example
734
- * sdk.navigateTo('/');
765
+ * ctx.navigateTo('/');
735
766
  */
736
767
  navigateTo: (path: string) => void;
737
768
  };
@@ -771,14 +802,23 @@ export declare type ItemFormAdditionalMethods = {
771
802
  * Hides/shows a specific field in the form
772
803
  *
773
804
  * @example
774
- * sdk.toggleField(sdk.fieldPath, true);
805
+ * const fieldPath = prompt(
806
+ * 'Please insert the path of a field in the form',
807
+ * ctx.fieldPath,
808
+ * );
809
+ *
810
+ * ctx.toggleField(fieldPath, true);
775
811
  */
776
812
  toggleField: (path: string, show: boolean) => void;
777
813
  /**
778
814
  * Disables/re-enables a specific field in the form
779
815
  *
780
816
  * @example
781
- * sdk.disableField(sdk.fieldPath, true);
817
+ * const fieldPath = prompt(
818
+ * 'Please insert the path of a field in the form',
819
+ * ctx.fieldPath,
820
+ * );
821
+ * ctx.disableField(fieldPath, true);
782
822
  */
783
823
  disableField: (path: string, disable: boolean) => void;
784
824
  /**
@@ -786,21 +826,29 @@ export declare type ItemFormAdditionalMethods = {
786
826
  * localized it will switch language tab and then navigate to the chosen field.
787
827
  *
788
828
  * @example
789
- * sdk.scrollToField(sdk.fieldPath);
829
+ * const fieldPath = prompt(
830
+ * 'Please insert the path of a field in the form',
831
+ * ctx.fieldPath,
832
+ * );
833
+ * ctx.scrollToField(fieldPath);
790
834
  */
791
835
  scrollToField: (path: string, locale?: string) => void;
792
836
  /**
793
837
  * Changes a specific path of the `formValues` object
794
838
  *
795
839
  * @example
796
- * sdk.setFieldValue(sdk.fieldPath, 'new value');
840
+ * const fieldPath = prompt(
841
+ * 'Please insert the path of a field in the form',
842
+ * ctx.fieldPath,
843
+ * );
844
+ * ctx.setFieldValue(fieldPath, 'new value');
797
845
  */
798
846
  setFieldValue: (path: string, value: unknown) => void;
799
847
  /**
800
848
  * Triggers a submit form for current record
801
849
  *
802
850
  * @example
803
- * await sdk.saveCurrentItem();
851
+ * await ctx.saveCurrentItem();
804
852
  */
805
853
  saveCurrentItem: () => Promise<void>;
806
854
  };
@@ -867,6 +915,14 @@ export declare type RenderModalAdditionalMethods = {
867
915
  /**
868
916
  * A function to be called by the plugin to close the modal. The `openModal`
869
917
  * call will be resolved with the passed return value
918
+ *
919
+ * @example
920
+ * const returnValue = prompt(
921
+ * 'Please specify the value to return to the caller:',
922
+ * 'success',
923
+ * );
924
+ *
925
+ * ctx.resolve(returnValue);
870
926
  */
871
927
  resolve: (returnValue: unknown) => void;
872
928
  };