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