datocms-plugin-sdk 1.1.1 → 2.0.1

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 (393) hide show
  1. package/dist/cjs/connect.js +75 -214
  2. package/dist/cjs/connect.js.map +1 -1
  3. package/dist/cjs/{types.js → ctx/base.js} +1 -1
  4. package/dist/cjs/ctx/base.js.map +1 -0
  5. package/dist/cjs/ctx/commonExtras/field.js +3 -0
  6. package/dist/cjs/ctx/commonExtras/field.js.map +1 -0
  7. package/dist/cjs/ctx/commonExtras/itemForm.js +3 -0
  8. package/dist/cjs/ctx/commonExtras/itemForm.js.map +1 -0
  9. package/dist/cjs/ctx/commonExtras/sizing.js +3 -0
  10. package/dist/cjs/ctx/commonExtras/sizing.js.map +1 -0
  11. package/dist/cjs/ctx/pluginFrame.js +3 -0
  12. package/dist/cjs/ctx/pluginFrame.js.map +1 -0
  13. package/dist/cjs/hooks/assetSources.js +3 -0
  14. package/dist/cjs/hooks/assetSources.js.map +1 -0
  15. package/dist/cjs/hooks/buildItemPresentationInfo.js +3 -0
  16. package/dist/cjs/hooks/buildItemPresentationInfo.js.map +1 -0
  17. package/dist/cjs/hooks/contentAreaSidebarItems.js +3 -0
  18. package/dist/cjs/hooks/contentAreaSidebarItems.js.map +1 -0
  19. package/dist/cjs/hooks/customBlockStylesForStructuredTextField.js +3 -0
  20. package/dist/cjs/hooks/customBlockStylesForStructuredTextField.js.map +1 -0
  21. package/dist/cjs/hooks/customMarksForStructuredTextField.js +3 -0
  22. package/dist/cjs/hooks/customMarksForStructuredTextField.js.map +1 -0
  23. package/dist/cjs/hooks/executeFieldDropdownAction.js +3 -0
  24. package/dist/cjs/hooks/executeFieldDropdownAction.js.map +1 -0
  25. package/dist/cjs/hooks/executeItemFormDropdownAction.js +3 -0
  26. package/dist/cjs/hooks/executeItemFormDropdownAction.js.map +1 -0
  27. package/dist/cjs/hooks/executeItemsDropdownAction.js +3 -0
  28. package/dist/cjs/hooks/executeItemsDropdownAction.js.map +1 -0
  29. package/dist/cjs/hooks/executeUploadsDropdownAction.js +3 -0
  30. package/dist/cjs/hooks/executeUploadsDropdownAction.js.map +1 -0
  31. package/dist/cjs/hooks/fieldDropdownActions.js +3 -0
  32. package/dist/cjs/hooks/fieldDropdownActions.js.map +1 -0
  33. package/dist/cjs/hooks/initialLocationQueryForItemSelector.js +3 -0
  34. package/dist/cjs/hooks/initialLocationQueryForItemSelector.js.map +1 -0
  35. package/dist/cjs/hooks/itemCollectionOutlets.js +3 -0
  36. package/dist/cjs/hooks/itemCollectionOutlets.js.map +1 -0
  37. package/dist/cjs/hooks/itemFormDropdownActions.js +3 -0
  38. package/dist/cjs/hooks/itemFormDropdownActions.js.map +1 -0
  39. package/dist/cjs/hooks/itemFormOutlets.js +3 -0
  40. package/dist/cjs/hooks/itemFormOutlets.js.map +1 -0
  41. package/dist/cjs/hooks/itemFormSidebarPanels.js +3 -0
  42. package/dist/cjs/hooks/itemFormSidebarPanels.js.map +1 -0
  43. package/dist/cjs/hooks/itemFormSidebars.js +3 -0
  44. package/dist/cjs/hooks/itemFormSidebars.js.map +1 -0
  45. package/dist/cjs/hooks/itemsDropdownActions.js +3 -0
  46. package/dist/cjs/hooks/itemsDropdownActions.js.map +1 -0
  47. package/dist/cjs/hooks/mainNavigationTabs.js +3 -0
  48. package/dist/cjs/hooks/mainNavigationTabs.js.map +1 -0
  49. package/dist/cjs/hooks/manualFieldExtensions.js +3 -0
  50. package/dist/cjs/hooks/manualFieldExtensions.js.map +1 -0
  51. package/dist/cjs/hooks/onBeforeItemUpsert.js +3 -0
  52. package/dist/cjs/hooks/onBeforeItemUpsert.js.map +1 -0
  53. package/dist/cjs/hooks/onBeforeItemsDestroy.js +3 -0
  54. package/dist/cjs/hooks/onBeforeItemsDestroy.js.map +1 -0
  55. package/dist/cjs/hooks/onBeforeItemsPublish.js +3 -0
  56. package/dist/cjs/hooks/onBeforeItemsPublish.js.map +1 -0
  57. package/dist/cjs/hooks/onBeforeItemsUnpublish.js +3 -0
  58. package/dist/cjs/hooks/onBeforeItemsUnpublish.js.map +1 -0
  59. package/dist/cjs/hooks/onBoot.js +3 -0
  60. package/dist/cjs/hooks/onBoot.js.map +1 -0
  61. package/dist/cjs/hooks/overrideFieldExtensions.js +3 -0
  62. package/dist/cjs/hooks/overrideFieldExtensions.js.map +1 -0
  63. package/dist/cjs/hooks/renderAssetSource.js +11 -0
  64. package/dist/cjs/hooks/renderAssetSource.js.map +1 -0
  65. package/dist/cjs/hooks/renderConfigScreen.js +11 -0
  66. package/dist/cjs/hooks/renderConfigScreen.js.map +1 -0
  67. package/dist/cjs/hooks/renderFieldExtension.js +11 -0
  68. package/dist/cjs/hooks/renderFieldExtension.js.map +1 -0
  69. package/dist/cjs/hooks/renderItemCollectionOutlet.js +11 -0
  70. package/dist/cjs/hooks/renderItemCollectionOutlet.js.map +1 -0
  71. package/dist/cjs/hooks/renderItemFormOutlet.js +11 -0
  72. package/dist/cjs/hooks/renderItemFormOutlet.js.map +1 -0
  73. package/dist/cjs/hooks/renderItemFormSidebar.js +11 -0
  74. package/dist/cjs/hooks/renderItemFormSidebar.js.map +1 -0
  75. package/dist/cjs/hooks/renderItemFormSidebarPanel.js +11 -0
  76. package/dist/cjs/hooks/renderItemFormSidebarPanel.js.map +1 -0
  77. package/dist/cjs/hooks/renderManualFieldExtensionConfigScreen.js +11 -0
  78. package/dist/cjs/hooks/renderManualFieldExtensionConfigScreen.js.map +1 -0
  79. package/dist/cjs/hooks/renderModal.js +11 -0
  80. package/dist/cjs/hooks/renderModal.js.map +1 -0
  81. package/dist/cjs/hooks/renderPage.js +11 -0
  82. package/dist/cjs/hooks/renderPage.js.map +1 -0
  83. package/dist/cjs/hooks/renderUploadSidebar.js +11 -0
  84. package/dist/cjs/hooks/renderUploadSidebar.js.map +1 -0
  85. package/dist/cjs/hooks/renderUploadSidebarPanel.js +11 -0
  86. package/dist/cjs/hooks/renderUploadSidebarPanel.js.map +1 -0
  87. package/dist/cjs/hooks/settingsAreaSidebarItemGroups.js +3 -0
  88. package/dist/cjs/hooks/settingsAreaSidebarItemGroups.js.map +1 -0
  89. package/dist/cjs/hooks/uploadSidebarPanels.js +3 -0
  90. package/dist/cjs/hooks/uploadSidebarPanels.js.map +1 -0
  91. package/dist/cjs/hooks/uploadSidebars.js +3 -0
  92. package/dist/cjs/hooks/uploadSidebars.js.map +1 -0
  93. package/dist/cjs/hooks/uploadsDropdownActions.js +3 -0
  94. package/dist/cjs/hooks/uploadsDropdownActions.js.map +1 -0
  95. package/dist/cjs/hooks/validateManualFieldExtensionParameters.js +3 -0
  96. package/dist/cjs/hooks/validateManualFieldExtensionParameters.js.map +1 -0
  97. package/dist/cjs/icon.js +3 -0
  98. package/dist/cjs/icon.js.map +1 -0
  99. package/dist/cjs/index.js +46 -1
  100. package/dist/cjs/index.js.map +1 -1
  101. package/dist/cjs/manifest.js +3172 -0
  102. package/dist/cjs/manifest.js.map +1 -0
  103. package/dist/cjs/manifestTypes.js +3 -0
  104. package/dist/cjs/manifestTypes.js.map +1 -0
  105. package/dist/cjs/shared.js +3 -0
  106. package/dist/cjs/shared.js.map +1 -0
  107. package/dist/cjs/utils.js +136 -0
  108. package/dist/cjs/utils.js.map +1 -0
  109. package/dist/esm/connect.d.ts +44 -244
  110. package/dist/esm/connect.js +74 -212
  111. package/dist/esm/connect.js.map +1 -1
  112. package/dist/esm/ctx/base.d.ts +684 -0
  113. package/dist/esm/ctx/base.js +2 -0
  114. package/dist/esm/ctx/base.js.map +1 -0
  115. package/dist/esm/ctx/commonExtras/field.d.ts +29 -0
  116. package/dist/esm/ctx/commonExtras/field.js +2 -0
  117. package/dist/esm/ctx/commonExtras/field.js.map +1 -0
  118. package/dist/esm/ctx/commonExtras/itemForm.d.ts +148 -0
  119. package/dist/esm/ctx/commonExtras/itemForm.js +2 -0
  120. package/dist/esm/ctx/commonExtras/itemForm.js.map +1 -0
  121. package/dist/esm/ctx/commonExtras/sizing.d.ts +23 -0
  122. package/dist/esm/ctx/commonExtras/sizing.js +2 -0
  123. package/dist/esm/ctx/commonExtras/sizing.js.map +1 -0
  124. package/dist/esm/ctx/pluginFrame.d.ts +12 -0
  125. package/dist/esm/ctx/pluginFrame.js +2 -0
  126. package/dist/esm/ctx/pluginFrame.js.map +1 -0
  127. package/dist/esm/hooks/assetSources.d.ts +42 -0
  128. package/dist/esm/hooks/assetSources.js +2 -0
  129. package/dist/esm/hooks/assetSources.js.map +1 -0
  130. package/dist/esm/hooks/buildItemPresentationInfo.d.ts +29 -0
  131. package/dist/esm/hooks/buildItemPresentationInfo.js +2 -0
  132. package/dist/esm/hooks/buildItemPresentationInfo.js.map +1 -0
  133. package/dist/esm/hooks/contentAreaSidebarItems.d.ts +40 -0
  134. package/dist/esm/hooks/contentAreaSidebarItems.js +2 -0
  135. package/dist/esm/hooks/contentAreaSidebarItems.js.map +1 -0
  136. package/dist/esm/hooks/customBlockStylesForStructuredTextField.d.ts +36 -0
  137. package/dist/esm/hooks/customBlockStylesForStructuredTextField.js +2 -0
  138. package/dist/esm/hooks/customBlockStylesForStructuredTextField.js.map +1 -0
  139. package/dist/esm/hooks/customMarksForStructuredTextField.d.ts +57 -0
  140. package/dist/esm/hooks/customMarksForStructuredTextField.js +2 -0
  141. package/dist/esm/hooks/customMarksForStructuredTextField.js.map +1 -0
  142. package/dist/esm/hooks/executeFieldDropdownAction.d.ts +17 -0
  143. package/dist/esm/hooks/executeFieldDropdownAction.js +2 -0
  144. package/dist/esm/hooks/executeFieldDropdownAction.js.map +1 -0
  145. package/dist/esm/hooks/executeItemFormDropdownAction.d.ts +16 -0
  146. package/dist/esm/hooks/executeItemFormDropdownAction.js +2 -0
  147. package/dist/esm/hooks/executeItemFormDropdownAction.js.map +1 -0
  148. package/dist/esm/hooks/executeItemsDropdownAction.d.ts +20 -0
  149. package/dist/esm/hooks/executeItemsDropdownAction.js +2 -0
  150. package/dist/esm/hooks/executeItemsDropdownAction.js.map +1 -0
  151. package/dist/esm/hooks/executeUploadsDropdownAction.d.ts +20 -0
  152. package/dist/esm/hooks/executeUploadsDropdownAction.js +2 -0
  153. package/dist/esm/hooks/executeUploadsDropdownAction.js.map +1 -0
  154. package/dist/esm/hooks/fieldDropdownActions.d.ts +20 -0
  155. package/dist/esm/hooks/fieldDropdownActions.js +2 -0
  156. package/dist/esm/hooks/fieldDropdownActions.js.map +1 -0
  157. package/dist/esm/hooks/initialLocationQueryForItemSelector.d.ts +27 -0
  158. package/dist/esm/hooks/initialLocationQueryForItemSelector.js +2 -0
  159. package/dist/esm/hooks/initialLocationQueryForItemSelector.js.map +1 -0
  160. package/dist/esm/hooks/itemCollectionOutlets.d.ts +31 -0
  161. package/dist/esm/hooks/itemCollectionOutlets.js +2 -0
  162. package/dist/esm/hooks/itemCollectionOutlets.js.map +1 -0
  163. package/dist/esm/hooks/itemFormDropdownActions.d.ts +20 -0
  164. package/dist/esm/hooks/itemFormDropdownActions.js +2 -0
  165. package/dist/esm/hooks/itemFormDropdownActions.js.map +1 -0
  166. package/dist/esm/hooks/itemFormOutlets.d.ts +30 -0
  167. package/dist/esm/hooks/itemFormOutlets.js +2 -0
  168. package/dist/esm/hooks/itemFormOutlets.js.map +1 -0
  169. package/dist/esm/hooks/itemFormSidebarPanels.d.ts +48 -0
  170. package/dist/esm/hooks/itemFormSidebarPanels.js +2 -0
  171. package/dist/esm/hooks/itemFormSidebarPanels.js.map +1 -0
  172. package/dist/esm/hooks/itemFormSidebars.d.ts +38 -0
  173. package/dist/esm/hooks/itemFormSidebars.js +2 -0
  174. package/dist/esm/hooks/itemFormSidebars.js.map +1 -0
  175. package/dist/esm/hooks/itemsDropdownActions.d.ts +23 -0
  176. package/dist/esm/hooks/itemsDropdownActions.js +2 -0
  177. package/dist/esm/hooks/itemsDropdownActions.js.map +1 -0
  178. package/dist/esm/hooks/mainNavigationTabs.d.ts +44 -0
  179. package/dist/esm/hooks/mainNavigationTabs.js +2 -0
  180. package/dist/esm/hooks/mainNavigationTabs.js.map +1 -0
  181. package/dist/esm/hooks/manualFieldExtensions.d.ts +59 -0
  182. package/dist/esm/hooks/manualFieldExtensions.js +2 -0
  183. package/dist/esm/hooks/manualFieldExtensions.js.map +1 -0
  184. package/dist/esm/hooks/onBeforeItemUpsert.d.ts +16 -0
  185. package/dist/esm/hooks/onBeforeItemUpsert.js +2 -0
  186. package/dist/esm/hooks/onBeforeItemUpsert.js.map +1 -0
  187. package/dist/esm/hooks/onBeforeItemsDestroy.d.ts +15 -0
  188. package/dist/esm/hooks/onBeforeItemsDestroy.js +2 -0
  189. package/dist/esm/hooks/onBeforeItemsDestroy.js.map +1 -0
  190. package/dist/esm/hooks/onBeforeItemsPublish.d.ts +15 -0
  191. package/dist/esm/hooks/onBeforeItemsPublish.js +2 -0
  192. package/dist/esm/hooks/onBeforeItemsPublish.js.map +1 -0
  193. package/dist/esm/hooks/onBeforeItemsUnpublish.d.ts +15 -0
  194. package/dist/esm/hooks/onBeforeItemsUnpublish.js +2 -0
  195. package/dist/esm/hooks/onBeforeItemsUnpublish.js.map +1 -0
  196. package/dist/esm/hooks/onBoot.d.ts +11 -0
  197. package/dist/esm/hooks/onBoot.js +2 -0
  198. package/dist/esm/hooks/onBoot.js.map +1 -0
  199. package/dist/esm/hooks/overrideFieldExtensions.d.ts +88 -0
  200. package/dist/esm/hooks/overrideFieldExtensions.js +2 -0
  201. package/dist/esm/hooks/overrideFieldExtensions.js.map +1 -0
  202. package/dist/esm/hooks/renderAssetSource.d.ts +98 -0
  203. package/dist/esm/hooks/renderAssetSource.js +8 -0
  204. package/dist/esm/hooks/renderAssetSource.js.map +1 -0
  205. package/dist/esm/hooks/renderConfigScreen.d.ts +12 -0
  206. package/dist/esm/hooks/renderConfigScreen.js +8 -0
  207. package/dist/esm/hooks/renderConfigScreen.js.map +1 -0
  208. package/dist/esm/hooks/renderFieldExtension.d.ts +20 -0
  209. package/dist/esm/hooks/renderFieldExtension.js +8 -0
  210. package/dist/esm/hooks/renderFieldExtension.js.map +1 -0
  211. package/dist/esm/hooks/renderItemCollectionOutlet.d.ts +15 -0
  212. package/dist/esm/hooks/renderItemCollectionOutlet.js +8 -0
  213. package/dist/esm/hooks/renderItemCollectionOutlet.js.map +1 -0
  214. package/dist/esm/hooks/renderItemFormOutlet.d.ts +16 -0
  215. package/dist/esm/hooks/renderItemFormOutlet.js +8 -0
  216. package/dist/esm/hooks/renderItemFormOutlet.js.map +1 -0
  217. package/dist/esm/hooks/renderItemFormSidebar.d.ts +21 -0
  218. package/dist/esm/hooks/renderItemFormSidebar.js +8 -0
  219. package/dist/esm/hooks/renderItemFormSidebar.js.map +1 -0
  220. package/dist/esm/hooks/renderItemFormSidebarPanel.d.ts +21 -0
  221. package/dist/esm/hooks/renderItemFormSidebarPanel.js +8 -0
  222. package/dist/esm/hooks/renderItemFormSidebarPanel.js.map +1 -0
  223. package/dist/esm/hooks/renderManualFieldExtensionConfigScreen.d.ts +55 -0
  224. package/dist/esm/hooks/renderManualFieldExtensionConfigScreen.js +8 -0
  225. package/dist/esm/hooks/renderManualFieldExtensionConfigScreen.js.map +1 -0
  226. package/dist/esm/hooks/renderModal.d.ts +37 -0
  227. package/dist/esm/hooks/renderModal.js +8 -0
  228. package/dist/esm/hooks/renderModal.js.map +1 -0
  229. package/dist/esm/hooks/renderPage.d.ts +16 -0
  230. package/dist/esm/hooks/renderPage.js +8 -0
  231. package/dist/esm/hooks/renderPage.js.map +1 -0
  232. package/dist/esm/hooks/renderUploadSidebar.d.ts +25 -0
  233. package/dist/esm/hooks/renderUploadSidebar.js +8 -0
  234. package/dist/esm/hooks/renderUploadSidebar.js.map +1 -0
  235. package/dist/esm/hooks/renderUploadSidebarPanel.d.ts +25 -0
  236. package/dist/esm/hooks/renderUploadSidebarPanel.js +8 -0
  237. package/dist/esm/hooks/renderUploadSidebarPanel.js.map +1 -0
  238. package/dist/esm/hooks/settingsAreaSidebarItemGroups.d.ts +53 -0
  239. package/dist/esm/hooks/settingsAreaSidebarItemGroups.js +2 -0
  240. package/dist/esm/hooks/settingsAreaSidebarItemGroups.js.map +1 -0
  241. package/dist/esm/hooks/uploadSidebarPanels.d.ts +48 -0
  242. package/dist/esm/hooks/uploadSidebarPanels.js +2 -0
  243. package/dist/esm/hooks/uploadSidebarPanels.js.map +1 -0
  244. package/dist/esm/hooks/uploadSidebars.d.ts +35 -0
  245. package/dist/esm/hooks/uploadSidebars.js +2 -0
  246. package/dist/esm/hooks/uploadSidebars.js.map +1 -0
  247. package/dist/esm/hooks/uploadsDropdownActions.d.ts +19 -0
  248. package/dist/esm/hooks/uploadsDropdownActions.js +2 -0
  249. package/dist/esm/hooks/uploadsDropdownActions.js.map +1 -0
  250. package/dist/esm/hooks/validateManualFieldExtensionParameters.d.ts +9 -0
  251. package/dist/esm/hooks/validateManualFieldExtensionParameters.js +2 -0
  252. package/dist/esm/hooks/validateManualFieldExtensionParameters.js.map +1 -0
  253. package/dist/esm/icon.d.ts +6 -0
  254. package/dist/esm/icon.js +2 -0
  255. package/dist/esm/icon.js.map +1 -0
  256. package/dist/esm/index.d.ts +57 -12
  257. package/dist/esm/index.js +46 -1
  258. package/dist/esm/index.js.map +1 -1
  259. package/dist/esm/manifest.d.ts +2 -0
  260. package/dist/esm/manifest.js +3169 -0
  261. package/dist/esm/manifest.js.map +1 -0
  262. package/dist/esm/manifestTypes.d.ts +146 -0
  263. package/dist/esm/manifestTypes.js +2 -0
  264. package/dist/esm/manifestTypes.js.map +1 -0
  265. package/dist/esm/shared.d.ts +56 -0
  266. package/dist/esm/shared.js +2 -0
  267. package/dist/esm/shared.js.map +1 -0
  268. package/dist/esm/utils.d.ts +31 -0
  269. package/dist/esm/utils.js +129 -0
  270. package/dist/esm/utils.js.map +1 -0
  271. package/dist/types/connect.d.ts +44 -244
  272. package/dist/types/ctx/base.d.ts +684 -0
  273. package/dist/types/ctx/commonExtras/field.d.ts +29 -0
  274. package/dist/types/ctx/commonExtras/itemForm.d.ts +148 -0
  275. package/dist/types/ctx/commonExtras/sizing.d.ts +23 -0
  276. package/dist/types/ctx/pluginFrame.d.ts +12 -0
  277. package/dist/types/hooks/assetSources.d.ts +42 -0
  278. package/dist/types/hooks/buildItemPresentationInfo.d.ts +29 -0
  279. package/dist/types/hooks/contentAreaSidebarItems.d.ts +40 -0
  280. package/dist/types/hooks/customBlockStylesForStructuredTextField.d.ts +36 -0
  281. package/dist/types/hooks/customMarksForStructuredTextField.d.ts +57 -0
  282. package/dist/types/hooks/executeFieldDropdownAction.d.ts +17 -0
  283. package/dist/types/hooks/executeItemFormDropdownAction.d.ts +16 -0
  284. package/dist/types/hooks/executeItemsDropdownAction.d.ts +20 -0
  285. package/dist/types/hooks/executeUploadsDropdownAction.d.ts +20 -0
  286. package/dist/types/hooks/fieldDropdownActions.d.ts +20 -0
  287. package/dist/types/hooks/initialLocationQueryForItemSelector.d.ts +27 -0
  288. package/dist/types/hooks/itemCollectionOutlets.d.ts +31 -0
  289. package/dist/types/hooks/itemFormDropdownActions.d.ts +20 -0
  290. package/dist/types/hooks/itemFormOutlets.d.ts +30 -0
  291. package/dist/types/hooks/itemFormSidebarPanels.d.ts +48 -0
  292. package/dist/types/hooks/itemFormSidebars.d.ts +38 -0
  293. package/dist/types/hooks/itemsDropdownActions.d.ts +23 -0
  294. package/dist/types/hooks/mainNavigationTabs.d.ts +44 -0
  295. package/dist/types/hooks/manualFieldExtensions.d.ts +59 -0
  296. package/dist/types/hooks/onBeforeItemUpsert.d.ts +16 -0
  297. package/dist/types/hooks/onBeforeItemsDestroy.d.ts +15 -0
  298. package/dist/types/hooks/onBeforeItemsPublish.d.ts +15 -0
  299. package/dist/types/hooks/onBeforeItemsUnpublish.d.ts +15 -0
  300. package/dist/types/hooks/onBoot.d.ts +11 -0
  301. package/dist/types/hooks/overrideFieldExtensions.d.ts +88 -0
  302. package/dist/types/hooks/renderAssetSource.d.ts +98 -0
  303. package/dist/types/hooks/renderConfigScreen.d.ts +12 -0
  304. package/dist/types/hooks/renderFieldExtension.d.ts +20 -0
  305. package/dist/types/hooks/renderItemCollectionOutlet.d.ts +15 -0
  306. package/dist/types/hooks/renderItemFormOutlet.d.ts +16 -0
  307. package/dist/types/hooks/renderItemFormSidebar.d.ts +21 -0
  308. package/dist/types/hooks/renderItemFormSidebarPanel.d.ts +21 -0
  309. package/dist/types/hooks/renderManualFieldExtensionConfigScreen.d.ts +55 -0
  310. package/dist/types/hooks/renderModal.d.ts +37 -0
  311. package/dist/types/hooks/renderPage.d.ts +16 -0
  312. package/dist/types/hooks/renderUploadSidebar.d.ts +25 -0
  313. package/dist/types/hooks/renderUploadSidebarPanel.d.ts +25 -0
  314. package/dist/types/hooks/settingsAreaSidebarItemGroups.d.ts +53 -0
  315. package/dist/types/hooks/uploadSidebarPanels.d.ts +48 -0
  316. package/dist/types/hooks/uploadSidebars.d.ts +35 -0
  317. package/dist/types/hooks/uploadsDropdownActions.d.ts +19 -0
  318. package/dist/types/hooks/validateManualFieldExtensionParameters.d.ts +9 -0
  319. package/dist/types/icon.d.ts +6 -0
  320. package/dist/types/index.d.ts +57 -12
  321. package/dist/types/manifest.d.ts +2 -0
  322. package/dist/types/manifestTypes.d.ts +146 -0
  323. package/dist/types/shared.d.ts +56 -0
  324. package/dist/types/utils.d.ts +31 -0
  325. package/manifest.json +3168 -0
  326. package/package.json +7 -6
  327. package/src/connect.ts +207 -709
  328. package/src/ctx/base.ts +746 -0
  329. package/src/ctx/commonExtras/field.ts +27 -0
  330. package/src/ctx/commonExtras/itemForm.ts +155 -0
  331. package/src/ctx/commonExtras/sizing.ts +27 -0
  332. package/src/ctx/pluginFrame.ts +39 -0
  333. package/src/hooks/assetSources.ts +45 -0
  334. package/src/hooks/buildItemPresentationInfo.ts +35 -0
  335. package/src/hooks/contentAreaSidebarItems.ts +45 -0
  336. package/src/hooks/customBlockStylesForStructuredTextField.ts +42 -0
  337. package/src/hooks/customMarksForStructuredTextField.ts +64 -0
  338. package/src/hooks/executeFieldDropdownAction.ts +28 -0
  339. package/src/hooks/executeItemFormDropdownAction.ts +26 -0
  340. package/src/hooks/executeItemsDropdownAction.ts +24 -0
  341. package/src/hooks/executeUploadsDropdownAction.ts +24 -0
  342. package/src/hooks/fieldDropdownActions.ts +27 -0
  343. package/src/hooks/initialLocationQueryForItemSelector.ts +35 -0
  344. package/src/hooks/itemCollectionOutlets.ts +37 -0
  345. package/src/hooks/itemFormDropdownActions.ts +27 -0
  346. package/src/hooks/itemFormOutlets.ts +36 -0
  347. package/src/hooks/itemFormSidebarPanels.ts +54 -0
  348. package/src/hooks/itemFormSidebars.ts +44 -0
  349. package/src/hooks/itemsDropdownActions.ts +28 -0
  350. package/src/hooks/mainNavigationTabs.ts +47 -0
  351. package/src/hooks/manualFieldExtensions.ts +82 -0
  352. package/src/hooks/onBeforeItemUpsert.ts +21 -0
  353. package/src/hooks/onBeforeItemsDestroy.ts +20 -0
  354. package/src/hooks/onBeforeItemsPublish.ts +20 -0
  355. package/src/hooks/onBeforeItemsUnpublish.ts +20 -0
  356. package/src/hooks/onBoot.ts +13 -0
  357. package/src/hooks/overrideFieldExtensions.ts +95 -0
  358. package/src/hooks/renderAssetSource.ts +119 -0
  359. package/src/hooks/renderConfigScreen.ts +27 -0
  360. package/src/hooks/renderFieldExtension.ts +46 -0
  361. package/src/hooks/renderItemCollectionOutlet.ts +35 -0
  362. package/src/hooks/renderItemFormOutlet.ts +40 -0
  363. package/src/hooks/renderItemFormSidebar.ts +45 -0
  364. package/src/hooks/renderItemFormSidebarPanel.ts +46 -0
  365. package/src/hooks/renderManualFieldExtensionConfigScreen.ts +83 -0
  366. package/src/hooks/renderModal.ts +54 -0
  367. package/src/hooks/renderPage.ts +33 -0
  368. package/src/hooks/renderUploadSidebar.ts +44 -0
  369. package/src/hooks/renderUploadSidebarPanel.ts +47 -0
  370. package/src/hooks/settingsAreaSidebarItemGroups.ts +59 -0
  371. package/src/hooks/uploadSidebarPanels.ts +59 -0
  372. package/src/hooks/uploadSidebars.ts +38 -0
  373. package/src/hooks/uploadsDropdownActions.ts +22 -0
  374. package/src/hooks/validateManualFieldExtensionParameters.ts +12 -0
  375. package/src/{types.ts → icon.ts} +0 -1739
  376. package/src/index.ts +49 -4
  377. package/src/manifest.ts +3375 -0
  378. package/src/manifestTypes.ts +153 -0
  379. package/src/shared.ts +67 -0
  380. package/src/utils.ts +253 -0
  381. package/dist/cjs/guards.js +0 -19
  382. package/dist/cjs/guards.js.map +0 -1
  383. package/dist/cjs/types.js.map +0 -1
  384. package/dist/esm/guards.d.ts +0 -37
  385. package/dist/esm/guards.js +0 -16
  386. package/dist/esm/guards.js.map +0 -1
  387. package/dist/esm/types.d.ts +0 -1569
  388. package/dist/esm/types.js +0 -2
  389. package/dist/esm/types.js.map +0 -1
  390. package/dist/types/guards.d.ts +0 -37
  391. package/dist/types/types.d.ts +0 -1569
  392. package/src/guards.ts +0 -51
  393. package/types.json +0 -37437
@@ -0,0 +1,37 @@
1
+ import type { SchemaTypes } from '@datocms/cma-client';
2
+ import { Ctx } from '../ctx/base';
3
+
4
+ type ItemType = SchemaTypes.ItemType;
5
+
6
+ export type ItemCollectionOutletsHook = {
7
+ /**
8
+ * Use this function to declare custom outlets to be shown at the top of a
9
+ * collection of records of a particular model
10
+ *
11
+ * @tag outlets
12
+ */
13
+ itemCollectionOutlets: (
14
+ itemType: ItemType,
15
+ ctx: ItemCollectionOutletsCtx,
16
+ ) => ItemCollectionOutlet[];
17
+ };
18
+
19
+ export type ItemCollectionOutletsCtx = Ctx;
20
+
21
+ /** An outlet to be shown at the top of a record's collection page */
22
+ export type ItemCollectionOutlet = {
23
+ /**
24
+ * ID of the outlet. Will be the first argument for the `renderItemCollectionOutlet`
25
+ * function
26
+ */
27
+ id: string;
28
+ /**
29
+ * Multiple outlets will be sorted by ascending `rank`. If you want to specify
30
+ * an explicit value for `rank`, make sure to offer a way for final users to
31
+ * customize it inside the plugin's settings form, otherwise the hardcoded
32
+ * value you choose might clash with the one of another plugin!
33
+ */
34
+ rank?: number;
35
+ /** The initial height to set for the iframe that will render the outlet */
36
+ initialHeight?: number;
37
+ };
@@ -0,0 +1,27 @@
1
+ import type { SchemaTypes } from '@datocms/cma-client';
2
+ import { Ctx } from '../ctx/base';
3
+ import { ItemFormAdditionalProperties } from '../ctx/commonExtras/itemForm';
4
+ import { DropdownAction, DropdownActionGroup } from '../shared';
5
+
6
+ type ItemType = SchemaTypes.ItemType;
7
+
8
+ export type ItemFormDropdownActionsHook = {
9
+ /**
10
+ * Use this function to define custom actions (or groups of actions) to be
11
+ * displayed at when editing a particular record.
12
+ *
13
+ * The `executeItemFormDropdownAction()` hook will be triggered once the user
14
+ * clicks on one of the defined actions.
15
+ *
16
+ * @tag dropdownActions
17
+ */
18
+ itemFormDropdownActions: (
19
+ itemType: ItemType,
20
+ ctx: ItemFormDropdownActionsCtx,
21
+ ) => Array<DropdownAction | DropdownActionGroup>;
22
+ };
23
+
24
+ export type ItemFormDropdownActionsCtx = ItemFormDropdownActionsProperties;
25
+
26
+ export type ItemFormDropdownActionsProperties =
27
+ Ctx<ItemFormAdditionalProperties>;
@@ -0,0 +1,36 @@
1
+ import type { SchemaTypes } from '@datocms/cma-client';
2
+ import { Ctx } from '../ctx/base';
3
+
4
+ type ItemType = SchemaTypes.ItemType;
5
+
6
+ export type ItemFormOutletsHook = {
7
+ /**
8
+ * Use this function to declare custom outlets to be shown at the top of the
9
+ * record's editing page
10
+ *
11
+ * @tag outlets
12
+ */
13
+ itemFormOutlets: (
14
+ itemType: ItemType,
15
+ ctx: ItemFormOutletsCtx,
16
+ ) => ItemFormOutlet[];
17
+ };
18
+
19
+ export type ItemFormOutletsCtx = Ctx;
20
+
21
+ export type ItemFormOutlet = {
22
+ /**
23
+ * ID of the outlet. Will be the first argument for the `renderItemFormOutlet`
24
+ * function
25
+ */
26
+ id: string;
27
+ /**
28
+ * Multiple outlets will be sorted by ascending `rank`. If you want to specify
29
+ * an explicit value for `rank`, make sure to offer a way for final users to
30
+ * customize it inside the plugin's settings form, otherwise the hardcoded
31
+ * value you choose might clash with the one of another plugin!
32
+ */
33
+ rank?: number;
34
+ /** The initial height to set for the iframe that will render the outlet */
35
+ initialHeight?: number;
36
+ };
@@ -0,0 +1,54 @@
1
+ import type { SchemaTypes } from '@datocms/cma-client';
2
+ import { Ctx } from '../ctx/base';
3
+ import { ItemFormSidebarPanelPlacement } from '../shared';
4
+
5
+ type ItemType = SchemaTypes.ItemType;
6
+
7
+ export type ItemFormSidebarPanelsHook = {
8
+ /**
9
+ * Use this function to declare new sidebar panels to be shown when the user
10
+ * edits records of a particular model
11
+ *
12
+ * @tag sidebarPanels
13
+ */
14
+ itemFormSidebarPanels: (
15
+ itemType: ItemType,
16
+ ctx: ItemFormSidebarPanelsCtx,
17
+ ) => ItemFormSidebarPanel[];
18
+ };
19
+
20
+ export type ItemFormSidebarPanelsCtx = Ctx;
21
+
22
+ export type ItemFormSidebarPanel = {
23
+ /**
24
+ * ID of the panel. Will be the first argument for the
25
+ * `renderItemFormSidebarPanel` function
26
+ */
27
+ id: string;
28
+ /** Label to be shown on the collapsible sidebar panel handle */
29
+ label: string;
30
+ /**
31
+ * An arbitrary configuration object that will be passed as the `parameters`
32
+ * property of the second argument of the `renderItemFormSidebarPanel`
33
+ * function
34
+ */
35
+ parameters?: Record<string, unknown>;
36
+ /** Whether the sidebar panel will start open or collapsed */
37
+ startOpen?: boolean;
38
+ /**
39
+ * Expresses where you want the item to be placed inside the sidebar. If not
40
+ * specified, the item will be placed after the standard panels provided by
41
+ * DatoCMS itself.
42
+ */
43
+ placement?: ItemFormSidebarPanelPlacement;
44
+ /**
45
+ * If multiple sidebar panels specify the same `placement`, they will be
46
+ * sorted by ascending `rank`. If you want to specify an explicit value for
47
+ * `rank`, make sure to offer a way for final users to customize it inside the
48
+ * plugin's settings form, otherwise the hardcoded value you choose might
49
+ * clash with the one of another plugin!
50
+ */
51
+ rank?: number;
52
+ /** The initial height to set for the iframe that will render the sidebar panel */
53
+ initialHeight?: number;
54
+ };
@@ -0,0 +1,44 @@
1
+ import type { SchemaTypes } from '@datocms/cma-client';
2
+ import { Ctx } from '../ctx/base';
3
+
4
+ type ItemType = SchemaTypes.ItemType;
5
+
6
+ export type ItemFormSidebarsHook = {
7
+ /**
8
+ * Use this function to declare new sidebar to be shown when the user edits
9
+ * records of a particular model
10
+ *
11
+ * @tag sidebarPanels
12
+ */
13
+ itemFormSidebars: (
14
+ itemType: ItemType,
15
+ ctx: ItemFormSidebarsCtx,
16
+ ) => ItemFormSidebar[];
17
+ };
18
+
19
+ export type ItemFormSidebarsCtx = Ctx;
20
+
21
+ export type ItemFormSidebar = {
22
+ /**
23
+ * ID of the sidebar. Will be the first argument for the
24
+ * `renderItemFormSidebar` function
25
+ */
26
+ id: string;
27
+ /** Label to be shown on the collapsible sidebar handle */
28
+ label: string;
29
+ /**
30
+ * An arbitrary configuration object that will be passed as the `parameters`
31
+ * property of the second argument of the `renderItemFormSidebar` function
32
+ */
33
+ parameters?: Record<string, unknown>;
34
+ /**
35
+ * If multiple sidebars specify the same `placement`, they will be sorted by
36
+ * ascending `rank`. If you want to specify an explicit value for `rank`, make
37
+ * sure to offer a way for final users to customize it inside the plugin's
38
+ * settings form, otherwise the hardcoded value you choose might clash with
39
+ * the one of another plugin!
40
+ */
41
+ rank?: number;
42
+ /** The preferred width for the sidebar */
43
+ preferredWidth?: number;
44
+ };
@@ -0,0 +1,28 @@
1
+ import type { SchemaTypes } from '@datocms/cma-client';
2
+ import { Ctx } from '../ctx/base';
3
+ import { DropdownAction, DropdownActionGroup } from '../shared';
4
+
5
+ type ItemType = SchemaTypes.ItemType;
6
+
7
+ export type ItemsDropdownActionsHook = {
8
+ /**
9
+ * This function lets you set up custom actions (or groups of actions) that
10
+ * show up when the user:
11
+ *
12
+ * * selects multiple records in the collection view for batch operations, or
13
+ * * starts editing a specific record.
14
+ *
15
+ * The `executeItemsDropdownAction()` hook will be triggered once the user
16
+ * clicks on one of the defined actions.
17
+ *
18
+ * @tag dropdownActions
19
+ */
20
+ itemsDropdownActions: (
21
+ itemType: ItemType,
22
+ ctx: ItemDropdownActionsCtx,
23
+ ) => Array<DropdownAction | DropdownActionGroup>;
24
+ };
25
+
26
+ export type ItemDropdownActionsCtx = Ctx<{
27
+ itemType: ItemType;
28
+ }>;
@@ -0,0 +1,47 @@
1
+ import { Ctx } from '../ctx/base';
2
+ import { Icon } from '../icon';
3
+
4
+ export type MainNavigationTabsHook = {
5
+ /**
6
+ * Use this function to declare new tabs you want to add in the top-bar of the
7
+ * UI
8
+ *
9
+ * @tag pages
10
+ */
11
+ mainNavigationTabs: (ctx: MainNavigationTabsCtx) => MainNavigationTab[];
12
+ };
13
+
14
+ export type MainNavigationTabsCtx = Ctx;
15
+
16
+ /** A tab to be displayed in the top-bar of the UI */
17
+ export type MainNavigationTab = {
18
+ /** Label to be shown. Must be unique. */
19
+ label: string;
20
+ /**
21
+ * Icon to be shown alongside the label. Can be a FontAwesome icon name (ie.
22
+ * `"address-book"`) or a custom SVG definition. To maintain visual
23
+ * consistency with the rest of the interface, try to use FontAwesome icons
24
+ * whenever possible.
25
+ */
26
+ icon: Icon;
27
+ /** ID of the page linked to the tab */
28
+ pointsTo: {
29
+ pageId: string;
30
+ };
31
+ /**
32
+ * Expresses where you want to place the tab in the top-bar. If not specified,
33
+ * the tab will be placed after the standard tabs provided by DatoCMS itself.
34
+ */
35
+ placement?: [
36
+ 'before' | 'after',
37
+ 'content' | 'media' | 'schema' | 'configuration' | 'cdaPlayground',
38
+ ];
39
+ /**
40
+ * If different plugins specify the same `placement` for their tabs, they will
41
+ * be displayed by ascending `rank`. If you want to specify an explicit value
42
+ * for `rank`, make sure to offer a way for final users to customize it inside
43
+ * the plugin's settings form, otherwise the hardcoded value you choose might
44
+ * clash with the one of another plugin!
45
+ */
46
+ rank?: number;
47
+ };
@@ -0,0 +1,82 @@
1
+ import { Ctx } from '../ctx/base';
2
+
3
+ export type ManualFieldExtensionsHook = {
4
+ /**
5
+ * Use this function to declare new field extensions that users will be able
6
+ * to install manually in some field
7
+ *
8
+ * @tag manualFieldExtensions
9
+ */
10
+ manualFieldExtensions: (
11
+ ctx: ManualFieldExtensionsCtx,
12
+ ) => ManualFieldExtension[];
13
+ };
14
+
15
+ export type ManualFieldExtensionsCtx = Ctx;
16
+
17
+ export type ManualFieldExtension = {
18
+ /**
19
+ * ID of field extension. Will be the first argument for the
20
+ * `renderFieldExtension` function
21
+ */
22
+ id: string;
23
+ /** Name to be shown when editing fields */
24
+ name: string;
25
+ /**
26
+ * Type of field extension. An `editor` extension replaces the default field
27
+ * editor that DatoCMS provides, while an `addon` extension is placed
28
+ * underneath the field editor to provide additional info/behaviour. You can
29
+ * setup multiple field addons for every field.
30
+ */
31
+ type: FieldExtensionType;
32
+ /**
33
+ * For `editor` extensions: moves the field to the sidebar of the record
34
+ * editing page, mimicking a sidebar panel
35
+ */
36
+ asSidebarPanel?: boolean | { startOpen: boolean };
37
+ /**
38
+ * The type of fields that the field extension in compatible with. You can use
39
+ * the shortcut `all` to target all types of fields
40
+ */
41
+ fieldTypes: 'all' | FieldType[];
42
+ /**
43
+ * Whether this field extension needs some configuration options before being
44
+ * installed in a field or not. Will trigger the
45
+ * `renderManualFieldExtensionConfigScreen` and
46
+ * `validateManualFieldExtensionParameters` methods
47
+ */
48
+ configurable?: boolean | { initialHeight: number };
49
+ /**
50
+ * The initial height to set for the iframe that will render the field
51
+ * extension
52
+ */
53
+ initialHeight?: number;
54
+ };
55
+
56
+ /**
57
+ * The sidebar in the Content Area presents a number of user-defined menu-items.
58
+ * This object represents a new item to be added in the sidebar.
59
+ */
60
+
61
+ export type FieldExtensionType = 'editor' | 'addon';
62
+
63
+ export type FieldType =
64
+ | 'boolean'
65
+ | 'color'
66
+ | 'date_time'
67
+ | 'date'
68
+ | 'file'
69
+ | 'float'
70
+ | 'gallery'
71
+ | 'integer'
72
+ | 'json'
73
+ | 'lat_lon'
74
+ | 'link'
75
+ | 'links'
76
+ | 'rich_text'
77
+ | 'seo'
78
+ | 'slug'
79
+ | 'string'
80
+ | 'structured_text'
81
+ | 'text'
82
+ | 'video';
@@ -0,0 +1,21 @@
1
+ import type { SchemaTypes } from '@datocms/cma-client';
2
+ import { Ctx } from '../ctx/base';
3
+ import { MaybePromise } from '../utils';
4
+
5
+ type ItemUpdateSchema = SchemaTypes.ItemUpdateSchema;
6
+ type ItemCreateSchema = SchemaTypes.ItemCreateSchema;
7
+
8
+ export type OnBeforeItemUpsertHook = {
9
+ /**
10
+ * This function will be called before saving a new version of a record. You
11
+ * can stop the action by returning `false`
12
+ *
13
+ * @tag beforeHooks
14
+ */
15
+ onBeforeItemUpsert: (
16
+ createOrUpdateItemPayload: ItemUpdateSchema | ItemCreateSchema,
17
+ ctx: OnBeforeItemUpsertCtx,
18
+ ) => MaybePromise<boolean>;
19
+ };
20
+
21
+ export type OnBeforeItemUpsertCtx = Ctx;
@@ -0,0 +1,20 @@
1
+ import type { SchemaTypes } from '@datocms/cma-client';
2
+ import { Ctx } from '../ctx/base';
3
+ import { MaybePromise } from '../utils';
4
+
5
+ type Item = SchemaTypes.Item;
6
+
7
+ export type OnBeforeItemsDestroyHook = {
8
+ /**
9
+ * This function will be called before destroying records. You can stop the
10
+ * action by returning `false`
11
+ *
12
+ * @tag beforeHooks
13
+ */
14
+ onBeforeItemsDestroy: (
15
+ items: Item[],
16
+ ctx: OnBeforeItemsDestroyCtx,
17
+ ) => MaybePromise<boolean>;
18
+ };
19
+
20
+ export type OnBeforeItemsDestroyCtx = Ctx;
@@ -0,0 +1,20 @@
1
+ import type { SchemaTypes } from '@datocms/cma-client';
2
+ import { Ctx } from '../ctx/base';
3
+ import { MaybePromise } from '../utils';
4
+
5
+ type Item = SchemaTypes.Item;
6
+
7
+ export type OnBeforeItemsPublishHook = {
8
+ /**
9
+ * This function will be called before publishing records. You can stop the
10
+ * action by returning `false`
11
+ *
12
+ * @tag beforeHooks
13
+ */
14
+ onBeforeItemsPublish: (
15
+ items: Item[],
16
+ ctx: OnBeforeItemsPublishCtx,
17
+ ) => MaybePromise<boolean>;
18
+ };
19
+
20
+ export type OnBeforeItemsPublishCtx = Ctx;
@@ -0,0 +1,20 @@
1
+ import type { SchemaTypes } from '@datocms/cma-client';
2
+ import { Ctx } from '../ctx/base';
3
+ import { MaybePromise } from '../utils';
4
+
5
+ type Item = SchemaTypes.Item;
6
+
7
+ export type OnBeforeItemsUnpublishHook = {
8
+ /**
9
+ * This function will be called before unpublishing records. You can stop the
10
+ * action by returning `false`
11
+ *
12
+ * @tag beforeHooks
13
+ */
14
+ onBeforeItemsUnpublish: (
15
+ items: Item[],
16
+ ctx: OnBeforeItemsUnpublishCtx,
17
+ ) => MaybePromise<boolean>;
18
+ };
19
+
20
+ export type OnBeforeItemsUnpublishCtx = Ctx;
@@ -0,0 +1,13 @@
1
+ import { ImposedSizePluginFrameCtx } from '../ctx/pluginFrame';
2
+
3
+ export type OnBootHook = {
4
+ /**
5
+ * This function will be called once at boot time and can be used to perform
6
+ * ie. some initial integrity checks on the configuration.
7
+ *
8
+ * @tag boot
9
+ */
10
+ onBoot: (ctx: OnBootCtx) => void;
11
+ };
12
+
13
+ export type OnBootCtx = ImposedSizePluginFrameCtx<'onBoot'>;
@@ -0,0 +1,95 @@
1
+ import type { SchemaTypes } from '@datocms/cma-client';
2
+ import { Ctx } from '../ctx/base';
3
+ import { ItemFormSidebarPanelPlacement } from '../shared';
4
+
5
+ type Field = SchemaTypes.Field;
6
+ type ItemType = SchemaTypes.ItemType;
7
+
8
+ export type OverrideFieldExtensionsHook = {
9
+ /**
10
+ * Use this function to automatically force one or more field extensions to a
11
+ * particular field
12
+ *
13
+ * @tag forcedFieldExtensions
14
+ */
15
+ overrideFieldExtensions: (
16
+ field: Field,
17
+ ctx: OverrideFieldExtensionsCtx,
18
+ ) => FieldExtensionOverride | undefined;
19
+ };
20
+
21
+ export type OverrideFieldExtensionsCtx = Ctx<{
22
+ itemType: ItemType;
23
+ }>;
24
+
25
+ /**
26
+ * An object expressing some field extensions you want to force on a particular
27
+ * field
28
+ */
29
+ export type FieldExtensionOverride = {
30
+ /** Force a field editor/sidebar extension on a field */
31
+ editor?: EditorOverride;
32
+ /** One or more field sidebar extensions to forcefully add to a field */
33
+ addons?: AddonOverride[];
34
+ };
35
+
36
+ /** A field editor/sidebar forced on a field */
37
+ export type EditorOverride = {
38
+ /**
39
+ * ID of field extension. Will be the first argument for the
40
+ * `renderFieldExtension` function
41
+ */
42
+ id: string;
43
+ /**
44
+ * Moves the field to the sidebar of the record editing page, mimicking a
45
+ * sidebar panel
46
+ */
47
+ asSidebarPanel?:
48
+ | boolean
49
+ | { startOpen?: boolean; placement?: ItemFormSidebarPanelPlacement };
50
+ /**
51
+ * An arbitrary configuration object that will be passed as the `parameters`
52
+ * property of the second argument of the `renderFieldExtension` function
53
+ */
54
+ parameters?: Record<string, unknown>;
55
+ /**
56
+ * If multiple plugins override a field, the one with the lowest `rank` will
57
+ * win. If you want to specify an explicit value for `rank`, make sure to
58
+ * offer a way for final users to customize it inside the plugin's settings
59
+ * form, otherwise the hardcoded value you choose might clash with the one of
60
+ * another plugin!
61
+ */
62
+ rank?: number;
63
+ /**
64
+ * The initial height to set for the iframe that will render the field
65
+ * extension
66
+ */
67
+ initialHeight?: number;
68
+ };
69
+
70
+ /** A field addon extension forced on a field */
71
+ export type AddonOverride = {
72
+ /**
73
+ * ID of field extension. Will be the first argument for the
74
+ * `renderFieldExtension` function
75
+ */
76
+ id: string;
77
+ /**
78
+ * An arbitrary configuration object that will be passed as the `parameters`
79
+ * property of the second argument of the `renderFieldExtension` function
80
+ */
81
+ parameters?: Record<string, unknown>;
82
+ /**
83
+ * If multiple addons are present for a field, they will be sorted by
84
+ * ascending `rank`. If you want to specify an explicit value for `rank`, make
85
+ * sure to offer a way for final users to customize it inside the plugin's
86
+ * settings form, otherwise the hardcoded value you choose might clash with
87
+ * the one of another plugin!
88
+ */
89
+ rank?: number;
90
+ /**
91
+ * The initial height to set for the iframe that will render the field
92
+ * extension
93
+ */
94
+ initialHeight?: number;
95
+ };
@@ -0,0 +1,119 @@
1
+ import { SelfResizingPluginFrameCtx } from '../ctx/pluginFrame';
2
+ import { containedRenderModeBootstrapper } from '../utils';
3
+
4
+ export type RenderAssetSourceHook = {
5
+ /**
6
+ * This function will be called when the user selects one of the plugin's
7
+ * asset sources to upload a new media file.
8
+ *
9
+ * @tag assetSources
10
+ */
11
+ renderAssetSource: (assetSourceId: string, ctx: RenderAssetSourceCtx) => void;
12
+ };
13
+
14
+ export type RenderAssetSourceCtx = SelfResizingPluginFrameCtx<
15
+ 'renderAssetSource',
16
+ {
17
+ /** The ID of the assetSource that needs to be rendered */
18
+ assetSourceId: string;
19
+ },
20
+ {
21
+ /**
22
+ * Function to be called when the user selects the asset: it will trigger the
23
+ * creation of a new `Upload` that will be added in the Media Area.
24
+ *
25
+ * @example
26
+ *
27
+ * ```js
28
+ * await ctx.select({
29
+ * resource: {
30
+ * url: 'https://images.unsplash.com/photo-1416339306562-f3d12fefd36f',
31
+ * filename: 'man-drinking-coffee.jpg',
32
+ * },
33
+ * copyright: 'Royalty free (Unsplash)',
34
+ * author: 'Jeff Sheldon',
35
+ * notes: 'A man drinking a coffee',
36
+ * tags: ['man', 'coffee'],
37
+ * });
38
+ * ```
39
+ */
40
+ select: (newUpload: NewUpload) => void;
41
+ }
42
+ >;
43
+
44
+ export type NewUploadResourceAsUrl = {
45
+ /**
46
+ * URL for the resource. The URL must respond with a
47
+ * `Access-Control-Allow-Origin` header — for instance `*`, which will allow
48
+ * all hosts — allowing the image to be read by DatoCMS
49
+ */
50
+ url: string;
51
+ /** Any additional headers to pass when making the request to the URL */
52
+ headers?: Record<string, string>;
53
+ /**
54
+ * Optional filename to be used to generate the final DatoCMS URL. If not
55
+ * passed, the URL will be used
56
+ */
57
+ filename?: string;
58
+ };
59
+
60
+ export type NewUploadResourceAsBase64 = {
61
+ /**
62
+ * Base64 encoded data URI for the resource.
63
+ *
64
+ * Format:
65
+ *
66
+ * `data:[<mime type>][;charset=<charset>];base64,<encoded data>`
67
+ */
68
+ base64: string;
69
+ /** Filename to be used to generate the final DatoCMS URL */
70
+ filename: string;
71
+ };
72
+
73
+ export type NewUpload = {
74
+ /** The actual resource that will be uploaded */
75
+ resource: NewUploadResourceAsUrl | NewUploadResourceAsBase64;
76
+ /** Copyright to apply to the asset */
77
+ copyright?: string;
78
+ /** Author to apply to the asset */
79
+ author?: string;
80
+ /** Notes to apply to the asset */
81
+ notes?: string;
82
+ /** Tags to apply to the asset */
83
+ tags?: string[];
84
+ /**
85
+ * An hash containing, for each locale of the project, the default metadata to
86
+ * apply to the asset
87
+ */
88
+ default_field_metadata?: {
89
+ [k: string]: {
90
+ /** Alternate text for the asset */
91
+ alt: string | null;
92
+ /** Title for the asset */
93
+ title: string | null;
94
+ /** Object with arbitrary metadata */
95
+ custom_data: {
96
+ [k: string]: unknown;
97
+ };
98
+ /** Focal point (only for image assets) */
99
+ focal_point?: {
100
+ /** Horizontal position expressed as float between 0 and 1 */
101
+ x: number;
102
+ /** Vertical position expressed as float between 0 and 1 */
103
+ y: number;
104
+ } | null;
105
+ };
106
+ };
107
+ };
108
+
109
+ export const renderAssetSourceBootstrapper =
110
+ containedRenderModeBootstrapper<RenderAssetSourceCtx>(
111
+ 'renderAssetSource',
112
+ (configuration, ctx) => {
113
+ if (!configuration.renderAssetSource) {
114
+ return;
115
+ }
116
+
117
+ configuration.renderAssetSource(ctx.assetSourceId, ctx);
118
+ },
119
+ );