@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.
Files changed (64) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/content-store.d.ts +6 -1
  3. package/dist/content-store.d.ts.map +1 -1
  4. package/dist/content-store.js +37 -6
  5. package/dist/content-store.js.map +1 -1
  6. package/dist/types/content-store-api-document-fields.d.ts +3 -33
  7. package/dist/types/content-store-api-document-fields.d.ts.map +1 -1
  8. package/dist/types/content-store-document-fields.d.ts +1 -106
  9. package/dist/types/content-store-document-fields.d.ts.map +1 -1
  10. package/dist/types/content-store-documents.d.ts +4 -2
  11. package/dist/types/content-store-documents.d.ts.map +1 -1
  12. package/dist/types/custom-actions.d.ts +2 -3
  13. package/dist/types/custom-actions.d.ts.map +1 -1
  14. package/dist/types/index.d.ts +1 -0
  15. package/dist/types/index.d.ts.map +1 -1
  16. package/dist/types/index.js +1 -0
  17. package/dist/types/index.js.map +1 -1
  18. package/dist/utils/csi-to-api-docs-converter.d.ts +3 -9
  19. package/dist/utils/csi-to-api-docs-converter.d.ts.map +1 -1
  20. package/dist/utils/csi-to-api-docs-converter.js +23 -27
  21. package/dist/utils/csi-to-api-docs-converter.js.map +1 -1
  22. package/dist/utils/csi-to-store-docs-converter.d.ts.map +1 -1
  23. package/dist/utils/csi-to-store-docs-converter.js +0 -38
  24. package/dist/utils/csi-to-store-docs-converter.js.map +1 -1
  25. package/dist/utils/custom-actions.d.ts +2 -41
  26. package/dist/utils/custom-actions.d.ts.map +1 -1
  27. package/dist/utils/custom-actions.js +3 -198
  28. package/dist/utils/custom-actions.js.map +1 -1
  29. package/dist/utils/custom-search-filters.d.ts +12 -0
  30. package/dist/utils/custom-search-filters.d.ts.map +1 -0
  31. package/dist/utils/custom-search-filters.js +46 -0
  32. package/dist/utils/custom-search-filters.js.map +1 -0
  33. package/dist/utils/field-path-utils.d.ts +1 -1
  34. package/dist/utils/field-path-utils.d.ts.map +1 -1
  35. package/dist/utils/field-path-utils.js +4 -0
  36. package/dist/utils/field-path-utils.js.map +1 -1
  37. package/dist/utils/model-utils.d.ts.map +1 -1
  38. package/dist/utils/model-utils.js +21 -0
  39. package/dist/utils/model-utils.js.map +1 -1
  40. package/dist/utils/store-to-api-docs-converter.d.ts.map +1 -1
  41. package/dist/utils/store-to-api-docs-converter.js +26 -74
  42. package/dist/utils/store-to-api-docs-converter.js.map +1 -1
  43. package/dist/utils/store-to-api-v2-docs-converter.d.ts +2 -3
  44. package/dist/utils/store-to-api-v2-docs-converter.d.ts.map +1 -1
  45. package/dist/utils/store-to-api-v2-docs-converter.js +91 -148
  46. package/dist/utils/store-to-api-v2-docs-converter.js.map +1 -1
  47. package/package.json +5 -5
  48. package/src/content-store.ts +53 -8
  49. package/src/types/content-store-api-document-fields.ts +471 -0
  50. package/src/types/content-store-document-fields.ts +1 -50
  51. package/src/types/content-store-documents.ts +4 -2
  52. package/src/types/custom-actions.ts +2 -3
  53. package/src/types/index.ts +1 -0
  54. package/src/utils/csi-to-api-docs-converter.ts +27 -42
  55. package/src/utils/csi-to-store-docs-converter.ts +1 -42
  56. package/src/utils/custom-actions.ts +4 -277
  57. package/src/utils/field-path-utils.ts +6 -2
  58. package/src/utils/model-utils.ts +20 -2
  59. package/src/utils/store-to-api-docs-converter.ts +26 -79
  60. package/src/utils/store-to-api-v2-docs-converter.ts +441 -0
  61. package/dist/utils/file-cache.d.ts +0 -13
  62. package/dist/utils/file-cache.d.ts.map +0 -1
  63. package/dist/utils/file-cache.js +0 -69
  64. package/dist/utils/file-cache.js.map +0 -1
@@ -0,0 +1,471 @@
1
+ import { DocumentRichTextFieldValue, DocumentStringLikeFieldTypes, DocumentStyleFieldValue, ExtractByType } from './content-store-document-fields';
2
+ import { Document } from './content-store-documents';
3
+ import { FieldType } from '@stackbit/types';
4
+
5
+ export interface APIDocument extends Omit<Document, 'getPreview' | 'fields'> {
6
+ srcObjectLabel: string;
7
+ fields: Record<string, DocumentFieldAPIV2>;
8
+ }
9
+
10
+ /**
11
+ * string-like fields (e.g., string, url, slug, text, html, enum, date, datetime, color)
12
+ * The 'markdown' is not included, although it is a string field, because it has
13
+ * the `multiElement` and `isUnset` fields.
14
+ * The 'file' also has `isUnset` field and should have its own type anyway.
15
+ */
16
+ export type DocumentStringLikeFieldAPIV2 = DocumentStringLikeFieldForTypeAPIV2<DocumentStringLikeFieldTypes>;
17
+ export type DocumentStringLikeFieldNonLocalizedAPIV2 = APIV2DistributeDocumentStringLikeFieldNonLocalized<DocumentStringLikeFieldTypes>;
18
+ export type DocumentStringLikeFieldLocalizedAPIV2 = APIV2DistributeDocumentStringFieldLocalized<DocumentStringLikeFieldTypes>;
19
+
20
+ export type DocumentStringLikeFieldForTypeAPIV2<Type> = Type extends DocumentStringLikeFieldTypes
21
+ ? DocumentStringLikeFieldNonLocalizedForTypeAPIV2<Type> | DocumentStringLikeFieldLocalizedForTypeAPIV2<Type>
22
+ : never;
23
+ export type APIV2DistributeDocumentStringLikeFieldNonLocalized<Type> = Type extends DocumentStringLikeFieldTypes
24
+ ? DocumentStringLikeFieldNonLocalizedForTypeAPIV2<Type>
25
+ : never;
26
+ export type APIV2DistributeDocumentStringFieldLocalized<Type> = Type extends DocumentStringLikeFieldTypes
27
+ ? DocumentStringLikeFieldLocalizedForTypeAPIV2<Type>
28
+ : never;
29
+
30
+ export interface DocumentStringLikeFieldNonLocalizedForTypeAPIV2<Type extends DocumentStringLikeFieldTypes> {
31
+ type: Type;
32
+ label?: string;
33
+ localized?: false;
34
+ value?: string;
35
+ }
36
+
37
+ export interface DocumentStringLikeFieldLocalizedForTypeAPIV2<Type extends DocumentStringLikeFieldTypes> {
38
+ type: Type;
39
+ label?: string;
40
+ localized: true;
41
+ locales: Record<
42
+ string,
43
+ {
44
+ locale: string;
45
+ value: string;
46
+ }
47
+ >;
48
+ }
49
+
50
+ /**
51
+ * markdown
52
+ */
53
+ export type DocumentMarkdownFieldAPIV2 = DocumentMarkdownFieldNonLocalizedAPIV2 | DocumentMarkdownFieldLocalizedAPIV2;
54
+
55
+ export type DocumentMarkdownFieldNonLocalizedAPIV2 = {
56
+ type: 'markdown';
57
+ label?: string;
58
+ localized?: false;
59
+ multiElement?: boolean;
60
+ value?: string;
61
+ } & ({ isUnset: true; value?: never } | { isUnset?: false; value: string });
62
+
63
+ export interface DocumentMarkdownFieldLocalizedAPIV2 {
64
+ type: 'markdown';
65
+ label?: string;
66
+ localized: true;
67
+ locales: Record<
68
+ string,
69
+ {
70
+ locale: string;
71
+ multiElement?: boolean;
72
+ value: string;
73
+ }
74
+ >;
75
+ }
76
+
77
+ /**
78
+ * number
79
+ */
80
+ export type DocumentNumberFieldAPIV2 = DocumentNumberFieldNonLocalizedAPIV2 | DocumentNumberFieldLocalizedAPIV2;
81
+ export interface DocumentNumberFieldNonLocalizedAPIV2 {
82
+ type: 'number';
83
+ label?: string;
84
+ localized?: false;
85
+ value?: number;
86
+ }
87
+ export interface DocumentNumberFieldLocalizedAPIV2 {
88
+ type: 'number';
89
+ label?: string;
90
+ localized: true;
91
+ locales: Record<
92
+ string,
93
+ {
94
+ locale: string;
95
+ value: number;
96
+ }
97
+ >;
98
+ }
99
+
100
+ /**
101
+ * boolean
102
+ */
103
+ export type DocumentBooleanFieldAPIV2 = DocumentBooleanFieldNonLocalizedAPIV2 | DocumentBooleanFieldLocalizedAPIV2;
104
+ export interface DocumentBooleanFieldNonLocalizedAPIV2 {
105
+ type: 'boolean';
106
+ label?: string;
107
+ localized?: false;
108
+ value?: boolean;
109
+ }
110
+ export interface DocumentBooleanFieldLocalizedAPIV2 {
111
+ type: 'boolean';
112
+ label?: string;
113
+ localized: true;
114
+ locales: Record<
115
+ string,
116
+ {
117
+ locale: string;
118
+ value: boolean;
119
+ }
120
+ >;
121
+ }
122
+
123
+ /**
124
+ * json
125
+ */
126
+ export type DocumentJsonFieldAPIV2 = DocumentJsonFieldNonLocalizedAPIV2 | DocumentJsonFieldLocalizedAPIV2;
127
+ export type DocumentJsonFieldNonLocalizedAPIV2 = {
128
+ type: 'json';
129
+ label?: string;
130
+ localized?: false;
131
+ value?: any;
132
+ } & ({ isUnset: true; value?: never } | { isUnset?: false; value: any });
133
+ export interface DocumentJsonFieldLocalizedAPIV2 {
134
+ type: 'json';
135
+ label?: string;
136
+ localized: true;
137
+ locales: Record<
138
+ string,
139
+ {
140
+ locale: string;
141
+ value: any;
142
+ }
143
+ >;
144
+ }
145
+
146
+ /**
147
+ * style
148
+ */
149
+ export type DocumentStyleFieldAPIV2 = DocumentStyleFieldNonLocalizedAPIV2 | DocumentStyleFieldLocalizedAPIV2;
150
+ export interface DocumentStyleFieldNonLocalizedAPIV2 {
151
+ type: 'style';
152
+ label?: string;
153
+ localized?: false;
154
+ value?: DocumentStyleFieldValue;
155
+ }
156
+ export interface DocumentStyleFieldLocalizedAPIV2 {
157
+ type: 'style';
158
+ label?: string;
159
+ localized: true;
160
+ locales: Record<
161
+ string,
162
+ {
163
+ locale: string;
164
+ value: DocumentStyleFieldValue;
165
+ }
166
+ >;
167
+ }
168
+
169
+ /**
170
+ * richText
171
+ */
172
+ export type DocumentRichTextFieldAPIV2 = DocumentRichTextFieldNonLocalizedAPIV2 | DocumentRichTextFieldLocalizedAPIV2;
173
+ export type DocumentRichTextFieldNonLocalizedAPIV2 = {
174
+ type: 'richText';
175
+ label?: string;
176
+ localized?: false;
177
+ hint?: string;
178
+ multiElement?: boolean;
179
+ value?: DocumentRichTextFieldValue;
180
+ } & ({ isUnset: true; value?: never } | { isUnset?: false; value: DocumentRichTextFieldValue });
181
+ export interface DocumentRichTextFieldLocalizedAPIV2 {
182
+ type: 'richText';
183
+ label?: string;
184
+ localized: true;
185
+ locales: Record<
186
+ string,
187
+ {
188
+ locale: string;
189
+ hint?: string;
190
+ multiElement?: boolean;
191
+ value: DocumentRichTextFieldValue;
192
+ }
193
+ >;
194
+ }
195
+
196
+ /**
197
+ * file
198
+ */
199
+ export type DocumentFileFieldAPIV2 = DocumentFileFieldNonLocalizedAPIV2 | DocumentFileFieldLocalizedAPIV2;
200
+ export type DocumentFileFieldNonLocalizedAPIV2 = {
201
+ type: 'file';
202
+ label?: string;
203
+ localized?: false;
204
+ value?: any;
205
+ } & ({ isUnset: true; value?: never } | { isUnset?: false; value: any });
206
+ export interface DocumentFileFieldLocalizedAPIV2 {
207
+ type: 'file';
208
+ label?: string;
209
+ localized: true;
210
+ locales: Record<
211
+ string,
212
+ {
213
+ locale: string;
214
+ value: any;
215
+ }
216
+ >;
217
+ }
218
+
219
+ /**
220
+ * object
221
+ */
222
+ export type DocumentObjectFieldAPIV2 = DocumentObjectFieldNonLocalizedAPIV2 | DocumentObjectFieldLocalizedAPIV2;
223
+ export type DocumentObjectFieldNonLocalizedAPIV2 = {
224
+ type: 'object';
225
+ label?: string;
226
+ localized?: false;
227
+ } & (
228
+ | { isUnset: true }
229
+ | {
230
+ isUnset?: false;
231
+ srcObjectLabel: string;
232
+ fields: Record<string, DocumentFieldAPIV2>;
233
+ }
234
+ );
235
+ export interface DocumentObjectFieldLocalizedAPIV2 {
236
+ type: 'object';
237
+ label?: string;
238
+ localized: true;
239
+ locales: Record<
240
+ string,
241
+ {
242
+ locale: string;
243
+ srcObjectLabel: string;
244
+ fields: Record<string, DocumentFieldAPIV2>;
245
+ }
246
+ >;
247
+ }
248
+
249
+ /**
250
+ * model
251
+ */
252
+ export type DocumentModelFieldAPIV2 = DocumentModelFieldNonLocalizedAPIV2 | DocumentModelFieldLocalizedAPIV2;
253
+ export type DocumentModelFieldNonLocalizedAPIV2 = {
254
+ type: 'model';
255
+ label?: string;
256
+ localized?: false;
257
+ } & (
258
+ | { isUnset: true }
259
+ | {
260
+ isUnset?: false;
261
+ srcModelName: string;
262
+ srcModelLabel: string;
263
+ srcObjectLabel: string;
264
+ fields: Record<string, DocumentFieldAPIV2>;
265
+ }
266
+ );
267
+ export interface DocumentModelFieldLocalizedAPIV2 {
268
+ type: 'model';
269
+ label?: string;
270
+ localized: true;
271
+ locales: Record<
272
+ string,
273
+ {
274
+ locale: string;
275
+ srcModelName: string;
276
+ srcModelLabel: string;
277
+ srcObjectLabel: string;
278
+ fields: Record<string, DocumentFieldAPIV2>;
279
+ }
280
+ >;
281
+ }
282
+
283
+ /**
284
+ * list
285
+ */
286
+ export type DocumentListFieldAPIV2 = DocumentListFieldNonLocalizedAPIV2 | DocumentListFieldLocalizedAPIV2;
287
+ export type DocumentListFieldItemsAPIV2 = Exclude<DocumentFieldNonLocalizedAPIV2, DocumentListFieldNonLocalizedAPIV2>;
288
+ export interface DocumentListFieldNonLocalizedAPIV2 {
289
+ type: 'list';
290
+ label?: string;
291
+ localized?: false;
292
+ items: DocumentListFieldItemsAPIV2[];
293
+ }
294
+
295
+ export interface DocumentListFieldLocalizedAPIV2 {
296
+ type: 'list';
297
+ label?: string;
298
+ localized: true;
299
+ locales: Record<
300
+ string,
301
+ {
302
+ locale: string;
303
+ items: DocumentListFieldItemsAPIV2[];
304
+ }
305
+ >;
306
+ }
307
+
308
+ /**
309
+ * reference
310
+ */
311
+ export type DocumentReferenceFieldAPIV2 = DocumentReferenceFieldNonLocalizedAPIV2 | DocumentReferenceFieldLocalizedAPIV2;
312
+ export type DocumentReferenceFieldNonLocalizedAPIV2 = {
313
+ type: 'reference';
314
+ refType: 'document' | 'asset';
315
+ label?: string;
316
+ localized?: false;
317
+ } & (
318
+ | { isUnset: true }
319
+ | {
320
+ isUnset?: false;
321
+ refId: string;
322
+ srcModelLabel?: string;
323
+ srcObjectLabel?: string;
324
+ isMissing?: boolean;
325
+ }
326
+ );
327
+ export interface DocumentReferenceFieldLocalizedAPIV2 {
328
+ type: 'reference';
329
+ refType: 'document' | 'asset';
330
+ label?: string;
331
+ localized: true;
332
+ locales: Record<
333
+ string,
334
+ {
335
+ locale: string;
336
+ refId: string;
337
+ srcModelLabel?: string;
338
+ srcObjectLabel?: string;
339
+ isMissing?: boolean;
340
+ }
341
+ >;
342
+ }
343
+
344
+ /**
345
+ * cross-reference
346
+ */
347
+ export type DocumentCrossReferenceFieldAPIV2 = DocumentCrossReferenceFieldLocalizedAPIV2 | DocumentCrossReferenceFieldNonLocalizedAPIV2;
348
+ export type DocumentCrossReferenceFieldNonLocalizedAPIV2 = {
349
+ type: 'cross-reference';
350
+ refType: 'document' | 'asset';
351
+ label?: string;
352
+ localized?: false;
353
+ } & (
354
+ | { isUnset: true }
355
+ | {
356
+ isUnset?: false;
357
+ refId: string;
358
+ refSrcType: string;
359
+ refProjectId: string;
360
+ refModelLabel?: string;
361
+ refModelName?: string;
362
+ refObjectLabel?: string;
363
+ isMissing?: boolean;
364
+ }
365
+ );
366
+ export interface DocumentCrossReferenceFieldLocalizedAPIV2 {
367
+ type: 'cross-reference';
368
+ refType: 'document' | 'asset';
369
+ label?: string;
370
+ localized: true;
371
+ locales: Record<
372
+ string,
373
+ {
374
+ locale: string;
375
+ refId: string;
376
+ refSrcType: string;
377
+ refProjectId: string;
378
+ refModelLabel?: string;
379
+ refModelName?: string;
380
+ refObjectLabel?: string;
381
+ isMissing?: boolean;
382
+ }
383
+ >;
384
+ }
385
+
386
+ /**
387
+ * image
388
+ */
389
+ export type DocumentImageFieldAPIV2 = DocumentImageFieldNonLocalizedAPIV2 | DocumentImageFieldLocalizedAPIV2;
390
+ export type DocumentImageFieldNonLocalizedAPIV2 = {
391
+ type: 'image';
392
+ label?: string;
393
+ localized?: false;
394
+ source?: string;
395
+ } & (
396
+ | { isUnset: true }
397
+ | {
398
+ isUnset?: false;
399
+ sourceData?: any;
400
+ fields: ImageFieldsAPIV2;
401
+ }
402
+ );
403
+ export interface DocumentImageFieldLocalizedAPIV2 {
404
+ type: 'image';
405
+ label?: string;
406
+ source?: string;
407
+ localized: true;
408
+ locales: Record<
409
+ string,
410
+ {
411
+ locale: string;
412
+ sourceData?: any;
413
+ fields: ImageFieldsAPIV2;
414
+ }
415
+ >;
416
+ }
417
+ export type ImageFieldsAPIV2 = {
418
+ title: DocumentStringLikeFieldNonLocalizedForTypeAPIV2<'string'>;
419
+ url: DocumentStringLikeFieldNonLocalizedForTypeAPIV2<'string'>;
420
+ };
421
+
422
+ export type DocumentFieldAPIV2 =
423
+ | DocumentStringLikeFieldAPIV2
424
+ | DocumentMarkdownFieldAPIV2
425
+ | DocumentNumberFieldAPIV2
426
+ | DocumentBooleanFieldAPIV2
427
+ | DocumentJsonFieldAPIV2
428
+ | DocumentStyleFieldAPIV2
429
+ | DocumentRichTextFieldAPIV2
430
+ | DocumentFileFieldAPIV2
431
+ | DocumentImageFieldAPIV2
432
+ | DocumentObjectFieldAPIV2
433
+ | DocumentModelFieldAPIV2
434
+ | DocumentReferenceFieldAPIV2
435
+ | DocumentCrossReferenceFieldAPIV2
436
+ | DocumentListFieldAPIV2;
437
+
438
+ export type DocumentFieldNonLocalizedAPIV2 =
439
+ | DocumentStringLikeFieldNonLocalizedAPIV2
440
+ | DocumentMarkdownFieldNonLocalizedAPIV2
441
+ | DocumentNumberFieldNonLocalizedAPIV2
442
+ | DocumentBooleanFieldNonLocalizedAPIV2
443
+ | DocumentJsonFieldNonLocalizedAPIV2
444
+ | DocumentStyleFieldNonLocalizedAPIV2
445
+ | DocumentRichTextFieldNonLocalizedAPIV2
446
+ | DocumentFileFieldNonLocalizedAPIV2
447
+ | DocumentImageFieldNonLocalizedAPIV2
448
+ | DocumentObjectFieldNonLocalizedAPIV2
449
+ | DocumentModelFieldNonLocalizedAPIV2
450
+ | DocumentReferenceFieldNonLocalizedAPIV2
451
+ | DocumentCrossReferenceFieldNonLocalizedAPIV2
452
+ | DocumentListFieldNonLocalizedAPIV2;
453
+
454
+ export type DocumentFieldLocalizedAPIV2 =
455
+ | DocumentStringLikeFieldLocalizedAPIV2
456
+ | DocumentMarkdownFieldLocalizedAPIV2
457
+ | DocumentNumberFieldLocalizedAPIV2
458
+ | DocumentBooleanFieldLocalizedAPIV2
459
+ | DocumentJsonFieldLocalizedAPIV2
460
+ | DocumentStyleFieldLocalizedAPIV2
461
+ | DocumentRichTextFieldLocalizedAPIV2
462
+ | DocumentFileFieldLocalizedAPIV2
463
+ | DocumentImageFieldLocalizedAPIV2
464
+ | DocumentObjectFieldLocalizedAPIV2
465
+ | DocumentModelFieldLocalizedAPIV2
466
+ | DocumentReferenceFieldLocalizedAPIV2
467
+ | DocumentCrossReferenceFieldLocalizedAPIV2
468
+ | DocumentListFieldLocalizedAPIV2;
469
+
470
+ export type DocumentFieldNonLocalizedForTypeAPIV2<Type extends FieldType> = ExtractByType<DocumentFieldNonLocalizedAPIV2, Type>;
471
+ export type DocumentFieldForTypeAPIV2<Type extends FieldType> = ExtractByType<DocumentFieldAPIV2, Type>;