datocms-plugin-sdk 2.0.0 → 2.0.2

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 (114) hide show
  1. package/dist/cjs/hooks/renderItemCollectionOutlet.js.map +1 -1
  2. package/dist/cjs/manifest.js +2446 -2111
  3. package/dist/cjs/manifest.js.map +1 -1
  4. package/dist/esm/ctx/base.d.ts +43 -29
  5. package/dist/esm/ctx/commonExtras/field.d.ts +4 -0
  6. package/dist/esm/ctx/commonExtras/itemForm.d.ts +14 -12
  7. package/dist/esm/ctx/commonExtras/sizing.d.ts +1 -0
  8. package/dist/esm/hooks/assetSources.d.ts +2 -1
  9. package/dist/esm/hooks/buildItemPresentationInfo.d.ts +2 -1
  10. package/dist/esm/hooks/contentAreaSidebarItems.d.ts +2 -1
  11. package/dist/esm/hooks/customBlockStylesForStructuredTextField.d.ts +2 -2
  12. package/dist/esm/hooks/customMarksForStructuredTextField.d.ts +2 -2
  13. package/dist/esm/hooks/executeFieldDropdownAction.d.ts +9 -1
  14. package/dist/esm/hooks/executeItemFormDropdownAction.d.ts +9 -1
  15. package/dist/esm/hooks/executeItemsDropdownAction.d.ts +11 -1
  16. package/dist/esm/hooks/executeUploadsDropdownAction.d.ts +11 -1
  17. package/dist/esm/hooks/fieldDropdownActions.d.ts +9 -0
  18. package/dist/esm/hooks/initialLocationQueryForItemSelector.d.ts +2 -1
  19. package/dist/esm/hooks/itemCollectionOutlets.d.ts +8 -1
  20. package/dist/esm/hooks/itemFormDropdownActions.d.ts +9 -0
  21. package/dist/esm/hooks/itemFormOutlets.d.ts +3 -2
  22. package/dist/esm/hooks/itemFormSidebarPanels.d.ts +2 -1
  23. package/dist/esm/hooks/itemFormSidebars.d.ts +2 -1
  24. package/dist/esm/hooks/itemsDropdownActions.d.ts +12 -0
  25. package/dist/esm/hooks/mainNavigationTabs.d.ts +2 -1
  26. package/dist/esm/hooks/manualFieldExtensions.d.ts +2 -1
  27. package/dist/esm/hooks/onBeforeItemUpsert.d.ts +2 -1
  28. package/dist/esm/hooks/onBeforeItemsDestroy.d.ts +2 -1
  29. package/dist/esm/hooks/onBeforeItemsPublish.d.ts +2 -1
  30. package/dist/esm/hooks/onBeforeItemsUnpublish.d.ts +2 -1
  31. package/dist/esm/hooks/overrideFieldExtensions.d.ts +2 -2
  32. package/dist/esm/hooks/renderItemCollectionOutlet.d.ts +6 -0
  33. package/dist/esm/hooks/renderItemCollectionOutlet.js.map +1 -1
  34. package/dist/esm/hooks/renderItemFormOutlet.d.ts +3 -3
  35. package/dist/esm/hooks/settingsAreaSidebarItemGroups.d.ts +2 -1
  36. package/dist/esm/hooks/uploadSidebarPanels.d.ts +2 -1
  37. package/dist/esm/hooks/uploadSidebars.d.ts +2 -1
  38. package/dist/esm/hooks/uploadsDropdownActions.d.ts +15 -1
  39. package/dist/esm/manifest.js +2446 -2111
  40. package/dist/esm/manifest.js.map +1 -1
  41. package/dist/esm/manifestTypes.d.ts +117 -22
  42. package/dist/types/ctx/base.d.ts +43 -29
  43. package/dist/types/ctx/commonExtras/field.d.ts +4 -0
  44. package/dist/types/ctx/commonExtras/itemForm.d.ts +14 -12
  45. package/dist/types/ctx/commonExtras/sizing.d.ts +1 -0
  46. package/dist/types/hooks/assetSources.d.ts +2 -1
  47. package/dist/types/hooks/buildItemPresentationInfo.d.ts +2 -1
  48. package/dist/types/hooks/contentAreaSidebarItems.d.ts +2 -1
  49. package/dist/types/hooks/customBlockStylesForStructuredTextField.d.ts +2 -2
  50. package/dist/types/hooks/customMarksForStructuredTextField.d.ts +2 -2
  51. package/dist/types/hooks/executeFieldDropdownAction.d.ts +9 -1
  52. package/dist/types/hooks/executeItemFormDropdownAction.d.ts +9 -1
  53. package/dist/types/hooks/executeItemsDropdownAction.d.ts +11 -1
  54. package/dist/types/hooks/executeUploadsDropdownAction.d.ts +11 -1
  55. package/dist/types/hooks/fieldDropdownActions.d.ts +9 -0
  56. package/dist/types/hooks/initialLocationQueryForItemSelector.d.ts +2 -1
  57. package/dist/types/hooks/itemCollectionOutlets.d.ts +8 -1
  58. package/dist/types/hooks/itemFormDropdownActions.d.ts +9 -0
  59. package/dist/types/hooks/itemFormOutlets.d.ts +3 -2
  60. package/dist/types/hooks/itemFormSidebarPanels.d.ts +2 -1
  61. package/dist/types/hooks/itemFormSidebars.d.ts +2 -1
  62. package/dist/types/hooks/itemsDropdownActions.d.ts +12 -0
  63. package/dist/types/hooks/mainNavigationTabs.d.ts +2 -1
  64. package/dist/types/hooks/manualFieldExtensions.d.ts +2 -1
  65. package/dist/types/hooks/onBeforeItemUpsert.d.ts +2 -1
  66. package/dist/types/hooks/onBeforeItemsDestroy.d.ts +2 -1
  67. package/dist/types/hooks/onBeforeItemsPublish.d.ts +2 -1
  68. package/dist/types/hooks/onBeforeItemsUnpublish.d.ts +2 -1
  69. package/dist/types/hooks/overrideFieldExtensions.d.ts +2 -2
  70. package/dist/types/hooks/renderItemCollectionOutlet.d.ts +6 -0
  71. package/dist/types/hooks/renderItemFormOutlet.d.ts +3 -3
  72. package/dist/types/hooks/settingsAreaSidebarItemGroups.d.ts +2 -1
  73. package/dist/types/hooks/uploadSidebarPanels.d.ts +2 -1
  74. package/dist/types/hooks/uploadSidebars.d.ts +2 -1
  75. package/dist/types/hooks/uploadsDropdownActions.d.ts +15 -1
  76. package/dist/types/manifestTypes.d.ts +117 -22
  77. package/manifest.json +2354 -2019
  78. package/package.json +4 -4
  79. package/src/ctx/base.ts +62 -30
  80. package/src/ctx/commonExtras/field.ts +4 -0
  81. package/src/ctx/commonExtras/itemForm.ts +15 -12
  82. package/src/ctx/commonExtras/sizing.ts +1 -0
  83. package/src/hooks/assetSources.ts +3 -1
  84. package/src/hooks/buildItemPresentationInfo.ts +3 -1
  85. package/src/hooks/contentAreaSidebarItems.ts +5 -1
  86. package/src/hooks/customBlockStylesForStructuredTextField.ts +2 -2
  87. package/src/hooks/customMarksForStructuredTextField.ts +2 -2
  88. package/src/hooks/executeFieldDropdownAction.ts +7 -0
  89. package/src/hooks/executeItemFormDropdownAction.ts +7 -0
  90. package/src/hooks/executeItemsDropdownAction.ts +8 -0
  91. package/src/hooks/executeUploadsDropdownAction.ts +9 -0
  92. package/src/hooks/fieldDropdownActions.ts +9 -0
  93. package/src/hooks/initialLocationQueryForItemSelector.ts +3 -1
  94. package/src/hooks/itemCollectionOutlets.ts +9 -1
  95. package/src/hooks/itemFormDropdownActions.ts +9 -0
  96. package/src/hooks/itemFormOutlets.ts +7 -2
  97. package/src/hooks/itemFormSidebarPanels.ts +3 -1
  98. package/src/hooks/itemFormSidebars.ts +6 -1
  99. package/src/hooks/itemsDropdownActions.ts +12 -0
  100. package/src/hooks/mainNavigationTabs.ts +3 -1
  101. package/src/hooks/manualFieldExtensions.ts +5 -1
  102. package/src/hooks/onBeforeItemUpsert.ts +3 -1
  103. package/src/hooks/onBeforeItemsDestroy.ts +6 -1
  104. package/src/hooks/onBeforeItemsPublish.ts +6 -1
  105. package/src/hooks/onBeforeItemsUnpublish.ts +6 -1
  106. package/src/hooks/overrideFieldExtensions.ts +2 -2
  107. package/src/hooks/renderItemCollectionOutlet.ts +6 -0
  108. package/src/hooks/renderItemFormOutlet.ts +3 -3
  109. package/src/hooks/settingsAreaSidebarItemGroups.ts +5 -1
  110. package/src/hooks/uploadSidebarPanels.ts +3 -1
  111. package/src/hooks/uploadSidebars.ts +3 -1
  112. package/src/hooks/uploadsDropdownActions.ts +15 -1
  113. package/src/manifest.ts +2562 -2151
  114. package/src/manifestTypes.ts +125 -28
@@ -2,7 +2,15 @@ import { Ctx } from '../ctx/base';
2
2
  import type { FieldAdditionalProperties } from '../ctx/commonExtras/field';
3
3
  import type { ItemFormAdditionalMethods, ItemFormAdditionalProperties } from '../ctx/commonExtras/itemForm';
4
4
  export type ExecuteFieldDropdownActionHook = {
5
- executeFieldDropdownAction: (actionId: string, ctx: ExecuteFieldDropdownActionCtx) => Promise<void>;
5
+ /**
6
+ * Use this function to execute a particular dropdown action defined via
7
+ * the `fieldDropdownActions()` hook.
8
+ *
9
+ * @tag dropdownActions
10
+ */
11
+ executeFieldDropdownAction: (
12
+ /** The ID of the action that was requested by the user */
13
+ actionId: string, ctx: ExecuteFieldDropdownActionCtx) => Promise<void>;
6
14
  };
7
15
  export type ExecuteFieldDropdownActionCtx = Ctx<ItemFormAdditionalProperties & FieldAdditionalProperties & {
8
16
  parameters: Record<string, unknown> | undefined;
@@ -1,7 +1,15 @@
1
1
  import { Ctx } from '../ctx/base';
2
2
  import type { ItemFormAdditionalMethods, ItemFormAdditionalProperties } from '../ctx/commonExtras/itemForm';
3
3
  export type ExecuteItemFormDropdownActionHook = {
4
- executeItemFormDropdownAction: (actionId: string, ctx: ExecuteItemFormDropdownActionCtx) => Promise<void>;
4
+ /**
5
+ * Use this function to execute a particular dropdown action defined via
6
+ * the `itemFormDropdownActions()` hook.
7
+ *
8
+ * @tag dropdownActions
9
+ */
10
+ executeItemFormDropdownAction: (
11
+ /** The ID of the action that was requested by the user */
12
+ actionId: string, ctx: ExecuteItemFormDropdownActionCtx) => Promise<void>;
5
13
  };
6
14
  export type ExecuteItemFormDropdownActionCtx = Ctx<ItemFormAdditionalProperties & {
7
15
  parameters: Record<string, unknown> | undefined;
@@ -2,7 +2,17 @@ import type { SchemaTypes } from '@datocms/cma-client';
2
2
  import { Ctx } from '../ctx/base';
3
3
  type Item = SchemaTypes.Item;
4
4
  export type ExecuteItemsDropdownActionHook = {
5
- executeItemsDropdownAction: (actionId: string, items: Item[], ctx: ExecuteItemsDropdownActionCtx) => Promise<void>;
5
+ /**
6
+ * Use this function to execute a particular dropdown action defined via
7
+ * the `itemsDropdownActions()` hook.
8
+ *
9
+ * @tag dropdownActions
10
+ */
11
+ executeItemsDropdownAction: (
12
+ /** The ID of the action that was requested by the user */
13
+ actionId: string,
14
+ /** The records on which the action should be executed */
15
+ items: Item[], ctx: ExecuteItemsDropdownActionCtx) => Promise<void>;
6
16
  };
7
17
  export type ExecuteItemsDropdownActionCtx = Ctx<{
8
18
  parameters: Record<string, unknown> | undefined;
@@ -2,7 +2,17 @@ import type { SchemaTypes } from '@datocms/cma-client';
2
2
  import { Ctx } from '../ctx/base';
3
3
  type Upload = SchemaTypes.Upload;
4
4
  export type ExecuteUploadsDropdownActionHook = {
5
- executeUploadsDropdownAction: (actionId: string, uploads: Upload[], ctx: ExecuteUploadsDropdownActionCtx) => Promise<void>;
5
+ /**
6
+ * Use this function to execute a particular dropdown action defined via
7
+ * the `uploadsDropdownActions()` hook.
8
+ *
9
+ * @tag dropdownActions
10
+ */
11
+ executeUploadsDropdownAction: (
12
+ /** The ID of the action that was requested by the user */
13
+ actionId: string,
14
+ /** The assets on which the action should be executed */
15
+ uploads: Upload[], ctx: ExecuteUploadsDropdownActionCtx) => Promise<void>;
6
16
  };
7
17
  export type ExecuteUploadsDropdownActionCtx = Ctx<{
8
18
  parameters: Record<string, unknown> | undefined;
@@ -5,6 +5,15 @@ import { ItemFormAdditionalProperties } from '../ctx/commonExtras/itemForm';
5
5
  import { DropdownAction, DropdownActionGroup } from '../shared';
6
6
  type Field = SchemaTypes.Field;
7
7
  export type FieldDropdownActionsHook = {
8
+ /**
9
+ * Use this function to define custom actions (or groups of actions) to be
10
+ * displayed at the individual field level in the record editing form.
11
+ *
12
+ * The `executeFieldDropdownAction()` hook will be triggered once the user
13
+ * clicks on one of the defined actions.
14
+ *
15
+ * @tag dropdownActions
16
+ */
8
17
  fieldDropdownActions: (field: Field, ctx: FieldDropdownActionsCtx) => Array<DropdownAction | DropdownActionGroup>;
9
18
  };
10
19
  export type FieldDropdownActionsCtx = Ctx<ItemFormAdditionalProperties & FieldAdditionalProperties>;
@@ -10,8 +10,9 @@ export type InitialLocationQueryForItemSelectorHook = {
10
10
  *
11
11
  * @tag locationQuery
12
12
  */
13
- initialLocationQueryForItemSelector: (openerField: Field, itemType: ItemType, ctx: Ctx) => MaybePromise<InitialLocationQueryForItemSelector | undefined>;
13
+ initialLocationQueryForItemSelector: (openerField: Field, itemType: ItemType, ctx: InitialLocationQueryForItemSelectorCtx) => MaybePromise<InitialLocationQueryForItemSelector | undefined>;
14
14
  };
15
+ export type InitialLocationQueryForItemSelectorCtx = Ctx;
15
16
  export type InitialLocationQueryForItemSelector = {
16
17
  locationQuery: ItemListLocationQuery;
17
18
  /**
@@ -2,8 +2,15 @@ import type { SchemaTypes } from '@datocms/cma-client';
2
2
  import { Ctx } from '../ctx/base';
3
3
  type ItemType = SchemaTypes.ItemType;
4
4
  export type ItemCollectionOutletsHook = {
5
- itemCollectionOutlets: (itemType: ItemType, ctx: Ctx) => ItemCollectionOutlet[];
5
+ /**
6
+ * Use this function to declare custom outlets to be shown at the top of a
7
+ * collection of records of a particular model
8
+ *
9
+ * @tag outlets
10
+ */
11
+ itemCollectionOutlets: (itemType: ItemType, ctx: ItemCollectionOutletsCtx) => ItemCollectionOutlet[];
6
12
  };
13
+ export type ItemCollectionOutletsCtx = Ctx;
7
14
  /** An outlet to be shown at the top of a record's collection page */
8
15
  export type ItemCollectionOutlet = {
9
16
  /**
@@ -4,6 +4,15 @@ import { ItemFormAdditionalProperties } from '../ctx/commonExtras/itemForm';
4
4
  import { DropdownAction, DropdownActionGroup } from '../shared';
5
5
  type ItemType = SchemaTypes.ItemType;
6
6
  export type ItemFormDropdownActionsHook = {
7
+ /**
8
+ * Use this function to define custom actions (or groups of actions) to be
9
+ * displayed at when editing a particular record.
10
+ *
11
+ * The `executeItemFormDropdownAction()` hook will be triggered once the user
12
+ * clicks on one of the defined actions.
13
+ *
14
+ * @tag dropdownActions
15
+ */
7
16
  itemFormDropdownActions: (itemType: ItemType, ctx: ItemFormDropdownActionsCtx) => Array<DropdownAction | DropdownActionGroup>;
8
17
  };
9
18
  export type ItemFormDropdownActionsCtx = ItemFormDropdownActionsProperties;
@@ -6,10 +6,11 @@ export type ItemFormOutletsHook = {
6
6
  * Use this function to declare custom outlets to be shown at the top of the
7
7
  * record's editing page
8
8
  *
9
- * @tag itemFormOutlets
9
+ * @tag outlets
10
10
  */
11
- itemFormOutlets: (itemType: ItemType, ctx: Ctx) => ItemFormOutlet[];
11
+ itemFormOutlets: (itemType: ItemType, ctx: ItemFormOutletsCtx) => ItemFormOutlet[];
12
12
  };
13
+ export type ItemFormOutletsCtx = Ctx;
13
14
  export type ItemFormOutlet = {
14
15
  /**
15
16
  * ID of the outlet. Will be the first argument for the `renderItemFormOutlet`
@@ -9,8 +9,9 @@ export type ItemFormSidebarPanelsHook = {
9
9
  *
10
10
  * @tag sidebarPanels
11
11
  */
12
- itemFormSidebarPanels: (itemType: ItemType, ctx: Ctx) => ItemFormSidebarPanel[];
12
+ itemFormSidebarPanels: (itemType: ItemType, ctx: ItemFormSidebarPanelsCtx) => ItemFormSidebarPanel[];
13
13
  };
14
+ export type ItemFormSidebarPanelsCtx = Ctx;
14
15
  export type ItemFormSidebarPanel = {
15
16
  /**
16
17
  * ID of the panel. Will be the first argument for the
@@ -8,8 +8,9 @@ export type ItemFormSidebarsHook = {
8
8
  *
9
9
  * @tag sidebarPanels
10
10
  */
11
- itemFormSidebars: (itemType: ItemType, ctx: Ctx) => ItemFormSidebar[];
11
+ itemFormSidebars: (itemType: ItemType, ctx: ItemFormSidebarsCtx) => ItemFormSidebar[];
12
12
  };
13
+ export type ItemFormSidebarsCtx = Ctx;
13
14
  export type ItemFormSidebar = {
14
15
  /**
15
16
  * ID of the sidebar. Will be the first argument for the
@@ -3,6 +3,18 @@ import { Ctx } from '../ctx/base';
3
3
  import { DropdownAction, DropdownActionGroup } from '../shared';
4
4
  type ItemType = SchemaTypes.ItemType;
5
5
  export type ItemsDropdownActionsHook = {
6
+ /**
7
+ * This function lets you set up custom actions (or groups of actions) that
8
+ * show up when the user:
9
+ *
10
+ * * selects multiple records in the collection view for batch operations, or
11
+ * * starts editing a specific record.
12
+ *
13
+ * The `executeItemsDropdownAction()` hook will be triggered once the user
14
+ * clicks on one of the defined actions.
15
+ *
16
+ * @tag dropdownActions
17
+ */
6
18
  itemsDropdownActions: (itemType: ItemType, ctx: ItemDropdownActionsCtx) => Array<DropdownAction | DropdownActionGroup>;
7
19
  };
8
20
  export type ItemDropdownActionsCtx = Ctx<{
@@ -7,8 +7,9 @@ export type MainNavigationTabsHook = {
7
7
  *
8
8
  * @tag pages
9
9
  */
10
- mainNavigationTabs: (ctx: Ctx) => MainNavigationTab[];
10
+ mainNavigationTabs: (ctx: MainNavigationTabsCtx) => MainNavigationTab[];
11
11
  };
12
+ export type MainNavigationTabsCtx = Ctx;
12
13
  /** A tab to be displayed in the top-bar of the UI */
13
14
  export type MainNavigationTab = {
14
15
  /** Label to be shown. Must be unique. */
@@ -6,8 +6,9 @@ export type ManualFieldExtensionsHook = {
6
6
  *
7
7
  * @tag manualFieldExtensions
8
8
  */
9
- manualFieldExtensions: (ctx: Ctx) => ManualFieldExtension[];
9
+ manualFieldExtensions: (ctx: ManualFieldExtensionsCtx) => ManualFieldExtension[];
10
10
  };
11
+ export type ManualFieldExtensionsCtx = Ctx;
11
12
  export type ManualFieldExtension = {
12
13
  /**
13
14
  * ID of field extension. Will be the first argument for the
@@ -10,6 +10,7 @@ export type OnBeforeItemUpsertHook = {
10
10
  *
11
11
  * @tag beforeHooks
12
12
  */
13
- onBeforeItemUpsert: (createOrUpdateItemPayload: ItemUpdateSchema | ItemCreateSchema, ctx: Ctx) => MaybePromise<boolean>;
13
+ onBeforeItemUpsert: (createOrUpdateItemPayload: ItemUpdateSchema | ItemCreateSchema, ctx: OnBeforeItemUpsertCtx) => MaybePromise<boolean>;
14
14
  };
15
+ export type OnBeforeItemUpsertCtx = Ctx;
15
16
  export {};
@@ -9,6 +9,7 @@ export type OnBeforeItemsDestroyHook = {
9
9
  *
10
10
  * @tag beforeHooks
11
11
  */
12
- onBeforeItemsDestroy: (items: Item[], ctx: Ctx) => MaybePromise<boolean>;
12
+ onBeforeItemsDestroy: (items: Item[], ctx: OnBeforeItemsDestroyCtx) => MaybePromise<boolean>;
13
13
  };
14
+ export type OnBeforeItemsDestroyCtx = Ctx;
14
15
  export {};
@@ -9,6 +9,7 @@ export type OnBeforeItemsPublishHook = {
9
9
  *
10
10
  * @tag beforeHooks
11
11
  */
12
- onBeforeItemsPublish: (items: Item[], ctx: Ctx) => MaybePromise<boolean>;
12
+ onBeforeItemsPublish: (items: Item[], ctx: OnBeforeItemsPublishCtx) => MaybePromise<boolean>;
13
13
  };
14
+ export type OnBeforeItemsPublishCtx = Ctx;
14
15
  export {};
@@ -9,6 +9,7 @@ export type OnBeforeItemsUnpublishHook = {
9
9
  *
10
10
  * @tag beforeHooks
11
11
  */
12
- onBeforeItemsUnpublish: (items: Item[], ctx: Ctx) => MaybePromise<boolean>;
12
+ onBeforeItemsUnpublish: (items: Item[], ctx: OnBeforeItemsUnpublishCtx) => MaybePromise<boolean>;
13
13
  };
14
+ export type OnBeforeItemsUnpublishCtx = Ctx;
14
15
  export {};
@@ -10,9 +10,9 @@ export type OverrideFieldExtensionsHook = {
10
10
  *
11
11
  * @tag forcedFieldExtensions
12
12
  */
13
- overrideFieldExtensions: (field: Field, ctx: OverrideFieldExtensionsHookCtx) => FieldExtensionOverride | undefined;
13
+ overrideFieldExtensions: (field: Field, ctx: OverrideFieldExtensionsCtx) => FieldExtensionOverride | undefined;
14
14
  };
15
- export type OverrideFieldExtensionsHookCtx = Ctx<{
15
+ export type OverrideFieldExtensionsCtx = Ctx<{
16
16
  itemType: ItemType;
17
17
  }>;
18
18
  /**
@@ -1,5 +1,11 @@
1
1
  import { SelfResizingPluginFrameCtx } from '../ctx/pluginFrame';
2
2
  export type RenderItemCollectionOutletHook = {
3
+ /**
4
+ * This function will be called when the plugin needs to render an outlet
5
+ * defined by the `itemFormOutlets()` hook.
6
+ *
7
+ * @tag outlets
8
+ */
3
9
  renderItemCollectionOutlet: (itemCollectionOutletId: string, ctx: RenderItemCollectionOutletCtx) => void;
4
10
  };
5
11
  export type RenderItemCollectionOutletCtx = SelfResizingPluginFrameCtx<'renderItemCollectionOutlet', {
@@ -2,10 +2,10 @@ import { ItemFormAdditionalMethods, ItemFormAdditionalProperties } from '../ctx/
2
2
  import { SelfResizingPluginFrameCtx } from '../ctx/pluginFrame';
3
3
  export type RenderItemFormOutletHook = {
4
4
  /**
5
- * This function will be called when the plugin needs to render an outlet (see
6
- * the `itemFormOutlets` function)
5
+ * This function will be called when the plugin needs to render an outlet
6
+ * defined by the `itemFormOutlets()` hook.
7
7
  *
8
- * @tag itemFormOutlets
8
+ * @tag outlets
9
9
  */
10
10
  renderItemFormOutlet: (itemFormOutletId: string, ctx: RenderItemFormOutletCtx) => void;
11
11
  };
@@ -7,8 +7,9 @@ export type SettingsAreaSidebarItemGroupsHook = {
7
7
  *
8
8
  * @tag pages
9
9
  */
10
- settingsAreaSidebarItemGroups: (ctx: Ctx) => SettingsAreaSidebarItemGroup[];
10
+ settingsAreaSidebarItemGroups: (ctx: SettingsAreaSidebarItemGroupsCtx) => SettingsAreaSidebarItemGroup[];
11
11
  };
12
+ export type SettingsAreaSidebarItemGroupsCtx = Ctx;
12
13
  /**
13
14
  * The sidebar in the Settings Area presents a number of pages grouped by topic.
14
15
  * This object represents a new group to be added in the sideebar to the
@@ -6,8 +6,9 @@ export type UploadSidebarPanelsHook = {
6
6
  *
7
7
  * @tag sidebarPanels
8
8
  */
9
- uploadSidebarPanels: (ctx: Ctx) => UploadSidebarPanel[];
9
+ uploadSidebarPanels: (ctx: UploadSidebarPanelsCtx) => UploadSidebarPanel[];
10
10
  };
11
+ export type UploadSidebarPanelsCtx = Ctx;
11
12
  export type UploadSidebarPanel = {
12
13
  /**
13
14
  * ID of the panel. Will be the first argument for the
@@ -6,8 +6,9 @@ export type UploadSidebarsHook = {
6
6
  *
7
7
  * @tag sidebarPanels
8
8
  */
9
- uploadSidebars: (ctx: Ctx) => UploadSidebar[];
9
+ uploadSidebars: (ctx: UploadSidebarsCtx) => UploadSidebar[];
10
10
  };
11
+ export type UploadSidebarsCtx = Ctx;
11
12
  export type UploadSidebar = {
12
13
  /**
13
14
  * ID of the sidebar. Will be the first argument for the
@@ -1,5 +1,19 @@
1
1
  import { Ctx } from '../ctx/base';
2
2
  import { DropdownAction, DropdownActionGroup } from '../shared';
3
3
  export type UploadsDropdownActionsHook = {
4
- uploadsDropdownActions: (ctx: Ctx) => Array<DropdownAction | DropdownActionGroup>;
4
+ /**
5
+ * This function lets you set up custom actions (or groups of actions) that
6
+ * show up when the user:
7
+ *
8
+ * * selects multiple assets in the Media Area for batch operations, or
9
+ * * opens up a specific asset from the Media Area.
10
+ *
11
+ * The `executeUploadsDropdownAction()` hook will be triggered once the user
12
+ * clicks on one of the defined actions.
13
+ *
14
+ * @tag dropdownActions
15
+ */
16
+ uploadsDropdownActions: (ctx: UploadsDropdownActionsCtx) => Array<DropdownAction | DropdownActionGroup>;
5
17
  };
18
+ type UploadsDropdownActionsCtx = Ctx;
19
+ export {};
@@ -1,51 +1,146 @@
1
+ /**
2
+ * Type representing a manifest.
3
+ */
1
4
  export type Manifest = {
5
+ /**
6
+ * Hooks and their respective information.
7
+ */
2
8
  hooks: Record<string, HookInfo>;
9
+ /**
10
+ * Base properties and methods available on every context argument.
11
+ */
3
12
  baseCtx: {
4
- properties: AdditionalPropertiesOrMethods;
5
- methods: AdditionalPropertiesOrMethods;
13
+ /**
14
+ * Properties in the base context.
15
+ */
16
+ properties: AdditionalPropertiesOrMethodsGroup[];
17
+ /**
18
+ * Methods in the base context.
19
+ */
20
+ methods: AdditionalPropertiesOrMethodsGroup[];
6
21
  };
7
- selfResizingPluginFrameCtxSizingUtilities: AdditionalPropertiesOrMethods;
22
+ /**
23
+ * Extra properties and methods available on every SelfResizingPluginFrameCtx context argument
24
+ */
25
+ selfResizingPluginFrameCtxSizingUtilities: AdditionalPropertiesOrMethodsGroup;
26
+ };
27
+ /**
28
+ * Type representing hook information.
29
+ */
30
+ export type HookInfo = {
31
+ /**
32
+ * Name of the hook.
33
+ */
34
+ name: string;
35
+ /**
36
+ * JSDoc comment and tag for the hook.
37
+ */
38
+ comment?: Comment;
39
+ /**
40
+ * Non-context arguments for the hook.
41
+ */
42
+ nonCtxArguments: NonCtxArgument[];
43
+ /**
44
+ * Context argument for the hook, if any.
45
+ */
46
+ ctxArgument?: CtxArgument;
47
+ /**
48
+ * Return type of the hook function.
49
+ */
50
+ returnType: string;
51
+ /**
52
+ * Code location where the hook is defined.
53
+ */
54
+ location: CodeLocation;
55
+ };
56
+ /**
57
+ * Type representing a code location.
58
+ */
59
+ export type CodeLocation = {
60
+ /**
61
+ * File path where the code is defined.
62
+ */
63
+ filePath: string;
64
+ /**
65
+ * Line number in the file where the hook is defined.
66
+ */
67
+ lineNumber: number;
8
68
  };
9
69
  /**
10
70
  * Type alias for additional parameters or methods in context.
11
71
  */
12
72
  export type AdditionalPropertyOrMethod = {
13
- comment: Comment | null;
14
- location: {
15
- filePath: string;
16
- lineNumber: number;
17
- };
73
+ /**
74
+ * Description of the parameter or method.
75
+ */
76
+ comment?: Comment;
77
+ /**
78
+ * Code location where the parameter or method is defined.
79
+ */
80
+ location: CodeLocation;
81
+ /**
82
+ * Type of the parameter or method.
83
+ */
18
84
  type: string;
19
85
  };
20
- export type AdditionalPropertiesOrMethods = Record<string, AdditionalPropertyOrMethod>;
86
+ export type AdditionalPropertiesOrMethodsGroup = {
87
+ /**
88
+ * Name of the group
89
+ */
90
+ name?: string;
91
+ /**
92
+ * Description of the group
93
+ */
94
+ comment?: Comment;
95
+ /**
96
+ * Type of the parameter or method.
97
+ */
98
+ items: Record<string, AdditionalPropertyOrMethod>;
99
+ };
21
100
  /**
22
101
  * Type alias for the context argument extracted from hook type.
23
102
  */
24
103
  export type CtxArgument = {
104
+ /**
105
+ * Type of the context argument.
106
+ */
25
107
  type: string;
26
- additionalProperties: AdditionalPropertiesOrMethods | null;
27
- additionalMethods: AdditionalPropertiesOrMethods | null;
108
+ /**
109
+ * Additional properties in the context argument, if any.
110
+ */
111
+ additionalProperties?: AdditionalPropertiesOrMethodsGroup[];
112
+ /**
113
+ * Additional methods in the context argument, if any.
114
+ */
115
+ additionalMethods?: AdditionalPropertiesOrMethodsGroup[];
28
116
  };
29
117
  /**
30
118
  * Type alias for non-context arguments.
31
119
  */
32
120
  export type NonCtxArgument = {
121
+ /**
122
+ * Name of the non-context argument.
123
+ */
33
124
  name: string;
125
+ /**
126
+ * Type name of the non-context argument.
127
+ */
34
128
  typeName: string;
35
129
  };
36
- export interface HookInfo {
37
- name: string;
38
- comment: Comment | null;
39
- nonCtxArguments: NonCtxArgument[];
40
- ctxArgument: CtxArgument | null;
41
- returnType: string;
42
- location: {
43
- filePath: string;
44
- lineNumber: number;
45
- };
46
- }
130
+ /**
131
+ * Type representing a comment.
132
+ */
47
133
  export type Comment = {
134
+ /**
135
+ * The comment itself.
136
+ */
48
137
  comment: string;
138
+ /**
139
+ * JSDoc tag for the comment, if any.
140
+ */
49
141
  tag?: string;
142
+ /**
143
+ * Example or example code for the comment, if any.
144
+ */
50
145
  example?: string;
51
146
  };