datocms-plugin-sdk 2.0.11 → 2.0.13

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 (41) hide show
  1. package/dist/cjs/connect.js.map +1 -1
  2. package/dist/cjs/hooks/executeSchemaItemTypeDropdownAction.js +3 -0
  3. package/dist/cjs/hooks/executeSchemaItemTypeDropdownAction.js.map +1 -0
  4. package/dist/cjs/hooks/renderPage.js.map +1 -1
  5. package/dist/cjs/hooks/schemaItemTypeDropdownActions.js +3 -0
  6. package/dist/cjs/hooks/schemaItemTypeDropdownActions.js.map +1 -0
  7. package/dist/cjs/index.js +2 -0
  8. package/dist/cjs/index.js.map +1 -1
  9. package/dist/cjs/manifest.js +110 -28
  10. package/dist/cjs/manifest.js.map +1 -1
  11. package/dist/esm/connect.d.ts +3 -1
  12. package/dist/esm/connect.js.map +1 -1
  13. package/dist/esm/ctx/base.d.ts +2 -0
  14. package/dist/esm/hooks/executeSchemaItemTypeDropdownAction.d.ts +20 -0
  15. package/dist/esm/hooks/executeSchemaItemTypeDropdownAction.js +2 -0
  16. package/dist/esm/hooks/executeSchemaItemTypeDropdownAction.js.map +1 -0
  17. package/dist/esm/hooks/renderPage.d.ts +6 -0
  18. package/dist/esm/hooks/renderPage.js.map +1 -1
  19. package/dist/esm/hooks/schemaItemTypeDropdownActions.d.ts +17 -0
  20. package/dist/esm/hooks/schemaItemTypeDropdownActions.js +2 -0
  21. package/dist/esm/hooks/schemaItemTypeDropdownActions.js.map +1 -0
  22. package/dist/esm/index.d.ts +2 -0
  23. package/dist/esm/index.js +2 -0
  24. package/dist/esm/index.js.map +1 -1
  25. package/dist/esm/manifest.js +110 -28
  26. package/dist/esm/manifest.js.map +1 -1
  27. package/dist/types/connect.d.ts +3 -1
  28. package/dist/types/ctx/base.d.ts +2 -0
  29. package/dist/types/hooks/executeSchemaItemTypeDropdownAction.d.ts +20 -0
  30. package/dist/types/hooks/renderPage.d.ts +6 -0
  31. package/dist/types/hooks/schemaItemTypeDropdownActions.d.ts +17 -0
  32. package/dist/types/index.d.ts +2 -0
  33. package/manifest.json +110 -28
  34. package/package.json +2 -2
  35. package/src/connect.ts +4 -0
  36. package/src/ctx/base.ts +3 -0
  37. package/src/hooks/executeSchemaItemTypeDropdownAction.ts +24 -0
  38. package/src/hooks/renderPage.ts +7 -0
  39. package/src/hooks/schemaItemTypeDropdownActions.ts +22 -0
  40. package/src/index.ts +2 -0
  41. package/src/manifest.ts +113 -28
@@ -0,0 +1,20 @@
1
+ import type { SchemaTypes } from '@datocms/cma-client';
2
+ import { Ctx } from '../ctx/base';
3
+ type ItemType = SchemaTypes.ItemType;
4
+ export type ExecuteSchemaItemTypeDropdownActionHook = {
5
+ /**
6
+ * Use this function to execute a particular dropdown action defined via
7
+ * the `schemaItemTypeDropdownActions()` hook.
8
+ *
9
+ * @tag dropdownActions
10
+ */
11
+ executeSchemaItemTypeDropdownAction: (
12
+ /** The ID of the action that was requested by the user */
13
+ actionId: string,
14
+ /** The model/block model on which the action should be executed */
15
+ itemType: ItemType, ctx: ExecuteSchemaItemTypeDropdownActionCtx) => Promise<void>;
16
+ };
17
+ export type ExecuteSchemaItemTypeDropdownActionCtx = Ctx<{
18
+ parameters: Record<string, unknown> | undefined;
19
+ }>;
20
+ export {};
@@ -12,5 +12,11 @@ export type RenderPageHook = {
12
12
  export type RenderPageCtx = ImposedSizePluginFrameCtx<'renderPage', {
13
13
  /** The ID of the page that needs to be rendered */
14
14
  pageId: string;
15
+ /** Current page location */
16
+ location: {
17
+ pathname: string;
18
+ search: string;
19
+ hash: string;
20
+ };
15
21
  }>;
16
22
  export declare const renderPageBootstrapper: import("../utils").Bootstrapper<"renderPage">;
@@ -0,0 +1,17 @@
1
+ import type { SchemaTypes } from '@datocms/cma-client';
2
+ import { Ctx } from '../ctx/base';
3
+ import { DropdownAction, DropdownActionGroup } from '../shared';
4
+ type ItemType = SchemaTypes.ItemType;
5
+ export type SchemaItemTypeDropdownActionsHook = {
6
+ /**
7
+ * Use this function to define custom actions (or groups of actions) for a model/block model in the Schema section.
8
+ *
9
+ * The `executeSchemaItemTypeDropdownAction()` hook will be triggered once the user
10
+ * clicks on one of the defined actions.
11
+ *
12
+ * @tag dropdownActions
13
+ */
14
+ schemaItemTypeDropdownActions: (itemType: ItemType, ctx: SchemaItemTypeDropdownActionsCtx) => Array<DropdownAction | DropdownActionGroup>;
15
+ };
16
+ export type SchemaItemTypeDropdownActionsCtx = Ctx;
17
+ export {};
@@ -23,6 +23,7 @@ export * from './hooks/customMarksForStructuredTextField';
23
23
  export * from './hooks/executeFieldDropdownAction';
24
24
  export * from './hooks/executeItemFormDropdownAction';
25
25
  export * from './hooks/executeItemsDropdownAction';
26
+ export * from './hooks/executeSchemaItemTypeDropdownAction';
26
27
  export * from './hooks/executeUploadsDropdownAction';
27
28
  export * from './hooks/fieldDropdownActions';
28
29
  export * from './hooks/initialLocationQueryForItemSelector';
@@ -52,6 +53,7 @@ export * from './hooks/renderModal';
52
53
  export * from './hooks/renderPage';
53
54
  export * from './hooks/renderUploadSidebar';
54
55
  export * from './hooks/renderUploadSidebarPanel';
56
+ export * from './hooks/schemaItemTypeDropdownActions';
55
57
  export * from './hooks/settingsAreaSidebarItemGroups';
56
58
  export * from './hooks/uploadsDropdownActions';
57
59
  export * from './hooks/uploadSidebarPanels';
package/manifest.json CHANGED
@@ -94,6 +94,29 @@
94
94
  "lineNumber": 19
95
95
  }
96
96
  },
97
+ "schemaItemTypeDropdownActions": {
98
+ "name": "schemaItemTypeDropdownActions",
99
+ "comment": {
100
+ "markdownText": "Use this function to define custom actions (or groups of actions) for a model/block model in the Schema section.\n\nThe `executeSchemaItemTypeDropdownAction()` hook will be triggered once the user\nclicks on one of the defined actions.",
101
+ "tag": "dropdownActions"
102
+ },
103
+ "nonCtxArguments": [
104
+ {
105
+ "name": "itemType",
106
+ "typeName": "ItemType"
107
+ }
108
+ ],
109
+ "ctxArgument": {
110
+ "type": "Ctx",
111
+ "additionalProperties": [],
112
+ "additionalMethods": []
113
+ },
114
+ "returnType": "Array<DropdownAction | DropdownActionGroup>",
115
+ "location": {
116
+ "filePath": "src/hooks/schemaItemTypeDropdownActions.ts",
117
+ "lineNumber": 16
118
+ }
119
+ },
97
120
  "renderUploadSidebarPanel": {
98
121
  "name": "renderUploadSidebarPanel",
99
122
  "comment": {
@@ -236,6 +259,16 @@
236
259
  "lineNumber": 19
237
260
  },
238
261
  "type": "string"
262
+ },
263
+ "location": {
264
+ "comment": {
265
+ "markdownText": "Current page location."
266
+ },
267
+ "location": {
268
+ "filePath": "src/hooks/renderPage.ts",
269
+ "lineNumber": 22
270
+ },
271
+ "type": "{\n pathname: string;\n search: string;\n hash: string;\n }"
239
272
  }
240
273
  }
241
274
  }
@@ -2134,6 +2167,45 @@
2134
2167
  "lineNumber": 13
2135
2168
  }
2136
2169
  },
2170
+ "executeSchemaItemTypeDropdownAction": {
2171
+ "name": "executeSchemaItemTypeDropdownAction",
2172
+ "comment": {
2173
+ "markdownText": "Use this function to execute a particular dropdown action defined via\nthe `schemaItemTypeDropdownActions()` hook.",
2174
+ "tag": "dropdownActions"
2175
+ },
2176
+ "nonCtxArguments": [
2177
+ {
2178
+ "name": "actionId",
2179
+ "typeName": "string"
2180
+ },
2181
+ {
2182
+ "name": "itemType",
2183
+ "typeName": "ItemType"
2184
+ }
2185
+ ],
2186
+ "ctxArgument": {
2187
+ "type": "Ctx",
2188
+ "additionalProperties": [
2189
+ {
2190
+ "items": {
2191
+ "parameters": {
2192
+ "location": {
2193
+ "filePath": "src/hooks/executeSchemaItemTypeDropdownAction.ts",
2194
+ "lineNumber": 23
2195
+ },
2196
+ "type": "Record<string, unknown> | undefined"
2197
+ }
2198
+ }
2199
+ }
2200
+ ],
2201
+ "additionalMethods": []
2202
+ },
2203
+ "returnType": "Promise<void>",
2204
+ "location": {
2205
+ "filePath": "src/hooks/executeSchemaItemTypeDropdownAction.ts",
2206
+ "lineNumber": 13
2207
+ }
2208
+ },
2137
2209
  "executeItemsDropdownAction": {
2138
2210
  "name": "executeItemsDropdownAction",
2139
2211
  "comment": {
@@ -2860,13 +2932,23 @@
2860
2932
  },
2861
2933
  "type": "string"
2862
2934
  },
2935
+ "isEnvironmentPrimary": {
2936
+ "comment": {
2937
+ "markdownText": "Whether the current environment is the primary one."
2938
+ },
2939
+ "location": {
2940
+ "filePath": "src/ctx/base.ts",
2941
+ "lineNumber": 64
2942
+ },
2943
+ "type": "boolean"
2944
+ },
2863
2945
  "owner": {
2864
2946
  "comment": {
2865
2947
  "markdownText": "The account/organization that is the project owner."
2866
2948
  },
2867
2949
  "location": {
2868
2950
  "filePath": "src/ctx/base.ts",
2869
- "lineNumber": 64
2951
+ "lineNumber": 67
2870
2952
  },
2871
2953
  "type": "Account | Organization"
2872
2954
  },
@@ -2877,7 +2959,7 @@
2877
2959
  },
2878
2960
  "location": {
2879
2961
  "filePath": "src/ctx/base.ts",
2880
- "lineNumber": 72
2962
+ "lineNumber": 75
2881
2963
  },
2882
2964
  "type": "Account | undefined"
2883
2965
  },
@@ -2887,7 +2969,7 @@
2887
2969
  },
2888
2970
  "location": {
2889
2971
  "filePath": "src/ctx/base.ts",
2890
- "lineNumber": 78
2972
+ "lineNumber": 81
2891
2973
  },
2892
2974
  "type": "{\n /** Preferred locale */\n locale: string;\n }"
2893
2975
  },
@@ -2897,7 +2979,7 @@
2897
2979
  },
2898
2980
  "location": {
2899
2981
  "filePath": "src/ctx/base.ts",
2900
- "lineNumber": 84
2982
+ "lineNumber": 87
2901
2983
  },
2902
2984
  "type": "Theme"
2903
2985
  }
@@ -2915,7 +2997,7 @@
2915
2997
  },
2916
2998
  "location": {
2917
2999
  "filePath": "src/ctx/base.ts",
2918
- "lineNumber": 94
3000
+ "lineNumber": 97
2919
3001
  },
2920
3002
  "type": "Partial<Record<string, ItemType>>"
2921
3003
  },
@@ -2925,7 +3007,7 @@
2925
3007
  },
2926
3008
  "location": {
2927
3009
  "filePath": "src/ctx/base.ts",
2928
- "lineNumber": 101
3010
+ "lineNumber": 104
2929
3011
  },
2930
3012
  "type": "Partial<Record<string, Field>>"
2931
3013
  },
@@ -2935,7 +3017,7 @@
2935
3017
  },
2936
3018
  "location": {
2937
3019
  "filePath": "src/ctx/base.ts",
2938
- "lineNumber": 108
3020
+ "lineNumber": 111
2939
3021
  },
2940
3022
  "type": "Partial<Record<string, Fieldset>>"
2941
3023
  },
@@ -2945,7 +3027,7 @@
2945
3027
  },
2946
3028
  "location": {
2947
3029
  "filePath": "src/ctx/base.ts",
2948
- "lineNumber": 115
3030
+ "lineNumber": 118
2949
3031
  },
2950
3032
  "type": "Partial<Record<string, User>>"
2951
3033
  },
@@ -2955,7 +3037,7 @@
2955
3037
  },
2956
3038
  "location": {
2957
3039
  "filePath": "src/ctx/base.ts",
2958
- "lineNumber": 122
3040
+ "lineNumber": 125
2959
3041
  },
2960
3042
  "type": "Partial<Record<string, SsoUser>>"
2961
3043
  }
@@ -2976,7 +3058,7 @@
2976
3058
  },
2977
3059
  "location": {
2978
3060
  "filePath": "src/ctx/base.ts",
2979
- "lineNumber": 165
3061
+ "lineNumber": 168
2980
3062
  },
2981
3063
  "type": "(itemTypeId: string) => Promise<Field[]>"
2982
3064
  },
@@ -2987,7 +3069,7 @@
2987
3069
  },
2988
3070
  "location": {
2989
3071
  "filePath": "src/ctx/base.ts",
2990
- "lineNumber": 184
3072
+ "lineNumber": 187
2991
3073
  },
2992
3074
  "type": "(itemTypeId: string) => Promise<Fieldset[]>"
2993
3075
  },
@@ -2998,7 +3080,7 @@
2998
3080
  },
2999
3081
  "location": {
3000
3082
  "filePath": "src/ctx/base.ts",
3001
- "lineNumber": 201
3083
+ "lineNumber": 204
3002
3084
  },
3003
3085
  "type": "() => Promise<Field[]>"
3004
3086
  },
@@ -3009,7 +3091,7 @@
3009
3091
  },
3010
3092
  "location": {
3011
3093
  "filePath": "src/ctx/base.ts",
3012
- "lineNumber": 214
3094
+ "lineNumber": 217
3013
3095
  },
3014
3096
  "type": "() => Promise<User[]>"
3015
3097
  },
@@ -3020,7 +3102,7 @@
3020
3102
  },
3021
3103
  "location": {
3022
3104
  "filePath": "src/ctx/base.ts",
3023
- "lineNumber": 227
3105
+ "lineNumber": 230
3024
3106
  },
3025
3107
  "type": "() => Promise<SsoUser[]>"
3026
3108
  }
@@ -3039,7 +3121,7 @@
3039
3121
  },
3040
3122
  "location": {
3041
3123
  "filePath": "src/ctx/base.ts",
3042
- "lineNumber": 249
3124
+ "lineNumber": 252
3043
3125
  },
3044
3126
  "type": "(params: Record<string, unknown>) => Promise<void>"
3045
3127
  },
@@ -3050,7 +3132,7 @@
3050
3132
  },
3051
3133
  "location": {
3052
3134
  "filePath": "src/ctx/base.ts",
3053
- "lineNumber": 300
3135
+ "lineNumber": 303
3054
3136
  },
3055
3137
  "type": "(\n fieldId: string,\n changes: FieldAppearanceChange[],\n ) => Promise<void>"
3056
3138
  }
@@ -3069,7 +3151,7 @@
3069
3151
  },
3070
3152
  "location": {
3071
3153
  "filePath": "src/ctx/base.ts",
3072
- "lineNumber": 405
3154
+ "lineNumber": 408
3073
3155
  },
3074
3156
  "type": "(message: string) => Promise<void>"
3075
3157
  },
@@ -3080,7 +3162,7 @@
3080
3162
  },
3081
3163
  "location": {
3082
3164
  "filePath": "src/ctx/base.ts",
3083
- "lineNumber": 420
3165
+ "lineNumber": 423
3084
3166
  },
3085
3167
  "type": "(message: string) => Promise<void>"
3086
3168
  },
@@ -3091,7 +3173,7 @@
3091
3173
  },
3092
3174
  "location": {
3093
3175
  "filePath": "src/ctx/base.ts",
3094
- "lineNumber": 444
3176
+ "lineNumber": 447
3095
3177
  },
3096
3178
  "type": "<CtaValue = unknown>(\n toast: Toast<CtaValue>,\n ) => Promise<CtaValue | null>"
3097
3179
  }
@@ -3110,7 +3192,7 @@
3110
3192
  },
3111
3193
  "location": {
3112
3194
  "filePath": "src/ctx/base.ts",
3113
- "lineNumber": 330
3195
+ "lineNumber": 333
3114
3196
  },
3115
3197
  "type": "(itemTypeId: string) => Promise<Item | null>"
3116
3198
  },
@@ -3121,7 +3203,7 @@
3121
3203
  },
3122
3204
  "location": {
3123
3205
  "filePath": "src/ctx/base.ts",
3124
- "lineNumber": 351
3206
+ "lineNumber": 354
3125
3207
  },
3126
3208
  "type": "{\n (\n itemTypeId: string,\n options: { multiple: true; initialLocationQuery?: ItemListLocationQuery },\n ): Promise<Item[] | null>;\n (\n itemTypeId: string,\n options?: {\n multiple: false;\n initialLocationQuery?: ItemListLocationQuery;\n },\n ): Promise<Item | null>;\n }"
3127
3209
  },
@@ -3132,7 +3214,7 @@
3132
3214
  },
3133
3215
  "location": {
3134
3216
  "filePath": "src/ctx/base.ts",
3135
- "lineNumber": 383
3217
+ "lineNumber": 386
3136
3218
  },
3137
3219
  "type": "(itemId: string) => Promise<Item | null>"
3138
3220
  }
@@ -3151,7 +3233,7 @@
3151
3233
  },
3152
3234
  "location": {
3153
3235
  "filePath": "src/ctx/base.ts",
3154
- "lineNumber": 471
3236
+ "lineNumber": 474
3155
3237
  },
3156
3238
  "type": "{\n (options: { multiple: true }): Promise<Upload[] | null>;\n (options?: { multiple: false }): Promise<Upload | null>;\n }"
3157
3239
  },
@@ -3162,7 +3244,7 @@
3162
3244
  },
3163
3245
  "location": {
3164
3246
  "filePath": "src/ctx/base.ts",
3165
- "lineNumber": 499
3247
+ "lineNumber": 502
3166
3248
  },
3167
3249
  "type": "(\n uploadId: string,\n ) => Promise<(Upload & { deleted?: true }) | null>"
3168
3250
  },
@@ -3173,7 +3255,7 @@
3173
3255
  },
3174
3256
  "location": {
3175
3257
  "filePath": "src/ctx/base.ts",
3176
- "lineNumber": 527
3258
+ "lineNumber": 530
3177
3259
  },
3178
3260
  "type": "(\n /** The \"single asset\" field structure */\n fileFieldValue: FileFieldValue,\n /** Shows metadata information for a specific locale */\n locale?: string,\n ) => Promise<FileFieldValue | null>"
3179
3261
  }
@@ -3192,7 +3274,7 @@
3192
3274
  },
3193
3275
  "location": {
3194
3276
  "filePath": "src/ctx/base.ts",
3195
- "lineNumber": 558
3277
+ "lineNumber": 561
3196
3278
  },
3197
3279
  "type": "(modal: Modal) => Promise<unknown>"
3198
3280
  },
@@ -3203,7 +3285,7 @@
3203
3285
  },
3204
3286
  "location": {
3205
3287
  "filePath": "src/ctx/base.ts",
3206
- "lineNumber": 595
3288
+ "lineNumber": 598
3207
3289
  },
3208
3290
  "type": "(options: ConfirmOptions) => Promise<unknown>"
3209
3291
  }
@@ -3222,7 +3304,7 @@
3222
3304
  },
3223
3305
  "location": {
3224
3306
  "filePath": "src/ctx/base.ts",
3225
- "lineNumber": 609
3307
+ "lineNumber": 612
3226
3308
  },
3227
3309
  "type": "(path: string) => Promise<void>"
3228
3310
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datocms-plugin-sdk",
3
- "version": "2.0.11",
3
+ "version": "2.0.13",
4
4
  "description": "DatoCMS Plugin SDK",
5
5
  "keywords": [
6
6
  "datocms",
@@ -45,5 +45,5 @@
45
45
  "glob": "^11.0.0",
46
46
  "typescript": "^5.6.2"
47
47
  },
48
- "gitHead": "3f849aa16b3588d7bbd3f44ba07f3bca6eb71626"
48
+ "gitHead": "1420d4ce991da7c84da85b1b4e1375df19e156d7"
49
49
  }
package/src/connect.ts CHANGED
@@ -7,6 +7,7 @@ import type { CustomMarksForStructuredTextFieldHook } from './hooks/customMarksF
7
7
  import type { ExecuteFieldDropdownActionHook } from './hooks/executeFieldDropdownAction';
8
8
  import type { ExecuteItemFormDropdownActionHook } from './hooks/executeItemFormDropdownAction';
9
9
  import type { ExecuteItemsDropdownActionHook } from './hooks/executeItemsDropdownAction';
10
+ import type { ExecuteSchemaItemTypeDropdownActionHook } from './hooks/executeSchemaItemTypeDropdownAction';
10
11
  import type { ExecuteUploadsDropdownActionHook } from './hooks/executeUploadsDropdownAction';
11
12
  import type { FieldDropdownActionsHook } from './hooks/fieldDropdownActions';
12
13
  import type { InitialLocationQueryForItemSelectorHook } from './hooks/initialLocationQueryForItemSelector';
@@ -66,6 +67,7 @@ import {
66
67
  RenderUploadSidebarPanelHook,
67
68
  renderUploadSidebarPanelBootstrapper,
68
69
  } from './hooks/renderUploadSidebarPanel';
70
+ import type { SchemaItemTypeDropdownActionsHook } from './hooks/schemaItemTypeDropdownActions';
69
71
  import type { SettingsAreaSidebarItemGroupsHook } from './hooks/settingsAreaSidebarItemGroups';
70
72
  import { UploadSidebarPanelsHook } from './hooks/uploadSidebarPanels';
71
73
  import { UploadSidebarsHook } from './hooks/uploadSidebars';
@@ -87,6 +89,7 @@ export type FullConnectParameters = AssetSourcesHook &
87
89
  ExecuteFieldDropdownActionHook &
88
90
  ExecuteItemFormDropdownActionHook &
89
91
  ExecuteItemsDropdownActionHook &
92
+ ExecuteSchemaItemTypeDropdownActionHook &
90
93
  ExecuteUploadsDropdownActionHook &
91
94
  FieldDropdownActionsHook &
92
95
  InitialLocationQueryForItemSelectorHook &
@@ -116,6 +119,7 @@ export type FullConnectParameters = AssetSourcesHook &
116
119
  RenderPageHook &
117
120
  RenderUploadSidebarHook &
118
121
  RenderUploadSidebarPanelHook &
122
+ SchemaItemTypeDropdownActionsHook &
119
123
  SettingsAreaSidebarItemGroupsHook &
120
124
  UploadsDropdownActionsHook &
121
125
  UploadSidebarPanelsHook &
package/src/ctx/base.ts CHANGED
@@ -60,6 +60,9 @@ type ProjectProperties = {
60
60
  /** The ID of the current environment */
61
61
  environment: string;
62
62
 
63
+ /** Whether the current environment is the primary one */
64
+ isEnvironmentPrimary: boolean;
65
+
63
66
  /** The account/organization that is the project owner */
64
67
  owner: Account | Organization;
65
68
 
@@ -0,0 +1,24 @@
1
+ import type { SchemaTypes } from '@datocms/cma-client';
2
+ import { Ctx } from '../ctx/base';
3
+
4
+ type ItemType = SchemaTypes.ItemType;
5
+
6
+ export type ExecuteSchemaItemTypeDropdownActionHook = {
7
+ /**
8
+ * Use this function to execute a particular dropdown action defined via
9
+ * the `schemaItemTypeDropdownActions()` hook.
10
+ *
11
+ * @tag dropdownActions
12
+ */
13
+ executeSchemaItemTypeDropdownAction: (
14
+ /** The ID of the action that was requested by the user */
15
+ actionId: string,
16
+ /** The model/block model on which the action should be executed */
17
+ itemType: ItemType,
18
+ ctx: ExecuteSchemaItemTypeDropdownActionCtx,
19
+ ) => Promise<void>;
20
+ };
21
+
22
+ export type ExecuteSchemaItemTypeDropdownActionCtx = Ctx<{
23
+ parameters: Record<string, unknown> | undefined;
24
+ }>;
@@ -17,6 +17,13 @@ export type RenderPageCtx = ImposedSizePluginFrameCtx<
17
17
  {
18
18
  /** The ID of the page that needs to be rendered */
19
19
  pageId: string;
20
+
21
+ /** Current page location */
22
+ location: {
23
+ pathname: string;
24
+ search: string;
25
+ hash: string;
26
+ };
20
27
  }
21
28
  >;
22
29
 
@@ -0,0 +1,22 @@
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 SchemaItemTypeDropdownActionsHook = {
8
+ /**
9
+ * Use this function to define custom actions (or groups of actions) for a model/block model in the Schema section.
10
+ *
11
+ * The `executeSchemaItemTypeDropdownAction()` hook will be triggered once the user
12
+ * clicks on one of the defined actions.
13
+ *
14
+ * @tag dropdownActions
15
+ */
16
+ schemaItemTypeDropdownActions: (
17
+ itemType: ItemType,
18
+ ctx: SchemaItemTypeDropdownActionsCtx,
19
+ ) => Array<DropdownAction | DropdownActionGroup>;
20
+ };
21
+
22
+ export type SchemaItemTypeDropdownActionsCtx = Ctx;
package/src/index.ts CHANGED
@@ -25,6 +25,7 @@ export * from './hooks/customMarksForStructuredTextField';
25
25
  export * from './hooks/executeFieldDropdownAction';
26
26
  export * from './hooks/executeItemFormDropdownAction';
27
27
  export * from './hooks/executeItemsDropdownAction';
28
+ export * from './hooks/executeSchemaItemTypeDropdownAction';
28
29
  export * from './hooks/executeUploadsDropdownAction';
29
30
  export * from './hooks/fieldDropdownActions';
30
31
  export * from './hooks/initialLocationQueryForItemSelector';
@@ -54,6 +55,7 @@ export * from './hooks/renderModal';
54
55
  export * from './hooks/renderPage';
55
56
  export * from './hooks/renderUploadSidebar';
56
57
  export * from './hooks/renderUploadSidebarPanel';
58
+ export * from './hooks/schemaItemTypeDropdownActions';
57
59
  export * from './hooks/settingsAreaSidebarItemGroups';
58
60
  export * from './hooks/uploadsDropdownActions';
59
61
  export * from './hooks/uploadSidebarPanels';