datocms-plugin-sdk 1.1.0 → 2.0.0

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 (394) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/connect.js +75 -208
  3. package/dist/cjs/connect.js.map +1 -1
  4. package/dist/cjs/{types.js → ctx/base.js} +1 -1
  5. package/dist/cjs/ctx/base.js.map +1 -0
  6. package/dist/cjs/ctx/commonExtras/field.js +3 -0
  7. package/dist/cjs/ctx/commonExtras/field.js.map +1 -0
  8. package/dist/cjs/ctx/commonExtras/itemForm.js +3 -0
  9. package/dist/cjs/ctx/commonExtras/itemForm.js.map +1 -0
  10. package/dist/cjs/ctx/commonExtras/sizing.js +3 -0
  11. package/dist/cjs/ctx/commonExtras/sizing.js.map +1 -0
  12. package/dist/cjs/ctx/pluginFrame.js +3 -0
  13. package/dist/cjs/ctx/pluginFrame.js.map +1 -0
  14. package/dist/cjs/hooks/assetSources.js +3 -0
  15. package/dist/cjs/hooks/assetSources.js.map +1 -0
  16. package/dist/cjs/hooks/buildItemPresentationInfo.js +3 -0
  17. package/dist/cjs/hooks/buildItemPresentationInfo.js.map +1 -0
  18. package/dist/cjs/hooks/contentAreaSidebarItems.js +3 -0
  19. package/dist/cjs/hooks/contentAreaSidebarItems.js.map +1 -0
  20. package/dist/cjs/hooks/customBlockStylesForStructuredTextField.js +3 -0
  21. package/dist/cjs/hooks/customBlockStylesForStructuredTextField.js.map +1 -0
  22. package/dist/cjs/hooks/customMarksForStructuredTextField.js +3 -0
  23. package/dist/cjs/hooks/customMarksForStructuredTextField.js.map +1 -0
  24. package/dist/cjs/hooks/executeFieldDropdownAction.js +3 -0
  25. package/dist/cjs/hooks/executeFieldDropdownAction.js.map +1 -0
  26. package/dist/cjs/hooks/executeItemFormDropdownAction.js +3 -0
  27. package/dist/cjs/hooks/executeItemFormDropdownAction.js.map +1 -0
  28. package/dist/cjs/hooks/executeItemsDropdownAction.js +3 -0
  29. package/dist/cjs/hooks/executeItemsDropdownAction.js.map +1 -0
  30. package/dist/cjs/hooks/executeUploadsDropdownAction.js +3 -0
  31. package/dist/cjs/hooks/executeUploadsDropdownAction.js.map +1 -0
  32. package/dist/cjs/hooks/fieldDropdownActions.js +3 -0
  33. package/dist/cjs/hooks/fieldDropdownActions.js.map +1 -0
  34. package/dist/cjs/hooks/initialLocationQueryForItemSelector.js +3 -0
  35. package/dist/cjs/hooks/initialLocationQueryForItemSelector.js.map +1 -0
  36. package/dist/cjs/hooks/itemCollectionOutlets.js +3 -0
  37. package/dist/cjs/hooks/itemCollectionOutlets.js.map +1 -0
  38. package/dist/cjs/hooks/itemFormDropdownActions.js +3 -0
  39. package/dist/cjs/hooks/itemFormDropdownActions.js.map +1 -0
  40. package/dist/cjs/hooks/itemFormOutlets.js +3 -0
  41. package/dist/cjs/hooks/itemFormOutlets.js.map +1 -0
  42. package/dist/cjs/hooks/itemFormSidebarPanels.js +3 -0
  43. package/dist/cjs/hooks/itemFormSidebarPanels.js.map +1 -0
  44. package/dist/cjs/hooks/itemFormSidebars.js +3 -0
  45. package/dist/cjs/hooks/itemFormSidebars.js.map +1 -0
  46. package/dist/cjs/hooks/itemsDropdownActions.js +3 -0
  47. package/dist/cjs/hooks/itemsDropdownActions.js.map +1 -0
  48. package/dist/cjs/hooks/mainNavigationTabs.js +3 -0
  49. package/dist/cjs/hooks/mainNavigationTabs.js.map +1 -0
  50. package/dist/cjs/hooks/manualFieldExtensions.js +3 -0
  51. package/dist/cjs/hooks/manualFieldExtensions.js.map +1 -0
  52. package/dist/cjs/hooks/onBeforeItemUpsert.js +3 -0
  53. package/dist/cjs/hooks/onBeforeItemUpsert.js.map +1 -0
  54. package/dist/cjs/hooks/onBeforeItemsDestroy.js +3 -0
  55. package/dist/cjs/hooks/onBeforeItemsDestroy.js.map +1 -0
  56. package/dist/cjs/hooks/onBeforeItemsPublish.js +3 -0
  57. package/dist/cjs/hooks/onBeforeItemsPublish.js.map +1 -0
  58. package/dist/cjs/hooks/onBeforeItemsUnpublish.js +3 -0
  59. package/dist/cjs/hooks/onBeforeItemsUnpublish.js.map +1 -0
  60. package/dist/cjs/hooks/onBoot.js +3 -0
  61. package/dist/cjs/hooks/onBoot.js.map +1 -0
  62. package/dist/cjs/hooks/overrideFieldExtensions.js +3 -0
  63. package/dist/cjs/hooks/overrideFieldExtensions.js.map +1 -0
  64. package/dist/cjs/hooks/renderAssetSource.js +11 -0
  65. package/dist/cjs/hooks/renderAssetSource.js.map +1 -0
  66. package/dist/cjs/hooks/renderConfigScreen.js +11 -0
  67. package/dist/cjs/hooks/renderConfigScreen.js.map +1 -0
  68. package/dist/cjs/hooks/renderFieldExtension.js +11 -0
  69. package/dist/cjs/hooks/renderFieldExtension.js.map +1 -0
  70. package/dist/cjs/hooks/renderItemCollectionOutlet.js +11 -0
  71. package/dist/cjs/hooks/renderItemCollectionOutlet.js.map +1 -0
  72. package/dist/cjs/hooks/renderItemFormOutlet.js +11 -0
  73. package/dist/cjs/hooks/renderItemFormOutlet.js.map +1 -0
  74. package/dist/cjs/hooks/renderItemFormSidebar.js +11 -0
  75. package/dist/cjs/hooks/renderItemFormSidebar.js.map +1 -0
  76. package/dist/cjs/hooks/renderItemFormSidebarPanel.js +11 -0
  77. package/dist/cjs/hooks/renderItemFormSidebarPanel.js.map +1 -0
  78. package/dist/cjs/hooks/renderManualFieldExtensionConfigScreen.js +11 -0
  79. package/dist/cjs/hooks/renderManualFieldExtensionConfigScreen.js.map +1 -0
  80. package/dist/cjs/hooks/renderModal.js +11 -0
  81. package/dist/cjs/hooks/renderModal.js.map +1 -0
  82. package/dist/cjs/hooks/renderPage.js +11 -0
  83. package/dist/cjs/hooks/renderPage.js.map +1 -0
  84. package/dist/cjs/hooks/renderUploadSidebar.js +11 -0
  85. package/dist/cjs/hooks/renderUploadSidebar.js.map +1 -0
  86. package/dist/cjs/hooks/renderUploadSidebarPanel.js +11 -0
  87. package/dist/cjs/hooks/renderUploadSidebarPanel.js.map +1 -0
  88. package/dist/cjs/hooks/settingsAreaSidebarItemGroups.js +3 -0
  89. package/dist/cjs/hooks/settingsAreaSidebarItemGroups.js.map +1 -0
  90. package/dist/cjs/hooks/uploadSidebarPanels.js +3 -0
  91. package/dist/cjs/hooks/uploadSidebarPanels.js.map +1 -0
  92. package/dist/cjs/hooks/uploadSidebars.js +3 -0
  93. package/dist/cjs/hooks/uploadSidebars.js.map +1 -0
  94. package/dist/cjs/hooks/uploadsDropdownActions.js +3 -0
  95. package/dist/cjs/hooks/uploadsDropdownActions.js.map +1 -0
  96. package/dist/cjs/hooks/validateManualFieldExtensionParameters.js +3 -0
  97. package/dist/cjs/hooks/validateManualFieldExtensionParameters.js.map +1 -0
  98. package/dist/cjs/icon.js +3 -0
  99. package/dist/cjs/icon.js.map +1 -0
  100. package/dist/cjs/index.js +46 -1
  101. package/dist/cjs/index.js.map +1 -1
  102. package/dist/cjs/manifest.js +2909 -0
  103. package/dist/cjs/manifest.js.map +1 -0
  104. package/dist/cjs/manifestTypes.js +3 -0
  105. package/dist/cjs/manifestTypes.js.map +1 -0
  106. package/dist/cjs/shared.js +3 -0
  107. package/dist/cjs/shared.js.map +1 -0
  108. package/dist/cjs/utils.js +136 -0
  109. package/dist/cjs/utils.js.map +1 -0
  110. package/dist/esm/connect.d.ts +44 -242
  111. package/dist/esm/connect.js +74 -206
  112. package/dist/esm/connect.js.map +1 -1
  113. package/dist/esm/ctx/base.d.ts +670 -0
  114. package/dist/esm/ctx/base.js +2 -0
  115. package/dist/esm/ctx/base.js.map +1 -0
  116. package/dist/esm/ctx/commonExtras/field.d.ts +29 -0
  117. package/dist/esm/ctx/commonExtras/field.js +2 -0
  118. package/dist/esm/ctx/commonExtras/field.js.map +1 -0
  119. package/dist/esm/ctx/commonExtras/itemForm.d.ts +148 -0
  120. package/dist/esm/ctx/commonExtras/itemForm.js +2 -0
  121. package/dist/esm/ctx/commonExtras/itemForm.js.map +1 -0
  122. package/dist/esm/ctx/commonExtras/sizing.d.ts +23 -0
  123. package/dist/esm/ctx/commonExtras/sizing.js +2 -0
  124. package/dist/esm/ctx/commonExtras/sizing.js.map +1 -0
  125. package/dist/esm/ctx/pluginFrame.d.ts +12 -0
  126. package/dist/esm/ctx/pluginFrame.js +2 -0
  127. package/dist/esm/ctx/pluginFrame.js.map +1 -0
  128. package/dist/esm/hooks/assetSources.d.ts +41 -0
  129. package/dist/esm/hooks/assetSources.js +2 -0
  130. package/dist/esm/hooks/assetSources.js.map +1 -0
  131. package/dist/esm/hooks/buildItemPresentationInfo.d.ts +28 -0
  132. package/dist/esm/hooks/buildItemPresentationInfo.js +2 -0
  133. package/dist/esm/hooks/buildItemPresentationInfo.js.map +1 -0
  134. package/dist/esm/hooks/contentAreaSidebarItems.d.ts +39 -0
  135. package/dist/esm/hooks/contentAreaSidebarItems.js +2 -0
  136. package/dist/esm/hooks/contentAreaSidebarItems.js.map +1 -0
  137. package/dist/esm/hooks/customBlockStylesForStructuredTextField.d.ts +36 -0
  138. package/dist/esm/hooks/customBlockStylesForStructuredTextField.js +2 -0
  139. package/dist/esm/hooks/customBlockStylesForStructuredTextField.js.map +1 -0
  140. package/dist/esm/hooks/customMarksForStructuredTextField.d.ts +57 -0
  141. package/dist/esm/hooks/customMarksForStructuredTextField.js +2 -0
  142. package/dist/esm/hooks/customMarksForStructuredTextField.js.map +1 -0
  143. package/dist/esm/hooks/executeFieldDropdownAction.d.ts +9 -0
  144. package/dist/esm/hooks/executeFieldDropdownAction.js +2 -0
  145. package/dist/esm/hooks/executeFieldDropdownAction.js.map +1 -0
  146. package/dist/esm/hooks/executeItemFormDropdownAction.d.ts +8 -0
  147. package/dist/esm/hooks/executeItemFormDropdownAction.js +2 -0
  148. package/dist/esm/hooks/executeItemFormDropdownAction.js.map +1 -0
  149. package/dist/esm/hooks/executeItemsDropdownAction.d.ts +10 -0
  150. package/dist/esm/hooks/executeItemsDropdownAction.js +2 -0
  151. package/dist/esm/hooks/executeItemsDropdownAction.js.map +1 -0
  152. package/dist/esm/hooks/executeUploadsDropdownAction.d.ts +10 -0
  153. package/dist/esm/hooks/executeUploadsDropdownAction.js +2 -0
  154. package/dist/esm/hooks/executeUploadsDropdownAction.js.map +1 -0
  155. package/dist/esm/hooks/fieldDropdownActions.d.ts +11 -0
  156. package/dist/esm/hooks/fieldDropdownActions.js +2 -0
  157. package/dist/esm/hooks/fieldDropdownActions.js.map +1 -0
  158. package/dist/esm/hooks/initialLocationQueryForItemSelector.d.ts +26 -0
  159. package/dist/esm/hooks/initialLocationQueryForItemSelector.js +2 -0
  160. package/dist/esm/hooks/initialLocationQueryForItemSelector.js.map +1 -0
  161. package/dist/esm/hooks/itemCollectionOutlets.d.ts +24 -0
  162. package/dist/esm/hooks/itemCollectionOutlets.js +2 -0
  163. package/dist/esm/hooks/itemCollectionOutlets.js.map +1 -0
  164. package/dist/esm/hooks/itemFormDropdownActions.d.ts +11 -0
  165. package/dist/esm/hooks/itemFormDropdownActions.js +2 -0
  166. package/dist/esm/hooks/itemFormDropdownActions.js.map +1 -0
  167. package/dist/esm/hooks/itemFormOutlets.d.ts +29 -0
  168. package/dist/esm/hooks/itemFormOutlets.js +2 -0
  169. package/dist/esm/hooks/itemFormOutlets.js.map +1 -0
  170. package/dist/esm/hooks/itemFormSidebarPanels.d.ts +47 -0
  171. package/dist/esm/hooks/itemFormSidebarPanels.js +2 -0
  172. package/dist/esm/hooks/itemFormSidebarPanels.js.map +1 -0
  173. package/dist/esm/hooks/itemFormSidebars.d.ts +37 -0
  174. package/dist/esm/hooks/itemFormSidebars.js +2 -0
  175. package/dist/esm/hooks/itemFormSidebars.js.map +1 -0
  176. package/dist/esm/hooks/itemsDropdownActions.d.ts +11 -0
  177. package/dist/esm/hooks/itemsDropdownActions.js +2 -0
  178. package/dist/esm/hooks/itemsDropdownActions.js.map +1 -0
  179. package/dist/esm/hooks/mainNavigationTabs.d.ts +43 -0
  180. package/dist/esm/hooks/mainNavigationTabs.js +2 -0
  181. package/dist/esm/hooks/mainNavigationTabs.js.map +1 -0
  182. package/dist/esm/hooks/manualFieldExtensions.d.ts +58 -0
  183. package/dist/esm/hooks/manualFieldExtensions.js +2 -0
  184. package/dist/esm/hooks/manualFieldExtensions.js.map +1 -0
  185. package/dist/esm/hooks/onBeforeItemUpsert.d.ts +15 -0
  186. package/dist/esm/hooks/onBeforeItemUpsert.js +2 -0
  187. package/dist/esm/hooks/onBeforeItemUpsert.js.map +1 -0
  188. package/dist/esm/hooks/onBeforeItemsDestroy.d.ts +14 -0
  189. package/dist/esm/hooks/onBeforeItemsDestroy.js +2 -0
  190. package/dist/esm/hooks/onBeforeItemsDestroy.js.map +1 -0
  191. package/dist/esm/hooks/onBeforeItemsPublish.d.ts +14 -0
  192. package/dist/esm/hooks/onBeforeItemsPublish.js +2 -0
  193. package/dist/esm/hooks/onBeforeItemsPublish.js.map +1 -0
  194. package/dist/esm/hooks/onBeforeItemsUnpublish.d.ts +14 -0
  195. package/dist/esm/hooks/onBeforeItemsUnpublish.js +2 -0
  196. package/dist/esm/hooks/onBeforeItemsUnpublish.js.map +1 -0
  197. package/dist/esm/hooks/onBoot.d.ts +11 -0
  198. package/dist/esm/hooks/onBoot.js +2 -0
  199. package/dist/esm/hooks/onBoot.js.map +1 -0
  200. package/dist/esm/hooks/overrideFieldExtensions.d.ts +88 -0
  201. package/dist/esm/hooks/overrideFieldExtensions.js +2 -0
  202. package/dist/esm/hooks/overrideFieldExtensions.js.map +1 -0
  203. package/dist/esm/hooks/renderAssetSource.d.ts +98 -0
  204. package/dist/esm/hooks/renderAssetSource.js +8 -0
  205. package/dist/esm/hooks/renderAssetSource.js.map +1 -0
  206. package/dist/esm/hooks/renderConfigScreen.d.ts +12 -0
  207. package/dist/esm/hooks/renderConfigScreen.js +8 -0
  208. package/dist/esm/hooks/renderConfigScreen.js.map +1 -0
  209. package/dist/esm/hooks/renderFieldExtension.d.ts +20 -0
  210. package/dist/esm/hooks/renderFieldExtension.js +8 -0
  211. package/dist/esm/hooks/renderFieldExtension.js.map +1 -0
  212. package/dist/esm/hooks/renderItemCollectionOutlet.d.ts +9 -0
  213. package/dist/esm/hooks/renderItemCollectionOutlet.js +8 -0
  214. package/dist/esm/hooks/renderItemCollectionOutlet.js.map +1 -0
  215. package/dist/esm/hooks/renderItemFormOutlet.d.ts +16 -0
  216. package/dist/esm/hooks/renderItemFormOutlet.js +8 -0
  217. package/dist/esm/hooks/renderItemFormOutlet.js.map +1 -0
  218. package/dist/esm/hooks/renderItemFormSidebar.d.ts +21 -0
  219. package/dist/esm/hooks/renderItemFormSidebar.js +8 -0
  220. package/dist/esm/hooks/renderItemFormSidebar.js.map +1 -0
  221. package/dist/esm/hooks/renderItemFormSidebarPanel.d.ts +21 -0
  222. package/dist/esm/hooks/renderItemFormSidebarPanel.js +8 -0
  223. package/dist/esm/hooks/renderItemFormSidebarPanel.js.map +1 -0
  224. package/dist/esm/hooks/renderManualFieldExtensionConfigScreen.d.ts +55 -0
  225. package/dist/esm/hooks/renderManualFieldExtensionConfigScreen.js +8 -0
  226. package/dist/esm/hooks/renderManualFieldExtensionConfigScreen.js.map +1 -0
  227. package/dist/esm/hooks/renderModal.d.ts +37 -0
  228. package/dist/esm/hooks/renderModal.js +8 -0
  229. package/dist/esm/hooks/renderModal.js.map +1 -0
  230. package/dist/esm/hooks/renderPage.d.ts +16 -0
  231. package/dist/esm/hooks/renderPage.js +8 -0
  232. package/dist/esm/hooks/renderPage.js.map +1 -0
  233. package/dist/esm/hooks/renderUploadSidebar.d.ts +25 -0
  234. package/dist/esm/hooks/renderUploadSidebar.js +8 -0
  235. package/dist/esm/hooks/renderUploadSidebar.js.map +1 -0
  236. package/dist/esm/hooks/renderUploadSidebarPanel.d.ts +25 -0
  237. package/dist/esm/hooks/renderUploadSidebarPanel.js +8 -0
  238. package/dist/esm/hooks/renderUploadSidebarPanel.js.map +1 -0
  239. package/dist/esm/hooks/settingsAreaSidebarItemGroups.d.ts +52 -0
  240. package/dist/esm/hooks/settingsAreaSidebarItemGroups.js +2 -0
  241. package/dist/esm/hooks/settingsAreaSidebarItemGroups.js.map +1 -0
  242. package/dist/esm/hooks/uploadSidebarPanels.d.ts +47 -0
  243. package/dist/esm/hooks/uploadSidebarPanels.js +2 -0
  244. package/dist/esm/hooks/uploadSidebarPanels.js.map +1 -0
  245. package/dist/esm/hooks/uploadSidebars.d.ts +34 -0
  246. package/dist/esm/hooks/uploadSidebars.js +2 -0
  247. package/dist/esm/hooks/uploadSidebars.js.map +1 -0
  248. package/dist/esm/hooks/uploadsDropdownActions.d.ts +5 -0
  249. package/dist/esm/hooks/uploadsDropdownActions.js +2 -0
  250. package/dist/esm/hooks/uploadsDropdownActions.js.map +1 -0
  251. package/dist/esm/hooks/validateManualFieldExtensionParameters.d.ts +9 -0
  252. package/dist/esm/hooks/validateManualFieldExtensionParameters.js +2 -0
  253. package/dist/esm/hooks/validateManualFieldExtensionParameters.js.map +1 -0
  254. package/dist/esm/icon.d.ts +6 -0
  255. package/dist/esm/icon.js +2 -0
  256. package/dist/esm/icon.js.map +1 -0
  257. package/dist/esm/index.d.ts +57 -12
  258. package/dist/esm/index.js +46 -1
  259. package/dist/esm/index.js.map +1 -1
  260. package/dist/esm/manifest.d.ts +2 -0
  261. package/dist/esm/manifest.js +2906 -0
  262. package/dist/esm/manifest.js.map +1 -0
  263. package/dist/esm/manifestTypes.d.ts +51 -0
  264. package/dist/esm/manifestTypes.js +2 -0
  265. package/dist/esm/manifestTypes.js.map +1 -0
  266. package/dist/esm/shared.d.ts +56 -0
  267. package/dist/esm/shared.js +2 -0
  268. package/dist/esm/shared.js.map +1 -0
  269. package/dist/esm/utils.d.ts +31 -0
  270. package/dist/esm/utils.js +129 -0
  271. package/dist/esm/utils.js.map +1 -0
  272. package/dist/types/connect.d.ts +44 -242
  273. package/dist/types/ctx/base.d.ts +670 -0
  274. package/dist/types/ctx/commonExtras/field.d.ts +29 -0
  275. package/dist/types/ctx/commonExtras/itemForm.d.ts +148 -0
  276. package/dist/types/ctx/commonExtras/sizing.d.ts +23 -0
  277. package/dist/types/ctx/pluginFrame.d.ts +12 -0
  278. package/dist/types/hooks/assetSources.d.ts +41 -0
  279. package/dist/types/hooks/buildItemPresentationInfo.d.ts +28 -0
  280. package/dist/types/hooks/contentAreaSidebarItems.d.ts +39 -0
  281. package/dist/types/hooks/customBlockStylesForStructuredTextField.d.ts +36 -0
  282. package/dist/types/hooks/customMarksForStructuredTextField.d.ts +57 -0
  283. package/dist/types/hooks/executeFieldDropdownAction.d.ts +9 -0
  284. package/dist/types/hooks/executeItemFormDropdownAction.d.ts +8 -0
  285. package/dist/types/hooks/executeItemsDropdownAction.d.ts +10 -0
  286. package/dist/types/hooks/executeUploadsDropdownAction.d.ts +10 -0
  287. package/dist/types/hooks/fieldDropdownActions.d.ts +11 -0
  288. package/dist/types/hooks/initialLocationQueryForItemSelector.d.ts +26 -0
  289. package/dist/types/hooks/itemCollectionOutlets.d.ts +24 -0
  290. package/dist/types/hooks/itemFormDropdownActions.d.ts +11 -0
  291. package/dist/types/hooks/itemFormOutlets.d.ts +29 -0
  292. package/dist/types/hooks/itemFormSidebarPanels.d.ts +47 -0
  293. package/dist/types/hooks/itemFormSidebars.d.ts +37 -0
  294. package/dist/types/hooks/itemsDropdownActions.d.ts +11 -0
  295. package/dist/types/hooks/mainNavigationTabs.d.ts +43 -0
  296. package/dist/types/hooks/manualFieldExtensions.d.ts +58 -0
  297. package/dist/types/hooks/onBeforeItemUpsert.d.ts +15 -0
  298. package/dist/types/hooks/onBeforeItemsDestroy.d.ts +14 -0
  299. package/dist/types/hooks/onBeforeItemsPublish.d.ts +14 -0
  300. package/dist/types/hooks/onBeforeItemsUnpublish.d.ts +14 -0
  301. package/dist/types/hooks/onBoot.d.ts +11 -0
  302. package/dist/types/hooks/overrideFieldExtensions.d.ts +88 -0
  303. package/dist/types/hooks/renderAssetSource.d.ts +98 -0
  304. package/dist/types/hooks/renderConfigScreen.d.ts +12 -0
  305. package/dist/types/hooks/renderFieldExtension.d.ts +20 -0
  306. package/dist/types/hooks/renderItemCollectionOutlet.d.ts +9 -0
  307. package/dist/types/hooks/renderItemFormOutlet.d.ts +16 -0
  308. package/dist/types/hooks/renderItemFormSidebar.d.ts +21 -0
  309. package/dist/types/hooks/renderItemFormSidebarPanel.d.ts +21 -0
  310. package/dist/types/hooks/renderManualFieldExtensionConfigScreen.d.ts +55 -0
  311. package/dist/types/hooks/renderModal.d.ts +37 -0
  312. package/dist/types/hooks/renderPage.d.ts +16 -0
  313. package/dist/types/hooks/renderUploadSidebar.d.ts +25 -0
  314. package/dist/types/hooks/renderUploadSidebarPanel.d.ts +25 -0
  315. package/dist/types/hooks/settingsAreaSidebarItemGroups.d.ts +52 -0
  316. package/dist/types/hooks/uploadSidebarPanels.d.ts +47 -0
  317. package/dist/types/hooks/uploadSidebars.d.ts +34 -0
  318. package/dist/types/hooks/uploadsDropdownActions.d.ts +5 -0
  319. package/dist/types/hooks/validateManualFieldExtensionParameters.d.ts +9 -0
  320. package/dist/types/icon.d.ts +6 -0
  321. package/dist/types/index.d.ts +57 -12
  322. package/dist/types/manifest.d.ts +2 -0
  323. package/dist/types/manifestTypes.d.ts +51 -0
  324. package/dist/types/shared.d.ts +56 -0
  325. package/dist/types/utils.d.ts +31 -0
  326. package/manifest.json +2905 -0
  327. package/package.json +7 -6
  328. package/src/connect.ts +207 -698
  329. package/src/ctx/base.ts +714 -0
  330. package/src/ctx/commonExtras/field.ts +27 -0
  331. package/src/ctx/commonExtras/itemForm.ts +155 -0
  332. package/src/ctx/commonExtras/sizing.ts +27 -0
  333. package/src/ctx/pluginFrame.ts +39 -0
  334. package/src/hooks/assetSources.ts +43 -0
  335. package/src/hooks/buildItemPresentationInfo.ts +33 -0
  336. package/src/hooks/contentAreaSidebarItems.ts +41 -0
  337. package/src/hooks/customBlockStylesForStructuredTextField.ts +42 -0
  338. package/src/hooks/customMarksForStructuredTextField.ts +64 -0
  339. package/src/hooks/executeFieldDropdownAction.ts +21 -0
  340. package/src/hooks/executeItemFormDropdownAction.ts +19 -0
  341. package/src/hooks/executeItemsDropdownAction.ts +16 -0
  342. package/src/hooks/executeUploadsDropdownAction.ts +15 -0
  343. package/src/hooks/fieldDropdownActions.ts +18 -0
  344. package/src/hooks/initialLocationQueryForItemSelector.ts +33 -0
  345. package/src/hooks/itemCollectionOutlets.ts +29 -0
  346. package/src/hooks/itemFormDropdownActions.ts +18 -0
  347. package/src/hooks/itemFormOutlets.ts +31 -0
  348. package/src/hooks/itemFormSidebarPanels.ts +52 -0
  349. package/src/hooks/itemFormSidebars.ts +39 -0
  350. package/src/hooks/itemsDropdownActions.ts +16 -0
  351. package/src/hooks/mainNavigationTabs.ts +45 -0
  352. package/src/hooks/manualFieldExtensions.ts +78 -0
  353. package/src/hooks/onBeforeItemUpsert.ts +19 -0
  354. package/src/hooks/onBeforeItemsDestroy.ts +15 -0
  355. package/src/hooks/onBeforeItemsPublish.ts +15 -0
  356. package/src/hooks/onBeforeItemsUnpublish.ts +15 -0
  357. package/src/hooks/onBoot.ts +13 -0
  358. package/src/hooks/overrideFieldExtensions.ts +95 -0
  359. package/src/hooks/renderAssetSource.ts +119 -0
  360. package/src/hooks/renderConfigScreen.ts +27 -0
  361. package/src/hooks/renderFieldExtension.ts +46 -0
  362. package/src/hooks/renderItemCollectionOutlet.ts +29 -0
  363. package/src/hooks/renderItemFormOutlet.ts +40 -0
  364. package/src/hooks/renderItemFormSidebar.ts +45 -0
  365. package/src/hooks/renderItemFormSidebarPanel.ts +46 -0
  366. package/src/hooks/renderManualFieldExtensionConfigScreen.ts +83 -0
  367. package/src/hooks/renderModal.ts +54 -0
  368. package/src/hooks/renderPage.ts +33 -0
  369. package/src/hooks/renderUploadSidebar.ts +44 -0
  370. package/src/hooks/renderUploadSidebarPanel.ts +47 -0
  371. package/src/hooks/settingsAreaSidebarItemGroups.ts +55 -0
  372. package/src/hooks/uploadSidebarPanels.ts +57 -0
  373. package/src/hooks/uploadSidebars.ts +36 -0
  374. package/src/hooks/uploadsDropdownActions.ts +8 -0
  375. package/src/hooks/validateManualFieldExtensionParameters.ts +12 -0
  376. package/src/{types.ts → icon.ts} +0 -1739
  377. package/src/index.ts +49 -4
  378. package/src/manifest.ts +3062 -0
  379. package/src/manifestTypes.ts +56 -0
  380. package/src/shared.ts +67 -0
  381. package/src/utils.ts +253 -0
  382. package/dist/cjs/guards.js +0 -19
  383. package/dist/cjs/guards.js.map +0 -1
  384. package/dist/cjs/types.js.map +0 -1
  385. package/dist/esm/guards.d.ts +0 -37
  386. package/dist/esm/guards.js +0 -16
  387. package/dist/esm/guards.js.map +0 -1
  388. package/dist/esm/types.d.ts +0 -1569
  389. package/dist/esm/types.js +0 -2
  390. package/dist/esm/types.js.map +0 -1
  391. package/dist/types/guards.d.ts +0 -37
  392. package/dist/types/types.d.ts +0 -1569
  393. package/src/guards.ts +0 -51
  394. package/types.json +0 -37395
@@ -1,1746 +1,7 @@
1
- import type { SchemaTypes } from '@datocms/cma-client';
2
- import type { BlockNodeTypeWithCustomStyle } from 'datocms-structured-text-utils';
3
-
4
- type Account = SchemaTypes.Account;
5
- type Organization = SchemaTypes.Organization;
6
- type Field = SchemaTypes.Field;
7
- type Fieldset = SchemaTypes.Fieldset;
8
- type Item = SchemaTypes.Item;
9
- type ItemType = SchemaTypes.ItemType;
10
- type Plugin = SchemaTypes.Plugin;
11
- type Role = SchemaTypes.Role;
12
- type Site = SchemaTypes.Site;
13
- type SsoUser = SchemaTypes.SsoUser;
14
- type Upload = SchemaTypes.Upload;
15
- type User = SchemaTypes.User;
16
-
17
1
  export type Icon =
18
2
  | AwesomeFontIconIdentifier
19
3
  | { type: 'svg'; viewBox: string; content: string };
20
4
 
21
- export type ItemListLocationQuery = {
22
- locale?: string;
23
- filter?: {
24
- query?: string;
25
- fields?: Record<string, unknown>;
26
- };
27
- };
28
-
29
- export type ItemPresentationInfo = {
30
- /** The title to present the record */
31
- title: string;
32
- /** An image representative of the record */
33
- imageUrl?: string;
34
- /**
35
- * If different plugins implement the `buildItemPresentationInfo` hook, the
36
- * one with the lowest `rank` will be used. If you want to specify an explicit
37
- * value for `rank`, make sure to offer a way for final users to customize it
38
- * inside the plugin's settings form, otherwise the hardcoded value you choose
39
- * might clash with the one of another plugin!
40
- */
41
- rank?: number;
42
- };
43
-
44
- export type InitialLocationQueryForItemSelector = {
45
- locationQuery: ItemListLocationQuery;
46
- /**
47
- * If different plugins implement the `initialLocationQueryForItemSelector`
48
- * hook, the one with the lowest `rank` will be used. If you want to specify
49
- * an explicit value for `rank`, make sure to offer a way for final users to
50
- * customize it inside the plugin's settings form, otherwise the hardcoded
51
- * value you choose might clash with the one of another plugin!
52
- */
53
- rank?: number;
54
- };
55
-
56
- /** A tab to be displayed in the top-bar of the UI */
57
- export type MainNavigationTab = {
58
- /** Label to be shown. Must be unique. */
59
- label: string;
60
- /**
61
- * Icon to be shown alongside the label. Can be a FontAwesome icon name (ie.
62
- * `"address-book"`) or a custom SVG definition. To maintain visual
63
- * consistency with the rest of the interface, try to use FontAwesome icons
64
- * whenever possible.
65
- */
66
- icon: Icon;
67
- /** ID of the page linked to the tab */
68
- pointsTo: {
69
- pageId: string;
70
- };
71
- /**
72
- * Expresses where you want to place the tab in the top-bar. If not specified,
73
- * the tab will be placed after the standard tabs provided by DatoCMS itself.
74
- */
75
- placement?: [
76
- 'before' | 'after',
77
- 'content' | 'media' | 'schema' | 'configuration' | 'cdaPlayground',
78
- ];
79
- /**
80
- * If different plugins specify the same `placement` for their tabs, they will
81
- * be displayed by ascending `rank`. If you want to specify an explicit value
82
- * for `rank`, make sure to offer a way for final users to customize it inside
83
- * the plugin's settings form, otherwise the hardcoded value you choose might
84
- * clash with the one of another plugin!
85
- */
86
- rank?: number;
87
- };
88
-
89
- /** An item contained in a Settings Area group */
90
- export type SettingsAreaSidebarItem = {
91
- /** Label to be shown. Must be unique. */
92
- label: string;
93
- /**
94
- * Icon to be shown alongside the label. Can be a FontAwesome icon name (ie.
95
- * `"address-book"`) or a custom SVG definition. To maintain visual
96
- * consistency with the rest of the interface, try to use FontAwesome icons
97
- * whenever possible.
98
- */
99
- icon: Icon;
100
- /** ID of the page linked to the item */
101
- pointsTo: {
102
- pageId: string;
103
- };
104
- };
105
-
106
- /**
107
- * The sidebar in the Settings Area presents a number of pages grouped by topic.
108
- * This object represents a new group to be added in the sideebar to the
109
- * standard ones DatoCMS provides.
110
- */
111
- export type SettingsAreaSidebarItemGroup = {
112
- /** Label to be shown. Must be unique. */
113
- label: string;
114
- /** The list of items it contains * */
115
- items: SettingsAreaSidebarItem[];
116
- /**
117
- * Expresses where you want the group to be placed inside the sidebar. If not
118
- * specified, the item will be placed after the standard items provided by
119
- * DatoCMS itself.
120
- */
121
- placement?: ['before' | 'after', 'properties' | 'permissions'];
122
- /**
123
- * If different plugins specify the same `placement` for their sections, they
124
- * will be displayed by ascending `rank`. If you want to specify an explicit
125
- * value for `rank`, make sure to offer a way for final users to customize it
126
- * inside the plugin's settings form, otherwise the hardcoded value you choose
127
- * might clash with the one of another plugin!
128
- */
129
- rank?: number;
130
- };
131
-
132
- /**
133
- * The sidebar in the Content Area presents a number of user-defined menu-items.
134
- * This object represents a new item to be added in the sidebar.
135
- */
136
- export type ContentAreaSidebarItem = {
137
- /** Label to be shown. Must be unique. */
138
- label: string;
139
- /**
140
- * Icon to be shown alongside the label. Can be a FontAwesome icon name (ie.
141
- * `"address-book"`) or a custom SVG definition. To maintain visual
142
- * consistency with the rest of the interface, try to use FontAwesome icons
143
- * whenever possible.
144
- */
145
- icon: Icon;
146
- /** ID of the page linked to the item */
147
- pointsTo: {
148
- pageId: string;
149
- };
150
- /**
151
- * Expresses where you want the item to be placed inside the sidebar. If not
152
- * specified, the item will be placed after the standard items provided by
153
- * DatoCMS itself.
154
- */
155
- placement?: ['before' | 'after', 'menuItems' | 'seoPreferences'];
156
- /**
157
- * If different plugins specify the same `placement` for their panels, they
158
- * will be displayed by ascending `rank`. If you want to specify an explicit
159
- * value for `rank`, make sure to offer a way for final users to customize it
160
- * inside the plugin's settings form, otherwise the hardcoded value you choose
161
- * might clash with the one of another plugin!
162
- */
163
- rank?: number;
164
- };
165
-
166
- export type FieldExtensionType = 'editor' | 'addon';
167
-
168
- export type FieldType =
169
- | 'boolean'
170
- | 'color'
171
- | 'date_time'
172
- | 'date'
173
- | 'file'
174
- | 'float'
175
- | 'gallery'
176
- | 'integer'
177
- | 'json'
178
- | 'lat_lon'
179
- | 'link'
180
- | 'links'
181
- | 'rich_text'
182
- | 'seo'
183
- | 'slug'
184
- | 'string'
185
- | 'structured_text'
186
- | 'text'
187
- | 'video';
188
-
189
- /**
190
- * Field extensions extend the basic functionality of DatoCMS when it comes to
191
- * presenting record's fields to the final user. Depending on the extension type
192
- * (`editor` or `addon`) they will be shown in different places of the
193
- * interface.
194
- */
195
- export type ManualFieldExtension = {
196
- /**
197
- * ID of field extension. Will be the first argument for the
198
- * `renderFieldExtension` function
199
- */
200
- id: string;
201
- /** Name to be shown when editing fields */
202
- name: string;
203
- /**
204
- * Type of field extension. An `editor` extension replaces the default field
205
- * editor that DatoCMS provides, while an `addon` extension is placed
206
- * underneath the field editor to provide additional info/behaviour. You can
207
- * setup multiple field addons for every field.
208
- */
209
- type: FieldExtensionType;
210
- /**
211
- * For `editor` extensions: moves the field to the sidebar of the record
212
- * editing page, mimicking a sidebar panel
213
- */
214
- asSidebarPanel?: boolean | { startOpen: boolean };
215
- /**
216
- * The type of fields that the field extension in compatible with. You can use
217
- * the shortcut `all` to target all types of fields
218
- */
219
- fieldTypes: 'all' | FieldType[];
220
- /**
221
- * Whether this field extension needs some configuration options before being
222
- * installed in a field or not. Will trigger the
223
- * `renderManualFieldExtensionConfigScreen` and
224
- * `validateManualFieldExtensionParameters` methods
225
- */
226
- configurable?: boolean | { initialHeight: number };
227
- /**
228
- * The initial height to set for the iframe that will render the field
229
- * extension
230
- */
231
- initialHeight?: number;
232
- };
233
-
234
- export type ItemFormSidebarPanelPlacement = [
235
- 'before' | 'after',
236
- 'info' | 'publishedVersion' | 'schedule' | 'links' | 'history',
237
- ];
238
-
239
- /** A sidebar panel to be shown inside the record's editing page */
240
- export type ItemFormSidebarPanel = {
241
- /**
242
- * ID of the panel. Will be the first argument for the
243
- * `renderItemFormSidebarPanel` function
244
- */
245
- id: string;
246
- /** Label to be shown on the collapsible sidebar panel handle */
247
- label: string;
248
- /**
249
- * An arbitrary configuration object that will be passed as the `parameters`
250
- * property of the second argument of the `renderItemFormSidebarPanel`
251
- * function
252
- */
253
- parameters?: Record<string, unknown>;
254
- /** Whether the sidebar panel will start open or collapsed */
255
- startOpen?: boolean;
256
- /**
257
- * Expresses where you want the item to be placed inside the sidebar. If not
258
- * specified, the item will be placed after the standard panels provided by
259
- * DatoCMS itself.
260
- */
261
- placement?: ItemFormSidebarPanelPlacement;
262
- /**
263
- * If multiple sidebar panels specify the same `placement`, they will be
264
- * sorted by ascending `rank`. If you want to specify an explicit value for
265
- * `rank`, make sure to offer a way for final users to customize it inside the
266
- * plugin's settings form, otherwise the hardcoded value you choose might
267
- * clash with the one of another plugin!
268
- */
269
- rank?: number;
270
- /** The initial height to set for the iframe that will render the sidebar panel */
271
- initialHeight?: number;
272
- };
273
-
274
- /** A sidebar to be shown inside the record's editing page */
275
- export type ItemFormSidebar = {
276
- /**
277
- * ID of the sidebar. Will be the first argument for the
278
- * `renderItemFormSidebar` function
279
- */
280
- id: string;
281
- /** Label to be shown on the collapsible sidebar handle */
282
- label: string;
283
- /**
284
- * An arbitrary configuration object that will be passed as the `parameters`
285
- * property of the second argument of the `renderItemFormSidebar` function
286
- */
287
- parameters?: Record<string, unknown>;
288
- /**
289
- * If multiple sidebars specify the same `placement`, they will be sorted by
290
- * ascending `rank`. If you want to specify an explicit value for `rank`, make
291
- * sure to offer a way for final users to customize it inside the plugin's
292
- * settings form, otherwise the hardcoded value you choose might clash with
293
- * the one of another plugin!
294
- */
295
- rank?: number;
296
- /** The preferred width for the sidebar */
297
- preferredWidth?: number;
298
- };
299
-
300
- /** An outlet to be shown at the top of a record's editing page */
301
- export type ItemFormOutlet = {
302
- /**
303
- * ID of the outlet. Will be the first argument for the `renderItemFormOutlet`
304
- * function
305
- */
306
- id: string;
307
- /**
308
- * Multiple outlets will be sorted by ascending `rank`. If you want to specify
309
- * an explicit value for `rank`, make sure to offer a way for final users to
310
- * customize it inside the plugin's settings form, otherwise the hardcoded
311
- * value you choose might clash with the one of another plugin!
312
- */
313
- rank?: number;
314
- /** The initial height to set for the iframe that will render the outlet */
315
- initialHeight?: number;
316
- };
317
-
318
- /** A field editor/sidebar forced on a field */
319
- export type EditorOverride = {
320
- /**
321
- * ID of field extension. Will be the first argument for the
322
- * `renderFieldExtension` function
323
- */
324
- id: string;
325
- /**
326
- * Moves the field to the sidebar of the record editing page, mimicking a
327
- * sidebar panel
328
- */
329
- asSidebarPanel?:
330
- | boolean
331
- | { startOpen?: boolean; placement?: ItemFormSidebarPanelPlacement };
332
- /**
333
- * An arbitrary configuration object that will be passed as the `parameters`
334
- * property of the second argument of the `renderFieldExtension` function
335
- */
336
- parameters?: Record<string, unknown>;
337
- /**
338
- * If multiple plugins override a field, the one with the lowest `rank` will
339
- * win. If you want to specify an explicit value for `rank`, make sure to
340
- * offer a way for final users to customize it inside the plugin's settings
341
- * form, otherwise the hardcoded value you choose might clash with the one of
342
- * another plugin!
343
- */
344
- rank?: number;
345
- /**
346
- * The initial height to set for the iframe that will render the field
347
- * extension
348
- */
349
- initialHeight?: number;
350
- };
351
-
352
- /** A field addon extension forced on a field */
353
- export type AddonOverride = {
354
- /**
355
- * ID of field extension. Will be the first argument for the
356
- * `renderFieldExtension` function
357
- */
358
- id: string;
359
- /**
360
- * An arbitrary configuration object that will be passed as the `parameters`
361
- * property of the second argument of the `renderFieldExtension` function
362
- */
363
- parameters?: Record<string, unknown>;
364
- /**
365
- * If multiple addons are present for a field, they will be sorted by
366
- * ascending `rank`. If you want to specify an explicit value for `rank`, make
367
- * sure to offer a way for final users to customize it inside the plugin's
368
- * settings form, otherwise the hardcoded value you choose might clash with
369
- * the one of another plugin!
370
- */
371
- rank?: number;
372
- /**
373
- * The initial height to set for the iframe that will render the field
374
- * extension
375
- */
376
- initialHeight?: number;
377
- };
378
-
379
- export type StructuredTextCustomMarkPlacement = [
380
- 'before' | 'after',
381
- 'strong' | 'emphasis' | 'underline' | 'code' | 'highlight' | 'strikethrough',
382
- ];
383
-
384
- /** An object expressing a custom mark for a Structured Text field */
385
- export type StructuredTextCustomMark = {
386
- /** ID of mark */
387
- id: string;
388
- /** Label representing the custom mark */
389
- label: string;
390
- /**
391
- * Icon to be shown alongside the label. Can be a FontAwesome icon name (ie.
392
- * `"address-book"`) or a custom SVG definition. To maintain visual
393
- * consistency with the rest of the interface, try to use FontAwesome icons
394
- * whenever possible
395
- */
396
- icon: Icon;
397
- /**
398
- * Expresses where you want the custom mark button to be placed inside the
399
- * toolbar. If not specified, the item will be placed after the standard marks
400
- * provided by DatoCMS itself.
401
- */
402
- placement?: StructuredTextCustomMarkPlacement;
403
- /**
404
- * If multiple custom marks specify the same `placement` for their toolbar
405
- * button, they will be sorted by ascending `rank`. If you want to specify an
406
- * explicit value for `rank`, make sure to offer a way for final users to
407
- * customize it inside the plugin's settings form, otherwise the hardcoded
408
- * value you choose might clash with the one of another plugin!
409
- */
410
- rank?: number;
411
- /**
412
- * Keyboard shortcut associated with the custom mark, expressed using the
413
- * https://github.com/ianstormtaylor/is-hotkey syntax (ie. `mod+shift+x`)
414
- */
415
- keyboardShortcut?: string;
416
- /** How the custom mark will be styled inside the editor */
417
- appliedStyle: React.CSSProperties;
418
- };
419
-
420
- /** An object expressing a custom block style for a Structured Text field */
421
- export type StructuredTextCustomBlockStyle = {
422
- /** ID of custom block style */
423
- id: string;
424
- /** The block node that can apply this style */
425
- node: BlockNodeTypeWithCustomStyle;
426
- /** ID of custom block style */
427
- label: string;
428
- /** How the block will be styled inside the editor to represent the style */
429
- appliedStyle: React.CSSProperties;
430
- /**
431
- * Custom styles for a block node will be sorted by ascending `rank`. If you
432
- * want to specify an explicit value for `rank`, make sure to offer a way for
433
- * final users to customize it inside the plugin's settings form, otherwise
434
- * the hardcoded value you choose might clash with the one of another plugin!
435
- */
436
- rank?: number;
437
- };
438
-
439
- /**
440
- * An object expressing some field extensions you want to force on a particular
441
- * field
442
- */
443
- export type FieldExtensionOverride = {
444
- /** Force a field editor/sidebar extension on a field */
445
- editor?: EditorOverride;
446
- /** One or more field sidebar extensions to forcefully add to a field */
447
- addons?: AddonOverride[];
448
- };
449
-
450
- /** An object containing the theme colors for the current DatoCMS project */
451
- export type Theme = {
452
- primaryColor: string;
453
- accentColor: string;
454
- semiTransparentAccentColor: string;
455
- lightColor: string;
456
- darkColor: string;
457
- };
458
-
459
- /** Focal point of an image asset */
460
- export type FocalPoint = {
461
- /** Horizontal position expressed as float between 0 and 1 */
462
- x: number;
463
- /** Vertical position expressed as float between 0 and 1 */
464
- y: number;
465
- };
466
-
467
- /** The structure contained in a "single asset" field */
468
- export type FileFieldValue = {
469
- /** ID of the asset */
470
- // eslint-disable-next-line camelcase
471
- upload_id: string;
472
- /** Alternate text for the asset */
473
- alt: string | null;
474
- /** Title for the asset */
475
- title: string | null;
476
- /** Focal point of an asset */
477
- // eslint-disable-next-line camelcase
478
- focal_point: FocalPoint | null;
479
- /** Object with arbitrary metadata related to the asset */
480
- // eslint-disable-next-line camelcase
481
- custom_data: Record<string, string>;
482
- };
483
-
484
- /** A modal to present to the user */
485
- export type Modal = {
486
- /** ID of the modal. Will be the first argument for the `renderModal` function */
487
- id: string;
488
- /** Title for the modal. Ignored by `fullWidth` modals */
489
- title?: string;
490
- /** Whether to present a close button for the modal or not */
491
- closeDisabled?: boolean;
492
- /** Width of the modal. Can be a number, or one of the predefined sizes */
493
- width?: 's' | 'm' | 'l' | 'xl' | 'fullWidth' | number;
494
- /**
495
- * An arbitrary configuration object that will be passed as the `parameters`
496
- * property of the second argument of the `renderModal` function
497
- */
498
- parameters?: Record<string, unknown>;
499
- /** The initial height to set for the iframe that will render the modal content */
500
- initialHeight?: number;
501
- };
502
-
503
- /** An additional asset source */
504
- export type AssetSource = {
505
- /**
506
- * ID of the asset source. Will be the first argument for the
507
- * `renderAssetSource` function
508
- */
509
- id: string;
510
- /** Name of the asset that will be shown to the user */
511
- name: string;
512
- /**
513
- * Icon to be shown alongside the name. Can be a FontAwesome icon name (ie.
514
- * `"address-book"`) or a custom SVG definition. To maintain visual
515
- * consistency with the rest of the interface, try to use FontAwesome icons
516
- * whenever possible.
517
- */
518
- icon: Icon;
519
- /**
520
- * Configuration options for the modal that will be opened to select a media
521
- * file from this source
522
- */
523
- modal?: {
524
- /** Width of the modal. Can be a number, or one of the predefined sizes */
525
- width?: 's' | 'm' | 'l' | 'xl' | number;
526
- /**
527
- * The initial height to set for the iframe that will render the modal
528
- * content
529
- */
530
- initialHeight?: number;
531
- };
532
- };
533
-
534
- /** A toast notification to present to the user */
535
- export type Toast<CtaValue = unknown> = {
536
- /** Message of the notification */
537
- message: string;
538
- /** Type of notification. Will present the toast in a different color accent. */
539
- type: 'notice' | 'alert' | 'warning';
540
- /** An optional button to show inside the toast */
541
- cta?: {
542
- /** Label for the button */
543
- label: string;
544
- /**
545
- * The value to be returned by the `customToast` promise if the button is
546
- * clicked by the user
547
- */
548
- value: CtaValue;
549
- };
550
- /** Whether the toast is to be automatically closed if the user changes page */
551
- dismissOnPageChange?: boolean;
552
- /**
553
- * Whether the toast is to be automatically closed after some time (`true`
554
- * will use the default DatoCMS time interval)
555
- */
556
- dismissAfterTimeout?: boolean | number;
557
- };
558
-
559
- /** A choice presented in a `openConfirm` panel */
560
- export type ConfirmChoice = {
561
- /** The label to be shown for the choice */
562
- label: string;
563
- /**
564
- * The value to be returned by the `openConfirm` promise if the button is
565
- * clicked by the user
566
- */
567
- value: unknown;
568
- /**
569
- * The intent of the button. Will present the button in a different color
570
- * accent.
571
- */
572
- intent?: 'positive' | 'negative';
573
- };
574
-
575
- /** Options for the `openConfirm` function */
576
- export type ConfirmOptions = {
577
- /** The title to be shown inside the confirmation panel */
578
- title: string;
579
- /** The main message to be shown inside the confirmation panel */
580
- content: string;
581
- /** The different options the user can choose from */
582
- choices: ConfirmChoice[];
583
- /** The cancel option to present to the user */
584
- cancel: ConfirmChoice;
585
- };
586
-
587
- /** Generic properties available in all the hooks */
588
- export type CommonProperties = {
589
- /** The current DatoCMS project */
590
- site: Site;
591
- /** The ID of the current environment */
592
- environment: string;
593
- /** All the models of the current DatoCMS project, indexed by ID */
594
- itemTypes: Partial<Record<string, ItemType>>;
595
- /**
596
- * The current DatoCMS user. It can either be the owner or one of the
597
- * collaborators (regular or SSO).
598
- */
599
- currentUser: User | SsoUser | Account | Organization;
600
- /** The role for the current DatoCMS user */
601
- currentRole: Role;
602
- /**
603
- * The access token to perform API calls on behalf of the current user. Only
604
- * available if `currentUserAccessToken` additional permission is granted
605
- */
606
- currentUserAccessToken: string | undefined;
607
- /** The current plugin */
608
- plugin: Plugin;
609
- /**
610
- * UI preferences of the current user (right now, only the preferred locale is
611
- * available)
612
- */
613
- ui: {
614
- /** Preferred locale */
615
- locale: string;
616
- };
617
- };
618
-
619
- export type InitAdditionalProperties = {
620
- mode: 'init';
621
- };
622
-
623
- export type InitProperties = CommonProperties & InitAdditionalProperties;
624
-
625
- export type InitMethods = {
626
- getSettings: () => Promise<InitProperties>;
627
- };
628
-
629
- export type InitPropertiesAndMethods = InitMethods & InitProperties;
630
-
631
- /** Additional properties available in all `renderXXX` hooks */
632
- export type RenderAdditionalProperties = {
633
- /**
634
- * All the fields currently loaded for the current DatoCMS project, indexed by
635
- * ID. It will always contain the current model fields and all the fields of
636
- * the blocks it might contain via Modular Content/Structured Text fields. If
637
- * some fields you need are not present, use the `loadItemTypeFields` function
638
- * to load them.
639
- */
640
- fields: Partial<Record<string, Field>>;
641
- /**
642
- * All the fieldsets currently loaded for the current DatoCMS project, indexed
643
- * by ID. It will always contain the current model fields and all the fields
644
- * of the blocks it might contain via Modular Content/Structured Text fields.
645
- * If some fields you need are not present, use the `loadItemTypeFieldsets`
646
- * function to load them.
647
- */
648
- fieldsets: Partial<Record<string, Fieldset>>;
649
- /** An object containing the theme colors for the current DatoCMS project */
650
- theme: Theme;
651
- /**
652
- * All the regular users currently loaded for the current DatoCMS project,
653
- * indexed by ID. It will always contain the current user. If some users you
654
- * need are not present, use the `loadUsers` function to load them.
655
- */
656
- users: Partial<Record<string, User>>;
657
- /**
658
- * All the SSO users currently loaded for the current DatoCMS project, indexed
659
- * by ID. It will always contain the current user. If some users you need are
660
- * not present, use the `loadSsoUsers` function to load them.
661
- */
662
- ssoUsers: Partial<Record<string, SsoUser>>;
663
- /**
664
- * The account that is the project owner
665
- *
666
- * @deprecated Please use `.owner` instead, as the project owner can also be
667
- * an organization
668
- */
669
- account: Account | undefined;
670
- /** The account that is the project owner */
671
- owner: Account | Organization;
672
- /** The padding in px that must be applied to the body */
673
- bodyPadding: [number, number, number, number];
674
- };
675
-
676
- export type RenderProperties = CommonProperties & RenderAdditionalProperties;
677
-
678
- export type FieldAppearanceChange =
679
- | {
680
- operation: 'removeEditor';
681
- }
682
- | {
683
- operation: 'updateEditor';
684
- newFieldExtensionId?: string;
685
- newParameters?: Record<string, unknown>;
686
- }
687
- | {
688
- operation: 'setEditor';
689
- fieldExtensionId: string;
690
- parameters: Record<string, unknown>;
691
- }
692
- | {
693
- operation: 'removeAddon';
694
- index: number;
695
- }
696
- | {
697
- operation: 'updateAddon';
698
- index: number;
699
- newFieldExtensionId?: string;
700
- newParameters?: Record<string, unknown>;
701
- }
702
- | {
703
- operation: 'insertAddon';
704
- index: number;
705
- fieldExtensionId: string;
706
- parameters: Record<string, unknown>;
707
- };
708
-
709
- /**
710
- * These methods can be used to update both plugin parameters and manual field
711
- * extensions configuration.
712
- */
713
- export type UpdateParametersMethods = {
714
- /**
715
- * Updates the plugin parameters.
716
- *
717
- * Always check `ctx.currentRole.meta.final_permissions.can_edit_schema`
718
- * before calling this, as the user might not have the permission to perform
719
- * the operation.
720
- *
721
- * @example
722
- *
723
- * ```js
724
- * await ctx.updatePluginParameters({ debugMode: true });
725
- * await ctx.notice('Plugin parameters successfully updated!');
726
- * ```
727
- */
728
- updatePluginParameters: (params: Record<string, unknown>) => Promise<void>;
729
- /**
730
- * Performs changes in the appearance of a field. You can install/remove a
731
- * manual field extension, or tweak their parameters. If multiple changes are
732
- * passed, they will be applied sequencially.
733
- *
734
- * Always check `ctx.currentRole.meta.final_permissions.can_edit_schema`
735
- * before calling this, as the user might not have the permission to perform
736
- * the operation.
737
- *
738
- * @example
739
- *
740
- * ```js
741
- * const fields = await ctx.loadFieldsUsingPlugin();
742
- *
743
- * if (fields.length === 0) {
744
- * ctx.alert('No field is using this plugin as a manual extension!');
745
- * return;
746
- * }
747
- *
748
- * for (const field of fields) {
749
- * const { appearance } = field.attributes;
750
- * const operations = [];
751
- *
752
- * if (appearance.editor === ctx.plugin.id) {
753
- * operations.push({
754
- * operation: 'updateEditor',
755
- * newParameters: {
756
- * ...appearance.parameters,
757
- * foo: 'bar',
758
- * },
759
- * });
760
- * }
761
- *
762
- * appearance.addons.forEach((addon, i) => {
763
- * if (addon.id !== ctx.plugin.id) {
764
- * return;
765
- * }
766
- *
767
- * operations.push({
768
- * operation: 'updateAddon',
769
- * index: i,
770
- * newParameters: { ...addon.parameters, foo: 'bar' },
771
- * });
772
- * });
773
- *
774
- * await ctx.updateFieldAppearance(field.id, operations);
775
- * ctx.notice(`Successfully edited field ${field.attributes.api_key}`);
776
- * }
777
- * ```
778
- */
779
- updateFieldAppearance: (
780
- fieldId: string,
781
- changes: FieldAppearanceChange[],
782
- ) => Promise<void>;
783
- };
784
-
785
- /**
786
- * These methods can be used to asyncronously load additional information your
787
- * plugin needs to work
788
- */
789
- export type LoadDataMethods = {
790
- /**
791
- * Loads all the fields for a specific model (or block). Fields will be
792
- * returned and will also be available in the the `fields` property.
793
- *
794
- * @example
795
- *
796
- * ```js
797
- * const itemTypeId = prompt('Please insert a model ID:');
798
- *
799
- * const fields = await ctx.loadItemTypeFields(itemTypeId);
800
- *
801
- * ctx.notice(
802
- * `Success! ${fields
803
- * .map((field) => field.attributes.api_key)
804
- * .join(', ')}`,
805
- * );
806
- * ```
807
- */
808
- loadItemTypeFields: (itemTypeId: string) => Promise<Field[]>;
809
- /**
810
- * Loads all the fieldsets for a specific model (or block). Fieldsets will be
811
- * returned and will also be available in the the `fieldsets` property.
812
- *
813
- * @example
814
- *
815
- * ```js
816
- * const itemTypeId = prompt('Please insert a model ID:');
817
- *
818
- * const fieldsets = await ctx.loadItemTypeFieldsets(itemTypeId);
819
- *
820
- * ctx.notice(
821
- * `Success! ${fieldsets
822
- * .map((fieldset) => fieldset.attributes.title)
823
- * .join(', ')}`,
824
- * );
825
- * ```
826
- */
827
- loadItemTypeFieldsets: (itemTypeId: string) => Promise<Fieldset[]>;
828
- /**
829
- * Loads all the fields in the project that are currently using the plugin for
830
- * one of its manual field extensions.
831
- *
832
- * @example
833
- *
834
- * ```js
835
- * const fields = await ctx.loadFieldsUsingPlugin();
836
- *
837
- * ctx.notice(
838
- * `Success! ${fields
839
- * .map((field) => field.attributes.api_key)
840
- * .join(', ')}`,
841
- * );
842
- * ```
843
- */
844
- loadFieldsUsingPlugin: () => Promise<Field[]>;
845
- /**
846
- * Loads all regular users. Users will be returned and will also be available
847
- * in the the `users` property.
848
- *
849
- * @example
850
- *
851
- * ```js
852
- * const users = await ctx.loadUsers();
853
- *
854
- * ctx.notice(`Success! ${users.map((user) => user.id).join(', ')}`);
855
- * ```
856
- */
857
- loadUsers: () => Promise<User[]>;
858
- /**
859
- * Loads all SSO users. Users will be returned and will also be available in
860
- * the the `ssoUsers` property.
861
- *
862
- * @example
863
- *
864
- * ```js
865
- * const users = await ctx.loadSsoUsers();
866
- *
867
- * ctx.notice(`Success! ${users.map((user) => user.id).join(', ')}`);
868
- * ```
869
- */
870
- loadSsoUsers: () => Promise<SsoUser[]>;
871
- };
872
-
873
- /**
874
- * These methods let you open the standard DatoCMS dialogs needed to interact
875
- * with records
876
- */
877
- export type ItemDialogMethods = {
878
- /**
879
- * Opens a dialog for creating a new record. It returns a promise resolved
880
- * with the newly created record or `null` if the user closes the dialog
881
- * without creating anything.
882
- *
883
- * @example
884
- *
885
- * ```js
886
- * const itemTypeId = prompt('Please insert a model ID:');
887
- *
888
- * const item = await ctx.createNewItem(itemTypeId);
889
- *
890
- * if (item) {
891
- * ctx.notice(`Success! ${item.id}`);
892
- * } else {
893
- * ctx.alert('Closed!');
894
- * }
895
- * ```
896
- */
897
- createNewItem: (itemTypeId: string) => Promise<Item | null>;
898
- /**
899
- * Opens a dialog for selecting one (or multiple) record(s) from a list of
900
- * existing records of type `itemTypeId`. It returns a promise resolved with
901
- * the selected record(s), or `null` if the user closes the dialog without
902
- * choosing any record.
903
- *
904
- * @example
905
- *
906
- * ```js
907
- * const itemTypeId = prompt('Please insert a model ID:');
908
- *
909
- * const items = await ctx.selectItem(itemTypeId, { multiple: true });
910
- *
911
- * if (items) {
912
- * ctx.notice(`Success! ${items.map((i) => i.id).join(', ')}`);
913
- * } else {
914
- * ctx.alert('Closed!');
915
- * }
916
- * ```
917
- */
918
- selectItem: {
919
- (
920
- itemTypeId: string,
921
- options: { multiple: true; initialLocationQuery?: ItemListLocationQuery },
922
- ): Promise<Item[] | null>;
923
- (
924
- itemTypeId: string,
925
- options?: {
926
- multiple: false;
927
- initialLocationQuery?: ItemListLocationQuery;
928
- },
929
- ): Promise<Item | null>;
930
- };
931
- /**
932
- * Opens a dialog for editing an existing record. It returns a promise
933
- * resolved with the edited record, or `null` if the user closes the dialog
934
- * without persisting any change.
935
- *
936
- * @example
937
- *
938
- * ```js
939
- * const itemId = prompt('Please insert a record ID:');
940
- *
941
- * const item = await ctx.editItem(itemId);
942
- *
943
- * if (item) {
944
- * ctx.notice(`Success! ${item.id}`);
945
- * } else {
946
- * ctx.alert('Closed!');
947
- * }
948
- * ```
949
- */
950
- editItem: (itemId: string) => Promise<Item | null>;
951
- };
952
-
953
- /**
954
- * These methods can be used to show UI-consistent toast notifications to the
955
- * end-user
956
- */
957
- export type ToastMethods = {
958
- /**
959
- * Triggers an "error" toast displaying the selected message
960
- *
961
- * @example
962
- *
963
- * ```js
964
- * const message = prompt(
965
- * 'Please insert a message:',
966
- * 'This is an alert message!',
967
- * );
968
- *
969
- * await ctx.alert(message);
970
- * ```
971
- */
972
- alert: (message: string) => Promise<void>;
973
- /**
974
- * Triggers a "success" toast displaying the selected message
975
- *
976
- * @example
977
- *
978
- * ```js
979
- * const message = prompt(
980
- * 'Please insert a message:',
981
- * 'This is a notice message!',
982
- * );
983
- *
984
- * await ctx.notice(message);
985
- * ```
986
- */
987
- notice: (message: string) => Promise<void>;
988
- /**
989
- * Triggers a custom toast displaying the selected message (and optionally a
990
- * CTA)
991
- *
992
- * @example
993
- *
994
- * ```js
995
- * const result = await ctx.customToast({
996
- * type: 'warning',
997
- * message: 'Just a sample warning notification!',
998
- * dismissOnPageChange: true,
999
- * dismissAfterTimeout: 5000,
1000
- * cta: {
1001
- * label: 'Execute call-to-action',
1002
- * value: 'cta',
1003
- * },
1004
- * });
1005
- *
1006
- * if (result === 'cta') {
1007
- * ctx.notice(`Clicked CTA!`);
1008
- * }
1009
- * ```
1010
- */
1011
- customToast: <CtaValue = unknown>(
1012
- toast: Toast<CtaValue>,
1013
- ) => Promise<CtaValue | null>;
1014
- };
1015
-
1016
- /**
1017
- * These methods let you open the standard DatoCMS dialogs needed to interact
1018
- * with Media Area assets
1019
- */
1020
- export type UploadDialogMethods = {
1021
- /**
1022
- * Opens a dialog for selecting one (or multiple) existing asset(s). It
1023
- * returns a promise resolved with the selected asset(s), or `null` if the
1024
- * user closes the dialog without selecting any upload.
1025
- *
1026
- * @example
1027
- *
1028
- * ```js
1029
- * const item = await ctx.selectUpload({ multiple: false });
1030
- *
1031
- * if (item) {
1032
- * ctx.notice(`Success! ${item.id}`);
1033
- * } else {
1034
- * ctx.alert('Closed!');
1035
- * }
1036
- * ```
1037
- */
1038
- selectUpload: {
1039
- (options: { multiple: true }): Promise<Upload[] | null>;
1040
- (options?: { multiple: false }): Promise<Upload | null>;
1041
- };
1042
-
1043
- /**
1044
- * Opens a dialog for editing a Media Area asset. It returns a promise
1045
- * resolved with:
1046
- *
1047
- * - The updated asset, if the user persists some changes to the asset itself
1048
- * - `null`, if the user closes the dialog without persisting any change
1049
- * - An asset structure with an additional `deleted` property set to true, if
1050
- * the user deletes the asset
1051
- *
1052
- * @example
1053
- *
1054
- * ```js
1055
- * const uploadId = prompt('Please insert an asset ID:');
1056
- *
1057
- * const item = await ctx.editUpload(uploadId);
1058
- *
1059
- * if (item) {
1060
- * ctx.notice(`Success! ${item.id}`);
1061
- * } else {
1062
- * ctx.alert('Closed!');
1063
- * }
1064
- * ```
1065
- */
1066
- editUpload: (
1067
- uploadId: string,
1068
- ) => Promise<(Upload & { deleted?: true }) | null>;
1069
- /**
1070
- * Opens a dialog for editing a "single asset" field structure. It returns a
1071
- * promise resolved with the updated structure, or `null` if the user closes
1072
- * the dialog without persisting any change.
1073
- *
1074
- * @example
1075
- *
1076
- * ```js
1077
- * const uploadId = prompt('Please insert an asset ID:');
1078
- *
1079
- * const result = await ctx.editUploadMetadata({
1080
- * upload_id: uploadId,
1081
- * alt: null,
1082
- * title: null,
1083
- * custom_data: {},
1084
- * focal_point: null,
1085
- * });
1086
- *
1087
- * if (result) {
1088
- * ctx.notice(`Success! ${JSON.stringify(result)}`);
1089
- * } else {
1090
- * ctx.alert('Closed!');
1091
- * }
1092
- * ```
1093
- */
1094
- editUploadMetadata: (
1095
- /** The "single asset" field structure */
1096
- fileFieldValue: FileFieldValue,
1097
- /** Shows metadata information for a specific locale */
1098
- locale?: string,
1099
- ) => Promise<FileFieldValue | null>;
1100
- };
1101
-
1102
- /** These methods can be used to open custom dialogs/confirmation panels */
1103
- export type CustomDialogMethods = {
1104
- /**
1105
- * Opens a custom modal. Returns a promise resolved with what the modal itself
1106
- * returns calling the `resolve()` function
1107
- *
1108
- * @example
1109
- *
1110
- * ```js
1111
- * const result = await ctx.openModal({
1112
- * id: 'regular',
1113
- * title: 'Custom title!',
1114
- * width: 'l',
1115
- * parameters: { foo: 'bar' },
1116
- * });
1117
- *
1118
- * if (result) {
1119
- * ctx.notice(`Success! ${JSON.stringify(result)}`);
1120
- * } else {
1121
- * ctx.alert('Closed!');
1122
- * }
1123
- * ```
1124
- */
1125
- openModal: (modal: Modal) => Promise<unknown>;
1126
- /**
1127
- * Opens a UI-consistent confirmation dialog. Returns a promise resolved with
1128
- * the value of the choice made by the user
1129
- *
1130
- * @example
1131
- *
1132
- * ```js
1133
- * const result = await ctx.openConfirm({
1134
- * title: 'Custom title',
1135
- * content:
1136
- * 'Lorem Ipsum is simply dummy text of the printing and typesetting industry',
1137
- * choices: [
1138
- * {
1139
- * label: 'Positive',
1140
- * value: 'positive',
1141
- * intent: 'positive',
1142
- * },
1143
- * {
1144
- * label: 'Negative',
1145
- * value: 'negative',
1146
- * intent: 'negative',
1147
- * },
1148
- * ],
1149
- * cancel: {
1150
- * label: 'Cancel',
1151
- * value: false,
1152
- * },
1153
- * });
1154
- *
1155
- * if (result) {
1156
- * ctx.notice(`Success! ${result}`);
1157
- * } else {
1158
- * ctx.alert('Cancelled!');
1159
- * }
1160
- * ```
1161
- */
1162
- openConfirm: (options: ConfirmOptions) => Promise<unknown>;
1163
- };
1164
-
1165
- /** These methods can be used to take the user to different pages */
1166
- export type NavigateMethods = {
1167
- /**
1168
- * Moves the user to another URL internal to the backend
1169
- *
1170
- * @example
1171
- *
1172
- * ```js
1173
- * await ctx.navigateTo('/');
1174
- * ```
1175
- */
1176
- navigateTo: (path: string) => Promise<void>;
1177
- };
1178
-
1179
- /** These methods can be used to set various properties of the containing iframe */
1180
- export type IframeMethods = {
1181
- /** Sets the height for the iframe */
1182
- setHeight: (number: number) => Promise<void>;
1183
- };
1184
-
1185
- export type RenderMethods = LoadDataMethods &
1186
- UpdateParametersMethods &
1187
- ToastMethods &
1188
- ItemDialogMethods &
1189
- UploadDialogMethods &
1190
- CustomDialogMethods &
1191
- NavigateMethods;
1192
-
1193
- /**
1194
- * These information describe the current state of the form that's being shown
1195
- * to the end-user to edit a record
1196
- */
1197
- export type ItemFormAdditionalProperties = {
1198
- /** The currently active locale for the record */
1199
- locale: string;
1200
- /**
1201
- * If an already persisted record is being edited, returns the full record
1202
- * entity
1203
- */
1204
- item: Item | null;
1205
- /** The model for the record being edited */
1206
- itemType: ItemType;
1207
- /** The complete internal form state */
1208
- formValues: Record<string, unknown>;
1209
- /** The current status of the record being edited */
1210
- itemStatus: 'new' | 'draft' | 'updated' | 'published';
1211
- /** Whether the form is currently submitting itself or not */
1212
- isSubmitting: boolean;
1213
- /** Whether the form has some non-persisted changes or not */
1214
- isFormDirty: boolean;
1215
- /** Current number of blocks present in form state */
1216
- blocksAnalysis: {
1217
- usage: {
1218
- /** Total number of blocks present in form state */
1219
- total: number;
1220
- /** Total number of blocks present in non-localized fields */
1221
- nonLocalized: number;
1222
- /** Total number of blocks present in localized fields, per locale */
1223
- perLocale: Record<string, number>;
1224
- };
1225
- /** Maximum number of blocks per item */
1226
- maximumPerItem: number;
1227
- };
1228
- };
1229
-
1230
- export type ItemFormProperties = RenderProperties &
1231
- ItemFormAdditionalProperties;
1232
-
1233
- /**
1234
- * These methods can be used to interact with the form that's being shown to the
1235
- * end-user to edit a record
1236
- */
1237
- export type ItemFormAdditionalMethods = {
1238
- /**
1239
- * Hides/shows a specific field in the form. Please be aware that when a field
1240
- * is hidden, the field editor for that field will be removed from the DOM
1241
- * itself, including any associated plugins. When it is shown again, its
1242
- * plugins will be reinitialized.
1243
- *
1244
- * @example
1245
- *
1246
- * ```js
1247
- * const fieldPath = prompt(
1248
- * 'Please insert the path of a field in the form',
1249
- * ctx.fieldPath,
1250
- * );
1251
- *
1252
- * await ctx.toggleField(fieldPath, true);
1253
- * ```
1254
- */
1255
- toggleField: (path: string, show: boolean) => Promise<void>;
1256
- /**
1257
- * Disables/re-enables a specific field in the form
1258
- *
1259
- * @example
1260
- *
1261
- * ```js
1262
- * const fieldPath = prompt(
1263
- * 'Please insert the path of a field in the form',
1264
- * ctx.fieldPath,
1265
- * );
1266
- *
1267
- * await ctx.disableField(fieldPath, true);
1268
- * ```
1269
- */
1270
- disableField: (path: string, disable: boolean) => Promise<void>;
1271
- /**
1272
- * Smoothly navigates to a specific field in the form. If the field is
1273
- * localized it will switch language tab and then navigate to the chosen
1274
- * field.
1275
- *
1276
- * @example
1277
- *
1278
- * ```js
1279
- * const fieldPath = prompt(
1280
- * 'Please insert the path of a field in the form',
1281
- * ctx.fieldPath,
1282
- * );
1283
- *
1284
- * await ctx.scrollToField(fieldPath);
1285
- * ```
1286
- */
1287
- scrollToField: (path: string, locale?: string) => Promise<void>;
1288
- /**
1289
- * Changes a specific path of the `formValues` object
1290
- *
1291
- * @example
1292
- *
1293
- * ```js
1294
- * const fieldPath = prompt(
1295
- * 'Please insert the path of a field in the form',
1296
- * ctx.fieldPath,
1297
- * );
1298
- *
1299
- * await ctx.setFieldValue(fieldPath, 'new value');
1300
- * ```
1301
- */
1302
- setFieldValue: (path: string, value: unknown) => Promise<void>;
1303
- /**
1304
- * Takes the internal form state, and transforms it into an Item entity
1305
- * compatible with DatoCMS API.
1306
- *
1307
- * When `skipUnchangedFields`, only the fields that changed value will be
1308
- * serialized.
1309
- *
1310
- * If the required nested blocks are still not loaded, this method will return
1311
- * `undefined`.
1312
- *
1313
- * @example
1314
- *
1315
- * ```js
1316
- * await ctx.formValuesToItem(ctx.formValues, false);
1317
- * ```
1318
- */
1319
- formValuesToItem: (
1320
- formValues: Record<string, unknown>,
1321
- skipUnchangedFields?: boolean,
1322
- ) => Promise<Omit<Item, 'id' | 'meta'> | undefined>;
1323
- /**
1324
- * Takes an Item entity, and converts it into the internal form state
1325
- *
1326
- * @example
1327
- *
1328
- * ```js
1329
- * await ctx.itemToFormValues(ctx.item);
1330
- * ```
1331
- */
1332
- itemToFormValues: (
1333
- item: Omit<Item, 'id' | 'meta'>,
1334
- ) => Promise<Record<string, unknown>>;
1335
- /**
1336
- * Triggers a submit form for current record
1337
- *
1338
- * @example
1339
- *
1340
- * ```js
1341
- * await ctx.saveCurrentItem();
1342
- * ```
1343
- */
1344
- saveCurrentItem: (showToast?: boolean) => Promise<void>;
1345
- };
1346
-
1347
- export type ItemFormMethods = RenderMethods &
1348
- IframeMethods &
1349
- ItemFormAdditionalMethods;
1350
-
1351
- /** Information regarding the specific sidebar panel that you need to render */
1352
- export type RenderSidebarPanelAdditionalProperties = {
1353
- mode: 'renderItemFormSidebarPanel';
1354
- /** The ID of the sidebar panel that needs to be rendered */
1355
- sidebarPaneId: string;
1356
- /**
1357
- * The arbitrary `parameters` of the panel declared in the
1358
- * `itemFormSidebarPanels` function
1359
- */
1360
- parameters: Record<string, unknown>;
1361
- };
1362
-
1363
- export type RenderSidebarPanelProperties = ItemFormProperties &
1364
- RenderSidebarPanelAdditionalProperties;
1365
-
1366
- export type RenderSidebarPanelAdditionalMethods = {
1367
- getSettings: () => Promise<RenderSidebarPanelProperties>;
1368
- };
1369
-
1370
- export type RenderSidebarPanelMethods = ItemFormMethods &
1371
- RenderSidebarPanelAdditionalMethods;
1372
-
1373
- export type RenderSidebarPanelPropertiesAndMethods = RenderSidebarPanelMethods &
1374
- RenderSidebarPanelProperties;
1375
-
1376
- /** Information regarding the specific sidebar panel that you need to render */
1377
- export type RenderSidebarAdditionalProperties = {
1378
- mode: 'renderItemFormSidebar';
1379
- /** The ID of the sidebar that needs to be rendered */
1380
- sidebarId: string;
1381
- /**
1382
- * The arbitrary `parameters` of the declared in the `itemFormSidebars`
1383
- * function
1384
- */
1385
- parameters: Record<string, unknown>;
1386
- };
1387
-
1388
- export type RenderSidebarProperties = ItemFormProperties &
1389
- RenderSidebarAdditionalProperties;
1390
-
1391
- export type RenderSidebarAdditionalMethods = {
1392
- getSettings: () => Promise<RenderSidebarProperties>;
1393
- };
1394
-
1395
- export type RenderSidebarMethods = ItemFormMethods &
1396
- RenderSidebarAdditionalMethods;
1397
-
1398
- export type RenderSidebarPropertiesAndMethods = RenderSidebarMethods &
1399
- RenderSidebarProperties;
1400
-
1401
- /** Information regarding the specific outlet that you need to render */
1402
- export type RenderItemFormOutletAdditionalProperties = {
1403
- mode: 'renderItemFormOutlet';
1404
- /** The ID of the outlet that needs to be rendered */
1405
- itemFormOutletId: string;
1406
- };
1407
-
1408
- export type RenderItemFormOutletProperties = ItemFormProperties &
1409
- RenderItemFormOutletAdditionalProperties;
1410
-
1411
- export type RenderItemFormOutletAdditionalMethods = {
1412
- getSettings: () => Promise<RenderItemFormOutletProperties>;
1413
- };
1414
-
1415
- export type RenderItemFormOutletMethods = ItemFormMethods &
1416
- RenderItemFormOutletAdditionalMethods;
1417
-
1418
- export type RenderItemFormOutletPropertiesAndMethods =
1419
- RenderItemFormOutletMethods & RenderItemFormOutletProperties;
1420
-
1421
- /**
1422
- * Information regarding the state of a specific field where you need to render
1423
- * the field extension
1424
- */
1425
- export type RenderFieldExtensionAdditionalProperties = {
1426
- mode: 'renderFieldExtension';
1427
- /** The ID of the field extension that needs to be rendered */
1428
- fieldExtensionId: string;
1429
- /** The arbitrary `parameters` of the field extension */
1430
- parameters: Record<string, unknown>;
1431
- /** Whether the field is currently disabled or not */
1432
- disabled: boolean;
1433
- /**
1434
- * The path in the `formValues` object where to find the current value for the
1435
- * field
1436
- */
1437
- fieldPath: string;
1438
- /** The field where the field extension is installed to */
1439
- field: Field;
1440
- /**
1441
- * If the field extension is installed in a field of a block, returns the top
1442
- * level Modular Content/Structured Text field containing the block itself
1443
- */
1444
- parentField: Field | undefined;
1445
- /**
1446
- * If the field extension is installed in a field of a block, returns the ID
1447
- * of the block — or `undefined` if the block is still not persisted — and the
1448
- * block model.
1449
- */
1450
- block: undefined | { id: string | undefined; blockModel: ItemType };
1451
- };
1452
-
1453
- export type RenderFieldExtensionProperties = ItemFormProperties &
1454
- RenderFieldExtensionAdditionalProperties;
1455
-
1456
- export type RenderFieldExtensionAdditionalMethods = {
1457
- getSettings: () => Promise<RenderFieldExtensionProperties>;
1458
- };
1459
-
1460
- export type RenderFieldExtensionMethods = ItemFormMethods &
1461
- RenderFieldExtensionAdditionalMethods;
1462
-
1463
- export type RenderFieldExtensionPropertiesAndMethods =
1464
- RenderFieldExtensionMethods & RenderFieldExtensionProperties;
1465
-
1466
- /** Information regarding the specific custom modal that you need to render */
1467
- export type RenderModalAdditionalProperties = {
1468
- mode: 'renderModal';
1469
- /** The ID of the modal that needs to be rendered */
1470
- modalId: string;
1471
- /**
1472
- * The arbitrary `parameters` of the modal declared in the `openModal`
1473
- * function
1474
- */
1475
- parameters: Record<string, unknown>;
1476
- };
1477
-
1478
- export type RenderModalProperties = RenderProperties &
1479
- RenderModalAdditionalProperties;
1480
-
1481
- /** These methods can be used to close the modal */
1482
- export type RenderModalAdditionalMethods = {
1483
- getSettings: () => Promise<RenderModalProperties>;
1484
- /**
1485
- * A function to be called by the plugin to close the modal. The `openModal`
1486
- * call will be resolved with the passed return value
1487
- *
1488
- * @example
1489
- *
1490
- * ```js
1491
- * const returnValue = prompt(
1492
- * 'Please specify the value to return to the caller:',
1493
- * 'success',
1494
- * );
1495
- *
1496
- * await ctx.resolve(returnValue);
1497
- * ```
1498
- */
1499
- resolve: (returnValue: unknown) => Promise<void>;
1500
- };
1501
-
1502
- export type RenderModalMethods = RenderMethods &
1503
- IframeMethods &
1504
- RenderModalAdditionalMethods;
1505
-
1506
- export type RenderModalPropertiesAndMethods = RenderModalMethods &
1507
- RenderModalProperties;
1508
-
1509
- /**
1510
- * Information regarding the specific asset source browser that you need to
1511
- * render
1512
- */
1513
- export type RenderAssetSourceAdditionalProperties = {
1514
- mode: 'renderAssetSource';
1515
- /** The ID of the assetSource that needs to be rendered */
1516
- assetSourceId: string;
1517
- };
1518
-
1519
- export type RenderAssetSourceProperties = RenderProperties &
1520
- RenderAssetSourceAdditionalProperties;
1521
-
1522
- export type NewUploadResourceAsUrl = {
1523
- /**
1524
- * URL for the resource. The URL must respond with a
1525
- * `Access-Control-Allow-Origin` header — for instance `*`, which will allow
1526
- * all hosts — allowing the image to be read by DatoCMS
1527
- */
1528
- url: string;
1529
- /** Any additional headers to pass when making the request to the URL */
1530
- headers?: Record<string, string>;
1531
- /**
1532
- * Optional filename to be used to generate the final DatoCMS URL. If not
1533
- * passed, the URL will be used
1534
- */
1535
- filename?: string;
1536
- };
1537
-
1538
- export type NewUploadResourceAsBase64 = {
1539
- /**
1540
- * Base64 encoded data URI for the resource.
1541
- *
1542
- * Format:
1543
- *
1544
- * `data:[<mime type>][;charset=<charset>];base64,<encoded data>`
1545
- */
1546
- base64: string;
1547
- /** Filename to be used to generate the final DatoCMS URL */
1548
- filename: string;
1549
- };
1550
-
1551
- export type NewUpload = {
1552
- /** The actual resource that will be uploaded */
1553
- resource: NewUploadResourceAsUrl | NewUploadResourceAsBase64;
1554
- /** Copyright to apply to the asset */
1555
- copyright?: string;
1556
- /** Author to apply to the asset */
1557
- author?: string;
1558
- /** Notes to apply to the asset */
1559
- notes?: string;
1560
- /** Tags to apply to the asset */
1561
- tags?: string[];
1562
- /**
1563
- * An hash containing, for each locale of the project, the default metadata to
1564
- * apply to the asset
1565
- */
1566
- default_field_metadata?: {
1567
- [k: string]: {
1568
- /** Alternate text for the asset */
1569
- alt: string | null;
1570
- /** Title for the asset */
1571
- title: string | null;
1572
- /** Object with arbitrary metadata */
1573
- custom_data: {
1574
- [k: string]: unknown;
1575
- };
1576
- /** Focal point (only for image assets) */
1577
- focal_point?: {
1578
- /** Horizontal position expressed as float between 0 and 1 */
1579
- x: number;
1580
- /** Vertical position expressed as float between 0 and 1 */
1581
- y: number;
1582
- } | null;
1583
- };
1584
- };
1585
- };
1586
-
1587
- /** Use these methods to confirm */
1588
- export type RenderAssetSourceAdditionalMethods = {
1589
- getSettings: () => Promise<RenderAssetSourceProperties>;
1590
- /**
1591
- * Function to be called when the user selects the asset: it will trigger the
1592
- * creation of a new `Upload` that will be added in the Media Area.
1593
- *
1594
- * @example
1595
- *
1596
- * ```js
1597
- * await ctx.select({
1598
- * resource: {
1599
- * url: 'https://images.unsplash.com/photo-1416339306562-f3d12fefd36f',
1600
- * filename: 'man-drinking-coffee.jpg',
1601
- * },
1602
- * copyright: 'Royalty free (Unsplash)',
1603
- * author: 'Jeff Sheldon',
1604
- * notes: 'A man drinking a coffee',
1605
- * tags: ['man', 'coffee'],
1606
- * });
1607
- * ```
1608
- */
1609
- select: (newUpload: NewUpload) => void;
1610
- };
1611
-
1612
- export type RenderAssetSourceMethods = RenderMethods &
1613
- IframeMethods &
1614
- RenderAssetSourceAdditionalMethods;
1615
-
1616
- export type RenderAssetSourcePropertiesAndMethods = RenderAssetSourceMethods &
1617
- RenderAssetSourceProperties;
1618
-
1619
- /** Information regarding the specific page that you need to render */
1620
- export type RenderPageAdditionalProperties = {
1621
- mode: 'renderPage';
1622
- /** The ID of the page that needs to be rendered */
1623
- pageId: string;
1624
- };
1625
-
1626
- export type RenderPageProperties = RenderProperties &
1627
- RenderPageAdditionalProperties;
1628
-
1629
- export type RenderPageAdditionalMethods = {
1630
- getSettings: () => Promise<RenderPageProperties>;
1631
- };
1632
-
1633
- export type RenderPageMethods = RenderMethods & RenderPageAdditionalMethods;
1634
-
1635
- export type RenderPagePropertiesAndMethods = RenderPageMethods &
1636
- RenderPageProperties;
1637
-
1638
- export type PendingField = {
1639
- id?: string;
1640
- type: 'field';
1641
- attributes: {
1642
- api_key: Field['attributes']['api_key'];
1643
- appearance: Field['attributes']['appearance'];
1644
- default_value: Field['attributes']['default_value'];
1645
- field_type: Field['attributes']['field_type'];
1646
- hint: Field['attributes']['hint'];
1647
- label: Field['attributes']['label'];
1648
- localized: Field['attributes']['localized'];
1649
- validators: Field['attributes']['validators'];
1650
- };
1651
- };
1652
-
1653
- /**
1654
- * Information regarding the specific form that you need to render to let the
1655
- * end-user edit the configuration object of a field extension
1656
- */
1657
- export type RenderManualFieldExtensionConfigScreenAdditionalProperties = {
1658
- mode: 'renderManualFieldExtensionConfigScreen';
1659
- /**
1660
- * The ID of the field extension for which we need to render the parameters
1661
- * form
1662
- */
1663
- fieldExtensionId: string;
1664
- /**
1665
- * The current value of the parameters (you can change the value with the
1666
- * `setParameters` function)
1667
- */
1668
- parameters: Record<string, unknown>;
1669
- /**
1670
- * The current validation errors for the parameters (you can set them
1671
- * implementing the `validateManualFieldExtensionParameters` function)
1672
- */
1673
- errors: Record<string, unknown>;
1674
-
1675
- /** The field entity that is being edited in the form */
1676
- pendingField: PendingField;
1677
-
1678
- /** The model for the field being edited */
1679
- itemType: ItemType;
1680
- };
1681
-
1682
- export type RenderManualFieldExtensionConfigScreenProperties =
1683
- RenderProperties & RenderManualFieldExtensionConfigScreenAdditionalProperties;
1684
-
1685
- /**
1686
- * These methods can be used to update the configuration object of a specific
1687
- * field extension
1688
- */
1689
- export type RenderManualFieldExtensionConfigScreenAdditionalMethods = {
1690
- getSettings: () => Promise<RenderManualFieldExtensionConfigScreenProperties>;
1691
- /**
1692
- * Sets a new value for the parameters
1693
- *
1694
- * @example
1695
- *
1696
- * ```js
1697
- * await ctx.setParameters({ color: '#ff0000' });
1698
- * ```
1699
- */
1700
- setParameters: (params: Record<string, unknown>) => Promise<void>;
1701
- };
1702
-
1703
- export type RenderManualFieldExtensionConfigScreenMethods = RenderMethods &
1704
- IframeMethods &
1705
- RenderManualFieldExtensionConfigScreenAdditionalMethods;
1706
-
1707
- export type RenderManualFieldExtensionConfigScreenPropertiesAndMethods =
1708
- RenderManualFieldExtensionConfigScreenMethods &
1709
- RenderManualFieldExtensionConfigScreenProperties;
1710
-
1711
- export type RenderConfigScreenAdditionalProperties = {
1712
- mode: 'renderConfigScreen';
1713
- };
1714
-
1715
- export type RenderConfigScreenProperties = RenderProperties &
1716
- RenderConfigScreenAdditionalProperties;
1717
-
1718
- /** These methods can be used to update the configuration object of your plugin */
1719
- export type RenderConfigScreenAdditionalMethods = {
1720
- getSettings: () => Promise<RenderConfigScreenProperties>;
1721
- };
1722
-
1723
- export type RenderConfigScreenMethods = RenderMethods &
1724
- IframeMethods &
1725
- RenderConfigScreenAdditionalMethods;
1726
-
1727
- export type RenderConfigScreenPropertiesAndMethods = RenderConfigScreenMethods &
1728
- RenderConfigScreenProperties;
1729
-
1730
- export type OnBootAdditionalProperties = {
1731
- mode: 'onBoot';
1732
- };
1733
-
1734
- export type OnBootProperties = RenderProperties & OnBootAdditionalProperties;
1735
-
1736
- export type OnBootAdditionalMethods = {
1737
- getSettings: () => Promise<OnBootProperties>;
1738
- };
1739
-
1740
- export type OnBootMethods = RenderMethods & OnBootAdditionalMethods;
1741
-
1742
- export type OnBootPropertiesAndMethods = OnBootMethods & OnBootProperties;
1743
-
1744
5
  export type AwesomeFontIconIdentifier =
1745
6
  | '0'
1746
7
  | '00'