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 +1 -1
- package/dist/esm/types.d.ts +100 -44
- package/dist/types/types.d.ts +100 -44
- package/package.json +2 -2
- package/types.json +169 -163
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# `datocms-plugin-sdk`
|
|
2
2
|
|
|
3
|
-
|
|
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
|
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -442,8 +442,9 @@ export declare type UpdateParametersMethods = {
|
|
|
442
442
|
* the operation.
|
|
443
443
|
*
|
|
444
444
|
* @example
|
|
445
|
-
* const fieldId =
|
|
446
|
-
*
|
|
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
|
|
471
|
-
*
|
|
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
|
|
484
|
-
*
|
|
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
|
|
497
|
-
*
|
|
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
|
|
506
|
-
*
|
|
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
|
|
525
|
+
* const itemTypeId = prompt('Please insert a model ID:');
|
|
526
|
+
*
|
|
527
|
+
* const item = await ctx.createNewItem(itemTypeId);
|
|
528
|
+
*
|
|
519
529
|
* if (item) {
|
|
520
|
-
*
|
|
530
|
+
* ctx.notice(`Success! ${item.id}`);
|
|
521
531
|
* } else {
|
|
522
|
-
*
|
|
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
|
|
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
|
|
567
|
+
* const itemId = prompt('Please insert a record ID:');
|
|
568
|
+
*
|
|
569
|
+
* const item = await ctx.editItem(itemId);
|
|
555
570
|
*
|
|
556
571
|
* if (item) {
|
|
557
|
-
*
|
|
572
|
+
* ctx.notice(`Success! ${item.id}`);
|
|
558
573
|
* } else {
|
|
559
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
|
609
|
+
* const result = await ctx.customToast({
|
|
585
610
|
* type: 'warning',
|
|
586
611
|
* message: 'Just a sample warning notification!',
|
|
587
612
|
* dismissOnPageChange: true,
|
|
588
|
-
* dismissAfterTimeout:
|
|
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
|
-
*
|
|
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
|
|
637
|
+
* const item = await ctx.selectUpload({ multiple: false });
|
|
613
638
|
*
|
|
614
639
|
* if (item) {
|
|
615
|
-
*
|
|
640
|
+
* ctx.notice(`Success! ${item.id}`);
|
|
616
641
|
* } else {
|
|
617
|
-
*
|
|
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
|
|
662
|
+
* const uploadId = prompt('Please insert an asset ID:');
|
|
663
|
+
*
|
|
664
|
+
* const item = await ctx.editUpload(uploadId);
|
|
638
665
|
*
|
|
639
666
|
* if (item) {
|
|
640
|
-
*
|
|
667
|
+
* ctx.notice(`Success! ${item.id}`);
|
|
641
668
|
* } else {
|
|
642
|
-
*
|
|
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
|
|
655
|
-
*
|
|
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
|
-
*
|
|
692
|
+
* ctx.notice(`Success! ${JSON.stringify(result)}`);
|
|
664
693
|
* } else {
|
|
665
|
-
*
|
|
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
|
|
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
|
-
*
|
|
718
|
+
* ctx.notice(`Success! ${JSON.stringify(result)}`);
|
|
689
719
|
* } else {
|
|
690
|
-
*
|
|
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
|
|
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
|
-
*
|
|
752
|
+
* ctx.notice(`Success! ${result}`);
|
|
722
753
|
* } else {
|
|
723
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
|
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
|
};
|
package/dist/types/types.d.ts
CHANGED
|
@@ -442,8 +442,9 @@ export declare type UpdateParametersMethods = {
|
|
|
442
442
|
* the operation.
|
|
443
443
|
*
|
|
444
444
|
* @example
|
|
445
|
-
* const fieldId =
|
|
446
|
-
*
|
|
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
|
|
471
|
-
*
|
|
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
|
|
484
|
-
*
|
|
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
|
|
497
|
-
*
|
|
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
|
|
506
|
-
*
|
|
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
|
|
525
|
+
* const itemTypeId = prompt('Please insert a model ID:');
|
|
526
|
+
*
|
|
527
|
+
* const item = await ctx.createNewItem(itemTypeId);
|
|
528
|
+
*
|
|
519
529
|
* if (item) {
|
|
520
|
-
*
|
|
530
|
+
* ctx.notice(`Success! ${item.id}`);
|
|
521
531
|
* } else {
|
|
522
|
-
*
|
|
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
|
|
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
|
|
567
|
+
* const itemId = prompt('Please insert a record ID:');
|
|
568
|
+
*
|
|
569
|
+
* const item = await ctx.editItem(itemId);
|
|
555
570
|
*
|
|
556
571
|
* if (item) {
|
|
557
|
-
*
|
|
572
|
+
* ctx.notice(`Success! ${item.id}`);
|
|
558
573
|
* } else {
|
|
559
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
|
609
|
+
* const result = await ctx.customToast({
|
|
585
610
|
* type: 'warning',
|
|
586
611
|
* message: 'Just a sample warning notification!',
|
|
587
612
|
* dismissOnPageChange: true,
|
|
588
|
-
* dismissAfterTimeout:
|
|
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
|
-
*
|
|
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
|
|
637
|
+
* const item = await ctx.selectUpload({ multiple: false });
|
|
613
638
|
*
|
|
614
639
|
* if (item) {
|
|
615
|
-
*
|
|
640
|
+
* ctx.notice(`Success! ${item.id}`);
|
|
616
641
|
* } else {
|
|
617
|
-
*
|
|
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
|
|
662
|
+
* const uploadId = prompt('Please insert an asset ID:');
|
|
663
|
+
*
|
|
664
|
+
* const item = await ctx.editUpload(uploadId);
|
|
638
665
|
*
|
|
639
666
|
* if (item) {
|
|
640
|
-
*
|
|
667
|
+
* ctx.notice(`Success! ${item.id}`);
|
|
641
668
|
* } else {
|
|
642
|
-
*
|
|
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
|
|
655
|
-
*
|
|
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
|
-
*
|
|
692
|
+
* ctx.notice(`Success! ${JSON.stringify(result)}`);
|
|
664
693
|
* } else {
|
|
665
|
-
*
|
|
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
|
|
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
|
-
*
|
|
718
|
+
* ctx.notice(`Success! ${JSON.stringify(result)}`);
|
|
689
719
|
* } else {
|
|
690
|
-
*
|
|
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
|
|
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
|
-
*
|
|
752
|
+
* ctx.notice(`Success! ${result}`);
|
|
722
753
|
* } else {
|
|
723
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
|
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
|
};
|