datocms-plugin-sdk 2.1.0-alpha.0 → 2.1.0-alpha.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 (81) hide show
  1. package/dist/cjs/connect.js +4 -0
  2. package/dist/cjs/connect.js.map +1 -1
  3. package/dist/cjs/guardUtils.js +12 -0
  4. package/dist/cjs/guardUtils.js.map +1 -1
  5. package/dist/cjs/hooks/executeSchemaItemTypeDropdownAction.js +3 -0
  6. package/dist/cjs/hooks/executeSchemaItemTypeDropdownAction.js.map +1 -0
  7. package/dist/cjs/hooks/mainNavigationTabs.js +4 -1
  8. package/dist/cjs/hooks/mainNavigationTabs.js.map +1 -1
  9. package/dist/cjs/hooks/renderInspector.js +11 -0
  10. package/dist/cjs/hooks/renderInspector.js.map +1 -0
  11. package/dist/cjs/hooks/renderInspectorPanel.js +11 -0
  12. package/dist/cjs/hooks/renderInspectorPanel.js.map +1 -0
  13. package/dist/cjs/hooks/renderPage.js.map +1 -1
  14. package/dist/cjs/hooks/schemaItemTypeDropdownActions.js +3 -0
  15. package/dist/cjs/hooks/schemaItemTypeDropdownActions.js.map +1 -0
  16. package/dist/cjs/icon.js +12 -5
  17. package/dist/cjs/icon.js.map +1 -1
  18. package/dist/cjs/index.js +4 -0
  19. package/dist/cjs/index.js.map +1 -1
  20. package/dist/cjs/manifest.js +268 -32
  21. package/dist/cjs/manifest.js.map +1 -1
  22. package/dist/esm/connect.d.ts +5 -1
  23. package/dist/esm/connect.js +4 -0
  24. package/dist/esm/connect.js.map +1 -1
  25. package/dist/esm/ctx/base.d.ts +2 -0
  26. package/dist/esm/guardUtils.d.ts +4 -0
  27. package/dist/esm/guardUtils.js +8 -0
  28. package/dist/esm/guardUtils.js.map +1 -1
  29. package/dist/esm/hooks/executeSchemaItemTypeDropdownAction.d.ts +20 -0
  30. package/dist/esm/hooks/executeSchemaItemTypeDropdownAction.js +2 -0
  31. package/dist/esm/hooks/executeSchemaItemTypeDropdownAction.js.map +1 -0
  32. package/dist/esm/hooks/mainNavigationTabs.d.ts +15 -1
  33. package/dist/esm/hooks/mainNavigationTabs.js +4 -1
  34. package/dist/esm/hooks/mainNavigationTabs.js.map +1 -1
  35. package/dist/esm/hooks/onBeforeItemUpsert.d.ts +28 -3
  36. package/dist/esm/hooks/renderInspector.d.ts +147 -0
  37. package/dist/esm/hooks/renderInspector.js +8 -0
  38. package/dist/esm/hooks/renderInspector.js.map +1 -0
  39. package/dist/esm/hooks/renderInspectorPanel.d.ts +20 -0
  40. package/dist/esm/hooks/renderInspectorPanel.js +8 -0
  41. package/dist/esm/hooks/renderInspectorPanel.js.map +1 -0
  42. package/dist/esm/hooks/renderPage.d.ts +6 -0
  43. package/dist/esm/hooks/renderPage.js.map +1 -1
  44. package/dist/esm/hooks/schemaItemTypeDropdownActions.d.ts +17 -0
  45. package/dist/esm/hooks/schemaItemTypeDropdownActions.js +2 -0
  46. package/dist/esm/hooks/schemaItemTypeDropdownActions.js.map +1 -0
  47. package/dist/esm/icon.d.ts +61 -2
  48. package/dist/esm/icon.js +11 -6
  49. package/dist/esm/icon.js.map +1 -1
  50. package/dist/esm/index.d.ts +4 -0
  51. package/dist/esm/index.js +4 -0
  52. package/dist/esm/index.js.map +1 -1
  53. package/dist/esm/manifest.js +268 -32
  54. package/dist/esm/manifest.js.map +1 -1
  55. package/dist/types/connect.d.ts +5 -1
  56. package/dist/types/ctx/base.d.ts +2 -0
  57. package/dist/types/guardUtils.d.ts +4 -0
  58. package/dist/types/hooks/executeSchemaItemTypeDropdownAction.d.ts +20 -0
  59. package/dist/types/hooks/mainNavigationTabs.d.ts +15 -1
  60. package/dist/types/hooks/onBeforeItemUpsert.d.ts +28 -3
  61. package/dist/types/hooks/renderInspector.d.ts +147 -0
  62. package/dist/types/hooks/renderInspectorPanel.d.ts +20 -0
  63. package/dist/types/hooks/renderPage.d.ts +6 -0
  64. package/dist/types/hooks/schemaItemTypeDropdownActions.d.ts +17 -0
  65. package/dist/types/icon.d.ts +61 -2
  66. package/dist/types/index.d.ts +4 -0
  67. package/manifest.json +268 -32
  68. package/package.json +4 -3
  69. package/src/connect.ts +16 -0
  70. package/src/ctx/base.ts +3 -0
  71. package/src/guardUtils.ts +13 -0
  72. package/src/hooks/executeSchemaItemTypeDropdownAction.ts +24 -0
  73. package/src/hooks/mainNavigationTabs.ts +24 -5
  74. package/src/hooks/onBeforeItemUpsert.ts +31 -3
  75. package/src/hooks/renderInspector.ts +176 -0
  76. package/src/hooks/renderInspectorPanel.ts +38 -0
  77. package/src/hooks/renderPage.ts +7 -0
  78. package/src/hooks/schemaItemTypeDropdownActions.ts +22 -0
  79. package/src/icon.ts +80 -9
  80. package/src/index.ts +4 -0
  81. package/src/manifest.ts +284 -32
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
  }
@@ -1106,6 +1139,140 @@
1106
1139
  "lineNumber": 14
1107
1140
  }
1108
1141
  },
1142
+ "renderInspectorPanel": {
1143
+ "name": "renderInspectorPanel",
1144
+ "comment": {
1145
+ "markdownText": "This function will be called when an inspector needs to render a specific\npanel (see the `renderInspector` and `setInspectorMode` functions).",
1146
+ "tag": "inspector"
1147
+ },
1148
+ "nonCtxArguments": [
1149
+ {
1150
+ "name": "panelId",
1151
+ "typeName": "string"
1152
+ }
1153
+ ],
1154
+ "ctxArgument": {
1155
+ "type": "ImposedSizePluginFrameCtx",
1156
+ "additionalProperties": [
1157
+ {
1158
+ "items": {
1159
+ "panelId": {
1160
+ "comment": {
1161
+ "markdownText": "The ID of the inspector panel that needs to be rendered."
1162
+ },
1163
+ "location": {
1164
+ "filePath": "src/hooks/renderInspectorPanel.ts",
1165
+ "lineNumber": 18
1166
+ },
1167
+ "type": "string"
1168
+ },
1169
+ "parameters": {
1170
+ "comment": {
1171
+ "markdownText": "The arbitrary `parameters` of the modal declared in the `setInspectorMode`\nfunction."
1172
+ },
1173
+ "location": {
1174
+ "filePath": "src/hooks/renderInspectorPanel.ts",
1175
+ "lineNumber": 24
1176
+ },
1177
+ "type": "Record<string, unknown>"
1178
+ }
1179
+ }
1180
+ }
1181
+ ],
1182
+ "additionalMethods": []
1183
+ },
1184
+ "returnType": "void",
1185
+ "location": {
1186
+ "filePath": "src/hooks/renderInspectorPanel.ts",
1187
+ "lineNumber": 11
1188
+ }
1189
+ },
1190
+ "renderInspector": {
1191
+ "name": "renderInspector",
1192
+ "comment": {
1193
+ "markdownText": "This function will be called when the plugin needs to render a specific\ninspector. Inspectors provide a side panel interface for displaying and\ninteracting with content alongside a custom interface.",
1194
+ "tag": "inspector",
1195
+ "example": "connect({\n renderInspector(inspectorId, ctx) {\n render(\n <div>\n <h1>Inspector: {inspectorId}</h1>\n <button onClick={() => ctx.setInspectorMode({\n type: 'itemEditor',\n itemId: 'some-item-id'\n })}>\n Show Item Editor\n </button>\n </div>\n );\n }\n});"
1196
+ },
1197
+ "nonCtxArguments": [
1198
+ {
1199
+ "name": "inspectorId",
1200
+ "typeName": "string"
1201
+ }
1202
+ ],
1203
+ "ctxArgument": {
1204
+ "type": "ImposedSizePluginFrameCtx",
1205
+ "additionalProperties": [
1206
+ {
1207
+ "items": {
1208
+ "inspectorId": {
1209
+ "comment": {
1210
+ "markdownText": "The ID of the inspector that needs to be rendered."
1211
+ },
1212
+ "location": {
1213
+ "filePath": "src/hooks/renderInspector.ts",
1214
+ "lineNumber": 80
1215
+ },
1216
+ "type": "string"
1217
+ },
1218
+ "highlightedItemId": {
1219
+ "comment": {
1220
+ "markdownText": "The ID of the record the currently is highlighted by the user."
1221
+ },
1222
+ "location": {
1223
+ "filePath": "src/hooks/renderInspector.ts",
1224
+ "lineNumber": 83
1225
+ },
1226
+ "type": "string | undefined"
1227
+ },
1228
+ "location": {
1229
+ "comment": {
1230
+ "markdownText": "Current page location."
1231
+ },
1232
+ "location": {
1233
+ "filePath": "src/hooks/renderInspector.ts",
1234
+ "lineNumber": 86
1235
+ },
1236
+ "type": "{\n pathname: string;\n search: string;\n hash: string;\n }"
1237
+ }
1238
+ }
1239
+ }
1240
+ ],
1241
+ "additionalMethods": [
1242
+ {
1243
+ "items": {
1244
+ "setInspectorMode": {
1245
+ "comment": {
1246
+ "markdownText": "Changes the current display mode of the inspector. This allows the plugin\nto dynamically switch between showing a record list, record editor, or custom\npanel within the inspector interface.",
1247
+ "example": "// Switch to record editor mode\nawait ctx.setInspectorMode({\n type: 'itemEditor',\n itemId: 'item-123',\n fieldPath: 'title'\n});\n\n// Switch to record list mode\nawait ctx.setInspectorMode({ type: 'itemList' });\nawait ctx.setInspectorItemListData({\n title: 'Related Records',\n itemIds: ['item-1', 'item-2', 'item-3']\n});\n\n// Switch to custom panel mode\nawait ctx.setInspectorMode({\n type: 'customPanel',\n panelId: 'my-custom-panel',\n parameters: { filter: 'active' }\n});\n\n// Low intent mode change - won't interrupt editing with unsaved changes\nawait ctx.setInspectorMode(\n { type: 'itemList' },\n { ignoreIfUnsavedChanges: true }\n);"
1248
+ },
1249
+ "location": {
1250
+ "filePath": "src/hooks/renderInspector.ts",
1251
+ "lineNumber": 136
1252
+ },
1253
+ "type": "(\n mode: InspectorMode,\n options?: SetInspectorModeOptions,\n ) => Promise<void>"
1254
+ },
1255
+ "setInspectorItemListData": {
1256
+ "comment": {
1257
+ "markdownText": "Sets the data for the item list inspector mode.",
1258
+ "example": "// Set the item list data\nawait ctx.setInspectorItemListData({\n title: 'Related Records',\n itemIds: ['item-1', 'item-2', 'item-3']\n});\n\n// Switch to item list mode\nawait ctx.setInspectorMode({ type: 'itemList' });"
1259
+ },
1260
+ "location": {
1261
+ "filePath": "src/hooks/renderInspector.ts",
1262
+ "lineNumber": 157
1263
+ },
1264
+ "type": "(data: {\n /** The title to show in the inspector header */\n title: string;\n /** Array of record IDs to display in the list */\n itemIds: string[];\n }) => Promise<void>"
1265
+ }
1266
+ }
1267
+ }
1268
+ ]
1269
+ },
1270
+ "returnType": "void",
1271
+ "location": {
1272
+ "filePath": "src/hooks/renderInspector.ts",
1273
+ "lineNumber": 73
1274
+ }
1275
+ },
1109
1276
  "renderFieldExtension": {
1110
1277
  "name": "renderFieldExtension",
1111
1278
  "comment": {
@@ -1583,7 +1750,7 @@
1583
1750
  "onBeforeItemUpsert": {
1584
1751
  "name": "onBeforeItemUpsert",
1585
1752
  "comment": {
1586
- "markdownText": "This function will be called before saving a new version of a record. You\ncan stop the action by returning `false`.",
1753
+ "markdownText": "This hook is called when the user attempts to save a record. You can use it to block record saving.\n\nIf you return `false`, the record will NOT be saved. A small on-page error will say \"A plugin blocked the action\".\nHowever, for better UX, consider also using `ctx.alert()` to better explain to the user why their save was blocked.\n\nIf you return `true`, the save will proceed as normal.\n\nThis hook runs BEFORE serverside validation. You can use it to do your own additional validation before returning.\nClientside validations are not affected by this hook, since those occur on individual fields' `onBlur()` events.",
1587
1754
  "tag": "beforeHooks"
1588
1755
  },
1589
1756
  "nonCtxArguments": [
@@ -1594,13 +1761,33 @@
1594
1761
  ],
1595
1762
  "ctxArgument": {
1596
1763
  "type": "Ctx",
1597
- "additionalProperties": [],
1598
- "additionalMethods": []
1764
+ "additionalProperties": [
1765
+ {
1766
+ "items": {}
1767
+ }
1768
+ ],
1769
+ "additionalMethods": [
1770
+ {
1771
+ "items": {
1772
+ "scrollToField": {
1773
+ "comment": {
1774
+ "markdownText": "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.",
1775
+ "example": "const fieldPath = prompt(\n 'Please insert the path of a field in the form',\n ctx.fieldPath,\n);\n\nawait ctx.scrollToField(fieldPath);"
1776
+ },
1777
+ "location": {
1778
+ "filePath": "src/hooks/onBeforeItemUpsert.ts",
1779
+ "lineNumber": 47
1780
+ },
1781
+ "type": "(path: string, locale?: string) => Promise<void>"
1782
+ }
1783
+ }
1784
+ }
1785
+ ]
1599
1786
  },
1600
1787
  "returnType": "MaybePromise<boolean>",
1601
1788
  "location": {
1602
1789
  "filePath": "src/hooks/onBeforeItemUpsert.ts",
1603
- "lineNumber": 15
1790
+ "lineNumber": 22
1604
1791
  }
1605
1792
  },
1606
1793
  "manualFieldExtensions": {
@@ -2114,6 +2301,45 @@
2114
2301
  "lineNumber": 13
2115
2302
  }
2116
2303
  },
2304
+ "executeSchemaItemTypeDropdownAction": {
2305
+ "name": "executeSchemaItemTypeDropdownAction",
2306
+ "comment": {
2307
+ "markdownText": "Use this function to execute a particular dropdown action defined via\nthe `schemaItemTypeDropdownActions()` hook.",
2308
+ "tag": "dropdownActions"
2309
+ },
2310
+ "nonCtxArguments": [
2311
+ {
2312
+ "name": "actionId",
2313
+ "typeName": "string"
2314
+ },
2315
+ {
2316
+ "name": "itemType",
2317
+ "typeName": "ItemType"
2318
+ }
2319
+ ],
2320
+ "ctxArgument": {
2321
+ "type": "Ctx",
2322
+ "additionalProperties": [
2323
+ {
2324
+ "items": {
2325
+ "parameters": {
2326
+ "location": {
2327
+ "filePath": "src/hooks/executeSchemaItemTypeDropdownAction.ts",
2328
+ "lineNumber": 23
2329
+ },
2330
+ "type": "Record<string, unknown> | undefined"
2331
+ }
2332
+ }
2333
+ }
2334
+ ],
2335
+ "additionalMethods": []
2336
+ },
2337
+ "returnType": "Promise<void>",
2338
+ "location": {
2339
+ "filePath": "src/hooks/executeSchemaItemTypeDropdownAction.ts",
2340
+ "lineNumber": 13
2341
+ }
2342
+ },
2117
2343
  "executeItemsDropdownAction": {
2118
2344
  "name": "executeItemsDropdownAction",
2119
2345
  "comment": {
@@ -2840,13 +3066,23 @@
2840
3066
  },
2841
3067
  "type": "string"
2842
3068
  },
3069
+ "isEnvironmentPrimary": {
3070
+ "comment": {
3071
+ "markdownText": "Whether the current environment is the primary one."
3072
+ },
3073
+ "location": {
3074
+ "filePath": "src/ctx/base.ts",
3075
+ "lineNumber": 64
3076
+ },
3077
+ "type": "boolean"
3078
+ },
2843
3079
  "owner": {
2844
3080
  "comment": {
2845
3081
  "markdownText": "The account/organization that is the project owner."
2846
3082
  },
2847
3083
  "location": {
2848
3084
  "filePath": "src/ctx/base.ts",
2849
- "lineNumber": 64
3085
+ "lineNumber": 67
2850
3086
  },
2851
3087
  "type": "Account | Organization"
2852
3088
  },
@@ -2857,7 +3093,7 @@
2857
3093
  },
2858
3094
  "location": {
2859
3095
  "filePath": "src/ctx/base.ts",
2860
- "lineNumber": 72
3096
+ "lineNumber": 75
2861
3097
  },
2862
3098
  "type": "Account | undefined"
2863
3099
  },
@@ -2867,7 +3103,7 @@
2867
3103
  },
2868
3104
  "location": {
2869
3105
  "filePath": "src/ctx/base.ts",
2870
- "lineNumber": 78
3106
+ "lineNumber": 81
2871
3107
  },
2872
3108
  "type": "{\n /** Preferred locale */\n locale: string;\n }"
2873
3109
  },
@@ -2877,7 +3113,7 @@
2877
3113
  },
2878
3114
  "location": {
2879
3115
  "filePath": "src/ctx/base.ts",
2880
- "lineNumber": 84
3116
+ "lineNumber": 87
2881
3117
  },
2882
3118
  "type": "Theme"
2883
3119
  }
@@ -2895,7 +3131,7 @@
2895
3131
  },
2896
3132
  "location": {
2897
3133
  "filePath": "src/ctx/base.ts",
2898
- "lineNumber": 94
3134
+ "lineNumber": 97
2899
3135
  },
2900
3136
  "type": "Partial<Record<string, ItemType>>"
2901
3137
  },
@@ -2905,7 +3141,7 @@
2905
3141
  },
2906
3142
  "location": {
2907
3143
  "filePath": "src/ctx/base.ts",
2908
- "lineNumber": 101
3144
+ "lineNumber": 104
2909
3145
  },
2910
3146
  "type": "Partial<Record<string, Field>>"
2911
3147
  },
@@ -2915,7 +3151,7 @@
2915
3151
  },
2916
3152
  "location": {
2917
3153
  "filePath": "src/ctx/base.ts",
2918
- "lineNumber": 108
3154
+ "lineNumber": 111
2919
3155
  },
2920
3156
  "type": "Partial<Record<string, Fieldset>>"
2921
3157
  },
@@ -2925,7 +3161,7 @@
2925
3161
  },
2926
3162
  "location": {
2927
3163
  "filePath": "src/ctx/base.ts",
2928
- "lineNumber": 115
3164
+ "lineNumber": 118
2929
3165
  },
2930
3166
  "type": "Partial<Record<string, User>>"
2931
3167
  },
@@ -2935,7 +3171,7 @@
2935
3171
  },
2936
3172
  "location": {
2937
3173
  "filePath": "src/ctx/base.ts",
2938
- "lineNumber": 122
3174
+ "lineNumber": 125
2939
3175
  },
2940
3176
  "type": "Partial<Record<string, SsoUser>>"
2941
3177
  }
@@ -2956,7 +3192,7 @@
2956
3192
  },
2957
3193
  "location": {
2958
3194
  "filePath": "src/ctx/base.ts",
2959
- "lineNumber": 165
3195
+ "lineNumber": 168
2960
3196
  },
2961
3197
  "type": "(itemTypeId: string) => Promise<Field[]>"
2962
3198
  },
@@ -2967,7 +3203,7 @@
2967
3203
  },
2968
3204
  "location": {
2969
3205
  "filePath": "src/ctx/base.ts",
2970
- "lineNumber": 184
3206
+ "lineNumber": 187
2971
3207
  },
2972
3208
  "type": "(itemTypeId: string) => Promise<Fieldset[]>"
2973
3209
  },
@@ -2978,7 +3214,7 @@
2978
3214
  },
2979
3215
  "location": {
2980
3216
  "filePath": "src/ctx/base.ts",
2981
- "lineNumber": 201
3217
+ "lineNumber": 204
2982
3218
  },
2983
3219
  "type": "() => Promise<Field[]>"
2984
3220
  },
@@ -2989,7 +3225,7 @@
2989
3225
  },
2990
3226
  "location": {
2991
3227
  "filePath": "src/ctx/base.ts",
2992
- "lineNumber": 214
3228
+ "lineNumber": 217
2993
3229
  },
2994
3230
  "type": "() => Promise<User[]>"
2995
3231
  },
@@ -3000,7 +3236,7 @@
3000
3236
  },
3001
3237
  "location": {
3002
3238
  "filePath": "src/ctx/base.ts",
3003
- "lineNumber": 227
3239
+ "lineNumber": 230
3004
3240
  },
3005
3241
  "type": "() => Promise<SsoUser[]>"
3006
3242
  }
@@ -3019,7 +3255,7 @@
3019
3255
  },
3020
3256
  "location": {
3021
3257
  "filePath": "src/ctx/base.ts",
3022
- "lineNumber": 249
3258
+ "lineNumber": 252
3023
3259
  },
3024
3260
  "type": "(params: Record<string, unknown>) => Promise<void>"
3025
3261
  },
@@ -3030,7 +3266,7 @@
3030
3266
  },
3031
3267
  "location": {
3032
3268
  "filePath": "src/ctx/base.ts",
3033
- "lineNumber": 300
3269
+ "lineNumber": 303
3034
3270
  },
3035
3271
  "type": "(\n fieldId: string,\n changes: FieldAppearanceChange[],\n ) => Promise<void>"
3036
3272
  }
@@ -3049,7 +3285,7 @@
3049
3285
  },
3050
3286
  "location": {
3051
3287
  "filePath": "src/ctx/base.ts",
3052
- "lineNumber": 405
3288
+ "lineNumber": 408
3053
3289
  },
3054
3290
  "type": "(message: string) => Promise<void>"
3055
3291
  },
@@ -3060,7 +3296,7 @@
3060
3296
  },
3061
3297
  "location": {
3062
3298
  "filePath": "src/ctx/base.ts",
3063
- "lineNumber": 420
3299
+ "lineNumber": 423
3064
3300
  },
3065
3301
  "type": "(message: string) => Promise<void>"
3066
3302
  },
@@ -3071,7 +3307,7 @@
3071
3307
  },
3072
3308
  "location": {
3073
3309
  "filePath": "src/ctx/base.ts",
3074
- "lineNumber": 444
3310
+ "lineNumber": 447
3075
3311
  },
3076
3312
  "type": "<CtaValue = unknown>(\n toast: Toast<CtaValue>,\n ) => Promise<CtaValue | null>"
3077
3313
  }
@@ -3090,7 +3326,7 @@
3090
3326
  },
3091
3327
  "location": {
3092
3328
  "filePath": "src/ctx/base.ts",
3093
- "lineNumber": 330
3329
+ "lineNumber": 333
3094
3330
  },
3095
3331
  "type": "(itemTypeId: string) => Promise<Item | null>"
3096
3332
  },
@@ -3101,7 +3337,7 @@
3101
3337
  },
3102
3338
  "location": {
3103
3339
  "filePath": "src/ctx/base.ts",
3104
- "lineNumber": 351
3340
+ "lineNumber": 354
3105
3341
  },
3106
3342
  "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 }"
3107
3343
  },
@@ -3112,7 +3348,7 @@
3112
3348
  },
3113
3349
  "location": {
3114
3350
  "filePath": "src/ctx/base.ts",
3115
- "lineNumber": 383
3351
+ "lineNumber": 386
3116
3352
  },
3117
3353
  "type": "(itemId: string) => Promise<Item | null>"
3118
3354
  }
@@ -3131,7 +3367,7 @@
3131
3367
  },
3132
3368
  "location": {
3133
3369
  "filePath": "src/ctx/base.ts",
3134
- "lineNumber": 471
3370
+ "lineNumber": 474
3135
3371
  },
3136
3372
  "type": "{\n (options: { multiple: true }): Promise<Upload[] | null>;\n (options?: { multiple: false }): Promise<Upload | null>;\n }"
3137
3373
  },
@@ -3142,7 +3378,7 @@
3142
3378
  },
3143
3379
  "location": {
3144
3380
  "filePath": "src/ctx/base.ts",
3145
- "lineNumber": 499
3381
+ "lineNumber": 502
3146
3382
  },
3147
3383
  "type": "(\n uploadId: string,\n ) => Promise<(Upload & { deleted?: true }) | null>"
3148
3384
  },
@@ -3153,7 +3389,7 @@
3153
3389
  },
3154
3390
  "location": {
3155
3391
  "filePath": "src/ctx/base.ts",
3156
- "lineNumber": 527
3392
+ "lineNumber": 530
3157
3393
  },
3158
3394
  "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>"
3159
3395
  }
@@ -3172,7 +3408,7 @@
3172
3408
  },
3173
3409
  "location": {
3174
3410
  "filePath": "src/ctx/base.ts",
3175
- "lineNumber": 558
3411
+ "lineNumber": 561
3176
3412
  },
3177
3413
  "type": "(modal: Modal) => Promise<unknown>"
3178
3414
  },
@@ -3183,7 +3419,7 @@
3183
3419
  },
3184
3420
  "location": {
3185
3421
  "filePath": "src/ctx/base.ts",
3186
- "lineNumber": 595
3422
+ "lineNumber": 598
3187
3423
  },
3188
3424
  "type": "(options: ConfirmOptions) => Promise<unknown>"
3189
3425
  }
@@ -3202,7 +3438,7 @@
3202
3438
  },
3203
3439
  "location": {
3204
3440
  "filePath": "src/ctx/base.ts",
3205
- "lineNumber": 609
3441
+ "lineNumber": 612
3206
3442
  },
3207
3443
  "type": "(path: string) => Promise<void>"
3208
3444
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datocms-plugin-sdk",
3
- "version": "2.1.0-alpha.0",
3
+ "version": "2.1.0-alpha.2",
4
4
  "description": "DatoCMS Plugin SDK",
5
5
  "keywords": [
6
6
  "datocms",
@@ -36,14 +36,15 @@
36
36
  "url": "https://github.com/datocms/plugins-sdk/issues"
37
37
  },
38
38
  "dependencies": {
39
- "@datocms/cma-client": "next",
39
+ "@datocms/cma-client": "^5.2.2",
40
40
  "@types/react": "^17.0.3",
41
41
  "datocms-structured-text-utils": "^2.0.0",
42
+ "emoji-regex-xs": "*",
42
43
  "penpal": "^4.1.1"
43
44
  },
44
45
  "devDependencies": {
45
46
  "glob": "^11.0.0",
46
47
  "typescript": "^5.6.2"
47
48
  },
48
- "gitHead": "614ec540796d1d8065543bc6ff88da2f62764956"
49
+ "gitHead": "774ac774ad3125a0ee778b691a660d651cd67f29"
49
50
  }
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';
@@ -36,6 +37,14 @@ import {
36
37
  RenderFieldExtensionHook,
37
38
  renderFieldExtensionBootstrapper,
38
39
  } from './hooks/renderFieldExtension';
40
+ import {
41
+ RenderInspectorHook,
42
+ renderInspectorBootstrapper,
43
+ } from './hooks/renderInspector';
44
+ import {
45
+ RenderInspectorPanelHook,
46
+ renderInspectorPanelBootstrapper,
47
+ } from './hooks/renderInspectorPanel';
39
48
  import {
40
49
  RenderItemCollectionOutletHook,
41
50
  renderItemCollectionOutletBootstrapper,
@@ -66,6 +75,7 @@ import {
66
75
  RenderUploadSidebarPanelHook,
67
76
  renderUploadSidebarPanelBootstrapper,
68
77
  } from './hooks/renderUploadSidebarPanel';
78
+ import type { SchemaItemTypeDropdownActionsHook } from './hooks/schemaItemTypeDropdownActions';
69
79
  import type { SettingsAreaSidebarItemGroupsHook } from './hooks/settingsAreaSidebarItemGroups';
70
80
  import { UploadSidebarPanelsHook } from './hooks/uploadSidebarPanels';
71
81
  import { UploadSidebarsHook } from './hooks/uploadSidebars';
@@ -87,6 +97,7 @@ export type FullConnectParameters = AssetSourcesHook &
87
97
  ExecuteFieldDropdownActionHook &
88
98
  ExecuteItemFormDropdownActionHook &
89
99
  ExecuteItemsDropdownActionHook &
100
+ ExecuteSchemaItemTypeDropdownActionHook &
90
101
  ExecuteUploadsDropdownActionHook &
91
102
  FieldDropdownActionsHook &
92
103
  InitialLocationQueryForItemSelectorHook &
@@ -114,8 +125,11 @@ export type FullConnectParameters = AssetSourcesHook &
114
125
  RenderManualFieldExtensionConfigScreenHook &
115
126
  RenderModalHook &
116
127
  RenderPageHook &
128
+ RenderInspectorHook &
129
+ RenderInspectorPanelHook &
117
130
  RenderUploadSidebarHook &
118
131
  RenderUploadSidebarPanelHook &
132
+ SchemaItemTypeDropdownActionsHook &
119
133
  SettingsAreaSidebarItemGroupsHook &
120
134
  UploadsDropdownActionsHook &
121
135
  UploadSidebarPanelsHook &
@@ -260,6 +274,8 @@ export async function connect(
260
274
  renderManualFieldExtensionConfigScreenBootstrapper,
261
275
  renderModal: renderModalBootstrapper,
262
276
  renderPage: renderPageBootstrapper,
277
+ renderInspector: renderInspectorBootstrapper,
278
+ renderInspectorPanel: renderInspectorPanelBootstrapper,
263
279
  renderUploadSidebar: renderUploadSidebarBootstrapper,
264
280
  renderUploadSidebarPanel: renderUploadSidebarPanelBootstrapper,
265
281
  };
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
 
package/src/guardUtils.ts CHANGED
@@ -1,3 +1,7 @@
1
+ import emojiRegex from 'emoji-regex-xs';
2
+
3
+ export type Emoji = string & { readonly __brand: 'Emoji' };
4
+
1
5
  export function isNullish(value: unknown): value is null | undefined {
2
6
  return value === null || value === undefined;
3
7
  }
@@ -10,6 +14,15 @@ export function isString(value: unknown): value is string {
10
14
  return typeof value === 'string';
11
15
  }
12
16
 
17
+ export function isEmoji(value: unknown): value is Emoji {
18
+ if (!isString(value)) return false;
19
+
20
+ const regex = emojiRegex();
21
+ const match = value.match(regex);
22
+
23
+ return match !== null && match.length === 1 && match[0] === value;
24
+ }
25
+
13
26
  export function isNumber(value: unknown): value is number {
14
27
  return typeof value === 'number';
15
28
  }
@@ -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
+ }>;