@stackbit/cms-core 0.1.29 → 0.1.30-alpha.0

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 (82) hide show
  1. package/dist/content-store-utils.d.ts +5 -5
  2. package/dist/content-store-utils.d.ts.map +1 -1
  3. package/dist/content-store-utils.js +6 -2
  4. package/dist/content-store-utils.js.map +1 -1
  5. package/dist/content-store.d.ts +3 -3
  6. package/dist/content-store.d.ts.map +1 -1
  7. package/dist/content-store.js +1 -1
  8. package/dist/content-store.js.map +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/types/content-store-document-fields.d.ts +600 -0
  14. package/dist/types/content-store-document-fields.d.ts.map +1 -0
  15. package/dist/types/content-store-document-fields.js +3 -0
  16. package/dist/types/content-store-document-fields.js.map +1 -0
  17. package/dist/types/content-store-documents.d.ts +99 -0
  18. package/dist/types/content-store-documents.d.ts.map +1 -0
  19. package/dist/types/content-store-documents.js +3 -0
  20. package/dist/types/content-store-documents.js.map +1 -0
  21. package/dist/types/content-store-types.d.ts +75 -0
  22. package/dist/types/content-store-types.d.ts.map +1 -0
  23. package/dist/types/content-store-types.js.map +1 -0
  24. package/dist/types/content-store-update-operation.d.ts +61 -0
  25. package/dist/types/content-store-update-operation.d.ts.map +1 -0
  26. package/dist/types/content-store-update-operation.js +3 -0
  27. package/dist/types/content-store-update-operation.js.map +1 -0
  28. package/dist/types/index.d.ts +6 -0
  29. package/dist/types/index.d.ts.map +1 -0
  30. package/dist/types/index.js +18 -0
  31. package/dist/types/index.js.map +1 -0
  32. package/dist/types/search-filter.d.ts +1 -1
  33. package/dist/types/search-filter.d.ts.map +1 -1
  34. package/dist/utils/create-update-csi-docs.d.ts +1 -1
  35. package/dist/utils/create-update-csi-docs.d.ts.map +1 -1
  36. package/dist/utils/create-update-csi-docs.js +9 -5
  37. package/dist/utils/create-update-csi-docs.js.map +1 -1
  38. package/dist/utils/csi-to-store-docs-converter.d.ts +1 -1
  39. package/dist/utils/csi-to-store-docs-converter.d.ts.map +1 -1
  40. package/dist/utils/csi-to-store-docs-converter.js +20 -4
  41. package/dist/utils/csi-to-store-docs-converter.js.map +1 -1
  42. package/dist/utils/duplicate-document.d.ts +1 -1
  43. package/dist/utils/duplicate-document.d.ts.map +1 -1
  44. package/dist/utils/index.d.ts +2 -2
  45. package/dist/utils/index.d.ts.map +1 -1
  46. package/dist/utils/search-utils.d.ts +1 -1
  47. package/dist/utils/search-utils.d.ts.map +1 -1
  48. package/dist/utils/search-utils.js +16 -16
  49. package/dist/utils/search-utils.js.map +1 -1
  50. package/dist/utils/site-map.d.ts +1 -1
  51. package/dist/utils/site-map.d.ts.map +1 -1
  52. package/dist/utils/store-to-api-docs-converter.d.ts +1 -1
  53. package/dist/utils/store-to-api-docs-converter.d.ts.map +1 -1
  54. package/dist/utils/store-to-api-docs-converter.js +39 -12
  55. package/dist/utils/store-to-api-docs-converter.js.map +1 -1
  56. package/dist/utils/store-to-csi-docs-converter.d.ts +1 -1
  57. package/dist/utils/store-to-csi-docs-converter.d.ts.map +1 -1
  58. package/dist/utils/timer.d.ts +1 -1
  59. package/dist/utils/timer.d.ts.map +1 -1
  60. package/package.json +4 -4
  61. package/src/content-store-utils.ts +10 -7
  62. package/src/content-store.ts +10 -10
  63. package/src/index.ts +1 -1
  64. package/src/types/content-store-document-fields.ts +658 -0
  65. package/src/types/content-store-documents.ts +113 -0
  66. package/src/types/content-store-types.ts +96 -0
  67. package/src/types/content-store-update-operation.ts +85 -0
  68. package/src/types/index.ts +5 -0
  69. package/src/types/search-filter.ts +26 -19
  70. package/src/utils/create-update-csi-docs.ts +13 -8
  71. package/src/utils/csi-to-store-docs-converter.ts +33 -14
  72. package/src/utils/duplicate-document.ts +2 -2
  73. package/src/utils/search-utils.ts +18 -19
  74. package/src/utils/site-map.ts +1 -1
  75. package/src/utils/store-to-api-docs-converter.ts +41 -13
  76. package/src/utils/store-to-csi-docs-converter.ts +1 -1
  77. package/src/utils/timer.ts +1 -1
  78. package/dist/content-store-types.d.ts +0 -413
  79. package/dist/content-store-types.d.ts.map +0 -1
  80. package/dist/content-store-types.js.map +0 -1
  81. package/src/content-store-types.ts +0 -531
  82. /package/dist/{content-store-types.js → types/content-store-types.js} +0 -0
@@ -1,11 +1,9 @@
1
1
  import _ from 'lodash';
2
2
  import { ImageModel, Model } from '@stackbit/sdk';
3
- import * as ContentSourceInterface from '@stackbit/types';
4
- import { getLocalizedFieldForLocale } from '@stackbit/types';
5
3
 
4
+ import * as ContentStoreTypes from '../types';
6
5
  import { SearchFilter, SearchFilterItem } from '../types/search-filter';
7
- import { ContentStoreTypes } from '..';
8
- import { getContentSourceId } from '../content-store-utils';
6
+ import { getContentSourceId, getDocumentFieldForLocale } from '../content-store-utils';
9
7
 
10
8
  const META_FIELD = {
11
9
  createdAt: {
@@ -91,7 +89,7 @@ const isDocumentMatchesPattern = (document: ContentStoreTypes.Document, query: s
91
89
  case 'text':
92
90
  case 'markdown':
93
91
  case 'html':
94
- value = getLocalizedFieldForLocale(field, locale)?.value;
92
+ value = getDocumentFieldForLocale(field, locale)?.value;
95
93
  break;
96
94
  }
97
95
 
@@ -105,13 +103,14 @@ const isDocumentMatchesPattern = (document: ContentStoreTypes.Document, query: s
105
103
 
106
104
  const getFieldForFilter = (document: ContentStoreTypes.Document, filter: SearchFilterItem): ContentStoreTypes.DocumentField => {
107
105
  if (filter.isMeta) {
108
- const fieldDef = META_FIELD[filter.field as keyof typeof META_FIELD];
109
- if (!fieldDef) {
106
+ if (filter.field !== 'createdAt' && filter.field !== 'updatedAt') {
110
107
  throw new Error(`Unsupported meta field ${filter.field}`);
111
108
  }
109
+ const fieldDef = META_FIELD[filter.field];
110
+ const dateValue = document[filter.field];
112
111
  return {
113
112
  ...fieldDef,
114
- value: document[filter.field as keyof typeof document]
113
+ value: dateValue
115
114
  };
116
115
  } else {
117
116
  const documentField = document.fields[filter.field];
@@ -180,7 +179,7 @@ const isStringFieldMatches = ({
180
179
  locale?: string;
181
180
  }) => {
182
181
  // ignoring case
183
- const fieldValue = getLocalizedFieldForLocale(field, locale)?.value?.toLowerCase();
182
+ const fieldValue = getDocumentFieldForLocale(field, locale)?.value?.toLowerCase();
184
183
 
185
184
  switch (filter.operator) {
186
185
  case 'is-undefined': return fieldValue === undefined;
@@ -202,9 +201,9 @@ const isStringFieldMatches = ({
202
201
  case 'neq':
203
202
  return fieldValue !== filterValue;
204
203
  case 'includes':
205
- return fieldValue.includes(filterValue);
204
+ return Boolean(fieldValue?.includes(filterValue));
206
205
  case 'not-includes':
207
- return !fieldValue.includes(filterValue);
206
+ return !Boolean(fieldValue?.includes(filterValue));
208
207
  }
209
208
  }
210
209
  }
@@ -213,7 +212,7 @@ const isStringFieldMatches = ({
213
212
  };
214
213
 
215
214
  const isNumberFieldMatches = ({ field, filter, locale }: { field: ContentStoreTypes.DocumentFieldForType<'number'>; filter: SearchFilterItem; locale?: string }) => {
216
- const fieldValue = getLocalizedFieldForLocale(field, locale)?.value;
215
+ const fieldValue = getDocumentFieldForLocale(field, locale)?.value;
217
216
 
218
217
  switch (filter.operator) {
219
218
  case 'is-undefined': return fieldValue === undefined;
@@ -234,9 +233,9 @@ const isNumberFieldMatches = ({ field, filter, locale }: { field: ContentStoreTy
234
233
  case 'neq':
235
234
  return fieldValue !== filter.value;
236
235
  case 'gte':
237
- return fieldValue >= filter.value;
236
+ return Boolean(fieldValue && fieldValue >= filter.value);
238
237
  case 'lte':
239
- return fieldValue <= filter.value;
238
+ return Boolean(fieldValue && fieldValue <= filter.value);
240
239
  }
241
240
  }
242
241
 
@@ -246,7 +245,7 @@ const isNumberFieldMatches = ({ field, filter, locale }: { field: ContentStoreTy
246
245
  throw new Error(`Filter startValue and endValue should be number for field ${filter.field}`);
247
246
  }
248
247
 
249
- return fieldValue >= filter.startValue && fieldValue <= filter.endValue;
248
+ return Boolean(fieldValue && fieldValue >= filter.startValue && fieldValue <= filter.endValue);
250
249
  }
251
250
  }
252
251
 
@@ -262,7 +261,7 @@ const isBooleanFieldMatches = ({
262
261
  filter: SearchFilterItem;
263
262
  locale?: string;
264
263
  }) => {
265
- const fieldValue = getLocalizedFieldForLocale(field, locale)?.value;
264
+ const fieldValue = getDocumentFieldForLocale(field, locale)?.value;
266
265
 
267
266
  switch (filter.operator) {
268
267
  case 'is-undefined': return fieldValue === undefined;
@@ -311,7 +310,7 @@ const isDateFieldMatches = ({
311
310
  filter: SearchFilterItem;
312
311
  locale?: string;
313
312
  }) => {
314
- const origValue = getLocalizedFieldForLocale(field, locale)?.value;
313
+ const origValue = getDocumentFieldForLocale(field, locale)?.value;
315
314
  const fieldValue = parseDateValue(origValue);
316
315
  if (origValue && !fieldValue) {
317
316
  throw new Error(`Can't parse value ${origValue} for field ${filter.field}`);
@@ -374,7 +373,7 @@ const isDateFieldMatches = ({
374
373
  };
375
374
 
376
375
  const isEnumFieldMatches = ({ field, filter, locale }: { field: ContentStoreTypes.DocumentFieldForType<'enum'>; filter: SearchFilterItem; locale?: string }) => {
377
- const fieldValue = getLocalizedFieldForLocale(field, locale)?.value;
376
+ const fieldValue = getDocumentFieldForLocale(field, locale)?.value;
378
377
 
379
378
  switch (filter.operator) {
380
379
  case 'is-undefined': return fieldValue === undefined;
@@ -415,7 +414,7 @@ const isListFieldMatches = ({
415
414
  throw new Error(`Unsupported filter for list field ${filter.field} with children ${listItemsType}`);
416
415
  }
417
416
 
418
- const fieldValue = getLocalizedFieldForLocale(field as ContentSourceInterface.DocumentFieldForType<'list'>, locale)?.items?.map((item) =>
417
+ const fieldValue = getDocumentFieldForLocale(field, locale)?.items?.map((item) =>
419
418
  'value' in item ? item.value : undefined
420
419
  );
421
420
 
@@ -3,7 +3,7 @@ import { Config } from '@stackbit/sdk';
3
3
  import { append } from '@stackbit/utils';
4
4
  import { SiteMapEntry } from '@stackbit/types';
5
5
  import * as CSITypes from '@stackbit/types';
6
- import * as ContentStoreTypes from '../content-store-types';
6
+ import * as ContentStoreTypes from '../types';
7
7
  import { mapStoreDocumentsToCSIDocumentsWithSource } from './store-to-csi-docs-converter';
8
8
  import { getContentSourceId, getDocumentFieldForLocale } from '../content-store-utils';
9
9
 
@@ -1,6 +1,7 @@
1
1
  import _ from 'lodash';
2
2
  import { omitByNil } from '@stackbit/utils';
3
- import * as ContentStoreTypes from '../content-store-types';
3
+ import * as ContentStoreTypes from '../types';
4
+ import { DocumentStringLikeFieldAPI } from '../types';
4
5
 
5
6
  export function mapDocumentsToLocalizedApiObjects(documents: ContentStoreTypes.Document[], locale?: string): ContentStoreTypes.APIDocumentObject[] {
6
7
  return documents.map((document) => documentToLocalizedApiObject(document, locale));
@@ -51,25 +52,46 @@ function toLocalizedAPIField(docField: ContentStoreTypes.DocumentField, locale?:
51
52
  case 'date':
52
53
  case 'datetime':
53
54
  case 'color':
54
- case 'style':
55
+ case 'style': {
56
+ if (docField.localized) {
57
+ const { localized, locales, ...base } = docField;
58
+ const localeProps = locales && locale ? locales[locale] : undefined;
59
+ return {
60
+ ...base,
61
+ ...localeProps,
62
+ ...localeFields(localized)
63
+ } as ContentStoreTypes.DocumentStringLikeFieldAPI;
64
+ }
65
+ return {
66
+ ...docField,
67
+ ...localeFields(docField.localized)
68
+ };
69
+ }
55
70
  case 'file':
56
71
  case 'json':
57
72
  case 'markdown':
58
- case 'richText':
73
+ case 'richText': {
59
74
  if (docField.localized) {
60
75
  const { localized, locales, ...base } = docField;
61
76
  const localeProps = locales && locale ? locales[locale] : undefined;
77
+ if (localeProps) {
78
+ return {
79
+ ...base,
80
+ ...localeProps,
81
+ ...localeFields(localized)
82
+ };
83
+ }
62
84
  return {
63
85
  ...base,
64
- ...(localeProps ?? { value: null }),
65
- ...localeFields(localized),
66
- ...(['file', 'json', 'markdown', 'richText'].includes(docField.type) && !localeProps ? { isUnset: true } : null)
86
+ isUnset: true,
87
+ ...localeFields(localized)
67
88
  };
68
89
  }
69
90
  return {
70
91
  ...docField,
71
92
  ...localeFields(docField.localized)
72
93
  };
94
+ }
73
95
  case 'image':
74
96
  if (docField.localized) {
75
97
  const { localized, locales, ...base } = docField;
@@ -265,9 +287,12 @@ function localizeAssetFields(assetFields: ContentStoreTypes.AssetFields, locale?
265
287
  const titleField = assetFields.title;
266
288
  if (titleField.localized) {
267
289
  if (locale) {
268
- fields.title.value = titleField.locales?.[locale]?.value ?? null;
269
- fields.title.localized = true;
270
- fields.title.locale = locale;
290
+ fields.title = {
291
+ type: 'string',
292
+ value: titleField.locales?.[locale]?.value ?? null,
293
+ localized: true,
294
+ locale: locale
295
+ };
271
296
  }
272
297
  } else {
273
298
  fields.title.value = titleField.value;
@@ -275,9 +300,12 @@ function localizeAssetFields(assetFields: ContentStoreTypes.AssetFields, locale?
275
300
  const assetFileField = assetFields.file;
276
301
  if (assetFileField.localized) {
277
302
  if (locale) {
278
- fields.url.value = assetFileField.locales?.[locale]?.url ?? null;
279
- fields.url.localized = true;
280
- fields.url.locale = locale;
303
+ fields.url = {
304
+ type: 'string',
305
+ value: assetFileField.locales?.[locale]?.url ?? null,
306
+ localized: true,
307
+ locale: locale
308
+ };
281
309
  }
282
310
  } else {
283
311
  fields.url.value = assetFileField.url;
@@ -302,7 +330,7 @@ function storeAssetToAPIAsset(asset: ContentStoreTypes.Asset, locale?: string):
302
330
  createdAt: asset.createdAt,
303
331
  url: localizedFileField.url,
304
332
  ...omitByNil({
305
- title: localizedTitleField?.value ?? null,
333
+ title: localizedTitleField?.value ?? undefined,
306
334
  fileName: localizedFileField.fileName,
307
335
  contentType: localizedFileField.contentType,
308
336
  size: localizedFileField.size,
@@ -1,6 +1,6 @@
1
1
  import _ from 'lodash';
2
2
  import * as CSITypes from '@stackbit/types';
3
- import * as ContentStoreTypes from '../content-store-types';
3
+ import * as ContentStoreTypes from '../types';
4
4
 
5
5
  export function mapStoreDocumentsToCSIDocumentsWithSource(documents: ContentStoreTypes.Document[]): CSITypes.DocumentWithSource[] {
6
6
  return documents.map((document) => mapStoreDocumentToCSIDocumentWithSource(document));
@@ -1,4 +1,4 @@
1
- import { Logger } from '../content-store-types';
1
+ import { Logger } from '@stackbit/types';
2
2
 
3
3
  export class Timer {
4
4
  private readonly timerCallback: () => void;
@@ -1,413 +0,0 @@
1
- import { DocumentStatus, FieldType } from '@stackbit/types';
2
- import { Model } from '@stackbit/sdk';
3
- import * as CSITypes from '@stackbit/types';
4
- export { FieldType, DocumentStatus, Logger } from '@stackbit/types';
5
- export interface ContentSourceData {
6
- id: string;
7
- instance: CSITypes.ContentSourceInterface;
8
- srcType: string;
9
- srcProjectId: string;
10
- locales?: CSITypes.Locale[];
11
- defaultLocaleCode?: string;
12
- models: Model[];
13
- modelMap: Record<string, Model>;
14
- csiModels: CSITypes.Model[];
15
- csiModelMap: Record<string, CSITypes.Model>;
16
- csiDocuments: CSITypes.Document[];
17
- csiDocumentMap: Record<string, CSITypes.Document>;
18
- documents: Document[];
19
- documentMap: Record<string, Document>;
20
- csiAssets: CSITypes.Asset[];
21
- csiAssetMap: Record<string, CSITypes.Asset>;
22
- assets: Asset[];
23
- assetMap: Record<string, Asset>;
24
- }
25
- export interface Document {
26
- type: 'document';
27
- srcType: string;
28
- srcProjectId: string;
29
- srcProjectUrl: string;
30
- srcEnvironment: string;
31
- srcObjectId: string;
32
- srcObjectUrl: string;
33
- srcObjectLabel: string;
34
- srcModelName: string;
35
- srcModelLabel: string;
36
- isChanged: boolean;
37
- status: DocumentStatus;
38
- createdAt: string;
39
- createdBy?: string;
40
- updatedAt: string;
41
- updatedBy?: string[];
42
- locale?: string;
43
- fields: Record<string, DocumentField>;
44
- }
45
- export interface Asset {
46
- type: 'asset';
47
- srcType: string;
48
- srcProjectId: string;
49
- srcProjectUrl: string;
50
- srcEnvironment: string;
51
- srcObjectId: string;
52
- srcObjectUrl: string;
53
- srcObjectLabel: string;
54
- srcModelName: string;
55
- srcModelLabel: string;
56
- isChanged: boolean;
57
- status: DocumentStatus;
58
- createdAt: string;
59
- createdBy?: string;
60
- updatedAt: string;
61
- updatedBy?: string[];
62
- locale?: string;
63
- fields: AssetFields;
64
- }
65
- export declare type AssetFields = {
66
- title: DocumentValueFieldForType<'string'>;
67
- file: AssetFileField;
68
- };
69
- export interface UploadAssetData {
70
- url: string;
71
- data?: string;
72
- metadata: {
73
- name: string;
74
- type: string;
75
- };
76
- }
77
- export interface ContentChangeResultItem {
78
- srcType: string;
79
- srcProjectId: string;
80
- srcObjectId: string;
81
- }
82
- export interface ContentChangeResult {
83
- updatedDocuments: ContentChangeResultItem[];
84
- updatedAssets: ContentChangeResultItem[];
85
- deletedDocuments: ContentChangeResultItem[];
86
- deletedAssets: ContentChangeResultItem[];
87
- }
88
- export declare type APIObject = APIDocumentObject | APIImageObject;
89
- export interface APIDocumentObject extends Omit<Document, 'fields' | 'type'> {
90
- type: 'object';
91
- fields: Record<string, DocumentFieldAPI>;
92
- }
93
- export interface APIImageObject extends Omit<Asset, 'fields' | 'type'> {
94
- type: 'image';
95
- fields: AssetFieldsAPI;
96
- }
97
- export declare type AssetFieldsAPI = {
98
- title: DocumentFieldAPIForType<'string'>;
99
- url: DocumentFieldAPIForType<'string'>;
100
- };
101
- export interface APIAsset {
102
- objectId: string;
103
- createdAt: string;
104
- url: string;
105
- title?: string;
106
- fileName?: string;
107
- contentType?: string;
108
- size?: number;
109
- width?: number;
110
- height?: number;
111
- }
112
- export declare type DocumentField = DocumentValueField | DocumentObjectField | DocumentModelField | DocumentReferenceField | DocumentCrossReferenceField | DocumentListField | DocumentMarkdownField | DocumentRichTextField | DocumentImageField;
113
- export declare type DocumentFieldLocalized = DocumentValueFieldLocalized | DocumentObjectFieldLocalized | DocumentModelFieldLocalized | DocumentReferenceFieldLocalized | DocumentCrossReferenceFieldLocalized | DocumentMarkdownFieldLocalized | DocumentRichTextFieldLocalized | DocumentListFieldLocalized | DocumentImageFieldLocalized;
114
- export declare type DocumentFieldNonLocalized = DocumentValueFieldNonLocalized | DocumentObjectFieldNonLocalized | DocumentModelFieldNonLocalized | DocumentReferenceFieldNonLocalized | DocumentCrossReferenceFieldNonLocalized | DocumentMarkdownFieldNonLocalized | DocumentRichTextFieldNonLocalized | DocumentListFieldNonLocalized | DocumentImageFieldNonLocalized;
115
- export declare type DocumentFieldAPI = DocumentValueFieldAPI | DocumentObjectFieldAPI | DocumentModelFieldAPI | DocumentReferenceFieldAPI | DocumentCrossReferenceFieldAPI | DocumentMarkdownFieldAPI | DocumentRichTextFieldAPI | DocumentListFieldAPI | DocumentImageFieldAPI;
116
- export declare type DocumentFieldBaseProps = DocumentValueFieldBaseProps | DocumentObjectFieldBase | DocumentModelFieldBase | DocumentReferenceFieldBase | DocumentCrossReferenceFieldBase | DocumentListFieldBase | DocumentRichTextFieldBase | DocumentImageFieldBase;
117
- export declare type DistributiveOmit<T, K extends PropertyKey> = T extends any ? Omit<T, K> : never;
118
- export declare type Simplify<T> = {
119
- [K in keyof T]: T[K];
120
- };
121
- export declare type FindByType<Union extends {
122
- type: FieldType | 'unresolved_reference';
123
- }, Type> = Union extends {
124
- type: Type;
125
- } ? Union : never;
126
- export declare type DocumentFieldForType<Type extends FieldType> = FindByType<DocumentField, Type>;
127
- export declare type DocumentFieldLocalizedForType<Type extends FieldType> = FindByType<DocumentFieldLocalized, Type>;
128
- export declare type DocumentFieldNonLocalizedForType<Type extends FieldType> = FindByType<DocumentFieldNonLocalized, Type>;
129
- export declare type DocumentFieldAPIForType<Type extends FieldType | 'unresolved_reference'> = FindByType<DocumentFieldAPI, Type>;
130
- export declare type DocumentFieldBasePropsForType<Type extends FieldType> = FindByType<DocumentFieldBaseProps, Type>;
131
- export declare type DocumentFieldSpecificPropsForType<Type extends FieldType> = Simplify<DistributiveOmit<DocumentFieldNonLocalizedForType<Type>, keyof DocumentFieldBasePropsForType<Type> | 'label' | 'locale' | 'localized'>>;
132
- export declare type DocumentFieldTypeLocalized<BaseFieldProps, LocalizedFieldProps> = Simplify<BaseFieldProps & {
133
- label?: string;
134
- localized: true;
135
- locales: Record<string, {
136
- locale: string;
137
- } & Omit<Exclude<LocalizedFieldProps, DocumentFieldUnsetProps>, 'isUnset'>>;
138
- }>;
139
- export declare type DocumentFieldTypeNonLocalized<BaseFieldProps, LocalizedFieldProps> = Simplify<BaseFieldProps & LocalizedFieldProps & {
140
- label?: string;
141
- localized?: false;
142
- }>;
143
- export declare type DocumentFieldTypeAPI<BaseFieldProps, LocalizedFieldProps> = BaseFieldProps & LocalizedFieldProps & {
144
- label?: string;
145
- description?: string;
146
- locale?: string;
147
- localized?: boolean;
148
- } & ({
149
- localized?: false;
150
- } | {
151
- localized: true;
152
- locale: string;
153
- });
154
- export declare type DocumentValueFieldType = Exclude<FieldType, 'object' | 'model' | 'reference' | 'cross-reference' | 'markdown' | 'richText' | 'list' | 'image'>;
155
- export declare type DocumentValueFieldForType<Type> = Type extends DocumentValueFieldType ? DocumentValueFieldLocalizedForType<Type> | DocumentValueFieldNonLocalizedForType<Type> : never;
156
- export declare type DocumentValueField = DocumentValueFieldForType<DocumentValueFieldType>;
157
- export declare type DocumentValueFieldLocalizedForType<Type> = Type extends DocumentValueFieldType ? DocumentFieldTypeLocalized<DocumentValueFieldBase<Type>, DocumentValueFieldProps> : never;
158
- export declare type DocumentValueFieldLocalized = DocumentValueFieldLocalizedForType<DocumentValueFieldType>;
159
- export declare type DocumentValueFieldNonLocalizedForType<Type> = Type extends DocumentValueFieldType ? DocumentFieldTypeNonLocalized<DocumentValueFieldBase<Type>, DocumentValueFieldProps> : never;
160
- export declare type DocumentValueFieldNonLocalized = DocumentValueFieldNonLocalizedForType<DocumentValueFieldType>;
161
- export declare type DocumentValueFieldAPIForType<Type> = Type extends DocumentValueFieldType ? DocumentFieldTypeAPI<DocumentValueFieldBase<Type>, DocumentValueFieldProps> : never;
162
- export declare type DocumentValueFieldAPI = DocumentValueFieldAPIForType<DocumentValueFieldType>;
163
- export declare type DocumentValueFieldBasePropsForType<Type> = Type extends DocumentValueFieldType ? DocumentValueFieldBase<Type> : never;
164
- export declare type DocumentValueFieldBaseProps = DocumentValueFieldBasePropsForType<DocumentValueFieldType>;
165
- export declare type DocumentValueFieldBase<Type extends DocumentValueFieldType> = {
166
- type: Type;
167
- };
168
- export declare type DocumentValueFieldProps = {
169
- value: any;
170
- };
171
- export declare type DocumentFieldUnsetProps = {
172
- isUnset: true;
173
- };
174
- export declare type DocumentObjectField = DocumentObjectFieldLocalized | DocumentObjectFieldNonLocalized;
175
- export declare type DocumentObjectFieldLocalized = DocumentFieldTypeLocalized<DocumentObjectFieldBase, DocumentObjectFieldProps>;
176
- export declare type DocumentObjectFieldNonLocalized = DocumentFieldTypeNonLocalized<DocumentObjectFieldBase, DocumentObjectFieldProps>;
177
- export declare type DocumentObjectFieldAPI = DocumentFieldTypeAPI<DocumentObjectFieldBase, DocumentObjectFieldPropsAPI>;
178
- export declare type DocumentObjectFieldBase = {
179
- type: 'object';
180
- };
181
- export declare type DocumentObjectFieldPropsCommon = {
182
- srcObjectLabel: string;
183
- };
184
- export declare type DocumentObjectFieldProps = DocumentFieldUnsetProps | ({
185
- isUnset?: false;
186
- fields: Record<string, DocumentField>;
187
- } & DocumentObjectFieldPropsCommon);
188
- export declare type DocumentObjectFieldPropsAPI = DocumentFieldUnsetProps | ({
189
- isUnset?: false;
190
- fields: Record<string, DocumentFieldAPI>;
191
- } & DocumentObjectFieldPropsCommon);
192
- export declare type DocumentModelField = DocumentModelFieldLocalized | DocumentModelFieldNonLocalized;
193
- export declare type DocumentModelFieldLocalized = DocumentFieldTypeLocalized<DocumentModelFieldBase, DocumentModelFieldProps>;
194
- export declare type DocumentModelFieldNonLocalized = DocumentFieldTypeNonLocalized<DocumentModelFieldBase, DocumentModelFieldProps>;
195
- export declare type DocumentModelFieldAPI = DocumentFieldTypeAPI<{
196
- type: 'object';
197
- }, DocumentModelFieldPropsAPI>;
198
- export declare type DocumentModelFieldBase = {
199
- type: 'model';
200
- };
201
- export declare type DocumentModelFieldPropsCommon = {
202
- srcObjectLabel: string;
203
- srcModelName: string;
204
- srcModelLabel: string;
205
- };
206
- export declare type DocumentModelFieldProps = DocumentFieldUnsetProps | ({
207
- isUnset?: false;
208
- fields: Record<string, DocumentField>;
209
- } & DocumentModelFieldPropsCommon);
210
- export declare type DocumentModelFieldPropsAPI = DocumentFieldUnsetProps | ({
211
- isUnset?: false;
212
- fields: Record<string, DocumentFieldAPI>;
213
- } & DocumentModelFieldPropsCommon);
214
- export declare type DocumentReferenceField = DocumentReferenceFieldLocalized | DocumentReferenceFieldNonLocalized;
215
- export declare type DocumentReferenceFieldLocalized = DocumentFieldTypeLocalized<DocumentReferenceFieldBase, DocumentReferenceFieldProps>;
216
- export declare type DocumentReferenceFieldNonLocalized = DocumentFieldTypeNonLocalized<DocumentReferenceFieldBase, DocumentReferenceFieldProps>;
217
- export declare type DocumentReferenceFieldAPI = DocumentFieldTypeAPI<DocumentReferenceFieldBaseAPI, DocumentReferenceFieldProps>;
218
- export declare type DocumentReferenceFieldBase = {
219
- type: 'reference';
220
- refType: 'document' | 'asset';
221
- };
222
- export declare type DocumentReferenceFieldProps = DocumentFieldUnsetProps | {
223
- isUnset?: false;
224
- refId: string;
225
- };
226
- export declare type DocumentReferenceFieldBaseAPI = {
227
- type: 'unresolved_reference';
228
- refType: 'object' | 'image';
229
- };
230
- export declare type DocumentCrossReferenceField = DocumentCrossReferenceFieldLocalized | DocumentCrossReferenceFieldNonLocalized;
231
- export declare type DocumentCrossReferenceFieldLocalized = DocumentFieldTypeLocalized<DocumentCrossReferenceFieldBase, DocumentCrossReferenceFieldProps>;
232
- export declare type DocumentCrossReferenceFieldNonLocalized = DocumentFieldTypeNonLocalized<DocumentCrossReferenceFieldBase, DocumentCrossReferenceFieldProps>;
233
- export declare type DocumentCrossReferenceFieldAPI = DocumentFieldTypeAPI<DocumentCrossReferenceFieldBase, DocumentCrossReferenceFieldProps>;
234
- export declare type DocumentCrossReferenceFieldBase = {
235
- type: 'cross-reference';
236
- refType: 'document' | 'asset';
237
- };
238
- export declare type DocumentCrossReferenceFieldProps = DocumentFieldUnsetProps | {
239
- isUnset?: false;
240
- refId: string;
241
- refSrcType: string;
242
- refProjectId: string;
243
- };
244
- export declare type DocumentMarkdownField = DocumentMarkdownFieldLocalized | DocumentMarkdownFieldNonLocalized;
245
- export declare type DocumentMarkdownFieldLocalized = DocumentFieldTypeLocalized<DocumentMarkdownFieldBase, DocumentMarkdownFieldProps>;
246
- export declare type DocumentMarkdownFieldNonLocalized = DocumentFieldTypeNonLocalized<DocumentMarkdownFieldBase, DocumentMarkdownFieldProps>;
247
- export declare type DocumentMarkdownFieldAPI = DocumentFieldTypeAPI<DocumentMarkdownFieldBase, DocumentMarkdownFieldProps>;
248
- export declare type DocumentMarkdownFieldBase = {
249
- type: 'markdown';
250
- };
251
- export declare type DocumentMarkdownFieldProps = {
252
- isUnset?: boolean;
253
- multiElement?: boolean;
254
- value: any;
255
- };
256
- export declare type DocumentRichTextField = DocumentRichTextFieldLocalized | DocumentRichTextFieldNonLocalized;
257
- export declare type DocumentRichTextFieldLocalized = DocumentFieldTypeLocalized<DocumentRichTextFieldBase, DocumentRichTextFieldProps>;
258
- export declare type DocumentRichTextFieldNonLocalized = DocumentFieldTypeNonLocalized<DocumentRichTextFieldBase, DocumentRichTextFieldProps>;
259
- export declare type DocumentRichTextFieldAPI = DocumentFieldTypeAPI<DocumentRichTextFieldBase, DocumentRichTextFieldProps>;
260
- export declare type DocumentRichTextFieldBase = {
261
- type: 'richText';
262
- };
263
- export declare type DocumentRichTextFieldProps = {
264
- isUnset?: boolean;
265
- hint?: string;
266
- multiElement?: boolean;
267
- value: any;
268
- };
269
- export declare type DocumentListField = DocumentListFieldLocalized | DocumentListFieldNonLocalized;
270
- export declare type DocumentListFieldLocalized = DocumentFieldTypeLocalized<DocumentListFieldBase, DocumentListFieldProps>;
271
- export declare type DocumentListFieldNonLocalized = DocumentFieldTypeNonLocalized<DocumentListFieldBase, DocumentListFieldProps>;
272
- export declare type DocumentListFieldAPI = DocumentFieldTypeAPI<DocumentListFieldBase, DocumentListFieldPropsAPI>;
273
- export declare type DocumentListFieldBase = {
274
- type: 'list';
275
- };
276
- export declare type DocumentListFieldItems = Exclude<DocumentFieldNonLocalized, DocumentListFieldNonLocalized>;
277
- export declare type DocumentListFieldProps = {
278
- items: DocumentListFieldItems[];
279
- };
280
- export declare type DocumentListFieldItemsAPI = Exclude<DocumentFieldAPI, DocumentListFieldAPI>;
281
- export declare type DocumentListFieldPropsAPI = {
282
- items: DocumentListFieldItemsAPI[];
283
- };
284
- export declare type DocumentImageField = DocumentImageFieldLocalized | DocumentImageFieldNonLocalized;
285
- export declare type DocumentImageFieldLocalized = DocumentFieldTypeLocalized<DocumentImageFieldBase, DocumentImageFieldProps>;
286
- export declare type DocumentImageFieldNonLocalized = DocumentFieldTypeNonLocalized<DocumentImageFieldBase, DocumentImageFieldProps>;
287
- export declare type DocumentImageFieldAPI = DocumentFieldTypeAPI<DocumentImageFieldBase, DocumentImageFieldPropsAPI>;
288
- export declare type DocumentImageFieldBase = {
289
- type: 'image';
290
- source?: string;
291
- sourceData?: any;
292
- };
293
- export declare type DocumentImageFieldProps = DocumentFieldUnsetProps | {
294
- isUnset?: false;
295
- fields: ImageFields;
296
- };
297
- export declare type DocumentImageFieldPropsAPI = DocumentFieldUnsetProps | {
298
- isUnset?: false;
299
- fields: ImageFieldsAPI;
300
- };
301
- export declare type ImageFields = {
302
- title: DocumentFieldForType<'string'>;
303
- url: DocumentFieldForType<'string'>;
304
- };
305
- export declare type ImageFieldsAPI = AssetFieldsAPI;
306
- export declare type AssetFileField = AssetFileFieldLocalized | AssetFileFieldNonLocalized;
307
- export declare type AssetFileFieldLocalized = DocumentFieldTypeLocalized<AssetFileFieldBase, AssetFileFieldProps>;
308
- export declare type AssetFileFieldNonLocalized = DocumentFieldTypeNonLocalized<AssetFileFieldBase, AssetFileFieldProps>;
309
- export declare type AssetFileFieldBase = {
310
- type: 'assetFile';
311
- };
312
- export declare type AssetFileFieldProps = {
313
- url: string;
314
- fileName?: string;
315
- contentType?: string;
316
- size?: number;
317
- dimensions?: {
318
- width?: number;
319
- height?: number;
320
- };
321
- };
322
- export declare type UpdateOperation = UpdateOperationSet | UpdateOperationUnset | UpdateOperationInsert | UpdateOperationRemove | UpdateOperationReorder;
323
- export interface UpdateOperationBase {
324
- opType: string;
325
- fieldPath: (string | number)[];
326
- locale?: string;
327
- }
328
- export interface UpdateOperationSet extends UpdateOperationBase {
329
- opType: 'set';
330
- field: UpdateOperationField;
331
- }
332
- export interface UpdateOperationUnset extends UpdateOperationBase {
333
- opType: 'unset';
334
- }
335
- export interface UpdateOperationInsert extends UpdateOperationBase {
336
- opType: 'insert';
337
- index?: number;
338
- item: Exclude<UpdateOperationField, UpdateOperationListField>;
339
- }
340
- export interface UpdateOperationRemove extends UpdateOperationBase {
341
- opType: 'remove';
342
- index: number;
343
- }
344
- export interface UpdateOperationReorder extends UpdateOperationBase {
345
- opType: 'reorder';
346
- order: number[];
347
- }
348
- export declare type UpdateOperationField = UpdateOperationValueField | UpdateOperationObjectField | UpdateOperationModelField | UpdateOperationReferenceField | UpdateOperationCrossReferenceField | UpdateOperationListField;
349
- export declare type UpdateOperationValueFieldType = Exclude<FieldType, 'object' | 'model' | 'reference' | 'cross-reference' | 'list'>;
350
- export declare type UpdateOperationValueField = DistributeUpdateOperationValueField<UpdateOperationValueFieldType>;
351
- export declare type DistributeUpdateOperationValueField<Type extends UpdateOperationValueFieldType> = Type extends UpdateOperationValueFieldType ? UpdateOperationValueFieldForType<Type> : never;
352
- export declare type UpdateOperationValueFieldForType<Type extends UpdateOperationValueFieldType> = {
353
- type: Type;
354
- value: any;
355
- };
356
- export declare type UpdateOperationObjectField = {
357
- type: 'object';
358
- object: Record<string, any>;
359
- };
360
- export declare type UpdateOperationModelField = {
361
- type: 'model';
362
- modelName: string;
363
- object: Record<string, any>;
364
- };
365
- export declare type UpdateOperationReferenceField = {
366
- type: 'reference';
367
- refType: 'document' | 'asset';
368
- refId: string;
369
- };
370
- export declare type UpdateOperationCrossReferenceField = {
371
- type: 'cross-reference';
372
- refType: 'document' | 'asset';
373
- refId: string;
374
- refSrcType: string;
375
- refProjectId: string;
376
- };
377
- export declare type UpdateOperationListField = {
378
- type: 'list';
379
- items: any[];
380
- };
381
- export declare type User = {
382
- name: string;
383
- email: string;
384
- connections: {
385
- type: string;
386
- [key: string]: any;
387
- }[];
388
- };
389
- export declare type ValidationError = {
390
- message: string;
391
- srcType: string;
392
- srcProjectId: string;
393
- srcObjectType: string;
394
- srcObjectId: string;
395
- fieldPath: (string | number)[];
396
- isUniqueValidation?: boolean;
397
- };
398
- export declare type HasAccessResult = {
399
- hasConnection: boolean;
400
- hasPermissions: boolean;
401
- contentSources: {
402
- srcType: string;
403
- srcProjectId: string;
404
- hasConnection: boolean;
405
- hasPermissions: boolean;
406
- }[];
407
- };
408
- export interface CrossReferenceData {
409
- refId: string;
410
- refSrcType: string;
411
- refProjectId: string;
412
- }
413
- //# sourceMappingURL=content-store-types.d.ts.map