datocms-plugin-sdk 2.0.4 → 2.0.6

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.
Files changed (140) hide show
  1. package/dist/cjs/guardUtils.js +33 -0
  2. package/dist/cjs/guardUtils.js.map +1 -0
  3. package/dist/cjs/hooks/assetSources.js +24 -0
  4. package/dist/cjs/hooks/assetSources.js.map +1 -1
  5. package/dist/cjs/hooks/buildItemPresentationInfo.js +12 -0
  6. package/dist/cjs/hooks/buildItemPresentationInfo.js.map +1 -1
  7. package/dist/cjs/hooks/contentAreaSidebarItems.js +16 -0
  8. package/dist/cjs/hooks/contentAreaSidebarItems.js.map +1 -1
  9. package/dist/cjs/hooks/customBlockStylesForStructuredTextField.js +13 -0
  10. package/dist/cjs/hooks/customBlockStylesForStructuredTextField.js.map +1 -1
  11. package/dist/cjs/hooks/customMarksForStructuredTextField.js +17 -0
  12. package/dist/cjs/hooks/customMarksForStructuredTextField.js.map +1 -1
  13. package/dist/cjs/hooks/initialLocationQueryForItemSelector.js +11 -0
  14. package/dist/cjs/hooks/initialLocationQueryForItemSelector.js.map +1 -1
  15. package/dist/cjs/hooks/itemCollectionOutlets.js +12 -0
  16. package/dist/cjs/hooks/itemCollectionOutlets.js.map +1 -1
  17. package/dist/cjs/hooks/itemFormOutlets.js +12 -0
  18. package/dist/cjs/hooks/itemFormOutlets.js.map +1 -1
  19. package/dist/cjs/hooks/itemFormSidebarPanels.js +16 -0
  20. package/dist/cjs/hooks/itemFormSidebarPanels.js.map +1 -1
  21. package/dist/cjs/hooks/itemFormSidebars.js +14 -0
  22. package/dist/cjs/hooks/itemFormSidebars.js.map +1 -1
  23. package/dist/cjs/hooks/mainNavigationTabs.js +16 -0
  24. package/dist/cjs/hooks/mainNavigationTabs.js.map +1 -1
  25. package/dist/cjs/hooks/manualFieldExtensions.js +24 -0
  26. package/dist/cjs/hooks/manualFieldExtensions.js.map +1 -1
  27. package/dist/cjs/hooks/overrideFieldExtensions.js +35 -0
  28. package/dist/cjs/hooks/overrideFieldExtensions.js.map +1 -1
  29. package/dist/cjs/hooks/uploadSidebarPanels.js +16 -0
  30. package/dist/cjs/hooks/uploadSidebarPanels.js.map +1 -1
  31. package/dist/cjs/hooks/uploadSidebars.js +14 -0
  32. package/dist/cjs/hooks/uploadSidebars.js.map +1 -1
  33. package/dist/cjs/hooks/validateManualFieldExtensionParameters.js +5 -0
  34. package/dist/cjs/hooks/validateManualFieldExtensionParameters.js.map +1 -1
  35. package/dist/cjs/icon.js +9 -0
  36. package/dist/cjs/icon.js.map +1 -1
  37. package/dist/cjs/manifest.js +18 -18
  38. package/dist/cjs/manifest.js.map +1 -1
  39. package/dist/cjs/shared.js +31 -0
  40. package/dist/cjs/shared.js.map +1 -1
  41. package/dist/esm/guardUtils.d.ts +7 -0
  42. package/dist/esm/guardUtils.js +24 -0
  43. package/dist/esm/guardUtils.js.map +1 -0
  44. package/dist/esm/hooks/assetSources.d.ts +7 -1
  45. package/dist/esm/hooks/assetSources.js +22 -1
  46. package/dist/esm/hooks/assetSources.js.map +1 -1
  47. package/dist/esm/hooks/buildItemPresentationInfo.d.ts +7 -0
  48. package/dist/esm/hooks/buildItemPresentationInfo.js +10 -1
  49. package/dist/esm/hooks/buildItemPresentationInfo.js.map +1 -1
  50. package/dist/esm/hooks/contentAreaSidebarItems.d.ts +7 -0
  51. package/dist/esm/hooks/contentAreaSidebarItems.js +14 -1
  52. package/dist/esm/hooks/contentAreaSidebarItems.js.map +1 -1
  53. package/dist/esm/hooks/customBlockStylesForStructuredTextField.d.ts +7 -1
  54. package/dist/esm/hooks/customBlockStylesForStructuredTextField.js +11 -1
  55. package/dist/esm/hooks/customBlockStylesForStructuredTextField.js.map +1 -1
  56. package/dist/esm/hooks/customMarksForStructuredTextField.d.ts +7 -1
  57. package/dist/esm/hooks/customMarksForStructuredTextField.js +15 -1
  58. package/dist/esm/hooks/customMarksForStructuredTextField.js.map +1 -1
  59. package/dist/esm/hooks/initialLocationQueryForItemSelector.d.ts +7 -0
  60. package/dist/esm/hooks/initialLocationQueryForItemSelector.js +9 -1
  61. package/dist/esm/hooks/initialLocationQueryForItemSelector.js.map +1 -1
  62. package/dist/esm/hooks/itemCollectionOutlets.d.ts +7 -1
  63. package/dist/esm/hooks/itemCollectionOutlets.js +10 -1
  64. package/dist/esm/hooks/itemCollectionOutlets.js.map +1 -1
  65. package/dist/esm/hooks/itemFormOutlets.d.ts +7 -0
  66. package/dist/esm/hooks/itemFormOutlets.js +10 -1
  67. package/dist/esm/hooks/itemFormOutlets.js.map +1 -1
  68. package/dist/esm/hooks/itemFormSidebarPanels.d.ts +8 -0
  69. package/dist/esm/hooks/itemFormSidebarPanels.js +14 -1
  70. package/dist/esm/hooks/itemFormSidebarPanels.js.map +1 -1
  71. package/dist/esm/hooks/itemFormSidebars.d.ts +8 -0
  72. package/dist/esm/hooks/itemFormSidebars.js +12 -1
  73. package/dist/esm/hooks/itemFormSidebars.js.map +1 -1
  74. package/dist/esm/hooks/mainNavigationTabs.d.ts +7 -1
  75. package/dist/esm/hooks/mainNavigationTabs.js +14 -1
  76. package/dist/esm/hooks/mainNavigationTabs.js.map +1 -1
  77. package/dist/esm/hooks/manualFieldExtensions.d.ts +8 -0
  78. package/dist/esm/hooks/manualFieldExtensions.js +22 -1
  79. package/dist/esm/hooks/manualFieldExtensions.js.map +1 -1
  80. package/dist/esm/hooks/overrideFieldExtensions.d.ts +6 -0
  81. package/dist/esm/hooks/overrideFieldExtensions.js +31 -1
  82. package/dist/esm/hooks/overrideFieldExtensions.js.map +1 -1
  83. package/dist/esm/hooks/uploadSidebarPanels.d.ts +8 -0
  84. package/dist/esm/hooks/uploadSidebarPanels.js +14 -1
  85. package/dist/esm/hooks/uploadSidebarPanels.js.map +1 -1
  86. package/dist/esm/hooks/uploadSidebars.d.ts +8 -0
  87. package/dist/esm/hooks/uploadSidebars.js +12 -1
  88. package/dist/esm/hooks/uploadSidebars.js.map +1 -1
  89. package/dist/esm/hooks/validateManualFieldExtensionParameters.d.ts +1 -0
  90. package/dist/esm/hooks/validateManualFieldExtensionParameters.js +4 -1
  91. package/dist/esm/hooks/validateManualFieldExtensionParameters.js.map +1 -1
  92. package/dist/esm/icon.d.ts +1 -0
  93. package/dist/esm/icon.js +8 -1
  94. package/dist/esm/icon.js.map +1 -1
  95. package/dist/esm/manifest.js +18 -18
  96. package/dist/esm/manifest.js.map +1 -1
  97. package/dist/esm/shared.d.ts +13 -0
  98. package/dist/esm/shared.js +28 -1
  99. package/dist/esm/shared.js.map +1 -1
  100. package/dist/types/guardUtils.d.ts +7 -0
  101. package/dist/types/hooks/assetSources.d.ts +7 -1
  102. package/dist/types/hooks/buildItemPresentationInfo.d.ts +7 -0
  103. package/dist/types/hooks/contentAreaSidebarItems.d.ts +7 -0
  104. package/dist/types/hooks/customBlockStylesForStructuredTextField.d.ts +7 -1
  105. package/dist/types/hooks/customMarksForStructuredTextField.d.ts +7 -1
  106. package/dist/types/hooks/initialLocationQueryForItemSelector.d.ts +7 -0
  107. package/dist/types/hooks/itemCollectionOutlets.d.ts +7 -1
  108. package/dist/types/hooks/itemFormOutlets.d.ts +7 -0
  109. package/dist/types/hooks/itemFormSidebarPanels.d.ts +8 -0
  110. package/dist/types/hooks/itemFormSidebars.d.ts +8 -0
  111. package/dist/types/hooks/mainNavigationTabs.d.ts +7 -1
  112. package/dist/types/hooks/manualFieldExtensions.d.ts +8 -0
  113. package/dist/types/hooks/overrideFieldExtensions.d.ts +6 -0
  114. package/dist/types/hooks/uploadSidebarPanels.d.ts +8 -0
  115. package/dist/types/hooks/uploadSidebars.d.ts +8 -0
  116. package/dist/types/hooks/validateManualFieldExtensionParameters.d.ts +1 -0
  117. package/dist/types/icon.d.ts +1 -0
  118. package/dist/types/shared.d.ts +13 -0
  119. package/manifest.json +18 -18
  120. package/package.json +2 -2
  121. package/src/guardUtils.ts +34 -0
  122. package/src/hooks/assetSources.ts +39 -2
  123. package/src/hooks/buildItemPresentationInfo.ts +23 -0
  124. package/src/hooks/contentAreaSidebarItems.ts +34 -1
  125. package/src/hooks/customBlockStylesForStructuredTextField.ts +30 -1
  126. package/src/hooks/customMarksForStructuredTextField.ts +35 -2
  127. package/src/hooks/initialLocationQueryForItemSelector.ts +22 -1
  128. package/src/hooks/itemCollectionOutlets.ts +29 -1
  129. package/src/hooks/itemFormOutlets.ts +27 -0
  130. package/src/hooks/itemFormSidebarPanels.ts +36 -0
  131. package/src/hooks/itemFormSidebars.ts +30 -0
  132. package/src/hooks/mainNavigationTabs.ts +34 -2
  133. package/src/hooks/manualFieldExtensions.ts +43 -0
  134. package/src/hooks/overrideFieldExtensions.ts +55 -0
  135. package/src/hooks/uploadSidebarPanels.ts +36 -0
  136. package/src/hooks/uploadSidebars.ts +30 -0
  137. package/src/hooks/validateManualFieldExtensionParameters.ts +8 -0
  138. package/src/icon.ts +12 -0
  139. package/src/manifest.ts +18 -18
  140. package/src/shared.ts +58 -1
package/src/manifest.ts CHANGED
@@ -22,7 +22,7 @@ export const manifest: Manifest = {
22
22
  returnType: 'Record<string, unknown> | Promise<Record<string, unknown>>',
23
23
  location: {
24
24
  filePath: 'src/hooks/validateManualFieldExtensionParameters.ts',
25
- lineNumber: 8,
25
+ lineNumber: 10,
26
26
  },
27
27
  },
28
28
  uploadsDropdownActions: {
@@ -60,7 +60,7 @@ export const manifest: Manifest = {
60
60
  returnType: 'UploadSidebar[]',
61
61
  location: {
62
62
  filePath: 'src/hooks/uploadSidebars.ts',
63
- lineNumber: 10,
63
+ lineNumber: 17,
64
64
  },
65
65
  },
66
66
  uploadSidebarPanels: {
@@ -79,7 +79,7 @@ export const manifest: Manifest = {
79
79
  returnType: 'UploadSidebarPanel[]',
80
80
  location: {
81
81
  filePath: 'src/hooks/uploadSidebarPanels.ts',
82
- lineNumber: 10,
82
+ lineNumber: 19,
83
83
  },
84
84
  },
85
85
  settingsAreaSidebarItemGroups: {
@@ -1601,7 +1601,7 @@ export const manifest: Manifest = {
1601
1601
  itemType: {
1602
1602
  location: {
1603
1603
  filePath: 'src/hooks/overrideFieldExtensions.ts',
1604
- lineNumber: 22,
1604
+ lineNumber: 31,
1605
1605
  },
1606
1606
  type: 'ItemType',
1607
1607
  },
@@ -1613,7 +1613,7 @@ export const manifest: Manifest = {
1613
1613
  returnType: 'FieldExtensionOverride | undefined',
1614
1614
  location: {
1615
1615
  filePath: 'src/hooks/overrideFieldExtensions.ts',
1616
- lineNumber: 15,
1616
+ lineNumber: 24,
1617
1617
  },
1618
1618
  },
1619
1619
  onBoot: {
@@ -1747,7 +1747,7 @@ export const manifest: Manifest = {
1747
1747
  returnType: 'ManualFieldExtension[]',
1748
1748
  location: {
1749
1749
  filePath: 'src/hooks/manualFieldExtensions.ts',
1750
- lineNumber: 10,
1750
+ lineNumber: 18,
1751
1751
  },
1752
1752
  },
1753
1753
  mainNavigationTabs: {
@@ -1766,7 +1766,7 @@ export const manifest: Manifest = {
1766
1766
  returnType: 'MainNavigationTab[]',
1767
1767
  location: {
1768
1768
  filePath: 'src/hooks/mainNavigationTabs.ts',
1769
- lineNumber: 11,
1769
+ lineNumber: 19,
1770
1770
  },
1771
1771
  },
1772
1772
  itemsDropdownActions: {
@@ -1826,7 +1826,7 @@ export const manifest: Manifest = {
1826
1826
  returnType: 'ItemFormSidebar[]',
1827
1827
  location: {
1828
1828
  filePath: 'src/hooks/itemFormSidebars.ts',
1829
- lineNumber: 13,
1829
+ lineNumber: 20,
1830
1830
  },
1831
1831
  },
1832
1832
  itemFormSidebarPanels: {
@@ -1850,7 +1850,7 @@ export const manifest: Manifest = {
1850
1850
  returnType: 'ItemFormSidebarPanel[]',
1851
1851
  location: {
1852
1852
  filePath: 'src/hooks/itemFormSidebarPanels.ts',
1853
- lineNumber: 14,
1853
+ lineNumber: 23,
1854
1854
  },
1855
1855
  },
1856
1856
  itemFormOutlets: {
@@ -1874,7 +1874,7 @@ export const manifest: Manifest = {
1874
1874
  returnType: 'ItemFormOutlet[]',
1875
1875
  location: {
1876
1876
  filePath: 'src/hooks/itemFormOutlets.ts',
1877
- lineNumber: 13,
1877
+ lineNumber: 20,
1878
1878
  },
1879
1879
  },
1880
1880
  itemFormDropdownActions: {
@@ -2017,7 +2017,7 @@ export const manifest: Manifest = {
2017
2017
  returnType: 'ItemCollectionOutlet[]',
2018
2018
  location: {
2019
2019
  filePath: 'src/hooks/itemCollectionOutlets.ts',
2020
- lineNumber: 13,
2020
+ lineNumber: 20,
2021
2021
  },
2022
2022
  },
2023
2023
  initialLocationQueryForItemSelector: {
@@ -2851,7 +2851,7 @@ export const manifest: Manifest = {
2851
2851
  itemType: {
2852
2852
  location: {
2853
2853
  filePath: 'src/hooks/customMarksForStructuredTextField.ts',
2854
- lineNumber: 22,
2854
+ lineNumber: 30,
2855
2855
  },
2856
2856
  type: 'ItemType',
2857
2857
  },
@@ -2863,7 +2863,7 @@ export const manifest: Manifest = {
2863
2863
  returnType: 'StructuredTextCustomMark[] | undefined',
2864
2864
  location: {
2865
2865
  filePath: 'src/hooks/customMarksForStructuredTextField.ts',
2866
- lineNumber: 15,
2866
+ lineNumber: 23,
2867
2867
  },
2868
2868
  },
2869
2869
  customBlockStylesForStructuredTextField: {
@@ -2888,7 +2888,7 @@ export const manifest: Manifest = {
2888
2888
  location: {
2889
2889
  filePath:
2890
2890
  'src/hooks/customBlockStylesForStructuredTextField.ts',
2891
- lineNumber: 22,
2891
+ lineNumber: 29,
2892
2892
  },
2893
2893
  type: 'ItemType',
2894
2894
  },
@@ -2900,7 +2900,7 @@ export const manifest: Manifest = {
2900
2900
  returnType: 'StructuredTextCustomBlockStyle[] | undefined',
2901
2901
  location: {
2902
2902
  filePath: 'src/hooks/customBlockStylesForStructuredTextField.ts',
2903
- lineNumber: 15,
2903
+ lineNumber: 22,
2904
2904
  },
2905
2905
  },
2906
2906
  contentAreaSidebarItems: {
@@ -2919,7 +2919,7 @@ export const manifest: Manifest = {
2919
2919
  returnType: 'ContentAreaSidebarItem[]',
2920
2920
  location: {
2921
2921
  filePath: 'src/hooks/contentAreaSidebarItems.ts',
2922
- lineNumber: 10,
2922
+ lineNumber: 18,
2923
2923
  },
2924
2924
  },
2925
2925
  buildItemPresentationInfo: {
@@ -2943,7 +2943,7 @@ export const manifest: Manifest = {
2943
2943
  returnType: 'MaybePromise<ItemPresentationInfo | undefined>',
2944
2944
  location: {
2945
2945
  filePath: 'src/hooks/buildItemPresentationInfo.ts',
2946
- lineNumber: 14,
2946
+ lineNumber: 15,
2947
2947
  },
2948
2948
  },
2949
2949
  assetSources: {
@@ -2962,7 +2962,7 @@ export const manifest: Manifest = {
2962
2962
  returnType: 'AssetSource[] | undefined',
2963
2963
  location: {
2964
2964
  filePath: 'src/hooks/assetSources.ts',
2965
- lineNumber: 11,
2965
+ lineNumber: 18,
2966
2966
  },
2967
2967
  },
2968
2968
  },
package/src/shared.ts CHANGED
@@ -1,5 +1,18 @@
1
- import { Icon } from './icon';
1
+ import {
2
+ isArray,
3
+ isBoolean,
4
+ isNullish,
5
+ isNumber,
6
+ isRecord,
7
+ isString,
8
+ } from './guardUtils.js';
9
+ import { Icon, isIcon } from './icon';
2
10
 
11
+ /**
12
+ * An object expressing a dropdown action to be shown in the interface
13
+ *
14
+ * @see {isDropdownAction}
15
+ */
3
16
  export type DropdownAction = {
4
17
  /**
5
18
  * ID of action. Will be the first argument for the
@@ -38,6 +51,11 @@ export type DropdownAction = {
38
51
  rank?: number;
39
52
  };
40
53
 
54
+ /**
55
+ * An object expressing a dropdown submenu containing actions to be shown in the interface
56
+ *
57
+ * @see {isDropdownActionGroup}
58
+ */
41
59
  export type DropdownActionGroup = {
42
60
  /** Label to be shown. Must be unique. */
43
61
  label: string;
@@ -65,3 +83,42 @@ export type ItemFormSidebarPanelPlacement = [
65
83
  'before' | 'after',
66
84
  'info' | 'publishedVersion' | 'schedule' | 'links' | 'history',
67
85
  ];
86
+
87
+ export function isDropdownAction(value: unknown): value is DropdownAction {
88
+ if (!isRecord(value)) return false;
89
+
90
+ return (
91
+ isString(value.id) &&
92
+ (isNullish(value.parameters) || isRecord(value.parameters)) &&
93
+ isString(value.label) &&
94
+ isIcon(value.icon) &&
95
+ (isNullish(value.active) || isBoolean(value.active)) &&
96
+ (isNullish(value.alert) || isBoolean(value.alert)) &&
97
+ (isNullish(value.disabled) || isBoolean(value.disabled)) &&
98
+ (isNullish(value.closeMenuOnClick) || isBoolean(value.closeMenuOnClick)) &&
99
+ (isNullish(value.rank) || isNumber(value.rank))
100
+ );
101
+ }
102
+
103
+ export function isDropdownActionGroup(
104
+ value: unknown,
105
+ ): value is DropdownActionGroup {
106
+ if (!isRecord(value)) return false;
107
+
108
+ return (
109
+ isString(value.label) &&
110
+ isIcon(value.icon) &&
111
+ isArray(value.actions, isDropdownAction) &&
112
+ (isNullish(value.rank) || isNumber(value.rank))
113
+ );
114
+ }
115
+
116
+ export function isDropdownActionOrGroupArray(
117
+ value: unknown,
118
+ ): value is Array<DropdownAction | DropdownActionGroup> {
119
+ return isArray(
120
+ value,
121
+ (innerValue) =>
122
+ isDropdownAction(innerValue) || isDropdownActionGroup(innerValue),
123
+ );
124
+ }