datocms-plugin-sdk 2.0.9 → 2.0.12

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 (36) 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/schemaItemTypeDropdownActions.js +3 -0
  5. package/dist/cjs/hooks/schemaItemTypeDropdownActions.js.map +1 -0
  6. package/dist/cjs/index.js +2 -0
  7. package/dist/cjs/index.js.map +1 -1
  8. package/dist/cjs/manifest.js +84 -2
  9. package/dist/cjs/manifest.js.map +1 -1
  10. package/dist/esm/connect.d.ts +3 -1
  11. package/dist/esm/connect.js.map +1 -1
  12. package/dist/esm/hooks/executeSchemaItemTypeDropdownAction.d.ts +20 -0
  13. package/dist/esm/hooks/executeSchemaItemTypeDropdownAction.js +2 -0
  14. package/dist/esm/hooks/executeSchemaItemTypeDropdownAction.js.map +1 -0
  15. package/dist/esm/hooks/onBeforeItemUpsert.d.ts +19 -1
  16. package/dist/esm/hooks/schemaItemTypeDropdownActions.d.ts +17 -0
  17. package/dist/esm/hooks/schemaItemTypeDropdownActions.js +2 -0
  18. package/dist/esm/hooks/schemaItemTypeDropdownActions.js.map +1 -0
  19. package/dist/esm/index.d.ts +2 -0
  20. package/dist/esm/index.js +2 -0
  21. package/dist/esm/index.js.map +1 -1
  22. package/dist/esm/manifest.js +84 -2
  23. package/dist/esm/manifest.js.map +1 -1
  24. package/dist/types/connect.d.ts +3 -1
  25. package/dist/types/hooks/executeSchemaItemTypeDropdownAction.d.ts +20 -0
  26. package/dist/types/hooks/onBeforeItemUpsert.d.ts +19 -1
  27. package/dist/types/hooks/schemaItemTypeDropdownActions.d.ts +17 -0
  28. package/dist/types/index.d.ts +2 -0
  29. package/manifest.json +84 -2
  30. package/package.json +2 -2
  31. package/src/connect.ts +4 -0
  32. package/src/hooks/executeSchemaItemTypeDropdownAction.ts +24 -0
  33. package/src/hooks/onBeforeItemUpsert.ts +22 -1
  34. package/src/hooks/schemaItemTypeDropdownActions.ts +22 -0
  35. package/src/index.ts +2 -0
  36. package/src/manifest.ts +88 -2
@@ -18,4 +18,25 @@ export type OnBeforeItemUpsertHook = {
18
18
  ) => MaybePromise<boolean>;
19
19
  };
20
20
 
21
- export type OnBeforeItemUpsertCtx = Ctx;
21
+ export type OnBeforeItemUpsertCtx = Ctx<
22
+ {},
23
+ {
24
+ /**
25
+ * Smoothly navigates to a specific field in the form. If the field is
26
+ * localized it will switch language tab and then navigate to the chosen
27
+ * field.
28
+ *
29
+ * @example
30
+ *
31
+ * ```js
32
+ * const fieldPath = prompt(
33
+ * 'Please insert the path of a field in the form',
34
+ * ctx.fieldPath,
35
+ * );
36
+ *
37
+ * await ctx.scrollToField(fieldPath);
38
+ * ```
39
+ */
40
+ scrollToField: (path: string, locale?: string) => Promise<void>;
41
+ }
42
+ >;
@@ -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';
package/src/manifest.ts CHANGED
@@ -101,6 +101,30 @@ export const manifest: Manifest = {
101
101
  lineNumber: 19,
102
102
  },
103
103
  },
104
+ schemaItemTypeDropdownActions: {
105
+ name: 'schemaItemTypeDropdownActions',
106
+ comment: {
107
+ markdownText:
108
+ '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.',
109
+ tag: 'dropdownActions',
110
+ },
111
+ nonCtxArguments: [
112
+ {
113
+ name: 'itemType',
114
+ typeName: 'ItemType',
115
+ },
116
+ ],
117
+ ctxArgument: {
118
+ type: 'Ctx',
119
+ additionalProperties: [],
120
+ additionalMethods: [],
121
+ },
122
+ returnType: 'Array<DropdownAction | DropdownActionGroup>',
123
+ location: {
124
+ filePath: 'src/hooks/schemaItemTypeDropdownActions.ts',
125
+ lineNumber: 16,
126
+ },
127
+ },
104
128
  renderUploadSidebarPanel: {
105
129
  name: 'renderUploadSidebarPanel',
106
130
  comment: {
@@ -1722,8 +1746,30 @@ export const manifest: Manifest = {
1722
1746
  ],
1723
1747
  ctxArgument: {
1724
1748
  type: 'Ctx',
1725
- additionalProperties: [],
1726
- additionalMethods: [],
1749
+ additionalProperties: [
1750
+ {
1751
+ items: {},
1752
+ },
1753
+ ],
1754
+ additionalMethods: [
1755
+ {
1756
+ items: {
1757
+ scrollToField: {
1758
+ comment: {
1759
+ markdownText:
1760
+ 'Smoothly navigates to a specific field in the form. If the field is\nlocalized it will switch language tab and then navigate to the chosen\nfield.',
1761
+ example:
1762
+ "const fieldPath = prompt(\n 'Please insert the path of a field in the form',\n ctx.fieldPath,\n);\n\nawait ctx.scrollToField(fieldPath);",
1763
+ },
1764
+ location: {
1765
+ filePath: 'src/hooks/onBeforeItemUpsert.ts',
1766
+ lineNumber: 40,
1767
+ },
1768
+ type: '(path: string, locale?: string) => Promise<void>',
1769
+ },
1770
+ },
1771
+ },
1772
+ ],
1727
1773
  },
1728
1774
  returnType: 'MaybePromise<boolean>',
1729
1775
  location: {
@@ -2272,6 +2318,46 @@ export const manifest: Manifest = {
2272
2318
  lineNumber: 13,
2273
2319
  },
2274
2320
  },
2321
+ executeSchemaItemTypeDropdownAction: {
2322
+ name: 'executeSchemaItemTypeDropdownAction',
2323
+ comment: {
2324
+ markdownText:
2325
+ 'Use this function to execute a particular dropdown action defined via\nthe `schemaItemTypeDropdownActions()` hook.',
2326
+ tag: 'dropdownActions',
2327
+ },
2328
+ nonCtxArguments: [
2329
+ {
2330
+ name: 'actionId',
2331
+ typeName: 'string',
2332
+ },
2333
+ {
2334
+ name: 'itemType',
2335
+ typeName: 'ItemType',
2336
+ },
2337
+ ],
2338
+ ctxArgument: {
2339
+ type: 'Ctx',
2340
+ additionalProperties: [
2341
+ {
2342
+ items: {
2343
+ parameters: {
2344
+ location: {
2345
+ filePath: 'src/hooks/executeSchemaItemTypeDropdownAction.ts',
2346
+ lineNumber: 23,
2347
+ },
2348
+ type: 'Record<string, unknown> | undefined',
2349
+ },
2350
+ },
2351
+ },
2352
+ ],
2353
+ additionalMethods: [],
2354
+ },
2355
+ returnType: 'Promise<void>',
2356
+ location: {
2357
+ filePath: 'src/hooks/executeSchemaItemTypeDropdownAction.ts',
2358
+ lineNumber: 13,
2359
+ },
2360
+ },
2275
2361
  executeItemsDropdownAction: {
2276
2362
  name: 'executeItemsDropdownAction',
2277
2363
  comment: {