@stackbit/cms-core 0.7.6-develop.2 → 0.8.0-develop.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 (63) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/content-store-utils.d.ts +44 -0
  3. package/dist/content-store-utils.d.ts.map +1 -1
  4. package/dist/content-store-utils.js +213 -1
  5. package/dist/content-store-utils.js.map +1 -1
  6. package/dist/content-store.d.ts +12 -1
  7. package/dist/content-store.d.ts.map +1 -1
  8. package/dist/content-store.js +45 -6
  9. package/dist/content-store.js.map +1 -1
  10. package/dist/index.d.ts +0 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +0 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/types/content-store-document-fields.d.ts +105 -0
  15. package/dist/types/content-store-document-fields.d.ts.map +1 -1
  16. package/dist/types/content-store-documents.d.ts +4 -1
  17. package/dist/types/content-store-documents.d.ts.map +1 -1
  18. package/dist/types/content-store-types.d.ts +10 -10
  19. package/dist/types/content-store-types.d.ts.map +1 -1
  20. package/dist/types/custom-actions.d.ts +108 -0
  21. package/dist/types/custom-actions.d.ts.map +1 -0
  22. package/dist/types/custom-actions.js +3 -0
  23. package/dist/types/custom-actions.js.map +1 -0
  24. package/dist/types/index.d.ts +1 -0
  25. package/dist/types/index.d.ts.map +1 -1
  26. package/dist/types/index.js +1 -0
  27. package/dist/types/index.js.map +1 -1
  28. package/dist/utils/csi-to-store-docs-converter.d.ts +2 -1
  29. package/dist/utils/csi-to-store-docs-converter.d.ts.map +1 -1
  30. package/dist/utils/csi-to-store-docs-converter.js +144 -11
  31. package/dist/utils/csi-to-store-docs-converter.js.map +1 -1
  32. package/dist/utils/custom-actions.d.ts +53 -0
  33. package/dist/utils/custom-actions.d.ts.map +1 -0
  34. package/dist/utils/custom-actions.js +586 -0
  35. package/dist/utils/custom-actions.js.map +1 -0
  36. package/dist/utils/document-hooks.d.ts +9 -0
  37. package/dist/utils/document-hooks.d.ts.map +1 -1
  38. package/dist/utils/document-hooks.js +3 -2
  39. package/dist/utils/document-hooks.js.map +1 -1
  40. package/dist/utils/search-utils.d.ts +1 -1
  41. package/dist/utils/search-utils.d.ts.map +1 -1
  42. package/dist/utils/store-to-api-docs-converter.d.ts.map +1 -1
  43. package/dist/utils/store-to-api-docs-converter.js +77 -29
  44. package/dist/utils/store-to-api-docs-converter.js.map +1 -1
  45. package/dist/utils/store-to-csi-docs-converter.d.ts +3 -0
  46. package/dist/utils/store-to-csi-docs-converter.d.ts.map +1 -1
  47. package/dist/utils/store-to-csi-docs-converter.js +2 -1
  48. package/dist/utils/store-to-csi-docs-converter.js.map +1 -1
  49. package/package.json +5 -5
  50. package/src/content-store-utils.ts +247 -0
  51. package/src/content-store.ts +62 -7
  52. package/src/index.ts +0 -1
  53. package/src/types/content-store-document-fields.ts +55 -2
  54. package/src/types/content-store-documents.ts +4 -1
  55. package/src/types/content-store-types.ts +10 -10
  56. package/src/types/custom-actions.ts +154 -0
  57. package/src/types/index.ts +1 -0
  58. package/src/utils/csi-to-store-docs-converter.ts +220 -12
  59. package/src/utils/custom-actions.ts +730 -0
  60. package/src/utils/document-hooks.ts +3 -3
  61. package/src/utils/search-utils.ts +1 -1
  62. package/src/utils/store-to-api-docs-converter.ts +88 -33
  63. package/src/utils/store-to-csi-docs-converter.ts +4 -4
@@ -1,4 +1,5 @@
1
1
  import * as CSITypes from '@stackbit/types';
2
+ import { APICustomActionField, APICustomActionObject } from './custom-actions';
2
3
 
3
4
  export type DocumentField =
4
5
  | DocumentStringLikeField
@@ -117,6 +118,7 @@ export interface DocumentStringLikeFieldNonLocalizedForType<Type extends Documen
117
118
  type: Type;
118
119
  label?: string;
119
120
  localized?: false;
121
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
120
122
  value?: string;
121
123
  }
122
124
 
@@ -124,6 +126,7 @@ export interface DocumentStringLikeFieldLocalizedForType<Type extends DocumentSt
124
126
  type: Type;
125
127
  label?: string;
126
128
  localized: true;
129
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
127
130
  locales: Record<
128
131
  string,
129
132
  {
@@ -137,6 +140,7 @@ export type DocumentStringLikeFieldAPIForType<Type extends DocumentStringLikeFie
137
140
  type: Type;
138
141
  label?: string;
139
142
  description?: string;
143
+ actions?: APICustomActionField[];
140
144
  value?: string | null;
141
145
  } & ({ localized?: false } | { localized: true; locale: string });
142
146
 
@@ -149,6 +153,7 @@ export type DocumentMarkdownFieldNonLocalized = {
149
153
  type: 'markdown';
150
154
  label?: string;
151
155
  localized?: false;
156
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
152
157
  multiElement?: boolean;
153
158
  value?: string;
154
159
  } & ({ isUnset: true; value?: never } | { isUnset?: false; value: string });
@@ -157,6 +162,7 @@ export interface DocumentMarkdownFieldLocalized {
157
162
  type: 'markdown';
158
163
  label?: string;
159
164
  localized: true;
165
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
160
166
  locales: Record<
161
167
  string,
162
168
  {
@@ -172,6 +178,7 @@ export type DocumentMarkdownFieldAPI = {
172
178
  multiElement?: boolean;
173
179
  label?: string;
174
180
  description?: string;
181
+ actions?: APICustomActionField[];
175
182
  value?: string | null;
176
183
  } & ({ isUnset: true; value?: null } | { isUnset?: false; value: string }) &
177
184
  ({ localized?: false } | { localized: true; locale: string });
@@ -185,6 +192,7 @@ export interface DocumentNumberFieldNonLocalized {
185
192
  type: 'number';
186
193
  label?: string;
187
194
  localized?: false;
195
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
188
196
  value?: number;
189
197
  }
190
198
 
@@ -192,6 +200,7 @@ export interface DocumentNumberFieldLocalized {
192
200
  type: 'number';
193
201
  label?: string;
194
202
  localized: true;
203
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
195
204
  locales: Record<
196
205
  string,
197
206
  {
@@ -206,6 +215,7 @@ export type DocumentNumberFieldAPI = {
206
215
  value?: number | null;
207
216
  label?: string;
208
217
  description?: string;
218
+ actions?: APICustomActionField[];
209
219
  } & ({ localized?: false } | { localized: true; locale: string });
210
220
 
211
221
  /**
@@ -217,6 +227,7 @@ export interface DocumentBooleanFieldNonLocalized {
217
227
  type: 'boolean';
218
228
  label?: string;
219
229
  localized?: false;
230
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
220
231
  value?: boolean;
221
232
  }
222
233
 
@@ -224,6 +235,7 @@ export interface DocumentBooleanFieldLocalized {
224
235
  type: 'boolean';
225
236
  label?: string;
226
237
  localized: true;
238
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
227
239
  locales: Record<
228
240
  string,
229
241
  {
@@ -238,6 +250,7 @@ export type DocumentBooleanFieldAPI = {
238
250
  value?: boolean | null;
239
251
  label?: string;
240
252
  description?: string;
253
+ actions?: APICustomActionField[];
241
254
  } & ({ localized?: false } | { localized: true; locale: string });
242
255
 
243
256
  /**
@@ -249,6 +262,7 @@ export type DocumentJsonFieldNonLocalized = {
249
262
  type: 'json';
250
263
  label?: string;
251
264
  localized?: false;
265
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
252
266
  value?: any;
253
267
  } & ({ isUnset: true; value?: never } | { isUnset?: false; value: any });
254
268
 
@@ -256,6 +270,7 @@ export interface DocumentJsonFieldLocalized {
256
270
  type: 'json';
257
271
  label?: string;
258
272
  localized: true;
273
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
259
274
  locales: Record<
260
275
  string,
261
276
  {
@@ -269,6 +284,7 @@ export type DocumentJsonFieldAPI = {
269
284
  type: 'json';
270
285
  label?: string;
271
286
  description?: string;
287
+ actions?: APICustomActionField[];
272
288
  value?: any;
273
289
  } & ({ isUnset: true; value?: null } | { isUnset?: false; value: any }) &
274
290
  ({ localized?: false } | { localized: true; locale: string });
@@ -283,6 +299,7 @@ export interface DocumentStyleFieldNonLocalized {
283
299
  type: 'style';
284
300
  label?: string;
285
301
  localized?: false;
302
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
286
303
  value?: DocumentStyleFieldValue;
287
304
  }
288
305
 
@@ -290,6 +307,7 @@ export interface DocumentStyleFieldLocalized {
290
307
  type: 'style';
291
308
  label?: string;
292
309
  localized: true;
310
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
293
311
  locales: Record<
294
312
  string,
295
313
  {
@@ -304,6 +322,7 @@ export type DocumentStyleFieldAPI = {
304
322
  value?: DocumentStyleFieldValue | null;
305
323
  label?: string;
306
324
  description?: string;
325
+ actions?: APICustomActionField[];
307
326
  } & ({ localized?: false } | { localized: true; locale: string });
308
327
 
309
328
  /**
@@ -317,6 +336,7 @@ export type DocumentRichTextFieldNonLocalized = {
317
336
  type: 'richText';
318
337
  label?: string;
319
338
  localized?: false;
339
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
320
340
  hint?: string;
321
341
  multiElement?: boolean;
322
342
  value?: DocumentRichTextFieldValue;
@@ -326,6 +346,7 @@ export interface DocumentRichTextFieldLocalized {
326
346
  type: 'richText';
327
347
  label?: string;
328
348
  localized: true;
349
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
329
350
  locales: Record<
330
351
  string,
331
352
  {
@@ -343,6 +364,7 @@ export type DocumentRichTextFieldAPI = {
343
364
  multiElement?: boolean;
344
365
  label?: string;
345
366
  description?: string;
367
+ actions?: APICustomActionField[];
346
368
  value?: DocumentRichTextFieldValue | null;
347
369
  } & ({ isUnset: true; value?: null } | { isUnset?: false; value: DocumentRichTextFieldValue }) &
348
370
  ({ localized?: false } | { localized: true; locale: string });
@@ -356,6 +378,7 @@ export type DocumentImageFieldNonLocalized = {
356
378
  type: 'image';
357
379
  label?: string;
358
380
  localized?: false;
381
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
359
382
  source?: string;
360
383
  } & (
361
384
  | { isUnset: true }
@@ -371,6 +394,7 @@ export interface DocumentImageFieldLocalized {
371
394
  label?: string;
372
395
  source?: string;
373
396
  localized: true;
397
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
374
398
  locales: Record<
375
399
  string,
376
400
  {
@@ -391,6 +415,7 @@ export type DocumentImageFieldAPI = {
391
415
  source?: string;
392
416
  label?: string;
393
417
  description?: string;
418
+ actions?: APICustomActionField[];
394
419
  } & ({ isUnset: true } | { isUnset?: false; sourceData?: any; fields: ImageFieldsAPI }) &
395
420
  ({ localized?: false } | { localized: true; locale: string });
396
421
 
@@ -408,6 +433,7 @@ export type DocumentFileFieldNonLocalized = {
408
433
  type: 'file';
409
434
  label?: string;
410
435
  localized?: false;
436
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
411
437
  value?: any;
412
438
  } & ({ isUnset: true; value?: never } | { isUnset?: false; value: any });
413
439
 
@@ -415,6 +441,7 @@ export interface DocumentFileFieldLocalized {
415
441
  type: 'file';
416
442
  label?: string;
417
443
  localized: true;
444
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
418
445
  locales: Record<
419
446
  string,
420
447
  {
@@ -428,6 +455,7 @@ export type DocumentFileFieldAPI = {
428
455
  type: 'file';
429
456
  label?: string;
430
457
  description?: string;
458
+ actions?: APICustomActionField[];
431
459
  value?: any;
432
460
  } & ({ isUnset: true; value?: null } | { isUnset?: false; value: any }) &
433
461
  ({ localized?: false } | { localized: true; locale: string });
@@ -441,11 +469,13 @@ export type DocumentObjectFieldNonLocalized = {
441
469
  type: 'object';
442
470
  label?: string;
443
471
  localized?: false;
472
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
444
473
  } & (
445
474
  | { isUnset: true }
446
475
  | {
447
476
  isUnset?: false;
448
477
  getPreview: (options: { delegate?: CSITypes.ConfigDelegate; locale?: string }) => DocumentObjectFieldPreview;
478
+ getObjectActions?: () => APICustomActionObject[] | undefined; // object actions can be defined only on existing object;
449
479
  fields: Record<string, DocumentField>;
450
480
  }
451
481
  );
@@ -454,11 +484,13 @@ export interface DocumentObjectFieldLocalized {
454
484
  type: 'object';
455
485
  label?: string;
456
486
  localized: true;
487
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
457
488
  locales: Record<
458
489
  string,
459
490
  {
460
491
  locale: string;
461
492
  getPreview: (options: { delegate?: CSITypes.ConfigDelegate; locale?: string }) => DocumentObjectFieldPreview;
493
+ getObjectActions?: () => APICustomActionObject[] | undefined; // object actions can be defined only on existing object
462
494
  fields: Record<string, DocumentField>;
463
495
  }
464
496
  >;
@@ -475,10 +507,14 @@ export type DocumentObjectFieldAPI = {
475
507
  label?: string;
476
508
  description?: string;
477
509
  } & (
478
- | { isUnset: true }
510
+ | {
511
+ isUnset: true;
512
+ actions?: APICustomActionField[];
513
+ }
479
514
  | {
480
515
  isUnset?: false;
481
516
  srcObjectLabel: string;
517
+ actions?: (APICustomActionField | APICustomActionObject)[]; // object actions can be defined only on existing object
482
518
  fields: Record<string, DocumentFieldAPI>;
483
519
  }
484
520
  ) &
@@ -493,6 +529,7 @@ export type DocumentModelFieldNonLocalized = {
493
529
  type: 'model';
494
530
  label?: string;
495
531
  localized?: false;
532
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
496
533
  } & (
497
534
  | { isUnset: true }
498
535
  | {
@@ -500,6 +537,7 @@ export type DocumentModelFieldNonLocalized = {
500
537
  srcModelName: string;
501
538
  srcModelLabel: string;
502
539
  getPreview: (options: { delegate?: CSITypes.ConfigDelegate; locale?: string }) => DocumentModelFieldPreview;
540
+ getObjectActions?: () => APICustomActionObject[] | undefined; // object actions can be defined only on existing object
503
541
  fields: Record<string, DocumentField>;
504
542
  }
505
543
  );
@@ -508,6 +546,7 @@ export interface DocumentModelFieldLocalized {
508
546
  type: 'model';
509
547
  label?: string;
510
548
  localized: true;
549
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
511
550
  locales: Record<
512
551
  string,
513
552
  {
@@ -515,6 +554,7 @@ export interface DocumentModelFieldLocalized {
515
554
  srcModelName: string;
516
555
  srcModelLabel: string;
517
556
  getPreview: (options: { delegate?: CSITypes.ConfigDelegate; locale?: string }) => DocumentModelFieldPreview;
557
+ getObjectActions?: () => APICustomActionObject[] | undefined; // object actions can be defined only on existing object
518
558
  fields: Record<string, DocumentField>;
519
559
  }
520
560
  >;
@@ -525,12 +565,16 @@ export type DocumentModelFieldAPI = {
525
565
  label?: string;
526
566
  description?: string;
527
567
  } & (
528
- | { isUnset: true }
568
+ | {
569
+ isUnset: true;
570
+ actions?: APICustomActionField[];
571
+ }
529
572
  | {
530
573
  isUnset?: false;
531
574
  srcObjectLabel: string;
532
575
  srcModelName: string;
533
576
  srcModelLabel: string;
577
+ actions?: (APICustomActionField | APICustomActionObject)[]; // object actions can be defined only on existing object
534
578
  fields: Record<string, DocumentFieldAPI>;
535
579
  }
536
580
  ) &
@@ -552,6 +596,7 @@ export type DocumentReferenceFieldNonLocalized = {
552
596
  refType: 'document' | 'asset';
553
597
  label?: string;
554
598
  localized?: false;
599
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
555
600
  } & (
556
601
  | { isUnset: true }
557
602
  | {
@@ -565,6 +610,7 @@ export interface DocumentReferenceFieldLocalized {
565
610
  refType: 'document' | 'asset';
566
611
  label?: string;
567
612
  localized: true;
613
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
568
614
  locales: Record<
569
615
  string,
570
616
  {
@@ -579,6 +625,7 @@ export type DocumentReferenceFieldAPI = {
579
625
  refType: 'object' | 'image';
580
626
  label?: string;
581
627
  description?: string;
628
+ actions?: APICustomActionField[];
582
629
  } & (
583
630
  | { isUnset: true }
584
631
  | {
@@ -598,6 +645,7 @@ export type DocumentCrossReferenceFieldNonLocalized = {
598
645
  refType: 'document' | 'asset';
599
646
  label?: string;
600
647
  localized?: false;
648
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
601
649
  } & (
602
650
  | { isUnset: true }
603
651
  | {
@@ -613,6 +661,7 @@ export interface DocumentCrossReferenceFieldLocalized {
613
661
  refType: 'document' | 'asset';
614
662
  label?: string;
615
663
  localized: true;
664
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
616
665
  locales: Record<
617
666
  string,
618
667
  {
@@ -629,6 +678,7 @@ export type DocumentCrossReferenceFieldAPI = {
629
678
  refType: 'document' | 'asset';
630
679
  label?: string;
631
680
  description?: string;
681
+ actions?: APICustomActionField[];
632
682
  } & (
633
683
  | { isUnset: true }
634
684
  | {
@@ -650,6 +700,7 @@ export interface DocumentListFieldNonLocalized {
650
700
  type: 'list';
651
701
  label?: string;
652
702
  localized?: false;
703
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
653
704
  items: DocumentListFieldItems[];
654
705
  }
655
706
 
@@ -657,6 +708,7 @@ export interface DocumentListFieldLocalized {
657
708
  type: 'list';
658
709
  label?: string;
659
710
  localized: true;
711
+ getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
660
712
  locales: Record<
661
713
  string,
662
714
  {
@@ -671,5 +723,6 @@ export type DocumentListFieldAPI = {
671
723
  type: 'list';
672
724
  label?: string;
673
725
  description?: string;
726
+ actions?: APICustomActionField[];
674
727
  items: DocumentListFieldItemsAPI[];
675
728
  } & ({ localized?: false } | { localized: true; locale: string });
@@ -1,5 +1,6 @@
1
1
  import { DocumentStatus, ConfigDelegate } from '@stackbit/types';
2
2
  import { DocumentField, DocumentFieldAPI, DocumentFieldAPIForType, DocumentStringLikeFieldForType } from './content-store-document-fields';
3
+ import { APICustomActionDocument } from './custom-actions';
3
4
 
4
5
  export interface Document {
5
6
  type: 'document';
@@ -12,6 +13,7 @@ export interface Document {
12
13
  /** @deprecated used by older, non-csi cms interface */
13
14
  srcObjectLabel?: string;
14
15
  getPreview: (options: { delegate?: ConfigDelegate; locale?: string }) => DocumentPreview;
16
+ getDocumentActions?: () => APICustomActionDocument[] | undefined;
15
17
  srcModelName: string;
16
18
  srcModelLabel: string;
17
19
  isChanged: boolean;
@@ -93,9 +95,10 @@ export interface AssetFileFieldProps {
93
95
  */
94
96
  export type APIObject = APIDocumentObject | APIImageObject;
95
97
 
96
- export interface APIDocumentObject extends Omit<Document, 'getPreview' | 'fields' | 'type'> {
98
+ export interface APIDocumentObject extends Omit<Document, 'getPreview' | 'getDocumentActions' | 'fields' | 'type'> {
97
99
  type: 'object';
98
100
  srcObjectLabel: string;
101
+ actions?: APICustomActionDocument[];
99
102
  fields: Record<string, DocumentFieldAPI>;
100
103
  }
101
104
 
@@ -1,4 +1,4 @@
1
- import * as CSITypes from '@stackbit/types';
1
+ import * as StackbitTypes from '@stackbit/types';
2
2
  import { Model } from '@stackbit/sdk';
3
3
  import { Asset, Document } from './content-store-documents';
4
4
  import { BackCompatContentSourceInterface } from '../utils/backward-compatibility';
@@ -12,35 +12,35 @@ export interface ContentSourceData {
12
12
  version: { interfaceVersion: string; contentSourceVersion: string };
13
13
  srcType: string;
14
14
  srcProjectId: string;
15
- locales?: CSITypes.Locale[];
15
+ locales?: StackbitTypes.Locale[];
16
16
  defaultLocaleCode?: string;
17
17
  /* Array of extended and validated Models */
18
18
  models: Model[];
19
19
  /* Map of extended and validated Models by model name */
20
20
  modelMap: Record<string, Model>;
21
21
  /* Array of original Models (as provided by content source) */
22
- csiSchema: CSITypes.Schema;
23
- csiModels: CSITypes.Model[];
22
+ csiSchema: StackbitTypes.Schema;
23
+ csiModels: StackbitTypes.Model[];
24
24
  /* Map of original Models (as provided by content source) by model name */
25
- csiModelMap: Record<string, CSITypes.Model>;
25
+ csiModelMap: Record<string, StackbitTypes.Model>;
26
26
  /* Array of original content source Documents */
27
- csiDocuments: CSITypes.Document[];
27
+ csiDocuments: StackbitTypes.Document[];
28
28
  /* Map of original content source Documents by document ID */
29
- csiDocumentMap: Record<string, CSITypes.Document>;
29
+ csiDocumentMap: Record<string, StackbitTypes.Document>;
30
30
  /* Array of converted content-store Documents */
31
31
  documents: Document[];
32
32
  /* Map of converted content-store Documents by document ID */
33
33
  documentMap: Record<string, Document>;
34
34
  /* Array of original content source Assets */
35
- csiAssets: CSITypes.Asset[];
35
+ csiAssets: StackbitTypes.Asset[];
36
36
  /* Map of original content source Assets by asset ID */
37
- csiAssetMap: Record<string, CSITypes.Asset>;
37
+ csiAssetMap: Record<string, StackbitTypes.Asset>;
38
38
  /* Array of converted content-store Assets */
39
39
  assets: Asset[];
40
40
  /* Map of converted content-store Assets by asset ID */
41
41
  assetMap: Record<string, Asset>;
42
42
  // Array of converted scheduled actions (publishes)
43
- scheduledActions: CSITypes.ScheduledAction[];
43
+ scheduledActions: StackbitTypes.ScheduledAction[];
44
44
  /* Map of advanced features to enable in the studio client */
45
45
  enabledFeatures: {
46
46
  scheduledActions: boolean;
@@ -0,0 +1,154 @@
1
+ import {
2
+ CustomActionGlobal,
3
+ CustomActionBulk,
4
+ CustomActionDocument,
5
+ CustomActionObjectModel,
6
+ CustomActionObjectField,
7
+ CustomActionField,
8
+ CustomActionState,
9
+ CustomActionInputField
10
+ } from '@stackbit/types';
11
+ import { User } from './index';
12
+
13
+ export type ContentStoreCustomActionMap = Record<string, ContentStoreCustomAction>;
14
+
15
+ export type ContentStoreCustomAction =
16
+ | ContentStoreCustomActionGlobal
17
+ | ContentStoreCustomActionBulk
18
+ | ContentStoreCustomActionDocument
19
+ | ContentStoreCustomActionObjectModel
20
+ | ContentStoreCustomActionObjectField
21
+ | ContentStoreCustomActionField;
22
+
23
+ export type ContentStoreCustomActionGlobal = CustomActionGlobal & ContentStoreCustomActionCommonProps;
24
+ export type ContentStoreCustomActionBulk = CustomActionBulk & ContentStoreCustomActionCommonProps;
25
+ export type ContentStoreCustomActionDocument = CustomActionDocument &
26
+ ContentStoreCustomActionCommonProps & {
27
+ type: 'document';
28
+ documentSpec: APICustomActionDocumentSpecifier;
29
+ };
30
+ export type ContentStoreCustomActionObjectModel = CustomActionObjectModel &
31
+ ContentStoreCustomActionCommonProps & {
32
+ type: 'objectModel';
33
+ documentSpec: APICustomActionDocumentSpecifier;
34
+ fieldPath: (string | number)[];
35
+ };
36
+ export type ContentStoreCustomActionObjectField = Omit<CustomActionObjectField, 'type'> &
37
+ ContentStoreCustomActionCommonProps & {
38
+ type: 'objectField';
39
+ documentSpec: APICustomActionDocumentSpecifier;
40
+ fieldPath: (string | number)[];
41
+ };
42
+ export type ContentStoreCustomActionField = CustomActionField &
43
+ ContentStoreCustomActionCommonProps & {
44
+ type: 'field';
45
+ documentSpec: APICustomActionDocumentSpecifier;
46
+ fieldPath: (string | number)[];
47
+ };
48
+ export type ContentStoreCustomActionCommonProps = {
49
+ type: string;
50
+ actionId: string;
51
+ // override optional label to required one
52
+ label: string;
53
+ // specifies if the action is current running in this container instance
54
+ runningHandler?: boolean;
55
+ // the action state returned by the recent 'run' invocation
56
+ lastResultState?: CustomActionState;
57
+ };
58
+
59
+ export type CustomActionType = 'global' | 'bulk' | 'document' | 'object' | 'field';
60
+
61
+ export type APICustomAction = APICustomActionGlobal | APICustomActionBulk | APICustomActionDocument | APICustomActionObject | APICustomActionField;
62
+
63
+ export interface APICustomActionGlobal extends APICustomActionCommonProps {
64
+ type: 'global';
65
+ }
66
+
67
+ export interface APICustomActionBulk extends APICustomActionCommonProps {
68
+ type: 'bulk';
69
+ }
70
+
71
+ export interface APICustomActionDocument extends APICustomActionCommonProps {
72
+ type: 'document';
73
+ }
74
+
75
+ export interface APICustomActionObject extends APICustomActionCommonProps {
76
+ type: 'object';
77
+ }
78
+
79
+ export interface APICustomActionField extends APICustomActionCommonProps {
80
+ type: 'field';
81
+ }
82
+
83
+ export interface APICustomActionCommonProps {
84
+ type: CustomActionType;
85
+ actionId: string;
86
+ name: string;
87
+ label: string;
88
+ icon?: string;
89
+ state: CustomActionState | 'unknown';
90
+ inputFields?: CustomActionInputField[];
91
+ needsResolving?: boolean;
92
+ }
93
+
94
+ export type APIRunCustomActionRequest =
95
+ | APIRunCustomActionRequestGlobal
96
+ | APIRunCustomActionRequestBulk
97
+ | APIRunCustomActionRequestDocument
98
+ | APIRunCustomActionRequestObject
99
+ | APIRunCustomActionRequestField;
100
+
101
+ export interface APIRunCustomActionRequestGlobal extends APIRunCustomActionRequestCommonParams {
102
+ actionType: 'global';
103
+ }
104
+
105
+ export interface APIRunCustomActionRequestBulk extends APIRunCustomActionRequestCommonParams {
106
+ actionType: 'bulk';
107
+ documents: APICustomActionDocumentSpecifier[];
108
+ }
109
+
110
+ export interface APIRunCustomActionRequestDocument extends APIRunCustomActionRequestCommonParams {
111
+ actionType: 'document';
112
+ }
113
+
114
+ export interface APIRunCustomActionRequestObject extends APIRunCustomActionRequestCommonParams {
115
+ actionType: 'object';
116
+ }
117
+
118
+ export interface APIRunCustomActionRequestField extends APIRunCustomActionRequestCommonParams {
119
+ actionType: 'field';
120
+ }
121
+
122
+ interface APIRunCustomActionRequestCommonParams {
123
+ actionType: string;
124
+ actionId: string;
125
+ actionName: string;
126
+ locale?: string;
127
+ user?: User;
128
+ pageUrl?: string;
129
+ currentPageDocument?: APICustomActionDocumentSpecifier; // the document id of the current page
130
+ inputData?: Record<string, any>;
131
+ }
132
+
133
+ export interface APIGetCustomActionRequest {
134
+ customActionIds: string[];
135
+ locale?: string;
136
+ user?: User;
137
+ pageUrl?: string;
138
+ currentPageDocument?: APICustomActionDocumentSpecifier; // the document id of the current page
139
+ }
140
+
141
+ export interface APICustomActionDocumentSpecifier {
142
+ srcType: string;
143
+ srcProjectId: string;
144
+ srcDocumentId: string;
145
+ }
146
+
147
+ export interface CustomActionStateChange {
148
+ actionType: CustomActionType;
149
+ actionId: string;
150
+ actionName: string;
151
+ state: CustomActionState;
152
+ success?: string;
153
+ error?: string;
154
+ }
@@ -3,3 +3,4 @@ export * from './content-store-documents';
3
3
  export * from './content-store-document-fields';
4
4
  export * from './content-store-update-operation';
5
5
  export * from './search-filter';
6
+ export * from './custom-actions';