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
@@ -0,0 +1,670 @@
1
+ import type { SchemaTypes } from '@datocms/cma-client';
2
+ type Account = SchemaTypes.Account;
3
+ type Field = SchemaTypes.Field;
4
+ type Fieldset = SchemaTypes.Fieldset;
5
+ type Item = SchemaTypes.Item;
6
+ type ItemType = SchemaTypes.ItemType;
7
+ type Organization = SchemaTypes.Organization;
8
+ type Plugin = SchemaTypes.Plugin;
9
+ type Role = SchemaTypes.Role;
10
+ type Site = SchemaTypes.Site;
11
+ type SsoUser = SchemaTypes.SsoUser;
12
+ type Upload = SchemaTypes.Upload;
13
+ type User = SchemaTypes.User;
14
+ export type Ctx<AdditionalProperties extends Record<string, unknown> = Record<string, never>, AdditionalMethods extends Record<string, unknown> = Record<string, never>> = BaseProperties & AdditionalProperties & BaseMethods & AdditionalMethods;
15
+ /** Generic properties available in all the hooks */
16
+ export type BaseProperties = {
17
+ /** The current DatoCMS project */
18
+ site: Site;
19
+ /** The ID of the current environment */
20
+ environment: string;
21
+ /** All the models of the current DatoCMS project, indexed by ID */
22
+ itemTypes: Partial<Record<string, ItemType>>;
23
+ /**
24
+ * The current DatoCMS user. It can either be the owner or one of the
25
+ * collaborators (regular or SSO).
26
+ */
27
+ currentUser: User | SsoUser | Account | Organization;
28
+ /** The role for the current DatoCMS user */
29
+ currentRole: Role;
30
+ /**
31
+ * The access token to perform API calls on behalf of the current user. Only
32
+ * available if `currentUserAccessToken` additional permission is granted
33
+ */
34
+ currentUserAccessToken: string | undefined;
35
+ /** The current plugin */
36
+ plugin: Plugin;
37
+ /**
38
+ * UI preferences of the current user (right now, only the preferred locale is
39
+ * available)
40
+ */
41
+ ui: {
42
+ /** Preferred locale */
43
+ locale: string;
44
+ };
45
+ /**
46
+ * All the fields currently loaded for the current DatoCMS project, indexed by
47
+ * ID. It will always contain the current model fields and all the fields of
48
+ * the blocks it might contain via Modular Content/Structured Text fields. If
49
+ * some fields you need are not present, use the `loadItemTypeFields` function
50
+ * to load them.
51
+ */
52
+ fields: Partial<Record<string, Field>>;
53
+ /**
54
+ * All the fieldsets currently loaded for the current DatoCMS project, indexed
55
+ * by ID. It will always contain the current model fields and all the fields
56
+ * of the blocks it might contain via Modular Content/Structured Text fields.
57
+ * If some fields you need are not present, use the `loadItemTypeFieldsets`
58
+ * function to load them.
59
+ */
60
+ fieldsets: Partial<Record<string, Fieldset>>;
61
+ /** An object containing the theme colors for the current DatoCMS project */
62
+ theme: Theme;
63
+ /**
64
+ * All the regular users currently loaded for the current DatoCMS project,
65
+ * indexed by ID. It will always contain the current user. If some users you
66
+ * need are not present, use the `loadUsers` function to load them.
67
+ */
68
+ users: Partial<Record<string, User>>;
69
+ /**
70
+ * All the SSO users currently loaded for the current DatoCMS project, indexed
71
+ * by ID. It will always contain the current user. If some users you need are
72
+ * not present, use the `loadSsoUsers` function to load them.
73
+ */
74
+ ssoUsers: Partial<Record<string, SsoUser>>;
75
+ /**
76
+ * The account that is the project owner
77
+ *
78
+ * @deprecated Please use `.owner` instead, as the project owner can also be
79
+ * an organization
80
+ */
81
+ account: Account | undefined;
82
+ /** The account that is the project owner */
83
+ owner: Account | Organization;
84
+ };
85
+ /** An object containing the theme colors for the current DatoCMS project */
86
+ export type Theme = {
87
+ primaryColor: string;
88
+ accentColor: string;
89
+ semiTransparentAccentColor: string;
90
+ lightColor: string;
91
+ darkColor: string;
92
+ };
93
+ export type BaseMethods = LoadDataMethods & UpdateParametersMethods & ToastMethods & ItemDialogMethods & UploadDialogMethods & CustomDialogMethods & NavigateMethods;
94
+ /**
95
+ * These methods can be used to asyncronously load additional information your
96
+ * plugin needs to work
97
+ */
98
+ type LoadDataMethods = {
99
+ /**
100
+ * Loads all the fields for a specific model (or block). Fields will be
101
+ * returned and will also be available in the the `fields` property.
102
+ *
103
+ * @example
104
+ *
105
+ * ```js
106
+ * const itemTypeId = prompt('Please insert a model ID:');
107
+ *
108
+ * const fields = await ctx.loadItemTypeFields(itemTypeId);
109
+ *
110
+ * ctx.notice(
111
+ * `Success! ${fields
112
+ * .map((field) => field.attributes.api_key)
113
+ * .join(', ')}`,
114
+ * );
115
+ * ```
116
+ */
117
+ loadItemTypeFields: (itemTypeId: string) => Promise<Field[]>;
118
+ /**
119
+ * Loads all the fieldsets for a specific model (or block). Fieldsets will be
120
+ * returned and will also be available in the the `fieldsets` property.
121
+ *
122
+ * @example
123
+ *
124
+ * ```js
125
+ * const itemTypeId = prompt('Please insert a model ID:');
126
+ *
127
+ * const fieldsets = await ctx.loadItemTypeFieldsets(itemTypeId);
128
+ *
129
+ * ctx.notice(
130
+ * `Success! ${fieldsets
131
+ * .map((fieldset) => fieldset.attributes.title)
132
+ * .join(', ')}`,
133
+ * );
134
+ * ```
135
+ */
136
+ loadItemTypeFieldsets: (itemTypeId: string) => Promise<Fieldset[]>;
137
+ /**
138
+ * Loads all the fields in the project that are currently using the plugin for
139
+ * one of its manual field extensions.
140
+ *
141
+ * @example
142
+ *
143
+ * ```js
144
+ * const fields = await ctx.loadFieldsUsingPlugin();
145
+ *
146
+ * ctx.notice(
147
+ * `Success! ${fields
148
+ * .map((field) => field.attributes.api_key)
149
+ * .join(', ')}`,
150
+ * );
151
+ * ```
152
+ */
153
+ loadFieldsUsingPlugin: () => Promise<Field[]>;
154
+ /**
155
+ * Loads all regular users. Users will be returned and will also be available
156
+ * in the the `users` property.
157
+ *
158
+ * @example
159
+ *
160
+ * ```js
161
+ * const users = await ctx.loadUsers();
162
+ *
163
+ * ctx.notice(`Success! ${users.map((user) => user.id).join(', ')}`);
164
+ * ```
165
+ */
166
+ loadUsers: () => Promise<User[]>;
167
+ /**
168
+ * Loads all SSO users. Users will be returned and will also be available in
169
+ * the the `ssoUsers` property.
170
+ *
171
+ * @example
172
+ *
173
+ * ```js
174
+ * const users = await ctx.loadSsoUsers();
175
+ *
176
+ * ctx.notice(`Success! ${users.map((user) => user.id).join(', ')}`);
177
+ * ```
178
+ */
179
+ loadSsoUsers: () => Promise<SsoUser[]>;
180
+ };
181
+ /**
182
+ * These methods can be used to update both plugin parameters and manual field
183
+ * extensions configuration.
184
+ */
185
+ type UpdateParametersMethods = {
186
+ /**
187
+ * Updates the plugin parameters.
188
+ *
189
+ * Always check `ctx.currentRole.meta.final_permissions.can_edit_schema`
190
+ * before calling this, as the user might not have the permission to perform
191
+ * the operation.
192
+ *
193
+ * @example
194
+ *
195
+ * ```js
196
+ * await ctx.updatePluginParameters({ debugMode: true });
197
+ * await ctx.notice('Plugin parameters successfully updated!');
198
+ * ```
199
+ */
200
+ updatePluginParameters: (params: Record<string, unknown>) => Promise<void>;
201
+ /**
202
+ * Performs changes in the appearance of a field. You can install/remove a
203
+ * manual field extension, or tweak their parameters. If multiple changes are
204
+ * passed, they will be applied sequencially.
205
+ *
206
+ * Always check `ctx.currentRole.meta.final_permissions.can_edit_schema`
207
+ * before calling this, as the user might not have the permission to perform
208
+ * the operation.
209
+ *
210
+ * @example
211
+ *
212
+ * ```js
213
+ * const fields = await ctx.loadFieldsUsingPlugin();
214
+ *
215
+ * if (fields.length === 0) {
216
+ * ctx.alert('No field is using this plugin as a manual extension!');
217
+ * return;
218
+ * }
219
+ *
220
+ * for (const field of fields) {
221
+ * const { appearance } = field.attributes;
222
+ * const operations = [];
223
+ *
224
+ * if (appearance.editor === ctx.plugin.id) {
225
+ * operations.push({
226
+ * operation: 'updateEditor',
227
+ * newParameters: {
228
+ * ...appearance.parameters,
229
+ * foo: 'bar',
230
+ * },
231
+ * });
232
+ * }
233
+ *
234
+ * appearance.addons.forEach((addon, i) => {
235
+ * if (addon.id !== ctx.plugin.id) {
236
+ * return;
237
+ * }
238
+ *
239
+ * operations.push({
240
+ * operation: 'updateAddon',
241
+ * index: i,
242
+ * newParameters: { ...addon.parameters, foo: 'bar' },
243
+ * });
244
+ * });
245
+ *
246
+ * await ctx.updateFieldAppearance(field.id, operations);
247
+ * ctx.notice(`Successfully edited field ${field.attributes.api_key}`);
248
+ * }
249
+ * ```
250
+ */
251
+ updateFieldAppearance: (fieldId: string, changes: FieldAppearanceChange[]) => Promise<void>;
252
+ };
253
+ /**
254
+ * These methods let you open the standard DatoCMS dialogs needed to interact
255
+ * with records
256
+ */
257
+ type ItemDialogMethods = {
258
+ /**
259
+ * Opens a dialog for creating a new record. It returns a promise resolved
260
+ * with the newly created record or `null` if the user closes the dialog
261
+ * without creating anything.
262
+ *
263
+ * @example
264
+ *
265
+ * ```js
266
+ * const itemTypeId = prompt('Please insert a model ID:');
267
+ *
268
+ * const item = await ctx.createNewItem(itemTypeId);
269
+ *
270
+ * if (item) {
271
+ * ctx.notice(`Success! ${item.id}`);
272
+ * } else {
273
+ * ctx.alert('Closed!');
274
+ * }
275
+ * ```
276
+ */
277
+ createNewItem: (itemTypeId: string) => Promise<Item | null>;
278
+ /**
279
+ * Opens a dialog for selecting one (or multiple) record(s) from a list of
280
+ * existing records of type `itemTypeId`. It returns a promise resolved with
281
+ * the selected record(s), or `null` if the user closes the dialog without
282
+ * choosing any record.
283
+ *
284
+ * @example
285
+ *
286
+ * ```js
287
+ * const itemTypeId = prompt('Please insert a model ID:');
288
+ *
289
+ * const items = await ctx.selectItem(itemTypeId, { multiple: true });
290
+ *
291
+ * if (items) {
292
+ * ctx.notice(`Success! ${items.map((i) => i.id).join(', ')}`);
293
+ * } else {
294
+ * ctx.alert('Closed!');
295
+ * }
296
+ * ```
297
+ */
298
+ selectItem: {
299
+ (itemTypeId: string, options: {
300
+ multiple: true;
301
+ initialLocationQuery?: ItemListLocationQuery;
302
+ }): Promise<Item[] | null>;
303
+ (itemTypeId: string, options?: {
304
+ multiple: false;
305
+ initialLocationQuery?: ItemListLocationQuery;
306
+ }): Promise<Item | null>;
307
+ };
308
+ /**
309
+ * Opens a dialog for editing an existing record. It returns a promise
310
+ * resolved with the edited record, or `null` if the user closes the dialog
311
+ * without persisting any change.
312
+ *
313
+ * @example
314
+ *
315
+ * ```js
316
+ * const itemId = prompt('Please insert a record ID:');
317
+ *
318
+ * const item = await ctx.editItem(itemId);
319
+ *
320
+ * if (item) {
321
+ * ctx.notice(`Success! ${item.id}`);
322
+ * } else {
323
+ * ctx.alert('Closed!');
324
+ * }
325
+ * ```
326
+ */
327
+ editItem: (itemId: string) => Promise<Item | null>;
328
+ };
329
+ /**
330
+ * These methods can be used to show UI-consistent toast notifications to the
331
+ * end-user
332
+ */
333
+ type ToastMethods = {
334
+ /**
335
+ * Triggers an "error" toast displaying the selected message
336
+ *
337
+ * @example
338
+ *
339
+ * ```js
340
+ * const message = prompt(
341
+ * 'Please insert a message:',
342
+ * 'This is an alert message!',
343
+ * );
344
+ *
345
+ * await ctx.alert(message);
346
+ * ```
347
+ */
348
+ alert: (message: string) => Promise<void>;
349
+ /**
350
+ * Triggers a "success" toast displaying the selected message
351
+ *
352
+ * @example
353
+ *
354
+ * ```js
355
+ * const message = prompt(
356
+ * 'Please insert a message:',
357
+ * 'This is a notice message!',
358
+ * );
359
+ *
360
+ * await ctx.notice(message);
361
+ * ```
362
+ */
363
+ notice: (message: string) => Promise<void>;
364
+ /**
365
+ * Triggers a custom toast displaying the selected message (and optionally a
366
+ * CTA)
367
+ *
368
+ * @example
369
+ *
370
+ * ```js
371
+ * const result = await ctx.customToast({
372
+ * type: 'warning',
373
+ * message: 'Just a sample warning notification!',
374
+ * dismissOnPageChange: true,
375
+ * dismissAfterTimeout: 5000,
376
+ * cta: {
377
+ * label: 'Execute call-to-action',
378
+ * value: 'cta',
379
+ * },
380
+ * });
381
+ *
382
+ * if (result === 'cta') {
383
+ * ctx.notice(`Clicked CTA!`);
384
+ * }
385
+ * ```
386
+ */
387
+ customToast: <CtaValue = unknown>(toast: Toast<CtaValue>) => Promise<CtaValue | null>;
388
+ };
389
+ /**
390
+ * These methods let you open the standard DatoCMS dialogs needed to interact
391
+ * with Media Area assets
392
+ */
393
+ type UploadDialogMethods = {
394
+ /**
395
+ * Opens a dialog for selecting one (or multiple) existing asset(s). It
396
+ * returns a promise resolved with the selected asset(s), or `null` if the
397
+ * user closes the dialog without selecting any upload.
398
+ *
399
+ * @example
400
+ *
401
+ * ```js
402
+ * const item = await ctx.selectUpload({ multiple: false });
403
+ *
404
+ * if (item) {
405
+ * ctx.notice(`Success! ${item.id}`);
406
+ * } else {
407
+ * ctx.alert('Closed!');
408
+ * }
409
+ * ```
410
+ */
411
+ selectUpload: {
412
+ (options: {
413
+ multiple: true;
414
+ }): Promise<Upload[] | null>;
415
+ (options?: {
416
+ multiple: false;
417
+ }): Promise<Upload | null>;
418
+ };
419
+ /**
420
+ * Opens a dialog for editing a Media Area asset. It returns a promise
421
+ * resolved with:
422
+ *
423
+ * - The updated asset, if the user persists some changes to the asset itself
424
+ * - `null`, if the user closes the dialog without persisting any change
425
+ * - An asset structure with an additional `deleted` property set to true, if
426
+ * the user deletes the asset
427
+ *
428
+ * @example
429
+ *
430
+ * ```js
431
+ * const uploadId = prompt('Please insert an asset ID:');
432
+ *
433
+ * const item = await ctx.editUpload(uploadId);
434
+ *
435
+ * if (item) {
436
+ * ctx.notice(`Success! ${item.id}`);
437
+ * } else {
438
+ * ctx.alert('Closed!');
439
+ * }
440
+ * ```
441
+ */
442
+ editUpload: (uploadId: string) => Promise<(Upload & {
443
+ deleted?: true;
444
+ }) | null>;
445
+ /**
446
+ * Opens a dialog for editing a "single asset" field structure. It returns a
447
+ * promise resolved with the updated structure, or `null` if the user closes
448
+ * the dialog without persisting any change.
449
+ *
450
+ * @example
451
+ *
452
+ * ```js
453
+ * const uploadId = prompt('Please insert an asset ID:');
454
+ *
455
+ * const result = await ctx.editUploadMetadata({
456
+ * upload_id: uploadId,
457
+ * alt: null,
458
+ * title: null,
459
+ * custom_data: {},
460
+ * focal_point: null,
461
+ * });
462
+ *
463
+ * if (result) {
464
+ * ctx.notice(`Success! ${JSON.stringify(result)}`);
465
+ * } else {
466
+ * ctx.alert('Closed!');
467
+ * }
468
+ * ```
469
+ */
470
+ editUploadMetadata: (
471
+ /** The "single asset" field structure */
472
+ fileFieldValue: FileFieldValue,
473
+ /** Shows metadata information for a specific locale */
474
+ locale?: string) => Promise<FileFieldValue | null>;
475
+ };
476
+ /** These methods can be used to open custom dialogs/confirmation panels */
477
+ type CustomDialogMethods = {
478
+ /**
479
+ * Opens a custom modal. Returns a promise resolved with what the modal itself
480
+ * returns calling the `resolve()` function
481
+ *
482
+ * @example
483
+ *
484
+ * ```js
485
+ * const result = await ctx.openModal({
486
+ * id: 'regular',
487
+ * title: 'Custom title!',
488
+ * width: 'l',
489
+ * parameters: { foo: 'bar' },
490
+ * });
491
+ *
492
+ * if (result) {
493
+ * ctx.notice(`Success! ${JSON.stringify(result)}`);
494
+ * } else {
495
+ * ctx.alert('Closed!');
496
+ * }
497
+ * ```
498
+ */
499
+ openModal: (modal: Modal) => Promise<unknown>;
500
+ /**
501
+ * Opens a UI-consistent confirmation dialog. Returns a promise resolved with
502
+ * the value of the choice made by the user
503
+ *
504
+ * @example
505
+ *
506
+ * ```js
507
+ * const result = await ctx.openConfirm({
508
+ * title: 'Custom title',
509
+ * content:
510
+ * 'Lorem Ipsum is simply dummy text of the printing and typesetting industry',
511
+ * choices: [
512
+ * {
513
+ * label: 'Positive',
514
+ * value: 'positive',
515
+ * intent: 'positive',
516
+ * },
517
+ * {
518
+ * label: 'Negative',
519
+ * value: 'negative',
520
+ * intent: 'negative',
521
+ * },
522
+ * ],
523
+ * cancel: {
524
+ * label: 'Cancel',
525
+ * value: false,
526
+ * },
527
+ * });
528
+ *
529
+ * if (result) {
530
+ * ctx.notice(`Success! ${result}`);
531
+ * } else {
532
+ * ctx.alert('Cancelled!');
533
+ * }
534
+ * ```
535
+ */
536
+ openConfirm: (options: ConfirmOptions) => Promise<unknown>;
537
+ };
538
+ /** These methods can be used to take the user to different pages */
539
+ type NavigateMethods = {
540
+ /**
541
+ * Moves the user to another URL internal to the backend
542
+ *
543
+ * @example
544
+ *
545
+ * ```js
546
+ * await ctx.navigateTo('/');
547
+ * ```
548
+ */
549
+ navigateTo: (path: string) => Promise<void>;
550
+ };
551
+ export type FieldAppearanceChange = {
552
+ operation: 'removeEditor';
553
+ } | {
554
+ operation: 'updateEditor';
555
+ newFieldExtensionId?: string;
556
+ newParameters?: Record<string, unknown>;
557
+ } | {
558
+ operation: 'setEditor';
559
+ fieldExtensionId: string;
560
+ parameters: Record<string, unknown>;
561
+ } | {
562
+ operation: 'removeAddon';
563
+ index: number;
564
+ } | {
565
+ operation: 'updateAddon';
566
+ index: number;
567
+ newFieldExtensionId?: string;
568
+ newParameters?: Record<string, unknown>;
569
+ } | {
570
+ operation: 'insertAddon';
571
+ index: number;
572
+ fieldExtensionId: string;
573
+ parameters: Record<string, unknown>;
574
+ };
575
+ export type ItemListLocationQuery = {
576
+ locale?: string;
577
+ filter?: {
578
+ query?: string;
579
+ fields?: Record<string, unknown>;
580
+ };
581
+ };
582
+ /** A toast notification to present to the user */
583
+ export type Toast<CtaValue = unknown> = {
584
+ /** Message of the notification */
585
+ message: string;
586
+ /** Type of notification. Will present the toast in a different color accent. */
587
+ type: 'notice' | 'alert' | 'warning';
588
+ /** An optional button to show inside the toast */
589
+ cta?: {
590
+ /** Label for the button */
591
+ label: string;
592
+ /**
593
+ * The value to be returned by the `customToast` promise if the button is
594
+ * clicked by the user
595
+ */
596
+ value: CtaValue;
597
+ };
598
+ /** Whether the toast is to be automatically closed if the user changes page */
599
+ dismissOnPageChange?: boolean;
600
+ /**
601
+ * Whether the toast is to be automatically closed after some time (`true`
602
+ * will use the default DatoCMS time interval)
603
+ */
604
+ dismissAfterTimeout?: boolean | number;
605
+ };
606
+ /** The structure contained in a "single asset" field */
607
+ export type FileFieldValue = {
608
+ /** ID of the asset */
609
+ upload_id: string;
610
+ /** Alternate text for the asset */
611
+ alt: string | null;
612
+ /** Title for the asset */
613
+ title: string | null;
614
+ /** Focal point of an asset */
615
+ focal_point: FocalPoint | null;
616
+ /** Object with arbitrary metadata related to the asset */
617
+ custom_data: Record<string, string>;
618
+ };
619
+ /** A modal to present to the user */
620
+ export type Modal = {
621
+ /** ID of the modal. Will be the first argument for the `renderModal` function */
622
+ id: string;
623
+ /** Title for the modal. Ignored by `fullWidth` modals */
624
+ title?: string;
625
+ /** Whether to present a close button for the modal or not */
626
+ closeDisabled?: boolean;
627
+ /** Width of the modal. Can be a number, or one of the predefined sizes */
628
+ width?: 's' | 'm' | 'l' | 'xl' | 'fullWidth' | number;
629
+ /**
630
+ * An arbitrary configuration object that will be passed as the `parameters`
631
+ * property of the second argument of the `renderModal` function
632
+ */
633
+ parameters?: Record<string, unknown>;
634
+ /** The initial height to set for the iframe that will render the modal content */
635
+ initialHeight?: number;
636
+ };
637
+ /** Focal point of an image asset */
638
+ export type FocalPoint = {
639
+ /** Horizontal position expressed as float between 0 and 1 */
640
+ x: number;
641
+ /** Vertical position expressed as float between 0 and 1 */
642
+ y: number;
643
+ };
644
+ /** Options for the `openConfirm` function */
645
+ export type ConfirmOptions = {
646
+ /** The title to be shown inside the confirmation panel */
647
+ title: string;
648
+ /** The main message to be shown inside the confirmation panel */
649
+ content: string;
650
+ /** The different options the user can choose from */
651
+ choices: ConfirmChoice[];
652
+ /** The cancel option to present to the user */
653
+ cancel: ConfirmChoice;
654
+ };
655
+ /** A choice presented in a `openConfirm` panel */
656
+ export type ConfirmChoice = {
657
+ /** The label to be shown for the choice */
658
+ label: string;
659
+ /**
660
+ * The value to be returned by the `openConfirm` promise if the button is
661
+ * clicked by the user
662
+ */
663
+ value: unknown;
664
+ /**
665
+ * The intent of the button. Will present the button in a different color
666
+ * accent.
667
+ */
668
+ intent?: 'positive' | 'negative';
669
+ };
670
+ export {};
@@ -0,0 +1,29 @@
1
+ import type { SchemaTypes } from '@datocms/cma-client';
2
+ type Field = SchemaTypes.Field;
3
+ type ItemType = SchemaTypes.ItemType;
4
+ export type FieldAdditionalProperties = {
5
+ /** Whether the field is currently disabled or not */
6
+ disabled: boolean;
7
+ /**
8
+ * The path in the `formValues` object where to find the current value for the
9
+ * field
10
+ */
11
+ fieldPath: string;
12
+ /** The field where the field extension is installed to */
13
+ field: Field;
14
+ /**
15
+ * If the field extension is installed in a field of a block, returns the top
16
+ * level Modular Content/Structured Text field containing the block itself
17
+ */
18
+ parentField: Field | undefined;
19
+ /**
20
+ * If the field extension is installed in a field of a block, returns the ID
21
+ * of the block — or `undefined` if the block is still not persisted — and the
22
+ * block model.
23
+ */
24
+ block: undefined | {
25
+ id: string | undefined;
26
+ blockModel: ItemType;
27
+ };
28
+ };
29
+ export {};