@stackbit/cms-core 1.0.2-develop.1 → 1.0.2-develop.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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/content-store.d.ts +6 -1
- package/dist/content-store.d.ts.map +1 -1
- package/dist/content-store.js +37 -6
- package/dist/content-store.js.map +1 -1
- package/dist/types/content-store-api-document-fields.d.ts +3 -33
- package/dist/types/content-store-api-document-fields.d.ts.map +1 -1
- package/dist/types/content-store-document-fields.d.ts +1 -106
- package/dist/types/content-store-document-fields.d.ts.map +1 -1
- package/dist/types/content-store-documents.d.ts +4 -2
- package/dist/types/content-store-documents.d.ts.map +1 -1
- package/dist/types/custom-actions.d.ts +2 -3
- package/dist/types/custom-actions.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/utils/csi-to-api-docs-converter.d.ts +3 -9
- package/dist/utils/csi-to-api-docs-converter.d.ts.map +1 -1
- package/dist/utils/csi-to-api-docs-converter.js +23 -27
- package/dist/utils/csi-to-api-docs-converter.js.map +1 -1
- package/dist/utils/csi-to-store-docs-converter.d.ts.map +1 -1
- package/dist/utils/csi-to-store-docs-converter.js +0 -38
- package/dist/utils/csi-to-store-docs-converter.js.map +1 -1
- package/dist/utils/custom-actions.d.ts +2 -41
- package/dist/utils/custom-actions.d.ts.map +1 -1
- package/dist/utils/custom-actions.js +3 -198
- package/dist/utils/custom-actions.js.map +1 -1
- package/dist/utils/custom-search-filters.d.ts +12 -0
- package/dist/utils/custom-search-filters.d.ts.map +1 -0
- package/dist/utils/custom-search-filters.js +46 -0
- package/dist/utils/custom-search-filters.js.map +1 -0
- package/dist/utils/field-path-utils.d.ts +1 -1
- package/dist/utils/field-path-utils.d.ts.map +1 -1
- package/dist/utils/field-path-utils.js +4 -0
- package/dist/utils/field-path-utils.js.map +1 -1
- package/dist/utils/model-utils.d.ts.map +1 -1
- package/dist/utils/model-utils.js +21 -0
- package/dist/utils/model-utils.js.map +1 -1
- package/dist/utils/store-to-api-docs-converter.d.ts.map +1 -1
- package/dist/utils/store-to-api-docs-converter.js +26 -74
- package/dist/utils/store-to-api-docs-converter.js.map +1 -1
- package/dist/utils/store-to-api-v2-docs-converter.d.ts +2 -3
- package/dist/utils/store-to-api-v2-docs-converter.d.ts.map +1 -1
- package/dist/utils/store-to-api-v2-docs-converter.js +91 -148
- package/dist/utils/store-to-api-v2-docs-converter.js.map +1 -1
- package/package.json +5 -5
- package/src/content-store.ts +53 -8
- package/src/types/content-store-api-document-fields.ts +471 -0
- package/src/types/content-store-document-fields.ts +1 -50
- package/src/types/content-store-documents.ts +4 -2
- package/src/types/custom-actions.ts +2 -3
- package/src/types/index.ts +1 -0
- package/src/utils/csi-to-api-docs-converter.ts +27 -42
- package/src/utils/csi-to-store-docs-converter.ts +1 -42
- package/src/utils/custom-actions.ts +4 -277
- package/src/utils/field-path-utils.ts +6 -2
- package/src/utils/model-utils.ts +20 -2
- package/src/utils/store-to-api-docs-converter.ts +26 -79
- package/src/utils/store-to-api-v2-docs-converter.ts +441 -0
- package/dist/utils/file-cache.d.ts +0 -13
- package/dist/utils/file-cache.d.ts.map +0 -1
- package/dist/utils/file-cache.js +0 -69
- package/dist/utils/file-cache.js.map +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as CSITypes from '@stackbit/types';
|
|
2
|
-
import { APICustomActionField, APICustomActionObject } from './custom-actions';
|
|
3
2
|
|
|
4
3
|
export type DocumentField =
|
|
5
4
|
| DocumentStringLikeField
|
|
@@ -98,7 +97,7 @@ export type DocumentFieldSpecificPropsForDocumentField<DocField extends Document
|
|
|
98
97
|
* the `multiElement` and `isUnset` fields.
|
|
99
98
|
* The 'file' also has `isUnset` field and should have its own type anyway.
|
|
100
99
|
*/
|
|
101
|
-
type DocumentStringLikeFieldTypes = Exclude<CSITypes.DocumentStringLikeFieldTypes, 'markdown' | 'file'>;
|
|
100
|
+
export type DocumentStringLikeFieldTypes = Exclude<CSITypes.DocumentStringLikeFieldTypes, 'markdown' | 'file'>;
|
|
102
101
|
|
|
103
102
|
export type DocumentStringLikeField = DocumentStringLikeFieldForType<DocumentStringLikeFieldTypes>;
|
|
104
103
|
export type DocumentStringLikeFieldNonLocalized = DistributeDocumentStringLikeFieldNonLocalized<DocumentStringLikeFieldTypes>;
|
|
@@ -118,7 +117,6 @@ export interface DocumentStringLikeFieldNonLocalizedForType<Type extends Documen
|
|
|
118
117
|
type: Type;
|
|
119
118
|
label?: string;
|
|
120
119
|
localized?: false;
|
|
121
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
122
120
|
value?: string;
|
|
123
121
|
}
|
|
124
122
|
|
|
@@ -126,7 +124,6 @@ export interface DocumentStringLikeFieldLocalizedForType<Type extends DocumentSt
|
|
|
126
124
|
type: Type;
|
|
127
125
|
label?: string;
|
|
128
126
|
localized: true;
|
|
129
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
130
127
|
locales: Record<
|
|
131
128
|
string,
|
|
132
129
|
{
|
|
@@ -140,7 +137,6 @@ export type DocumentStringLikeFieldAPIForType<Type extends DocumentStringLikeFie
|
|
|
140
137
|
type: Type;
|
|
141
138
|
label?: string;
|
|
142
139
|
description?: string;
|
|
143
|
-
actions?: APICustomActionField[];
|
|
144
140
|
value?: string | null;
|
|
145
141
|
} & ({ localized?: false } | { localized: true; locale: string });
|
|
146
142
|
|
|
@@ -153,7 +149,6 @@ export type DocumentMarkdownFieldNonLocalized = {
|
|
|
153
149
|
type: 'markdown';
|
|
154
150
|
label?: string;
|
|
155
151
|
localized?: false;
|
|
156
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
157
152
|
multiElement?: boolean;
|
|
158
153
|
value?: string;
|
|
159
154
|
} & ({ isUnset: true; value?: never } | { isUnset?: false; value: string });
|
|
@@ -162,7 +157,6 @@ export interface DocumentMarkdownFieldLocalized {
|
|
|
162
157
|
type: 'markdown';
|
|
163
158
|
label?: string;
|
|
164
159
|
localized: true;
|
|
165
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
166
160
|
locales: Record<
|
|
167
161
|
string,
|
|
168
162
|
{
|
|
@@ -178,7 +172,6 @@ export type DocumentMarkdownFieldAPI = {
|
|
|
178
172
|
multiElement?: boolean;
|
|
179
173
|
label?: string;
|
|
180
174
|
description?: string;
|
|
181
|
-
actions?: APICustomActionField[];
|
|
182
175
|
value?: string | null;
|
|
183
176
|
} & ({ isUnset: true; value?: null } | { isUnset?: false; value: string }) &
|
|
184
177
|
({ localized?: false } | { localized: true; locale: string });
|
|
@@ -192,7 +185,6 @@ export interface DocumentNumberFieldNonLocalized {
|
|
|
192
185
|
type: 'number';
|
|
193
186
|
label?: string;
|
|
194
187
|
localized?: false;
|
|
195
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
196
188
|
value?: number;
|
|
197
189
|
}
|
|
198
190
|
|
|
@@ -200,7 +192,6 @@ export interface DocumentNumberFieldLocalized {
|
|
|
200
192
|
type: 'number';
|
|
201
193
|
label?: string;
|
|
202
194
|
localized: true;
|
|
203
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
204
195
|
locales: Record<
|
|
205
196
|
string,
|
|
206
197
|
{
|
|
@@ -215,7 +206,6 @@ export type DocumentNumberFieldAPI = {
|
|
|
215
206
|
value?: number | null;
|
|
216
207
|
label?: string;
|
|
217
208
|
description?: string;
|
|
218
|
-
actions?: APICustomActionField[];
|
|
219
209
|
} & ({ localized?: false } | { localized: true; locale: string });
|
|
220
210
|
|
|
221
211
|
/**
|
|
@@ -227,7 +217,6 @@ export interface DocumentBooleanFieldNonLocalized {
|
|
|
227
217
|
type: 'boolean';
|
|
228
218
|
label?: string;
|
|
229
219
|
localized?: false;
|
|
230
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
231
220
|
value?: boolean;
|
|
232
221
|
}
|
|
233
222
|
|
|
@@ -235,7 +224,6 @@ export interface DocumentBooleanFieldLocalized {
|
|
|
235
224
|
type: 'boolean';
|
|
236
225
|
label?: string;
|
|
237
226
|
localized: true;
|
|
238
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
239
227
|
locales: Record<
|
|
240
228
|
string,
|
|
241
229
|
{
|
|
@@ -250,7 +238,6 @@ export type DocumentBooleanFieldAPI = {
|
|
|
250
238
|
value?: boolean | null;
|
|
251
239
|
label?: string;
|
|
252
240
|
description?: string;
|
|
253
|
-
actions?: APICustomActionField[];
|
|
254
241
|
} & ({ localized?: false } | { localized: true; locale: string });
|
|
255
242
|
|
|
256
243
|
/**
|
|
@@ -262,7 +249,6 @@ export type DocumentJsonFieldNonLocalized = {
|
|
|
262
249
|
type: 'json';
|
|
263
250
|
label?: string;
|
|
264
251
|
localized?: false;
|
|
265
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
266
252
|
value?: any;
|
|
267
253
|
} & ({ isUnset: true; value?: never } | { isUnset?: false; value: any });
|
|
268
254
|
|
|
@@ -270,7 +256,6 @@ export interface DocumentJsonFieldLocalized {
|
|
|
270
256
|
type: 'json';
|
|
271
257
|
label?: string;
|
|
272
258
|
localized: true;
|
|
273
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
274
259
|
locales: Record<
|
|
275
260
|
string,
|
|
276
261
|
{
|
|
@@ -284,7 +269,6 @@ export type DocumentJsonFieldAPI = {
|
|
|
284
269
|
type: 'json';
|
|
285
270
|
label?: string;
|
|
286
271
|
description?: string;
|
|
287
|
-
actions?: APICustomActionField[];
|
|
288
272
|
value?: any;
|
|
289
273
|
} & ({ isUnset: true; value?: null } | { isUnset?: false; value: any }) &
|
|
290
274
|
({ localized?: false } | { localized: true; locale: string });
|
|
@@ -299,7 +283,6 @@ export interface DocumentStyleFieldNonLocalized {
|
|
|
299
283
|
type: 'style';
|
|
300
284
|
label?: string;
|
|
301
285
|
localized?: false;
|
|
302
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
303
286
|
value?: DocumentStyleFieldValue;
|
|
304
287
|
}
|
|
305
288
|
|
|
@@ -307,7 +290,6 @@ export interface DocumentStyleFieldLocalized {
|
|
|
307
290
|
type: 'style';
|
|
308
291
|
label?: string;
|
|
309
292
|
localized: true;
|
|
310
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
311
293
|
locales: Record<
|
|
312
294
|
string,
|
|
313
295
|
{
|
|
@@ -322,7 +304,6 @@ export type DocumentStyleFieldAPI = {
|
|
|
322
304
|
value?: DocumentStyleFieldValue | null;
|
|
323
305
|
label?: string;
|
|
324
306
|
description?: string;
|
|
325
|
-
actions?: APICustomActionField[];
|
|
326
307
|
} & ({ localized?: false } | { localized: true; locale: string });
|
|
327
308
|
|
|
328
309
|
/**
|
|
@@ -336,7 +317,6 @@ export type DocumentRichTextFieldNonLocalized = {
|
|
|
336
317
|
type: 'richText';
|
|
337
318
|
label?: string;
|
|
338
319
|
localized?: false;
|
|
339
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
340
320
|
hint?: string;
|
|
341
321
|
multiElement?: boolean;
|
|
342
322
|
value?: DocumentRichTextFieldValue;
|
|
@@ -346,7 +326,6 @@ export interface DocumentRichTextFieldLocalized {
|
|
|
346
326
|
type: 'richText';
|
|
347
327
|
label?: string;
|
|
348
328
|
localized: true;
|
|
349
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
350
329
|
locales: Record<
|
|
351
330
|
string,
|
|
352
331
|
{
|
|
@@ -364,7 +343,6 @@ export type DocumentRichTextFieldAPI = {
|
|
|
364
343
|
multiElement?: boolean;
|
|
365
344
|
label?: string;
|
|
366
345
|
description?: string;
|
|
367
|
-
actions?: APICustomActionField[];
|
|
368
346
|
value?: DocumentRichTextFieldValue | null;
|
|
369
347
|
} & ({ isUnset: true; value?: null } | { isUnset?: false; value: DocumentRichTextFieldValue }) &
|
|
370
348
|
({ localized?: false } | { localized: true; locale: string });
|
|
@@ -378,7 +356,6 @@ export type DocumentImageFieldNonLocalized = {
|
|
|
378
356
|
type: 'image';
|
|
379
357
|
label?: string;
|
|
380
358
|
localized?: false;
|
|
381
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
382
359
|
source?: string;
|
|
383
360
|
} & (
|
|
384
361
|
| { isUnset: true }
|
|
@@ -394,7 +371,6 @@ export interface DocumentImageFieldLocalized {
|
|
|
394
371
|
label?: string;
|
|
395
372
|
source?: string;
|
|
396
373
|
localized: true;
|
|
397
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
398
374
|
locales: Record<
|
|
399
375
|
string,
|
|
400
376
|
{
|
|
@@ -415,7 +391,6 @@ export type DocumentImageFieldAPI = {
|
|
|
415
391
|
source?: string;
|
|
416
392
|
label?: string;
|
|
417
393
|
description?: string;
|
|
418
|
-
actions?: APICustomActionField[];
|
|
419
394
|
} & ({ isUnset: true } | { isUnset?: false; sourceData?: any; fields: ImageFieldsAPI }) &
|
|
420
395
|
({ localized?: false } | { localized: true; locale: string });
|
|
421
396
|
|
|
@@ -433,7 +408,6 @@ export type DocumentFileFieldNonLocalized = {
|
|
|
433
408
|
type: 'file';
|
|
434
409
|
label?: string;
|
|
435
410
|
localized?: false;
|
|
436
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
437
411
|
value?: any;
|
|
438
412
|
} & ({ isUnset: true; value?: never } | { isUnset?: false; value: any });
|
|
439
413
|
|
|
@@ -441,7 +415,6 @@ export interface DocumentFileFieldLocalized {
|
|
|
441
415
|
type: 'file';
|
|
442
416
|
label?: string;
|
|
443
417
|
localized: true;
|
|
444
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
445
418
|
locales: Record<
|
|
446
419
|
string,
|
|
447
420
|
{
|
|
@@ -455,7 +428,6 @@ export type DocumentFileFieldAPI = {
|
|
|
455
428
|
type: 'file';
|
|
456
429
|
label?: string;
|
|
457
430
|
description?: string;
|
|
458
|
-
actions?: APICustomActionField[];
|
|
459
431
|
value?: any;
|
|
460
432
|
} & ({ isUnset: true; value?: null } | { isUnset?: false; value: any }) &
|
|
461
433
|
({ localized?: false } | { localized: true; locale: string });
|
|
@@ -469,13 +441,11 @@ export type DocumentObjectFieldNonLocalized = {
|
|
|
469
441
|
type: 'object';
|
|
470
442
|
label?: string;
|
|
471
443
|
localized?: false;
|
|
472
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
473
444
|
} & (
|
|
474
445
|
| { isUnset: true }
|
|
475
446
|
| {
|
|
476
447
|
isUnset?: false;
|
|
477
448
|
getPreview: (options: { delegate?: CSITypes.ConfigDelegate; locale?: string }) => DocumentObjectFieldPreview;
|
|
478
|
-
getObjectActions?: () => APICustomActionObject[] | undefined; // object actions can be defined only on existing object;
|
|
479
449
|
fields: Record<string, DocumentField>;
|
|
480
450
|
}
|
|
481
451
|
);
|
|
@@ -484,13 +454,11 @@ export interface DocumentObjectFieldLocalized {
|
|
|
484
454
|
type: 'object';
|
|
485
455
|
label?: string;
|
|
486
456
|
localized: true;
|
|
487
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
488
457
|
locales: Record<
|
|
489
458
|
string,
|
|
490
459
|
{
|
|
491
460
|
locale: string;
|
|
492
461
|
getPreview: (options: { delegate?: CSITypes.ConfigDelegate; locale?: string }) => DocumentObjectFieldPreview;
|
|
493
|
-
getObjectActions?: () => APICustomActionObject[] | undefined; // object actions can be defined only on existing object
|
|
494
462
|
fields: Record<string, DocumentField>;
|
|
495
463
|
}
|
|
496
464
|
>;
|
|
@@ -509,12 +477,10 @@ export type DocumentObjectFieldAPI = {
|
|
|
509
477
|
} & (
|
|
510
478
|
| {
|
|
511
479
|
isUnset: true;
|
|
512
|
-
actions?: APICustomActionField[];
|
|
513
480
|
}
|
|
514
481
|
| {
|
|
515
482
|
isUnset?: false;
|
|
516
483
|
srcObjectLabel: string;
|
|
517
|
-
actions?: (APICustomActionField | APICustomActionObject)[]; // object actions can be defined only on existing object
|
|
518
484
|
fields: Record<string, DocumentFieldAPI>;
|
|
519
485
|
}
|
|
520
486
|
) &
|
|
@@ -529,7 +495,6 @@ export type DocumentModelFieldNonLocalized = {
|
|
|
529
495
|
type: 'model';
|
|
530
496
|
label?: string;
|
|
531
497
|
localized?: false;
|
|
532
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
533
498
|
} & (
|
|
534
499
|
| { isUnset: true }
|
|
535
500
|
| {
|
|
@@ -537,7 +502,6 @@ export type DocumentModelFieldNonLocalized = {
|
|
|
537
502
|
srcModelName: string;
|
|
538
503
|
srcModelLabel: string;
|
|
539
504
|
getPreview: (options: { delegate?: CSITypes.ConfigDelegate; locale?: string }) => DocumentModelFieldPreview;
|
|
540
|
-
getObjectActions?: () => APICustomActionObject[] | undefined; // object actions can be defined only on existing object
|
|
541
505
|
fields: Record<string, DocumentField>;
|
|
542
506
|
}
|
|
543
507
|
);
|
|
@@ -546,7 +510,6 @@ export interface DocumentModelFieldLocalized {
|
|
|
546
510
|
type: 'model';
|
|
547
511
|
label?: string;
|
|
548
512
|
localized: true;
|
|
549
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
550
513
|
locales: Record<
|
|
551
514
|
string,
|
|
552
515
|
{
|
|
@@ -554,7 +517,6 @@ export interface DocumentModelFieldLocalized {
|
|
|
554
517
|
srcModelName: string;
|
|
555
518
|
srcModelLabel: string;
|
|
556
519
|
getPreview: (options: { delegate?: CSITypes.ConfigDelegate; locale?: string }) => DocumentModelFieldPreview;
|
|
557
|
-
getObjectActions?: () => APICustomActionObject[] | undefined; // object actions can be defined only on existing object
|
|
558
520
|
fields: Record<string, DocumentField>;
|
|
559
521
|
}
|
|
560
522
|
>;
|
|
@@ -567,14 +529,12 @@ export type DocumentModelFieldAPI = {
|
|
|
567
529
|
} & (
|
|
568
530
|
| {
|
|
569
531
|
isUnset: true;
|
|
570
|
-
actions?: APICustomActionField[];
|
|
571
532
|
}
|
|
572
533
|
| {
|
|
573
534
|
isUnset?: false;
|
|
574
535
|
srcObjectLabel: string;
|
|
575
536
|
srcModelName: string;
|
|
576
537
|
srcModelLabel: string;
|
|
577
|
-
actions?: (APICustomActionField | APICustomActionObject)[]; // object actions can be defined only on existing object
|
|
578
538
|
fields: Record<string, DocumentFieldAPI>;
|
|
579
539
|
}
|
|
580
540
|
) &
|
|
@@ -596,7 +556,6 @@ export type DocumentReferenceFieldNonLocalized = {
|
|
|
596
556
|
refType: 'document' | 'asset';
|
|
597
557
|
label?: string;
|
|
598
558
|
localized?: false;
|
|
599
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
600
559
|
} & (
|
|
601
560
|
| { isUnset: true }
|
|
602
561
|
| {
|
|
@@ -610,7 +569,6 @@ export interface DocumentReferenceFieldLocalized {
|
|
|
610
569
|
refType: 'document' | 'asset';
|
|
611
570
|
label?: string;
|
|
612
571
|
localized: true;
|
|
613
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
614
572
|
locales: Record<
|
|
615
573
|
string,
|
|
616
574
|
{
|
|
@@ -625,7 +583,6 @@ export type DocumentReferenceFieldAPI = {
|
|
|
625
583
|
refType: 'object' | 'image';
|
|
626
584
|
label?: string;
|
|
627
585
|
description?: string;
|
|
628
|
-
actions?: APICustomActionField[];
|
|
629
586
|
} & (
|
|
630
587
|
| { isUnset: true }
|
|
631
588
|
| {
|
|
@@ -645,7 +602,6 @@ export type DocumentCrossReferenceFieldNonLocalized = {
|
|
|
645
602
|
refType: 'document' | 'asset';
|
|
646
603
|
label?: string;
|
|
647
604
|
localized?: false;
|
|
648
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
649
605
|
} & (
|
|
650
606
|
| { isUnset: true }
|
|
651
607
|
| {
|
|
@@ -661,7 +617,6 @@ export interface DocumentCrossReferenceFieldLocalized {
|
|
|
661
617
|
refType: 'document' | 'asset';
|
|
662
618
|
label?: string;
|
|
663
619
|
localized: true;
|
|
664
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
665
620
|
locales: Record<
|
|
666
621
|
string,
|
|
667
622
|
{
|
|
@@ -678,7 +633,6 @@ export type DocumentCrossReferenceFieldAPI = {
|
|
|
678
633
|
refType: 'document' | 'asset';
|
|
679
634
|
label?: string;
|
|
680
635
|
description?: string;
|
|
681
|
-
actions?: APICustomActionField[];
|
|
682
636
|
} & (
|
|
683
637
|
| { isUnset: true }
|
|
684
638
|
| {
|
|
@@ -700,7 +654,6 @@ export interface DocumentListFieldNonLocalized {
|
|
|
700
654
|
type: 'list';
|
|
701
655
|
label?: string;
|
|
702
656
|
localized?: false;
|
|
703
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
704
657
|
items: DocumentListFieldItems[];
|
|
705
658
|
}
|
|
706
659
|
|
|
@@ -708,7 +661,6 @@ export interface DocumentListFieldLocalized {
|
|
|
708
661
|
type: 'list';
|
|
709
662
|
label?: string;
|
|
710
663
|
localized: true;
|
|
711
|
-
getFieldActions?: (options?: { locale?: string }) => APICustomActionField[] | undefined;
|
|
712
664
|
locales: Record<
|
|
713
665
|
string,
|
|
714
666
|
{
|
|
@@ -723,6 +675,5 @@ export type DocumentListFieldAPI = {
|
|
|
723
675
|
type: 'list';
|
|
724
676
|
label?: string;
|
|
725
677
|
description?: string;
|
|
726
|
-
actions?: APICustomActionField[];
|
|
727
678
|
items: DocumentListFieldItemsAPI[];
|
|
728
679
|
} & ({ localized?: false } | { localized: true; locale: string });
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DocumentStatus, ConfigDelegate, DocumentVersion, DocumentVersionWithDocument } from '@stackbit/types';
|
|
2
2
|
import { DocumentField, DocumentFieldAPI, DocumentFieldAPIForType, DocumentStringLikeFieldForType } from './content-store-document-fields';
|
|
3
|
+
import { APIDocument } from './content-store-api-document-fields';
|
|
3
4
|
import { APICustomActionDocument } from './custom-actions';
|
|
4
5
|
|
|
5
6
|
export interface Document {
|
|
@@ -13,7 +14,6 @@ export interface Document {
|
|
|
13
14
|
/** @deprecated used by older, non-csi cms interface */
|
|
14
15
|
srcObjectLabel?: string;
|
|
15
16
|
getPreview: (options: { delegate?: ConfigDelegate; locale?: string }) => DocumentPreview;
|
|
16
|
-
getDocumentActions?: () => APICustomActionDocument[] | undefined;
|
|
17
17
|
srcModelName: string;
|
|
18
18
|
srcModelLabel: string;
|
|
19
19
|
isChanged: boolean;
|
|
@@ -95,7 +95,7 @@ export interface AssetFileFieldProps {
|
|
|
95
95
|
*/
|
|
96
96
|
export type APIObject = APIDocumentObject | APIImageObject;
|
|
97
97
|
|
|
98
|
-
export interface APIDocumentObject extends Omit<Document, 'getPreview' | '
|
|
98
|
+
export interface APIDocumentObject extends Omit<Document, 'getPreview' | 'fields' | 'type'> {
|
|
99
99
|
type: 'object';
|
|
100
100
|
srcObjectLabel: string;
|
|
101
101
|
actions?: APICustomActionDocument[];
|
|
@@ -126,8 +126,10 @@ export interface APIAsset {
|
|
|
126
126
|
|
|
127
127
|
export type APIDocumentVersion = DocumentVersion & {
|
|
128
128
|
object?: APIObject;
|
|
129
|
+
apiDocument?: APIDocument;
|
|
129
130
|
};
|
|
130
131
|
|
|
131
132
|
export type APIDocumentVersionWithDocument = DocumentVersionWithDocument & {
|
|
132
133
|
object: APIObject;
|
|
134
|
+
apiDocument: APIDocument;
|
|
133
135
|
};
|
|
@@ -88,13 +88,12 @@ export interface APICustomActionField extends APICustomActionCommonProps {
|
|
|
88
88
|
|
|
89
89
|
export interface APICustomActionCommonProps {
|
|
90
90
|
type: CustomActionType;
|
|
91
|
-
actionId: string;
|
|
92
91
|
name: string;
|
|
93
92
|
label: string;
|
|
94
93
|
icon?: string;
|
|
95
|
-
state: CustomActionState | 'unknown';
|
|
96
94
|
inputFields?: CustomActionInputField[];
|
|
97
|
-
|
|
95
|
+
actionId: string;
|
|
96
|
+
state: CustomActionState;
|
|
98
97
|
}
|
|
99
98
|
|
|
100
99
|
export type APIRunCustomActionRequest =
|
package/src/types/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './content-store-types';
|
|
2
2
|
export * from './content-store-documents';
|
|
3
3
|
export * from './content-store-document-fields';
|
|
4
|
+
export * from './content-store-api-document-fields';
|
|
4
5
|
export * from './content-store-update-operation';
|
|
5
6
|
export * from './search-filter';
|
|
6
7
|
export * from './custom-actions';
|
|
@@ -2,6 +2,8 @@ import type * as StackbitTypes from '@stackbit/types';
|
|
|
2
2
|
import type * as ContentStoreTypes from '../types';
|
|
3
3
|
import { mapCSIDocumentsToStoreDocuments } from './csi-to-store-docs-converter';
|
|
4
4
|
import { mapDocumentsToLocalizedApiObjects } from './store-to-api-docs-converter';
|
|
5
|
+
import { mapDocumentsToApiDocuments } from './store-to-api-v2-docs-converter';
|
|
6
|
+
import { ContentSourceData } from '../types';
|
|
5
7
|
|
|
6
8
|
type MapDocumentToApiProps = {
|
|
7
9
|
contentSourceData: ContentStoreTypes.ContentSourceData;
|
|
@@ -9,67 +11,50 @@ type MapDocumentToApiProps = {
|
|
|
9
11
|
assetSources: StackbitTypes.AssetSource[];
|
|
10
12
|
customActionRunStateMap: ContentStoreTypes.CustomActionRunStateMap;
|
|
11
13
|
createConfigDelegate: () => StackbitTypes.ConfigDelegate;
|
|
14
|
+
contentSourceDataById: Record<string, ContentSourceData>;
|
|
12
15
|
};
|
|
13
16
|
|
|
14
|
-
export function mapDocumentsToApiObjects({
|
|
15
|
-
documents,
|
|
16
|
-
contentSourceData,
|
|
17
|
-
locale,
|
|
18
|
-
assetSources,
|
|
19
|
-
customActionRunStateMap,
|
|
20
|
-
createConfigDelegate
|
|
21
|
-
}: {
|
|
22
|
-
documents: StackbitTypes.Document[];
|
|
23
|
-
contentSourceData: ContentStoreTypes.ContentSourceData;
|
|
24
|
-
locale?: string;
|
|
25
|
-
assetSources: StackbitTypes.AssetSource[];
|
|
26
|
-
customActionRunStateMap: ContentStoreTypes.CustomActionRunStateMap;
|
|
27
|
-
createConfigDelegate: () => StackbitTypes.ConfigDelegate;
|
|
28
|
-
}): ContentStoreTypes.APIDocumentObject[] {
|
|
29
|
-
const contentStoreDocuments = mapCSIDocumentsToStoreDocuments({
|
|
30
|
-
csiDocuments: documents,
|
|
31
|
-
contentSourceInstance: contentSourceData.instance,
|
|
32
|
-
modelMap: contentSourceData.modelMap,
|
|
33
|
-
defaultLocaleCode: contentSourceData.defaultLocaleCode,
|
|
34
|
-
createConfigDelegate,
|
|
35
|
-
customActionRunStateMap,
|
|
36
|
-
assetSources
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const apiObjects = mapDocumentsToLocalizedApiObjects({
|
|
40
|
-
documents: contentStoreDocuments,
|
|
41
|
-
locale,
|
|
42
|
-
delegate: createConfigDelegate()
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
return apiObjects;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
17
|
export function mapDocumentVersionsToApiDocumentVersions({
|
|
49
18
|
versions,
|
|
50
19
|
contentSourceData,
|
|
51
20
|
locale,
|
|
52
21
|
assetSources,
|
|
53
22
|
customActionRunStateMap,
|
|
54
|
-
createConfigDelegate
|
|
23
|
+
createConfigDelegate,
|
|
24
|
+
contentSourceDataById
|
|
55
25
|
}: MapDocumentToApiProps & { versions: StackbitTypes.DocumentVersion[] }): ContentStoreTypes.APIDocumentVersion[] {
|
|
56
26
|
return versions.map((version) => {
|
|
57
27
|
if (!version.document) {
|
|
58
28
|
return version;
|
|
59
29
|
}
|
|
60
30
|
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
contentSourceData,
|
|
64
|
-
|
|
65
|
-
|
|
31
|
+
const contentStoreDocuments = mapCSIDocumentsToStoreDocuments({
|
|
32
|
+
csiDocuments: [version.document],
|
|
33
|
+
contentSourceInstance: contentSourceData.instance,
|
|
34
|
+
modelMap: contentSourceData.modelMap,
|
|
35
|
+
defaultLocaleCode: contentSourceData.defaultLocaleCode,
|
|
36
|
+
createConfigDelegate,
|
|
66
37
|
customActionRunStateMap,
|
|
67
|
-
|
|
38
|
+
assetSources
|
|
39
|
+
});
|
|
40
|
+
const delegate = createConfigDelegate();
|
|
41
|
+
|
|
42
|
+
const [object] = mapDocumentsToLocalizedApiObjects({
|
|
43
|
+
documents: contentStoreDocuments,
|
|
44
|
+
locale,
|
|
45
|
+
delegate
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const [apiDocument] = mapDocumentsToApiDocuments({
|
|
49
|
+
documents: contentStoreDocuments,
|
|
50
|
+
contentSourceDataById,
|
|
51
|
+
delegate
|
|
68
52
|
});
|
|
69
53
|
|
|
70
54
|
return {
|
|
71
55
|
...version,
|
|
72
|
-
object
|
|
56
|
+
object,
|
|
57
|
+
apiDocument
|
|
73
58
|
};
|
|
74
59
|
});
|
|
75
60
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import { Model, ObjectModel, ImageModel
|
|
2
|
+
import { Model, ObjectModel, ImageModel } from '@stackbit/sdk';
|
|
3
3
|
import { omitByNil } from '@stackbit/utils';
|
|
4
4
|
import { isLocalizedField, getLocalizedFieldForLocale, isDocumentFieldOneOfFieldTypes } from '@stackbit/types';
|
|
5
5
|
import type * as StackbitTypes from '@stackbit/types';
|
|
@@ -8,7 +8,6 @@ import type * as ContentStoreTypes from '../types';
|
|
|
8
8
|
import { IMAGE_MODEL } from '../common/common-schema';
|
|
9
9
|
import { BackCompatContentSourceInterface } from './backward-compatibility';
|
|
10
10
|
import { getImageFieldsFromSourceData } from './asset-sources-utils';
|
|
11
|
-
import { getDocumentActionsThunk, getFieldActions, getObjectFieldActionsThunk, getObjectModelActionsThunk } from './custom-actions';
|
|
12
11
|
|
|
13
12
|
export function mapCSIAssetsToStoreAssets({
|
|
14
13
|
csiAssets,
|
|
@@ -163,13 +162,6 @@ function mapCSIDocumentToStoreDocument({
|
|
|
163
162
|
updatedAt: csiDocument.updatedAt,
|
|
164
163
|
updatedBy: csiDocument.updatedBy,
|
|
165
164
|
locale: getDocumentLocale({ csiDocument, model }),
|
|
166
|
-
getDocumentActions: getDocumentActionsThunk({
|
|
167
|
-
csiDocument,
|
|
168
|
-
model: model as PageModel | DataModel,
|
|
169
|
-
srcType: meta.srcType,
|
|
170
|
-
srcProjectId: meta.srcProjectId,
|
|
171
|
-
customActionRunStateMap
|
|
172
|
-
}),
|
|
173
165
|
fields: mapCSIFieldsToStoreFields({
|
|
174
166
|
csiDocumentFields: csiDocument.fields,
|
|
175
167
|
modelFields: model.fields ?? [],
|
|
@@ -222,17 +214,6 @@ function mapCSIFieldsToStoreFields({
|
|
|
222
214
|
}
|
|
223
215
|
});
|
|
224
216
|
docField.label = modelField.label;
|
|
225
|
-
if (Array.isArray(modelField.actions)) {
|
|
226
|
-
docField.getFieldActions = ({ locale }: { locale?: string } = {}) =>
|
|
227
|
-
getFieldActions({
|
|
228
|
-
modelField,
|
|
229
|
-
csiParentDocument: context.parentDocument,
|
|
230
|
-
srcType: context.srcType,
|
|
231
|
-
srcProjectId: context.srcProjectId,
|
|
232
|
-
customActionRunStateMap: context.customActionRunStateMap,
|
|
233
|
-
fieldPath: locale ? fieldPath.concat(locale) : fieldPath
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
217
|
result[modelField.name] = docField;
|
|
237
218
|
return result;
|
|
238
219
|
}, {});
|
|
@@ -509,20 +490,10 @@ function mapObjectField(
|
|
|
509
490
|
locale
|
|
510
491
|
}) as ContentStoreTypes.DocumentObjectFieldPreview;
|
|
511
492
|
};
|
|
512
|
-
const _getObjectActions = (fieldPath: (string | number)[]) =>
|
|
513
|
-
getObjectFieldActionsThunk({
|
|
514
|
-
modelField: modelField,
|
|
515
|
-
csiParentDocument: context.parentDocument,
|
|
516
|
-
srcType: context.srcType,
|
|
517
|
-
srcProjectId: context.srcProjectId,
|
|
518
|
-
customActionRunStateMap: context.customActionRunStateMap,
|
|
519
|
-
fieldPath: fieldPath
|
|
520
|
-
});
|
|
521
493
|
if (!isLocalizedField(csiDocumentField)) {
|
|
522
494
|
return {
|
|
523
495
|
type: csiDocumentField.type,
|
|
524
496
|
getPreview: _getObjectPreview,
|
|
525
|
-
getObjectActions: _getObjectActions(context.fieldPath),
|
|
526
497
|
fields: mapCSIFieldsToStoreFields({
|
|
527
498
|
csiDocumentFields: csiDocumentField.fields ?? {},
|
|
528
499
|
modelFields: modelField.fields ?? [],
|
|
@@ -538,7 +509,6 @@ function mapObjectField(
|
|
|
538
509
|
return {
|
|
539
510
|
locale: locale.locale,
|
|
540
511
|
getPreview: _getObjectPreview,
|
|
541
|
-
getObjectActions: _getObjectActions(fieldPath),
|
|
542
512
|
fields: mapCSIFieldsToStoreFields({
|
|
543
513
|
csiDocumentFields: locale.fields ?? {},
|
|
544
514
|
modelFields: modelField.fields ?? [],
|
|
@@ -570,15 +540,6 @@ function mapModelField(
|
|
|
570
540
|
locale
|
|
571
541
|
}) as ContentStoreTypes.DocumentModelFieldPreview;
|
|
572
542
|
};
|
|
573
|
-
const _getObjectActions = (model: ObjectModel, fieldPath: (string | number)[]) =>
|
|
574
|
-
getObjectModelActionsThunk({
|
|
575
|
-
csiParentDocument: context.parentDocument,
|
|
576
|
-
model: model,
|
|
577
|
-
srcType: context.srcType,
|
|
578
|
-
srcProjectId: context.srcProjectId,
|
|
579
|
-
customActionRunStateMap: context.customActionRunStateMap,
|
|
580
|
-
fieldPath: fieldPath
|
|
581
|
-
});
|
|
582
543
|
if (!isLocalizedField(csiDocumentField)) {
|
|
583
544
|
const model = context.modelMap[csiDocumentField.modelName]! as ObjectModel;
|
|
584
545
|
return {
|
|
@@ -586,7 +547,6 @@ function mapModelField(
|
|
|
586
547
|
getPreview: _getObjectPreview(model),
|
|
587
548
|
srcModelName: csiDocumentField.modelName,
|
|
588
549
|
srcModelLabel: model.label ?? _.startCase(model.name),
|
|
589
|
-
getObjectActions: _getObjectActions(model, context.fieldPath),
|
|
590
550
|
fields: mapCSIFieldsToStoreFields({
|
|
591
551
|
csiDocumentFields: csiDocumentField.fields ?? {},
|
|
592
552
|
modelFields: model.fields ?? [],
|
|
@@ -605,7 +565,6 @@ function mapModelField(
|
|
|
605
565
|
getPreview: _getObjectPreview(model),
|
|
606
566
|
srcModelName: locale.modelName,
|
|
607
567
|
srcModelLabel: model.label ?? _.startCase(model.name),
|
|
608
|
-
getObjectActions: _getObjectActions(model, fieldPath),
|
|
609
568
|
fields: mapCSIFieldsToStoreFields({
|
|
610
569
|
csiDocumentFields: locale.fields ?? {},
|
|
611
570
|
modelFields: model.fields ?? [],
|