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.
Files changed (49) 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/icon.js.map +1 -1
  8. package/dist/cjs/index.js +2 -0
  9. package/dist/cjs/index.js.map +1 -1
  10. package/dist/cjs/manifest.js +134 -32
  11. package/dist/cjs/manifest.js.map +1 -1
  12. package/dist/esm/connect.d.ts +3 -1
  13. package/dist/esm/connect.js.map +1 -1
  14. package/dist/esm/ctx/base.d.ts +2 -0
  15. package/dist/esm/hooks/executeSchemaItemTypeDropdownAction.d.ts +20 -0
  16. package/dist/esm/hooks/executeSchemaItemTypeDropdownAction.js +2 -0
  17. package/dist/esm/hooks/executeSchemaItemTypeDropdownAction.js.map +1 -0
  18. package/dist/esm/hooks/onBeforeItemUpsert.d.ts +28 -3
  19. package/dist/esm/hooks/renderPage.d.ts +6 -0
  20. package/dist/esm/hooks/renderPage.js.map +1 -1
  21. package/dist/esm/hooks/schemaItemTypeDropdownActions.d.ts +17 -0
  22. package/dist/esm/hooks/schemaItemTypeDropdownActions.js +2 -0
  23. package/dist/esm/hooks/schemaItemTypeDropdownActions.js.map +1 -0
  24. package/dist/esm/icon.d.ts +39 -1
  25. package/dist/esm/icon.js.map +1 -1
  26. package/dist/esm/index.d.ts +2 -0
  27. package/dist/esm/index.js +2 -0
  28. package/dist/esm/index.js.map +1 -1
  29. package/dist/esm/manifest.js +134 -32
  30. package/dist/esm/manifest.js.map +1 -1
  31. package/dist/types/connect.d.ts +3 -1
  32. package/dist/types/ctx/base.d.ts +2 -0
  33. package/dist/types/hooks/executeSchemaItemTypeDropdownAction.d.ts +20 -0
  34. package/dist/types/hooks/onBeforeItemUpsert.d.ts +28 -3
  35. package/dist/types/hooks/renderPage.d.ts +6 -0
  36. package/dist/types/hooks/schemaItemTypeDropdownActions.d.ts +17 -0
  37. package/dist/types/icon.d.ts +39 -1
  38. package/dist/types/index.d.ts +2 -0
  39. package/manifest.json +134 -32
  40. package/package.json +3 -3
  41. package/src/connect.ts +4 -0
  42. package/src/ctx/base.ts +3 -0
  43. package/src/hooks/executeSchemaItemTypeDropdownAction.ts +24 -0
  44. package/src/hooks/onBeforeItemUpsert.ts +31 -3
  45. package/src/hooks/renderPage.ts +7 -0
  46. package/src/hooks/schemaItemTypeDropdownActions.ts +22 -0
  47. package/src/icon.ts +46 -3
  48. package/src/index.ts +2 -0
  49. package/src/manifest.ts +139 -32
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: {
@@ -251,6 +275,16 @@ export const manifest: Manifest = {
251
275
  },
252
276
  type: 'string',
253
277
  },
278
+ location: {
279
+ comment: {
280
+ markdownText: 'Current page location.',
281
+ },
282
+ location: {
283
+ filePath: 'src/hooks/renderPage.ts',
284
+ lineNumber: 22,
285
+ },
286
+ type: '{\n pathname: string;\n search: string;\n hash: string;\n }',
287
+ },
254
288
  },
255
289
  },
256
290
  ],
@@ -1711,7 +1745,7 @@ export const manifest: Manifest = {
1711
1745
  name: 'onBeforeItemUpsert',
1712
1746
  comment: {
1713
1747
  markdownText:
1714
- 'This function will be called before saving a new version of a record. You\ncan stop the action by returning `false`.',
1748
+ '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.',
1715
1749
  tag: 'beforeHooks',
1716
1750
  },
1717
1751
  nonCtxArguments: [
@@ -1722,13 +1756,35 @@ export const manifest: Manifest = {
1722
1756
  ],
1723
1757
  ctxArgument: {
1724
1758
  type: 'Ctx',
1725
- additionalProperties: [],
1726
- additionalMethods: [],
1759
+ additionalProperties: [
1760
+ {
1761
+ items: {},
1762
+ },
1763
+ ],
1764
+ additionalMethods: [
1765
+ {
1766
+ items: {
1767
+ scrollToField: {
1768
+ comment: {
1769
+ markdownText:
1770
+ '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.',
1771
+ example:
1772
+ "const fieldPath = prompt(\n 'Please insert the path of a field in the form',\n ctx.fieldPath,\n);\n\nawait ctx.scrollToField(fieldPath);",
1773
+ },
1774
+ location: {
1775
+ filePath: 'src/hooks/onBeforeItemUpsert.ts',
1776
+ lineNumber: 47,
1777
+ },
1778
+ type: '(path: string, locale?: string) => Promise<void>',
1779
+ },
1780
+ },
1781
+ },
1782
+ ],
1727
1783
  },
1728
1784
  returnType: 'MaybePromise<boolean>',
1729
1785
  location: {
1730
1786
  filePath: 'src/hooks/onBeforeItemUpsert.ts',
1731
- lineNumber: 15,
1787
+ lineNumber: 22,
1732
1788
  },
1733
1789
  },
1734
1790
  manualFieldExtensions: {
@@ -2272,6 +2328,46 @@ export const manifest: Manifest = {
2272
2328
  lineNumber: 13,
2273
2329
  },
2274
2330
  },
2331
+ executeSchemaItemTypeDropdownAction: {
2332
+ name: 'executeSchemaItemTypeDropdownAction',
2333
+ comment: {
2334
+ markdownText:
2335
+ 'Use this function to execute a particular dropdown action defined via\nthe `schemaItemTypeDropdownActions()` hook.',
2336
+ tag: 'dropdownActions',
2337
+ },
2338
+ nonCtxArguments: [
2339
+ {
2340
+ name: 'actionId',
2341
+ typeName: 'string',
2342
+ },
2343
+ {
2344
+ name: 'itemType',
2345
+ typeName: 'ItemType',
2346
+ },
2347
+ ],
2348
+ ctxArgument: {
2349
+ type: 'Ctx',
2350
+ additionalProperties: [
2351
+ {
2352
+ items: {
2353
+ parameters: {
2354
+ location: {
2355
+ filePath: 'src/hooks/executeSchemaItemTypeDropdownAction.ts',
2356
+ lineNumber: 23,
2357
+ },
2358
+ type: 'Record<string, unknown> | undefined',
2359
+ },
2360
+ },
2361
+ },
2362
+ ],
2363
+ additionalMethods: [],
2364
+ },
2365
+ returnType: 'Promise<void>',
2366
+ location: {
2367
+ filePath: 'src/hooks/executeSchemaItemTypeDropdownAction.ts',
2368
+ lineNumber: 13,
2369
+ },
2370
+ },
2275
2371
  executeItemsDropdownAction: {
2276
2372
  name: 'executeItemsDropdownAction',
2277
2373
  comment: {
@@ -3050,6 +3146,17 @@ export const manifest: Manifest = {
3050
3146
  },
3051
3147
  type: 'string',
3052
3148
  },
3149
+ isEnvironmentPrimary: {
3150
+ comment: {
3151
+ markdownText:
3152
+ 'Whether the current environment is the primary one.',
3153
+ },
3154
+ location: {
3155
+ filePath: 'src/ctx/base.ts',
3156
+ lineNumber: 64,
3157
+ },
3158
+ type: 'boolean',
3159
+ },
3053
3160
  owner: {
3054
3161
  comment: {
3055
3162
  markdownText:
@@ -3057,7 +3164,7 @@ export const manifest: Manifest = {
3057
3164
  },
3058
3165
  location: {
3059
3166
  filePath: 'src/ctx/base.ts',
3060
- lineNumber: 64,
3167
+ lineNumber: 67,
3061
3168
  },
3062
3169
  type: 'Account | Organization',
3063
3170
  },
@@ -3069,7 +3176,7 @@ export const manifest: Manifest = {
3069
3176
  },
3070
3177
  location: {
3071
3178
  filePath: 'src/ctx/base.ts',
3072
- lineNumber: 72,
3179
+ lineNumber: 75,
3073
3180
  },
3074
3181
  type: 'Account | undefined',
3075
3182
  },
@@ -3080,7 +3187,7 @@ export const manifest: Manifest = {
3080
3187
  },
3081
3188
  location: {
3082
3189
  filePath: 'src/ctx/base.ts',
3083
- lineNumber: 78,
3190
+ lineNumber: 81,
3084
3191
  },
3085
3192
  type: '{\n /** Preferred locale */\n locale: string;\n }',
3086
3193
  },
@@ -3091,7 +3198,7 @@ export const manifest: Manifest = {
3091
3198
  },
3092
3199
  location: {
3093
3200
  filePath: 'src/ctx/base.ts',
3094
- lineNumber: 84,
3201
+ lineNumber: 87,
3095
3202
  },
3096
3203
  type: 'Theme',
3097
3204
  },
@@ -3111,7 +3218,7 @@ export const manifest: Manifest = {
3111
3218
  },
3112
3219
  location: {
3113
3220
  filePath: 'src/ctx/base.ts',
3114
- lineNumber: 94,
3221
+ lineNumber: 97,
3115
3222
  },
3116
3223
  type: 'Partial<Record<string, ItemType>>',
3117
3224
  },
@@ -3122,7 +3229,7 @@ export const manifest: Manifest = {
3122
3229
  },
3123
3230
  location: {
3124
3231
  filePath: 'src/ctx/base.ts',
3125
- lineNumber: 101,
3232
+ lineNumber: 104,
3126
3233
  },
3127
3234
  type: 'Partial<Record<string, Field>>',
3128
3235
  },
@@ -3133,7 +3240,7 @@ export const manifest: Manifest = {
3133
3240
  },
3134
3241
  location: {
3135
3242
  filePath: 'src/ctx/base.ts',
3136
- lineNumber: 108,
3243
+ lineNumber: 111,
3137
3244
  },
3138
3245
  type: 'Partial<Record<string, Fieldset>>',
3139
3246
  },
@@ -3144,7 +3251,7 @@ export const manifest: Manifest = {
3144
3251
  },
3145
3252
  location: {
3146
3253
  filePath: 'src/ctx/base.ts',
3147
- lineNumber: 115,
3254
+ lineNumber: 118,
3148
3255
  },
3149
3256
  type: 'Partial<Record<string, User>>',
3150
3257
  },
@@ -3155,7 +3262,7 @@ export const manifest: Manifest = {
3155
3262
  },
3156
3263
  location: {
3157
3264
  filePath: 'src/ctx/base.ts',
3158
- lineNumber: 122,
3265
+ lineNumber: 125,
3159
3266
  },
3160
3267
  type: 'Partial<Record<string, SsoUser>>',
3161
3268
  },
@@ -3179,7 +3286,7 @@ export const manifest: Manifest = {
3179
3286
  },
3180
3287
  location: {
3181
3288
  filePath: 'src/ctx/base.ts',
3182
- lineNumber: 165,
3289
+ lineNumber: 168,
3183
3290
  },
3184
3291
  type: '(itemTypeId: string) => Promise<Field[]>',
3185
3292
  },
@@ -3192,7 +3299,7 @@ export const manifest: Manifest = {
3192
3299
  },
3193
3300
  location: {
3194
3301
  filePath: 'src/ctx/base.ts',
3195
- lineNumber: 184,
3302
+ lineNumber: 187,
3196
3303
  },
3197
3304
  type: '(itemTypeId: string) => Promise<Fieldset[]>',
3198
3305
  },
@@ -3205,7 +3312,7 @@ export const manifest: Manifest = {
3205
3312
  },
3206
3313
  location: {
3207
3314
  filePath: 'src/ctx/base.ts',
3208
- lineNumber: 201,
3315
+ lineNumber: 204,
3209
3316
  },
3210
3317
  type: '() => Promise<Field[]>',
3211
3318
  },
@@ -3218,7 +3325,7 @@ export const manifest: Manifest = {
3218
3325
  },
3219
3326
  location: {
3220
3327
  filePath: 'src/ctx/base.ts',
3221
- lineNumber: 214,
3328
+ lineNumber: 217,
3222
3329
  },
3223
3330
  type: '() => Promise<User[]>',
3224
3331
  },
@@ -3231,7 +3338,7 @@ export const manifest: Manifest = {
3231
3338
  },
3232
3339
  location: {
3233
3340
  filePath: 'src/ctx/base.ts',
3234
- lineNumber: 227,
3341
+ lineNumber: 230,
3235
3342
  },
3236
3343
  type: '() => Promise<SsoUser[]>',
3237
3344
  },
@@ -3253,7 +3360,7 @@ export const manifest: Manifest = {
3253
3360
  },
3254
3361
  location: {
3255
3362
  filePath: 'src/ctx/base.ts',
3256
- lineNumber: 249,
3363
+ lineNumber: 252,
3257
3364
  },
3258
3365
  type: '(params: Record<string, unknown>) => Promise<void>',
3259
3366
  },
@@ -3266,7 +3373,7 @@ export const manifest: Manifest = {
3266
3373
  },
3267
3374
  location: {
3268
3375
  filePath: 'src/ctx/base.ts',
3269
- lineNumber: 300,
3376
+ lineNumber: 303,
3270
3377
  },
3271
3378
  type: '(\n fieldId: string,\n changes: FieldAppearanceChange[],\n ) => Promise<void>',
3272
3379
  },
@@ -3288,7 +3395,7 @@ export const manifest: Manifest = {
3288
3395
  },
3289
3396
  location: {
3290
3397
  filePath: 'src/ctx/base.ts',
3291
- lineNumber: 405,
3398
+ lineNumber: 408,
3292
3399
  },
3293
3400
  type: '(message: string) => Promise<void>',
3294
3401
  },
@@ -3301,7 +3408,7 @@ export const manifest: Manifest = {
3301
3408
  },
3302
3409
  location: {
3303
3410
  filePath: 'src/ctx/base.ts',
3304
- lineNumber: 420,
3411
+ lineNumber: 423,
3305
3412
  },
3306
3413
  type: '(message: string) => Promise<void>',
3307
3414
  },
@@ -3314,7 +3421,7 @@ export const manifest: Manifest = {
3314
3421
  },
3315
3422
  location: {
3316
3423
  filePath: 'src/ctx/base.ts',
3317
- lineNumber: 444,
3424
+ lineNumber: 447,
3318
3425
  },
3319
3426
  type: '<CtaValue = unknown>(\n toast: Toast<CtaValue>,\n ) => Promise<CtaValue | null>',
3320
3427
  },
@@ -3336,7 +3443,7 @@ export const manifest: Manifest = {
3336
3443
  },
3337
3444
  location: {
3338
3445
  filePath: 'src/ctx/base.ts',
3339
- lineNumber: 330,
3446
+ lineNumber: 333,
3340
3447
  },
3341
3448
  type: '(itemTypeId: string) => Promise<Item | null>',
3342
3449
  },
@@ -3349,7 +3456,7 @@ export const manifest: Manifest = {
3349
3456
  },
3350
3457
  location: {
3351
3458
  filePath: 'src/ctx/base.ts',
3352
- lineNumber: 351,
3459
+ lineNumber: 354,
3353
3460
  },
3354
3461
  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 }',
3355
3462
  },
@@ -3362,7 +3469,7 @@ export const manifest: Manifest = {
3362
3469
  },
3363
3470
  location: {
3364
3471
  filePath: 'src/ctx/base.ts',
3365
- lineNumber: 383,
3472
+ lineNumber: 386,
3366
3473
  },
3367
3474
  type: '(itemId: string) => Promise<Item | null>',
3368
3475
  },
@@ -3384,7 +3491,7 @@ export const manifest: Manifest = {
3384
3491
  },
3385
3492
  location: {
3386
3493
  filePath: 'src/ctx/base.ts',
3387
- lineNumber: 471,
3494
+ lineNumber: 474,
3388
3495
  },
3389
3496
  type: '{\n (options: { multiple: true }): Promise<Upload[] | null>;\n (options?: { multiple: false }): Promise<Upload | null>;\n }',
3390
3497
  },
@@ -3397,7 +3504,7 @@ export const manifest: Manifest = {
3397
3504
  },
3398
3505
  location: {
3399
3506
  filePath: 'src/ctx/base.ts',
3400
- lineNumber: 499,
3507
+ lineNumber: 502,
3401
3508
  },
3402
3509
  type: '(\n uploadId: string,\n ) => Promise<(Upload & { deleted?: true }) | null>',
3403
3510
  },
@@ -3410,7 +3517,7 @@ export const manifest: Manifest = {
3410
3517
  },
3411
3518
  location: {
3412
3519
  filePath: 'src/ctx/base.ts',
3413
- lineNumber: 527,
3520
+ lineNumber: 530,
3414
3521
  },
3415
3522
  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>',
3416
3523
  },
@@ -3432,7 +3539,7 @@ export const manifest: Manifest = {
3432
3539
  },
3433
3540
  location: {
3434
3541
  filePath: 'src/ctx/base.ts',
3435
- lineNumber: 558,
3542
+ lineNumber: 561,
3436
3543
  },
3437
3544
  type: '(modal: Modal) => Promise<unknown>',
3438
3545
  },
@@ -3445,7 +3552,7 @@ export const manifest: Manifest = {
3445
3552
  },
3446
3553
  location: {
3447
3554
  filePath: 'src/ctx/base.ts',
3448
- lineNumber: 595,
3555
+ lineNumber: 598,
3449
3556
  },
3450
3557
  type: '(options: ConfirmOptions) => Promise<unknown>',
3451
3558
  },
@@ -3466,7 +3573,7 @@ export const manifest: Manifest = {
3466
3573
  },
3467
3574
  location: {
3468
3575
  filePath: 'src/ctx/base.ts',
3469
- lineNumber: 609,
3576
+ lineNumber: 612,
3470
3577
  },
3471
3578
  type: '(path: string) => Promise<void>',
3472
3579
  },