datocms-plugin-sdk 2.1.0-alpha.0 → 2.1.0-alpha.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.
- package/dist/cjs/connect.js.map +1 -1
- package/dist/cjs/hooks/executeSchemaItemTypeDropdownAction.js +3 -0
- package/dist/cjs/hooks/executeSchemaItemTypeDropdownAction.js.map +1 -0
- package/dist/cjs/hooks/renderPage.js.map +1 -1
- package/dist/cjs/hooks/schemaItemTypeDropdownActions.js +3 -0
- package/dist/cjs/hooks/schemaItemTypeDropdownActions.js.map +1 -0
- package/dist/cjs/icon.js.map +1 -1
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/manifest.js +134 -32
- package/dist/cjs/manifest.js.map +1 -1
- package/dist/esm/connect.d.ts +3 -1
- package/dist/esm/connect.js.map +1 -1
- package/dist/esm/ctx/base.d.ts +2 -0
- package/dist/esm/hooks/executeSchemaItemTypeDropdownAction.d.ts +20 -0
- package/dist/esm/hooks/executeSchemaItemTypeDropdownAction.js +2 -0
- package/dist/esm/hooks/executeSchemaItemTypeDropdownAction.js.map +1 -0
- package/dist/esm/hooks/onBeforeItemUpsert.d.ts +28 -3
- package/dist/esm/hooks/renderPage.d.ts +6 -0
- package/dist/esm/hooks/renderPage.js.map +1 -1
- package/dist/esm/hooks/schemaItemTypeDropdownActions.d.ts +17 -0
- package/dist/esm/hooks/schemaItemTypeDropdownActions.js +2 -0
- package/dist/esm/hooks/schemaItemTypeDropdownActions.js.map +1 -0
- package/dist/esm/icon.d.ts +39 -1
- package/dist/esm/icon.js.map +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/manifest.js +134 -32
- package/dist/esm/manifest.js.map +1 -1
- package/dist/types/connect.d.ts +3 -1
- package/dist/types/ctx/base.d.ts +2 -0
- package/dist/types/hooks/executeSchemaItemTypeDropdownAction.d.ts +20 -0
- package/dist/types/hooks/onBeforeItemUpsert.d.ts +28 -3
- package/dist/types/hooks/renderPage.d.ts +6 -0
- package/dist/types/hooks/schemaItemTypeDropdownActions.d.ts +17 -0
- package/dist/types/icon.d.ts +39 -1
- package/dist/types/index.d.ts +2 -0
- package/manifest.json +134 -32
- package/package.json +3 -3
- package/src/connect.ts +4 -0
- package/src/ctx/base.ts +3 -0
- package/src/hooks/executeSchemaItemTypeDropdownAction.ts +24 -0
- package/src/hooks/onBeforeItemUpsert.ts +31 -3
- package/src/hooks/renderPage.ts +7 -0
- package/src/hooks/schemaItemTypeDropdownActions.ts +22 -0
- package/src/icon.ts +46 -3
- package/src/index.ts +2 -0
- package/src/manifest.ts +139 -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
|
}
|
|
@@ -1583,7 +1616,7 @@
|
|
|
1583
1616
|
"onBeforeItemUpsert": {
|
|
1584
1617
|
"name": "onBeforeItemUpsert",
|
|
1585
1618
|
"comment": {
|
|
1586
|
-
"markdownText": "This
|
|
1619
|
+
"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
1620
|
"tag": "beforeHooks"
|
|
1588
1621
|
},
|
|
1589
1622
|
"nonCtxArguments": [
|
|
@@ -1594,13 +1627,33 @@
|
|
|
1594
1627
|
],
|
|
1595
1628
|
"ctxArgument": {
|
|
1596
1629
|
"type": "Ctx",
|
|
1597
|
-
"additionalProperties": [
|
|
1598
|
-
|
|
1630
|
+
"additionalProperties": [
|
|
1631
|
+
{
|
|
1632
|
+
"items": {}
|
|
1633
|
+
}
|
|
1634
|
+
],
|
|
1635
|
+
"additionalMethods": [
|
|
1636
|
+
{
|
|
1637
|
+
"items": {
|
|
1638
|
+
"scrollToField": {
|
|
1639
|
+
"comment": {
|
|
1640
|
+
"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.",
|
|
1641
|
+
"example": "const fieldPath = prompt(\n 'Please insert the path of a field in the form',\n ctx.fieldPath,\n);\n\nawait ctx.scrollToField(fieldPath);"
|
|
1642
|
+
},
|
|
1643
|
+
"location": {
|
|
1644
|
+
"filePath": "src/hooks/onBeforeItemUpsert.ts",
|
|
1645
|
+
"lineNumber": 47
|
|
1646
|
+
},
|
|
1647
|
+
"type": "(path: string, locale?: string) => Promise<void>"
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
]
|
|
1599
1652
|
},
|
|
1600
1653
|
"returnType": "MaybePromise<boolean>",
|
|
1601
1654
|
"location": {
|
|
1602
1655
|
"filePath": "src/hooks/onBeforeItemUpsert.ts",
|
|
1603
|
-
"lineNumber":
|
|
1656
|
+
"lineNumber": 22
|
|
1604
1657
|
}
|
|
1605
1658
|
},
|
|
1606
1659
|
"manualFieldExtensions": {
|
|
@@ -2114,6 +2167,45 @@
|
|
|
2114
2167
|
"lineNumber": 13
|
|
2115
2168
|
}
|
|
2116
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
|
+
},
|
|
2117
2209
|
"executeItemsDropdownAction": {
|
|
2118
2210
|
"name": "executeItemsDropdownAction",
|
|
2119
2211
|
"comment": {
|
|
@@ -2840,13 +2932,23 @@
|
|
|
2840
2932
|
},
|
|
2841
2933
|
"type": "string"
|
|
2842
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
|
+
},
|
|
2843
2945
|
"owner": {
|
|
2844
2946
|
"comment": {
|
|
2845
2947
|
"markdownText": "The account/organization that is the project owner."
|
|
2846
2948
|
},
|
|
2847
2949
|
"location": {
|
|
2848
2950
|
"filePath": "src/ctx/base.ts",
|
|
2849
|
-
"lineNumber":
|
|
2951
|
+
"lineNumber": 67
|
|
2850
2952
|
},
|
|
2851
2953
|
"type": "Account | Organization"
|
|
2852
2954
|
},
|
|
@@ -2857,7 +2959,7 @@
|
|
|
2857
2959
|
},
|
|
2858
2960
|
"location": {
|
|
2859
2961
|
"filePath": "src/ctx/base.ts",
|
|
2860
|
-
"lineNumber":
|
|
2962
|
+
"lineNumber": 75
|
|
2861
2963
|
},
|
|
2862
2964
|
"type": "Account | undefined"
|
|
2863
2965
|
},
|
|
@@ -2867,7 +2969,7 @@
|
|
|
2867
2969
|
},
|
|
2868
2970
|
"location": {
|
|
2869
2971
|
"filePath": "src/ctx/base.ts",
|
|
2870
|
-
"lineNumber":
|
|
2972
|
+
"lineNumber": 81
|
|
2871
2973
|
},
|
|
2872
2974
|
"type": "{\n /** Preferred locale */\n locale: string;\n }"
|
|
2873
2975
|
},
|
|
@@ -2877,7 +2979,7 @@
|
|
|
2877
2979
|
},
|
|
2878
2980
|
"location": {
|
|
2879
2981
|
"filePath": "src/ctx/base.ts",
|
|
2880
|
-
"lineNumber":
|
|
2982
|
+
"lineNumber": 87
|
|
2881
2983
|
},
|
|
2882
2984
|
"type": "Theme"
|
|
2883
2985
|
}
|
|
@@ -2895,7 +2997,7 @@
|
|
|
2895
2997
|
},
|
|
2896
2998
|
"location": {
|
|
2897
2999
|
"filePath": "src/ctx/base.ts",
|
|
2898
|
-
"lineNumber":
|
|
3000
|
+
"lineNumber": 97
|
|
2899
3001
|
},
|
|
2900
3002
|
"type": "Partial<Record<string, ItemType>>"
|
|
2901
3003
|
},
|
|
@@ -2905,7 +3007,7 @@
|
|
|
2905
3007
|
},
|
|
2906
3008
|
"location": {
|
|
2907
3009
|
"filePath": "src/ctx/base.ts",
|
|
2908
|
-
"lineNumber":
|
|
3010
|
+
"lineNumber": 104
|
|
2909
3011
|
},
|
|
2910
3012
|
"type": "Partial<Record<string, Field>>"
|
|
2911
3013
|
},
|
|
@@ -2915,7 +3017,7 @@
|
|
|
2915
3017
|
},
|
|
2916
3018
|
"location": {
|
|
2917
3019
|
"filePath": "src/ctx/base.ts",
|
|
2918
|
-
"lineNumber":
|
|
3020
|
+
"lineNumber": 111
|
|
2919
3021
|
},
|
|
2920
3022
|
"type": "Partial<Record<string, Fieldset>>"
|
|
2921
3023
|
},
|
|
@@ -2925,7 +3027,7 @@
|
|
|
2925
3027
|
},
|
|
2926
3028
|
"location": {
|
|
2927
3029
|
"filePath": "src/ctx/base.ts",
|
|
2928
|
-
"lineNumber":
|
|
3030
|
+
"lineNumber": 118
|
|
2929
3031
|
},
|
|
2930
3032
|
"type": "Partial<Record<string, User>>"
|
|
2931
3033
|
},
|
|
@@ -2935,7 +3037,7 @@
|
|
|
2935
3037
|
},
|
|
2936
3038
|
"location": {
|
|
2937
3039
|
"filePath": "src/ctx/base.ts",
|
|
2938
|
-
"lineNumber":
|
|
3040
|
+
"lineNumber": 125
|
|
2939
3041
|
},
|
|
2940
3042
|
"type": "Partial<Record<string, SsoUser>>"
|
|
2941
3043
|
}
|
|
@@ -2956,7 +3058,7 @@
|
|
|
2956
3058
|
},
|
|
2957
3059
|
"location": {
|
|
2958
3060
|
"filePath": "src/ctx/base.ts",
|
|
2959
|
-
"lineNumber":
|
|
3061
|
+
"lineNumber": 168
|
|
2960
3062
|
},
|
|
2961
3063
|
"type": "(itemTypeId: string) => Promise<Field[]>"
|
|
2962
3064
|
},
|
|
@@ -2967,7 +3069,7 @@
|
|
|
2967
3069
|
},
|
|
2968
3070
|
"location": {
|
|
2969
3071
|
"filePath": "src/ctx/base.ts",
|
|
2970
|
-
"lineNumber":
|
|
3072
|
+
"lineNumber": 187
|
|
2971
3073
|
},
|
|
2972
3074
|
"type": "(itemTypeId: string) => Promise<Fieldset[]>"
|
|
2973
3075
|
},
|
|
@@ -2978,7 +3080,7 @@
|
|
|
2978
3080
|
},
|
|
2979
3081
|
"location": {
|
|
2980
3082
|
"filePath": "src/ctx/base.ts",
|
|
2981
|
-
"lineNumber":
|
|
3083
|
+
"lineNumber": 204
|
|
2982
3084
|
},
|
|
2983
3085
|
"type": "() => Promise<Field[]>"
|
|
2984
3086
|
},
|
|
@@ -2989,7 +3091,7 @@
|
|
|
2989
3091
|
},
|
|
2990
3092
|
"location": {
|
|
2991
3093
|
"filePath": "src/ctx/base.ts",
|
|
2992
|
-
"lineNumber":
|
|
3094
|
+
"lineNumber": 217
|
|
2993
3095
|
},
|
|
2994
3096
|
"type": "() => Promise<User[]>"
|
|
2995
3097
|
},
|
|
@@ -3000,7 +3102,7 @@
|
|
|
3000
3102
|
},
|
|
3001
3103
|
"location": {
|
|
3002
3104
|
"filePath": "src/ctx/base.ts",
|
|
3003
|
-
"lineNumber":
|
|
3105
|
+
"lineNumber": 230
|
|
3004
3106
|
},
|
|
3005
3107
|
"type": "() => Promise<SsoUser[]>"
|
|
3006
3108
|
}
|
|
@@ -3019,7 +3121,7 @@
|
|
|
3019
3121
|
},
|
|
3020
3122
|
"location": {
|
|
3021
3123
|
"filePath": "src/ctx/base.ts",
|
|
3022
|
-
"lineNumber":
|
|
3124
|
+
"lineNumber": 252
|
|
3023
3125
|
},
|
|
3024
3126
|
"type": "(params: Record<string, unknown>) => Promise<void>"
|
|
3025
3127
|
},
|
|
@@ -3030,7 +3132,7 @@
|
|
|
3030
3132
|
},
|
|
3031
3133
|
"location": {
|
|
3032
3134
|
"filePath": "src/ctx/base.ts",
|
|
3033
|
-
"lineNumber":
|
|
3135
|
+
"lineNumber": 303
|
|
3034
3136
|
},
|
|
3035
3137
|
"type": "(\n fieldId: string,\n changes: FieldAppearanceChange[],\n ) => Promise<void>"
|
|
3036
3138
|
}
|
|
@@ -3049,7 +3151,7 @@
|
|
|
3049
3151
|
},
|
|
3050
3152
|
"location": {
|
|
3051
3153
|
"filePath": "src/ctx/base.ts",
|
|
3052
|
-
"lineNumber":
|
|
3154
|
+
"lineNumber": 408
|
|
3053
3155
|
},
|
|
3054
3156
|
"type": "(message: string) => Promise<void>"
|
|
3055
3157
|
},
|
|
@@ -3060,7 +3162,7 @@
|
|
|
3060
3162
|
},
|
|
3061
3163
|
"location": {
|
|
3062
3164
|
"filePath": "src/ctx/base.ts",
|
|
3063
|
-
"lineNumber":
|
|
3165
|
+
"lineNumber": 423
|
|
3064
3166
|
},
|
|
3065
3167
|
"type": "(message: string) => Promise<void>"
|
|
3066
3168
|
},
|
|
@@ -3071,7 +3173,7 @@
|
|
|
3071
3173
|
},
|
|
3072
3174
|
"location": {
|
|
3073
3175
|
"filePath": "src/ctx/base.ts",
|
|
3074
|
-
"lineNumber":
|
|
3176
|
+
"lineNumber": 447
|
|
3075
3177
|
},
|
|
3076
3178
|
"type": "<CtaValue = unknown>(\n toast: Toast<CtaValue>,\n ) => Promise<CtaValue | null>"
|
|
3077
3179
|
}
|
|
@@ -3090,7 +3192,7 @@
|
|
|
3090
3192
|
},
|
|
3091
3193
|
"location": {
|
|
3092
3194
|
"filePath": "src/ctx/base.ts",
|
|
3093
|
-
"lineNumber":
|
|
3195
|
+
"lineNumber": 333
|
|
3094
3196
|
},
|
|
3095
3197
|
"type": "(itemTypeId: string) => Promise<Item | null>"
|
|
3096
3198
|
},
|
|
@@ -3101,7 +3203,7 @@
|
|
|
3101
3203
|
},
|
|
3102
3204
|
"location": {
|
|
3103
3205
|
"filePath": "src/ctx/base.ts",
|
|
3104
|
-
"lineNumber":
|
|
3206
|
+
"lineNumber": 354
|
|
3105
3207
|
},
|
|
3106
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 }"
|
|
3107
3209
|
},
|
|
@@ -3112,7 +3214,7 @@
|
|
|
3112
3214
|
},
|
|
3113
3215
|
"location": {
|
|
3114
3216
|
"filePath": "src/ctx/base.ts",
|
|
3115
|
-
"lineNumber":
|
|
3217
|
+
"lineNumber": 386
|
|
3116
3218
|
},
|
|
3117
3219
|
"type": "(itemId: string) => Promise<Item | null>"
|
|
3118
3220
|
}
|
|
@@ -3131,7 +3233,7 @@
|
|
|
3131
3233
|
},
|
|
3132
3234
|
"location": {
|
|
3133
3235
|
"filePath": "src/ctx/base.ts",
|
|
3134
|
-
"lineNumber":
|
|
3236
|
+
"lineNumber": 474
|
|
3135
3237
|
},
|
|
3136
3238
|
"type": "{\n (options: { multiple: true }): Promise<Upload[] | null>;\n (options?: { multiple: false }): Promise<Upload | null>;\n }"
|
|
3137
3239
|
},
|
|
@@ -3142,7 +3244,7 @@
|
|
|
3142
3244
|
},
|
|
3143
3245
|
"location": {
|
|
3144
3246
|
"filePath": "src/ctx/base.ts",
|
|
3145
|
-
"lineNumber":
|
|
3247
|
+
"lineNumber": 502
|
|
3146
3248
|
},
|
|
3147
3249
|
"type": "(\n uploadId: string,\n ) => Promise<(Upload & { deleted?: true }) | null>"
|
|
3148
3250
|
},
|
|
@@ -3153,7 +3255,7 @@
|
|
|
3153
3255
|
},
|
|
3154
3256
|
"location": {
|
|
3155
3257
|
"filePath": "src/ctx/base.ts",
|
|
3156
|
-
"lineNumber":
|
|
3258
|
+
"lineNumber": 530
|
|
3157
3259
|
},
|
|
3158
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>"
|
|
3159
3261
|
}
|
|
@@ -3172,7 +3274,7 @@
|
|
|
3172
3274
|
},
|
|
3173
3275
|
"location": {
|
|
3174
3276
|
"filePath": "src/ctx/base.ts",
|
|
3175
|
-
"lineNumber":
|
|
3277
|
+
"lineNumber": 561
|
|
3176
3278
|
},
|
|
3177
3279
|
"type": "(modal: Modal) => Promise<unknown>"
|
|
3178
3280
|
},
|
|
@@ -3183,7 +3285,7 @@
|
|
|
3183
3285
|
},
|
|
3184
3286
|
"location": {
|
|
3185
3287
|
"filePath": "src/ctx/base.ts",
|
|
3186
|
-
"lineNumber":
|
|
3288
|
+
"lineNumber": 598
|
|
3187
3289
|
},
|
|
3188
3290
|
"type": "(options: ConfirmOptions) => Promise<unknown>"
|
|
3189
3291
|
}
|
|
@@ -3202,7 +3304,7 @@
|
|
|
3202
3304
|
},
|
|
3203
3305
|
"location": {
|
|
3204
3306
|
"filePath": "src/ctx/base.ts",
|
|
3205
|
-
"lineNumber":
|
|
3307
|
+
"lineNumber": 612
|
|
3206
3308
|
},
|
|
3207
3309
|
"type": "(path: string) => Promise<void>"
|
|
3208
3310
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "datocms-plugin-sdk",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.1",
|
|
4
4
|
"description": "DatoCMS Plugin SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datocms",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"url": "https://github.com/datocms/plugins-sdk/issues"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@datocms/cma-client": "
|
|
39
|
+
"@datocms/cma-client": "^5.2.0-alpha.1",
|
|
40
40
|
"@types/react": "^17.0.3",
|
|
41
41
|
"datocms-structured-text-utils": "^2.0.0",
|
|
42
42
|
"penpal": "^4.1.1"
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"glob": "^11.0.0",
|
|
46
46
|
"typescript": "^5.6.2"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "423f893f8f19b054ae769e2dff1787342f866fab"
|
|
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
|
+
}>;
|
|
@@ -7,8 +7,15 @@ type ItemCreateSchema = SchemaTypes.ItemCreateSchema;
|
|
|
7
7
|
|
|
8
8
|
export type OnBeforeItemUpsertHook = {
|
|
9
9
|
/**
|
|
10
|
-
* This
|
|
11
|
-
*
|
|
10
|
+
* This hook is called when the user attempts to save a record. You can use it to block record saving.
|
|
11
|
+
*
|
|
12
|
+
* If you return `false`, the record will NOT be saved. A small on-page error will say "A plugin blocked the action".
|
|
13
|
+
* However, for better UX, consider also using `ctx.alert()` to better explain to the user why their save was blocked.
|
|
14
|
+
*
|
|
15
|
+
* If you return `true`, the save will proceed as normal.
|
|
16
|
+
*
|
|
17
|
+
* This hook runs BEFORE serverside validation. You can use it to do your own additional validation before returning.
|
|
18
|
+
* Clientside validations are not affected by this hook, since those occur on individual fields' `onBlur()` events.
|
|
12
19
|
*
|
|
13
20
|
* @tag beforeHooks
|
|
14
21
|
*/
|
|
@@ -18,4 +25,25 @@ export type OnBeforeItemUpsertHook = {
|
|
|
18
25
|
) => MaybePromise<boolean>;
|
|
19
26
|
};
|
|
20
27
|
|
|
21
|
-
export type OnBeforeItemUpsertCtx = Ctx
|
|
28
|
+
export type OnBeforeItemUpsertCtx = Ctx<
|
|
29
|
+
{},
|
|
30
|
+
{
|
|
31
|
+
/**
|
|
32
|
+
* Smoothly navigates to a specific field in the form. If the field is
|
|
33
|
+
* localized it will switch language tab and then navigate to the chosen
|
|
34
|
+
* field.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
*
|
|
38
|
+
* ```js
|
|
39
|
+
* const fieldPath = prompt(
|
|
40
|
+
* 'Please insert the path of a field in the form',
|
|
41
|
+
* ctx.fieldPath,
|
|
42
|
+
* );
|
|
43
|
+
*
|
|
44
|
+
* await ctx.scrollToField(fieldPath);
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
scrollToField: (path: string, locale?: string) => Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
>;
|
package/src/hooks/renderPage.ts
CHANGED
|
@@ -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/icon.ts
CHANGED
|
@@ -1,8 +1,44 @@
|
|
|
1
1
|
import { isRecord, isString } from './guardUtils.js';
|
|
2
2
|
|
|
3
|
-
export type Icon =
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export type Icon = AwesomeFontIconIdentifier | SvgDefinition;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Defines a custom SVG icon for use in DatoCMS plugins.
|
|
7
|
+
*
|
|
8
|
+
* To create an SVG definition from an existing SVG file:
|
|
9
|
+
* 1. Grab the `viewBox` attribute from your SVG element (e.g., "0 0 24 24")
|
|
10
|
+
* 2. Grab everything between the `<svg>` tags as the content (all the paths, circles, etc.)
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // From this SVG:
|
|
15
|
+
* // <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
16
|
+
* // <path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/>
|
|
17
|
+
* // </svg>
|
|
18
|
+
*
|
|
19
|
+
* const starIcon: SvgDefinition = {
|
|
20
|
+
* type: 'svg',
|
|
21
|
+
* viewBox: '0 0 24 24',
|
|
22
|
+
* content: '<path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/>'
|
|
23
|
+
* };
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export type SvgDefinition = {
|
|
27
|
+
/** Always set to 'svg' to indicate this is a custom SVG icon */
|
|
28
|
+
type: 'svg';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The viewBox attribute from your SVG element (e.g., "0 0 24 24").
|
|
32
|
+
* This defines the coordinate system and aspect ratio of the SVG.
|
|
33
|
+
*/
|
|
34
|
+
viewBox: string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The inner content of your SVG element — everything between the opening and closing <svg> tags.
|
|
38
|
+
* This includes all paths, circles, rectangles, and other SVG elements that make up your icon.
|
|
39
|
+
*/
|
|
40
|
+
content: string;
|
|
41
|
+
};
|
|
6
42
|
|
|
7
43
|
export function isIcon(value: unknown): value is Icon {
|
|
8
44
|
return (
|
|
@@ -14,6 +50,13 @@ export function isIcon(value: unknown): value is Icon {
|
|
|
14
50
|
);
|
|
15
51
|
}
|
|
16
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Font Awesome icon identifier for use in DatoCMS plugins.
|
|
55
|
+
*
|
|
56
|
+
* Use Font Awesome icons for consistent visual styling across the admin interface.
|
|
57
|
+
* This is the recommended approach for most plugin icons, with custom SVGs reserved
|
|
58
|
+
* primarily for brand/company logos where Font Awesome doesn't have an appropriate match.
|
|
59
|
+
*/
|
|
17
60
|
export type AwesomeFontIconIdentifier =
|
|
18
61
|
| '0'
|
|
19
62
|
| '00'
|
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';
|