@stackbit/cms-core 0.1.4-alpha.0 → 0.1.4-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/common-types.d.ts +1 -9
- package/dist/common/common-types.d.ts.map +1 -1
- package/dist/consts.d.ts +1 -24
- package/dist/consts.d.ts.map +1 -1
- package/dist/consts.js +5 -25
- package/dist/consts.js.map +1 -1
- package/dist/content-store-types.d.ts +18 -16
- package/dist/content-store-types.d.ts.map +1 -1
- package/dist/content-store-utils.d.ts +3 -2
- package/dist/content-store-utils.d.ts.map +1 -1
- package/dist/content-store-utils.js.map +1 -1
- package/dist/content-store.d.ts +1 -1
- package/dist/content-store.d.ts.map +1 -1
- package/dist/content-store.js +31 -14
- package/dist/content-store.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/utils/create-update-csi-docs.d.ts +4 -3
- package/dist/utils/create-update-csi-docs.d.ts.map +1 -1
- package/dist/utils/create-update-csi-docs.js +11 -1
- package/dist/utils/create-update-csi-docs.js.map +1 -1
- package/dist/utils/csi-to-store-docs-converter.d.ts +1 -1
- package/dist/utils/csi-to-store-docs-converter.d.ts.map +1 -1
- package/dist/utils/csi-to-store-docs-converter.js +8 -8
- package/dist/utils/csi-to-store-docs-converter.js.map +1 -1
- package/dist/utils/search-utils.d.ts.map +1 -1
- package/dist/utils/search-utils.js +8 -8
- package/dist/utils/search-utils.js.map +1 -1
- package/package.json +4 -3
- package/src/common/common-types.ts +1 -10
- package/src/consts.ts +1 -26
- package/src/content-store-types.ts +40 -39
- package/src/content-store-utils.ts +3 -2
- package/src/content-store.ts +45 -25
- package/src/index.ts +0 -1
- package/src/utils/create-update-csi-docs.ts +39 -22
- package/src/utils/csi-to-store-docs-converter.ts +3 -2
- package/src/utils/search-utils.ts +3 -2
- package/dist/content-source-interface.d.ts +0 -333
- package/dist/content-source-interface.d.ts.map +0 -1
- package/dist/content-source-interface.js +0 -28
- package/dist/content-source-interface.js.map +0 -1
- package/src/content-source-interface.ts +0 -486
package/src/content-store.ts
CHANGED
|
@@ -2,16 +2,15 @@ import _ from 'lodash';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import sanitizeFilename from 'sanitize-filename';
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as CSITypes from '@stackbit/types';
|
|
6
|
+
import { getLocalizedFieldForLocale, UserCommandSpawner } from '@stackbit/types';
|
|
7
|
+
import { Config, extendConfig, Field, loadConfigFromDir, Model, ImageModel, isImageModel, Preset, RawConfigWithPaths } from '@stackbit/sdk';
|
|
6
8
|
import { deferWhileRunning, mapPromise, reducePromise } from '@stackbit/utils';
|
|
7
9
|
|
|
8
|
-
import * as CSITypes from './content-source-interface';
|
|
9
10
|
import * as ContentStoreTypes from './content-store-types';
|
|
10
11
|
import { Timer } from './utils/timer';
|
|
11
|
-
import { UserCommandSpawner } from './common/common-types';
|
|
12
12
|
import { SearchFilter } from './types/search-filter';
|
|
13
13
|
import { searchDocuments } from './utils/search-utils';
|
|
14
|
-
import { getLocalizedFieldForLocale } from './content-source-interface';
|
|
15
14
|
import { mapCSIAssetsToStoreAssets, mapCSIDocumentsToStoreDocuments } from './utils/csi-to-store-docs-converter';
|
|
16
15
|
import { getContentSourceId, getContentSourceIdForContentSource, getModelFieldForFieldAtPath, getUserContextForSrcType } from './content-store-utils';
|
|
17
16
|
import { mapAssetsToLocalizedApiImages, mapDocumentsToLocalizedApiObjects, mapStoreAssetsToAPIAssets } from './utils/store-to-api-docs-converter';
|
|
@@ -39,7 +38,7 @@ interface ContentSourceData {
|
|
|
39
38
|
/* Map of extended and validated Models by model name */
|
|
40
39
|
modelMap: Record<string, Model>;
|
|
41
40
|
/* Map of original Models (as provided by content source) by model name */
|
|
42
|
-
csiModelMap: Record<string, Model>;
|
|
41
|
+
csiModelMap: Record<string, CSITypes.Model>;
|
|
43
42
|
/* Array of original content source Documents */
|
|
44
43
|
csiDocuments: CSITypes.Document[];
|
|
45
44
|
/* Map of original content source Documents by document ID */
|
|
@@ -210,7 +209,7 @@ export class ContentStore {
|
|
|
210
209
|
for (const contentSourceInstance of this.contentSources) {
|
|
211
210
|
const contentSourceId = getContentSourceIdForContentSource(contentSourceInstance);
|
|
212
211
|
this.logger.debug(`call onFilesChange for contentSource: ${contentSourceId}`);
|
|
213
|
-
const { schemaChanged, contentChangeEvent } = await contentSourceInstance.onFilesChange?.({ updatedFiles: updatedFiles }) ?? {};
|
|
212
|
+
const { schemaChanged, contentChangeEvent } = (await contentSourceInstance.onFilesChange?.({ updatedFiles: updatedFiles })) ?? {};
|
|
214
213
|
this.logger.debug(`schemaChanged: ${schemaChanged}, has contentChangeEvent: ${!!contentChangeEvent}`);
|
|
215
214
|
// if schema is changed, there is no need to return contentChanges
|
|
216
215
|
// because schema changes reloads everything and implies content changes
|
|
@@ -284,7 +283,8 @@ export class ContentStore {
|
|
|
284
283
|
const defaultLocaleCode = locales?.find((locale) => locale.default)?.code;
|
|
285
284
|
|
|
286
285
|
// for older versions of stackbit, it uses models to extend content source models
|
|
287
|
-
let
|
|
286
|
+
let modelsNoImage: Exclude<Model, ImageModel>[] = [];
|
|
287
|
+
let imageModel: ImageModel | undefined;
|
|
288
288
|
if (this.rawStackbitConfig) {
|
|
289
289
|
const result = await extendConfig({
|
|
290
290
|
config: this.rawStackbitConfig,
|
|
@@ -294,37 +294,57 @@ export class ContentStore {
|
|
|
294
294
|
this.userLogger.warn(error.message);
|
|
295
295
|
}
|
|
296
296
|
const config = await this.handleConfigAssets(result.config);
|
|
297
|
-
|
|
297
|
+
const modelsWithImageModel = config?.models ?? [];
|
|
298
|
+
const imageModelIndex = modelsWithImageModel.findIndex((model) => isImageModel(model));
|
|
299
|
+
if (imageModelIndex > -1) {
|
|
300
|
+
imageModel = modelsWithImageModel[imageModelIndex] as ImageModel;
|
|
301
|
+
modelsWithImageModel.splice(imageModelIndex, 1);
|
|
302
|
+
}
|
|
303
|
+
modelsNoImage = modelsWithImageModel as Exclude<Model, ImageModel>[];
|
|
298
304
|
|
|
299
305
|
// TODO: load presets externally from config, and create additional map
|
|
300
306
|
// that maps presetIds by model name instead of storing that map inside every model
|
|
301
307
|
|
|
302
308
|
// Augment presets with srcType and srcProjectId if they don't exist
|
|
303
|
-
this.presets = _.reduce(
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
309
|
+
this.presets = _.reduce(
|
|
310
|
+
Object.keys(config?.presets ?? {}),
|
|
311
|
+
(accum: Record<string, Preset>, presetId) => {
|
|
312
|
+
const preset = config?.presets?.[presetId];
|
|
313
|
+
_.set(accum, [presetId], {
|
|
314
|
+
...preset,
|
|
315
|
+
srcType: preset?.srcType ?? contentSourceInstance.getContentSourceType(),
|
|
316
|
+
srcProjectId: preset?.srcProjectId ?? contentSourceInstance.getProjectId()
|
|
317
|
+
});
|
|
318
|
+
return accum;
|
|
319
|
+
},
|
|
320
|
+
{}
|
|
321
|
+
);
|
|
312
322
|
}
|
|
313
323
|
|
|
314
324
|
if (this.rawStackbitConfig?.mapModels) {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
325
|
+
const srcType = contentSourceInstance.getContentSourceType();
|
|
326
|
+
const srcProjectId = contentSourceInstance.getProjectId();
|
|
327
|
+
const modelsWithSource = modelsNoImage.map((model) => ({
|
|
328
|
+
srcType,
|
|
329
|
+
srcProjectId,
|
|
330
|
+
...model
|
|
331
|
+
}));
|
|
332
|
+
const mappedModels = this.rawStackbitConfig.mapModels({
|
|
333
|
+
models: modelsWithSource
|
|
334
|
+
});
|
|
335
|
+
modelsNoImage = mappedModels.map((model) => {
|
|
336
|
+
const { srcType, srcProjectId, ...rest } = model;
|
|
337
|
+
return rest;
|
|
319
338
|
});
|
|
320
339
|
}
|
|
321
340
|
|
|
341
|
+
const models: Model[] = imageModel ? [...modelsNoImage, imageModel] : modelsNoImage;
|
|
322
342
|
const modelMap = _.keyBy(models, 'name');
|
|
323
|
-
const
|
|
343
|
+
const csiModelMap = _.keyBy(csiModels, 'name');
|
|
344
|
+
const csiDocuments = await contentSourceInstance.getDocuments({ modelMap: csiModelMap });
|
|
324
345
|
const csiAssets = await contentSourceInstance.getAssets();
|
|
325
346
|
const csiDocumentMap = _.keyBy(csiDocuments, 'id');
|
|
326
347
|
const csiAssetMap = _.keyBy(csiAssets, 'id');
|
|
327
|
-
const csiModelMap = _.keyBy(csiModels, 'name');
|
|
328
348
|
|
|
329
349
|
const contentStoreDocuments = mapCSIDocumentsToStoreDocuments({
|
|
330
350
|
csiDocuments,
|
|
@@ -592,7 +612,7 @@ export class ContentStore {
|
|
|
592
612
|
srcProjectId,
|
|
593
613
|
...result
|
|
594
614
|
})
|
|
595
|
-
}
|
|
615
|
+
};
|
|
596
616
|
},
|
|
597
617
|
{
|
|
598
618
|
hasConnection: true,
|
|
@@ -1317,7 +1337,7 @@ export class ContentStore {
|
|
|
1317
1337
|
|
|
1318
1338
|
documents.push(...contentSourceData.documents);
|
|
1319
1339
|
_.set(schema, [contentSourceData.type, contentSourceData.projectId], contentSourceData.modelMap);
|
|
1320
|
-
})
|
|
1340
|
+
});
|
|
1321
1341
|
|
|
1322
1342
|
return searchDocuments({
|
|
1323
1343
|
...data,
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,6 @@ export * as consts from './consts';
|
|
|
6
6
|
export * from './common/common-schema';
|
|
7
7
|
export * from './common/common-types';
|
|
8
8
|
export * from './content-store';
|
|
9
|
-
export * as ContentSourceTypes from './content-source-interface';
|
|
10
9
|
export * as ContentStoreTypes from './content-store-types';
|
|
11
10
|
export { default as encodeData } from './encoder';
|
|
12
11
|
export * from './encoder';
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import slugify from 'slugify';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { Model } from '@stackbit/sdk';
|
|
5
|
+
import { Model as CSIModel, Field, FieldObjectProps, FieldSpecificProps, UpdateOperationListFieldItem } from '@stackbit/types';
|
|
5
6
|
import { mapPromise } from '@stackbit/utils';
|
|
7
|
+
import * as CSITypes from '@stackbit/types';
|
|
6
8
|
|
|
7
|
-
import * as CSITypes from '../content-source-interface';
|
|
8
9
|
import * as ContentStoreTypes from '../content-store-types';
|
|
9
10
|
|
|
10
11
|
export type CreateDocumentCallback = ({
|
|
@@ -21,7 +22,7 @@ export function getCreateDocumentThunk({
|
|
|
21
22
|
userContext,
|
|
22
23
|
contentSourceInstance
|
|
23
24
|
}: {
|
|
24
|
-
csiModelMap: Record<string,
|
|
25
|
+
csiModelMap: Record<string, CSIModel>;
|
|
25
26
|
locale?: string;
|
|
26
27
|
userContext: unknown;
|
|
27
28
|
contentSourceInstance: CSITypes.ContentSourceInterface;
|
|
@@ -315,15 +316,25 @@ async function createNestedField({
|
|
|
315
316
|
if (!itemsField) {
|
|
316
317
|
throw new Error(`list field does not define items`);
|
|
317
318
|
}
|
|
318
|
-
const arrayResult = await mapPromise(
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
319
|
+
const arrayResult = await mapPromise(
|
|
320
|
+
value,
|
|
321
|
+
async (item, index): Promise<{ field: UpdateOperationListFieldItem; newRefDocuments: CSITypes.Document[] }> => {
|
|
322
|
+
const result = await createNestedField({
|
|
323
|
+
value: item,
|
|
324
|
+
modelField: itemsField,
|
|
325
|
+
fieldPath: fieldPath.concat(index),
|
|
326
|
+
modelMap,
|
|
327
|
+
createDocument
|
|
328
|
+
});
|
|
329
|
+
if (result.field.type === 'list') {
|
|
330
|
+
throw new Error('list cannot have list as immediate child');
|
|
331
|
+
}
|
|
332
|
+
return {
|
|
333
|
+
field: result.field,
|
|
334
|
+
newRefDocuments: result.newRefDocuments
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
);
|
|
327
338
|
return {
|
|
328
339
|
field: {
|
|
329
340
|
type: 'list',
|
|
@@ -392,16 +403,22 @@ export async function convertOperationField({
|
|
|
392
403
|
if (modelField.type !== 'list') {
|
|
393
404
|
throw new Error(`'the operation field type '${operationField.type}' does not match the model field type '${modelField.type}'`);
|
|
394
405
|
}
|
|
395
|
-
const result = await mapPromise(
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
406
|
+
const result: UpdateOperationListFieldItem[] = await mapPromise(
|
|
407
|
+
operationField.items,
|
|
408
|
+
async (item): Promise<UpdateOperationListFieldItem> => {
|
|
409
|
+
const result = await createNestedField({
|
|
410
|
+
value: item,
|
|
411
|
+
modelField: modelField.items!,
|
|
412
|
+
fieldPath,
|
|
413
|
+
modelMap,
|
|
414
|
+
createDocument
|
|
415
|
+
});
|
|
416
|
+
if (result.field.type === 'list') {
|
|
417
|
+
throw new Error('list cannot have list as immediate child');
|
|
418
|
+
}
|
|
419
|
+
return result.field;
|
|
420
|
+
}
|
|
421
|
+
);
|
|
405
422
|
return {
|
|
406
423
|
type: operationField.type,
|
|
407
424
|
items: result
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import { Field, FieldListProps, FieldModelProps, FieldObjectProps, FieldSpecificProps, Model } from '@stackbit/sdk';
|
|
3
|
-
import { isLocalizedField } from '
|
|
4
|
-
import * as CSITypes from '
|
|
3
|
+
import { isLocalizedField } from '@stackbit/types';
|
|
4
|
+
import * as CSITypes from '@stackbit/types';
|
|
5
|
+
|
|
5
6
|
import * as ContentStoreTypes from '../content-store-types';
|
|
6
7
|
import { IMAGE_MODEL } from '../common/common-schema';
|
|
7
8
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import { Model } from '@stackbit/sdk';
|
|
3
|
+
import * as ContentSourceInterface from '@stackbit/types';
|
|
4
|
+
import { getLocalizedFieldForLocale } from '@stackbit/types';
|
|
5
|
+
|
|
3
6
|
import { SearchFilter, SearchFilterItem } from '../types/search-filter';
|
|
4
7
|
import { ContentStoreTypes } from '..';
|
|
5
|
-
import * as ContentSourceInterface from '../content-source-interface';
|
|
6
|
-
import { getLocalizedFieldForLocale } from '../content-source-interface';
|
|
7
8
|
|
|
8
9
|
const META_FIELD = {
|
|
9
10
|
createdAt: {
|
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
import type { Model, Field } from '@stackbit/sdk';
|
|
2
|
-
import { Logger as UtilsLogger } from '@stackbit/utils';
|
|
3
|
-
import { UserCommandSpawner } from './common/common-types';
|
|
4
|
-
export interface Logger extends UtilsLogger {
|
|
5
|
-
createLogger: ({ label }: {
|
|
6
|
-
label: string;
|
|
7
|
-
}) => Logger;
|
|
8
|
-
}
|
|
9
|
-
export declare type DocumentStatus = 'added' | 'modified' | 'published' | 'deleted';
|
|
10
|
-
export interface Locale {
|
|
11
|
-
code: string;
|
|
12
|
-
default?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export interface Document<DocumentContext = unknown> {
|
|
15
|
-
type: 'document';
|
|
16
|
-
id: string;
|
|
17
|
-
manageUrl: string;
|
|
18
|
-
modelName: string;
|
|
19
|
-
status: DocumentStatus;
|
|
20
|
-
createdAt: string;
|
|
21
|
-
createdBy?: string;
|
|
22
|
-
updatedAt: string;
|
|
23
|
-
updatedBy?: string[];
|
|
24
|
-
fields: Record<string, DocumentField>;
|
|
25
|
-
context: DocumentContext;
|
|
26
|
-
}
|
|
27
|
-
export interface Asset<AssetContext = unknown> {
|
|
28
|
-
type: 'asset';
|
|
29
|
-
id: string;
|
|
30
|
-
manageUrl: string;
|
|
31
|
-
status: DocumentStatus;
|
|
32
|
-
createdAt: string;
|
|
33
|
-
createdBy?: string;
|
|
34
|
-
updatedAt: string;
|
|
35
|
-
updatedBy?: string[];
|
|
36
|
-
fields: AssetFields;
|
|
37
|
-
context: AssetContext;
|
|
38
|
-
}
|
|
39
|
-
export declare type AssetFields = {
|
|
40
|
-
title: DocumentValueFieldForType<'string'>;
|
|
41
|
-
file: AssetFileField;
|
|
42
|
-
};
|
|
43
|
-
export declare type DocumentField = DocumentValueField | DocumentObjectField | DocumentModelField | DocumentReferenceField | DocumentListField | DocumentRichTextField | DocumentImageField;
|
|
44
|
-
export declare type DocumentFieldLocalized = DocumentValueFieldLocalized | DocumentObjectFieldLocalized | DocumentModelFieldLocalized | DocumentReferenceFieldLocalized | DocumentListFieldLocalized | DocumentRichTextFieldLocalized | DocumentImageFieldLocalized;
|
|
45
|
-
export declare type DocumentFieldNonLocalized = DocumentValueFieldNonLocalized | DocumentObjectFieldNonLocalized | DocumentModelFieldNonLocalized | DocumentReferenceFieldNonLocalized | DocumentListFieldNonLocalized | DocumentRichTextFieldNonLocalized | DocumentImageFieldNonLocalized;
|
|
46
|
-
export declare type DocumentFieldBaseProps = DocumentValueFieldBaseProps | DocumentObjectFieldBase | DocumentModelFieldBase | DocumentReferenceFieldBase | DocumentListFieldBase | DocumentRichTextFieldBase | DocumentImageFieldBase;
|
|
47
|
-
export declare type DocumentFieldSpecificProps = DocumentValueFieldProps | DocumentObjectFieldProps | DocumentModelFieldProps | DocumentReferenceFieldProps | DocumentListFieldProps | DocumentRichTextFieldProps | DocumentImageFieldProps;
|
|
48
|
-
export declare function isLocalizedField(field: DocumentField | AssetFileField): field is DocumentFieldLocalized | AssetFileFieldLocalized;
|
|
49
|
-
export declare function getLocalizedFieldForLocale<Type extends FieldType>(field: DocumentFieldForType<Type>, locale?: string): DocumentFieldNonLocalizedForType<Type> | null;
|
|
50
|
-
export declare type FieldType = 'string' | 'url' | 'slug' | 'text' | 'markdown' | 'html' | 'number' | 'boolean' | 'enum' | 'date' | 'datetime' | 'color' | 'image' | 'file' | 'json' | 'richText' | 'object' | 'model' | 'reference' | 'style' | 'list';
|
|
51
|
-
export declare type Simplify<T> = {
|
|
52
|
-
[K in keyof T]: T[K];
|
|
53
|
-
};
|
|
54
|
-
export declare type FindByType<Union extends {
|
|
55
|
-
type: FieldType;
|
|
56
|
-
}, Type> = Union extends {
|
|
57
|
-
type: Type;
|
|
58
|
-
} ? Union : never;
|
|
59
|
-
export declare type DocumentFieldForType<Type extends FieldType> = FindByType<DocumentField, Type>;
|
|
60
|
-
export declare type DocumentFieldLocalizedForType<Type extends FieldType> = FindByType<DocumentFieldLocalized, Type>;
|
|
61
|
-
export declare type DocumentFieldNonLocalizedForType<Type extends FieldType> = FindByType<DocumentFieldNonLocalized, Type>;
|
|
62
|
-
export declare type DocumentFieldBasePropsForType<Type extends FieldType> = FindByType<DocumentFieldBaseProps, Type>;
|
|
63
|
-
export declare type DocumentFieldSpecificPropsForType<Type extends FieldType> = Simplify<Omit<DocumentFieldNonLocalizedForType<Type>, keyof DocumentFieldBasePropsForType<Type> | 'locale' | 'localized'>>;
|
|
64
|
-
export declare type DocumentFieldTypeLocalized<BaseFieldProps, LocalizedFieldProps> = Simplify<BaseFieldProps & {
|
|
65
|
-
localized: true;
|
|
66
|
-
locales: Record<string, {
|
|
67
|
-
locale: string;
|
|
68
|
-
} & LocalizedFieldProps>;
|
|
69
|
-
}>;
|
|
70
|
-
export declare type DocumentFieldTypeNonLocalized<BaseFieldProps, LocalizedFieldProps> = Simplify<BaseFieldProps & LocalizedFieldProps & {
|
|
71
|
-
localized?: false;
|
|
72
|
-
locale?: string;
|
|
73
|
-
}>;
|
|
74
|
-
export declare type DocumentValueFieldType = Exclude<FieldType, 'object' | 'model' | 'reference' | 'richText' | 'list' | 'image'>;
|
|
75
|
-
export declare type DocumentValueFieldForType<Type> = Type extends DocumentValueFieldType ? DocumentValueFieldLocalizedForType<Type> | DocumentValueFieldNonLocalizedForType<Type> : never;
|
|
76
|
-
export declare type DocumentValueField = DocumentValueFieldForType<DocumentValueFieldType>;
|
|
77
|
-
export declare type DocumentValueFieldLocalizedForType<Type> = Type extends DocumentValueFieldType ? DocumentFieldTypeLocalized<DocumentValueFieldBase<Type>, DocumentValueFieldProps> : never;
|
|
78
|
-
export declare type DocumentValueFieldLocalized = DocumentValueFieldLocalizedForType<DocumentValueFieldType>;
|
|
79
|
-
export declare type DocumentValueFieldNonLocalizedForType<Type> = Type extends DocumentValueFieldType ? DocumentFieldTypeNonLocalized<DocumentValueFieldBase<Type>, DocumentValueFieldProps> : never;
|
|
80
|
-
export declare type DocumentValueFieldNonLocalized = DocumentValueFieldNonLocalizedForType<DocumentValueFieldType>;
|
|
81
|
-
export declare type DocumentValueFieldBasePropsForType<Type> = Type extends DocumentValueFieldType ? DocumentValueFieldBase<Type> : never;
|
|
82
|
-
export declare type DocumentValueFieldBaseProps = DocumentValueFieldBasePropsForType<DocumentValueFieldType>;
|
|
83
|
-
export declare type DocumentValueFieldBase<Type extends DocumentValueFieldType> = {
|
|
84
|
-
type: Type;
|
|
85
|
-
};
|
|
86
|
-
export declare type DocumentValueFieldProps = {
|
|
87
|
-
value: any;
|
|
88
|
-
};
|
|
89
|
-
export declare type DocumentObjectField = DocumentObjectFieldLocalized | DocumentObjectFieldNonLocalized;
|
|
90
|
-
export declare type DocumentObjectFieldLocalized = DocumentFieldTypeLocalized<DocumentObjectFieldBase, DocumentObjectFieldProps>;
|
|
91
|
-
export declare type DocumentObjectFieldNonLocalized = DocumentFieldTypeNonLocalized<DocumentObjectFieldBase, DocumentObjectFieldProps>;
|
|
92
|
-
export declare type DocumentObjectFieldBase = {
|
|
93
|
-
type: 'object';
|
|
94
|
-
};
|
|
95
|
-
export declare type DocumentObjectFieldProps = {
|
|
96
|
-
fields: Record<string, DocumentField>;
|
|
97
|
-
};
|
|
98
|
-
export declare type DocumentModelField = DocumentModelFieldLocalized | DocumentModelFieldNonLocalized;
|
|
99
|
-
export declare type DocumentModelFieldLocalized = DocumentFieldTypeLocalized<DocumentModelFieldBase, DocumentModelFieldProps>;
|
|
100
|
-
export declare type DocumentModelFieldNonLocalized = DocumentFieldTypeNonLocalized<DocumentModelFieldBase, DocumentModelFieldProps>;
|
|
101
|
-
export declare type DocumentModelFieldBase = {
|
|
102
|
-
type: 'model';
|
|
103
|
-
};
|
|
104
|
-
export declare type DocumentModelFieldProps = {
|
|
105
|
-
modelName: string;
|
|
106
|
-
fields: Record<string, DocumentField>;
|
|
107
|
-
};
|
|
108
|
-
export declare type DocumentReferenceField = DocumentReferenceFieldLocalized | DocumentReferenceFieldNonLocalized;
|
|
109
|
-
export declare type DocumentReferenceFieldLocalized = DocumentFieldTypeLocalized<DocumentReferenceFieldBase, DocumentReferenceFieldProps>;
|
|
110
|
-
export declare type DocumentReferenceFieldNonLocalized = DocumentFieldTypeNonLocalized<DocumentReferenceFieldBase, DocumentReferenceFieldProps>;
|
|
111
|
-
export declare type DocumentReferenceFieldBase = {
|
|
112
|
-
type: 'reference';
|
|
113
|
-
refType: 'document' | 'asset';
|
|
114
|
-
};
|
|
115
|
-
export declare type DocumentReferenceFieldProps = {
|
|
116
|
-
refId: string;
|
|
117
|
-
};
|
|
118
|
-
export declare type DocumentRichTextField = DocumentRichTextFieldLocalized | DocumentRichTextFieldNonLocalized;
|
|
119
|
-
export declare type DocumentRichTextFieldLocalized = DocumentFieldTypeLocalized<DocumentRichTextFieldBase, DocumentRichTextFieldProps>;
|
|
120
|
-
export declare type DocumentRichTextFieldNonLocalized = DocumentFieldTypeNonLocalized<DocumentRichTextFieldBase, DocumentRichTextFieldProps>;
|
|
121
|
-
export declare type DocumentRichTextFieldBase = {
|
|
122
|
-
type: 'richText';
|
|
123
|
-
};
|
|
124
|
-
export declare type DocumentRichTextFieldProps = {
|
|
125
|
-
hint?: string;
|
|
126
|
-
value: any;
|
|
127
|
-
};
|
|
128
|
-
export declare type DocumentListField = DocumentListFieldLocalized | DocumentListFieldNonLocalized;
|
|
129
|
-
export declare type DocumentListFieldLocalized = DocumentFieldTypeLocalized<DocumentListFieldBase, DocumentListFieldProps>;
|
|
130
|
-
export declare type DocumentListFieldNonLocalized = DocumentFieldTypeNonLocalized<DocumentListFieldBase, DocumentListFieldProps>;
|
|
131
|
-
export declare type DocumentListFieldBase = {
|
|
132
|
-
type: 'list';
|
|
133
|
-
};
|
|
134
|
-
export declare type DocumentListFieldProps = {
|
|
135
|
-
items: DocumentFieldNonLocalized[];
|
|
136
|
-
};
|
|
137
|
-
export declare type DocumentImageField = DocumentImageFieldLocalized | DocumentImageFieldNonLocalized;
|
|
138
|
-
export declare type DocumentImageFieldLocalized = DocumentFieldTypeLocalized<DocumentImageFieldBase, DocumentImageFieldProps>;
|
|
139
|
-
export declare type DocumentImageFieldNonLocalized = DocumentFieldTypeNonLocalized<DocumentImageFieldBase, DocumentImageFieldProps>;
|
|
140
|
-
export declare type DocumentImageFieldBase = {
|
|
141
|
-
type: 'image';
|
|
142
|
-
};
|
|
143
|
-
export declare type DocumentImageFieldProps = {
|
|
144
|
-
fields: {
|
|
145
|
-
title: DocumentValueFieldForType<'string'>;
|
|
146
|
-
url: DocumentValueFieldForType<'string'>;
|
|
147
|
-
};
|
|
148
|
-
};
|
|
149
|
-
export declare type AssetFileField = AssetFileFieldLocalized | AssetFileFieldNonLocalized;
|
|
150
|
-
export declare type AssetFileFieldLocalized = DocumentFieldTypeLocalized<AssetFileFieldBase, AssetFileFieldProps>;
|
|
151
|
-
export declare type AssetFileFieldNonLocalized = DocumentFieldTypeNonLocalized<AssetFileFieldBase, AssetFileFieldProps>;
|
|
152
|
-
export declare type AssetFileFieldBase = {
|
|
153
|
-
type: 'assetFile';
|
|
154
|
-
};
|
|
155
|
-
export declare type AssetFileFieldProps = {
|
|
156
|
-
url: string;
|
|
157
|
-
fileName?: string;
|
|
158
|
-
contentType?: string;
|
|
159
|
-
size?: number;
|
|
160
|
-
dimensions: {
|
|
161
|
-
width?: number;
|
|
162
|
-
height?: number;
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
|
-
export interface InitOptions {
|
|
166
|
-
logger: Logger;
|
|
167
|
-
userLogger: Logger;
|
|
168
|
-
userCommandSpawner?: UserCommandSpawner;
|
|
169
|
-
localDev: boolean;
|
|
170
|
-
}
|
|
171
|
-
export interface ContentChangeEvent<DocumentContext = unknown, AssetContext = unknown> {
|
|
172
|
-
documents: Document<DocumentContext>[];
|
|
173
|
-
assets: Asset<AssetContext>[];
|
|
174
|
-
deletedDocumentIds: string[];
|
|
175
|
-
deletedAssetIds: string[];
|
|
176
|
-
}
|
|
177
|
-
export declare type UpdateOperation = UpdateOperationSet | UpdateOperationUnset | UpdateOperationInsert | UpdateOperationRemove | UpdateOperationReorder;
|
|
178
|
-
export declare type UpdateOperationBase = {
|
|
179
|
-
opType: string;
|
|
180
|
-
fieldPath: (string | number)[];
|
|
181
|
-
modelField: Field;
|
|
182
|
-
locale?: string;
|
|
183
|
-
};
|
|
184
|
-
export declare type UpdateOperationSet = Simplify<UpdateOperationBase & {
|
|
185
|
-
opType: 'set';
|
|
186
|
-
field: UpdateOperationField;
|
|
187
|
-
}>;
|
|
188
|
-
export declare type UpdateOperationUnset = Simplify<UpdateOperationBase & {
|
|
189
|
-
opType: 'unset';
|
|
190
|
-
}>;
|
|
191
|
-
export declare type UpdateOperationInsert = Simplify<UpdateOperationBase & {
|
|
192
|
-
opType: 'insert';
|
|
193
|
-
index?: number;
|
|
194
|
-
item: UpdateOperationField;
|
|
195
|
-
}>;
|
|
196
|
-
export declare type UpdateOperationRemove = Simplify<UpdateOperationBase & {
|
|
197
|
-
opType: 'remove';
|
|
198
|
-
index: number;
|
|
199
|
-
}>;
|
|
200
|
-
export declare type UpdateOperationReorder = Simplify<UpdateOperationBase & {
|
|
201
|
-
opType: 'reorder';
|
|
202
|
-
order: number[];
|
|
203
|
-
}>;
|
|
204
|
-
export declare type UpdateOperationField = UpdateOperationValueField | UpdateOperationObjectField | UpdateOperationModelField | UpdateOperationReferenceField | UpdateOperationListField;
|
|
205
|
-
export declare type UpdateOperationValueFieldType = Exclude<FieldType, 'object' | 'model' | 'reference' | 'list'>;
|
|
206
|
-
export declare type UpdateOperationValueField<Type = UpdateOperationValueFieldType> = Type extends UpdateOperationValueFieldType ? UpdateOperationValueFieldForType<Type> : never;
|
|
207
|
-
export declare type UpdateOperationValueFieldForType<Type extends UpdateOperationValueFieldType> = {
|
|
208
|
-
type: Type;
|
|
209
|
-
value: any;
|
|
210
|
-
};
|
|
211
|
-
export declare type UpdateOperationObjectField = {
|
|
212
|
-
type: 'object';
|
|
213
|
-
fields: Record<string, UpdateOperationField>;
|
|
214
|
-
};
|
|
215
|
-
export declare type UpdateOperationModelField = {
|
|
216
|
-
type: 'model';
|
|
217
|
-
modelName: string;
|
|
218
|
-
fields: Record<string, UpdateOperationField>;
|
|
219
|
-
};
|
|
220
|
-
export declare type UpdateOperationReferenceField = {
|
|
221
|
-
type: 'reference';
|
|
222
|
-
refType: 'document' | 'asset';
|
|
223
|
-
refId: string;
|
|
224
|
-
};
|
|
225
|
-
export declare type UpdateOperationListField = {
|
|
226
|
-
type: 'list';
|
|
227
|
-
items: UpdateOperationField[];
|
|
228
|
-
};
|
|
229
|
-
export declare type ValidationError = {
|
|
230
|
-
message: string;
|
|
231
|
-
objectType: 'document' | 'asset';
|
|
232
|
-
objectId: string;
|
|
233
|
-
fieldPath: (string | number)[];
|
|
234
|
-
isUniqueValidation?: boolean;
|
|
235
|
-
};
|
|
236
|
-
export declare type ModelMap = Record<string, Model>;
|
|
237
|
-
export interface ContentSourceInterface<UserContext = unknown, DocumentContext = unknown, AssetContext = unknown> {
|
|
238
|
-
/**
|
|
239
|
-
* This function should return the type of the content source.
|
|
240
|
-
* The type must be unique among other content sources within the same project.
|
|
241
|
-
*/
|
|
242
|
-
getContentSourceType(): string;
|
|
243
|
-
/**
|
|
244
|
-
* This function should return the project ID of the content source.
|
|
245
|
-
* The ID must be unique among other content sources of the same type.
|
|
246
|
-
*/
|
|
247
|
-
getProjectId(): string;
|
|
248
|
-
getProjectEnvironment(): string;
|
|
249
|
-
getProjectManageUrl(): string;
|
|
250
|
-
/**
|
|
251
|
-
* This function should initialize the content source by fetching the schema
|
|
252
|
-
* and everything else needed to produce the StackbitSchema
|
|
253
|
-
*/
|
|
254
|
-
init(options: InitOptions): Promise<void>;
|
|
255
|
-
reset(): Promise<void>;
|
|
256
|
-
onFilesChange?({ updatedFiles }: {
|
|
257
|
-
updatedFiles: string[];
|
|
258
|
-
}): Promise<{
|
|
259
|
-
schemaChanged?: boolean;
|
|
260
|
-
contentChangeEvent?: ContentChangeEvent<DocumentContext, AssetContext>;
|
|
261
|
-
}>;
|
|
262
|
-
startWatchingContentUpdates(options: {
|
|
263
|
-
getModelMap: () => ModelMap;
|
|
264
|
-
getDocument: ({ documentId }: {
|
|
265
|
-
documentId: string;
|
|
266
|
-
}) => Document<DocumentContext> | undefined;
|
|
267
|
-
getAsset: ({ assetId }: {
|
|
268
|
-
assetId: string;
|
|
269
|
-
}) => Asset<AssetContext> | undefined;
|
|
270
|
-
onContentChange: (contentChangeEvent: ContentChangeEvent<DocumentContext, AssetContext>) => void;
|
|
271
|
-
onSchemaChange: () => void;
|
|
272
|
-
}): void;
|
|
273
|
-
stopWatchingContentUpdates(): void;
|
|
274
|
-
/**
|
|
275
|
-
* This function is responsible to fetch and convert content models
|
|
276
|
-
* to Stackbit models.
|
|
277
|
-
*/
|
|
278
|
-
getModels(): Promise<Model[]>;
|
|
279
|
-
getLocales(): Promise<Locale[]>;
|
|
280
|
-
/**
|
|
281
|
-
* This function should fetch the documents and convert them into Stackbit's
|
|
282
|
-
* Document type
|
|
283
|
-
*/
|
|
284
|
-
getDocuments(options: {
|
|
285
|
-
modelMap: ModelMap;
|
|
286
|
-
}): Promise<Document<DocumentContext>[]>;
|
|
287
|
-
getAssets(): Promise<Asset<AssetContext>[]>;
|
|
288
|
-
hasAccess(options: {
|
|
289
|
-
userContext?: UserContext;
|
|
290
|
-
}): Promise<{
|
|
291
|
-
hasConnection: boolean;
|
|
292
|
-
hasPermissions: boolean;
|
|
293
|
-
}>;
|
|
294
|
-
createDocument(options: {
|
|
295
|
-
updateOperationFields: Record<string, UpdateOperationField>;
|
|
296
|
-
model: Model;
|
|
297
|
-
modelMap: ModelMap;
|
|
298
|
-
locale?: string;
|
|
299
|
-
userContext?: UserContext;
|
|
300
|
-
}): Promise<Document<DocumentContext>>;
|
|
301
|
-
updateDocument(options: {
|
|
302
|
-
document: Document<DocumentContext>;
|
|
303
|
-
operations: UpdateOperation[];
|
|
304
|
-
modelMap: ModelMap;
|
|
305
|
-
userContext?: UserContext;
|
|
306
|
-
}): Promise<Document<DocumentContext>>;
|
|
307
|
-
deleteDocument(options: {
|
|
308
|
-
document: Document<DocumentContext>;
|
|
309
|
-
userContext?: UserContext;
|
|
310
|
-
}): Promise<void>;
|
|
311
|
-
uploadAsset(options: {
|
|
312
|
-
url?: string;
|
|
313
|
-
base64?: string;
|
|
314
|
-
fileName: string;
|
|
315
|
-
mimeType: string;
|
|
316
|
-
locale?: string;
|
|
317
|
-
userContext?: UserContext;
|
|
318
|
-
}): Promise<Asset<AssetContext>>;
|
|
319
|
-
validateDocuments(options: {
|
|
320
|
-
documents: Document<DocumentContext>[];
|
|
321
|
-
assets: Asset<AssetContext>[];
|
|
322
|
-
locale?: string;
|
|
323
|
-
userContext?: UserContext;
|
|
324
|
-
}): Promise<{
|
|
325
|
-
errors: ValidationError[];
|
|
326
|
-
}>;
|
|
327
|
-
publishDocuments(options: {
|
|
328
|
-
documents: Document<DocumentContext>[];
|
|
329
|
-
assets: Asset<AssetContext>[];
|
|
330
|
-
userContext?: UserContext;
|
|
331
|
-
}): Promise<void>;
|
|
332
|
-
}
|
|
333
|
-
//# sourceMappingURL=content-source-interface.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"content-source-interface.d.ts","sourceRoot":"","sources":["../src/content-source-interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAA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,eAAe,CAAC,EAAE,CAAC;QAAC,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC;QAAC,WAAW,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClJ"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getLocalizedFieldForLocale = exports.isLocalizedField = void 0;
|
|
4
|
-
function isLocalizedField(field) {
|
|
5
|
-
return !!field.localized;
|
|
6
|
-
}
|
|
7
|
-
exports.isLocalizedField = isLocalizedField;
|
|
8
|
-
function getLocalizedFieldForLocale(field, locale) {
|
|
9
|
-
if (field.localized) {
|
|
10
|
-
if (!locale) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
const { localized, locales, ...base } = field;
|
|
14
|
-
const localizedField = locales[locale];
|
|
15
|
-
if (!localizedField) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
...base,
|
|
20
|
-
...localizedField
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
return field;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.getLocalizedFieldForLocale = getLocalizedFieldForLocale;
|
|
28
|
-
//# sourceMappingURL=content-source-interface.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"content-source-interface.js","sourceRoot":"","sources":["../src/content-source-interface.ts"],"names":[],"mappings":";;;AA4FA,SAAgB,gBAAgB,CAAC,KAAqC;IAClE,OAAO,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;AAC7B,CAAC;AAFD,4CAEC;AAED,SAAgB,0BAA0B,CACtC,KAAiC,EACjC,MAAe;IAEf,IAAI,KAAK,CAAC,SAAS,EAAE;QACjB,IAAI,CAAC,MAAM,EAAE;YACT,OAAO,IAAI,CAAC;SACf;QACD,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;QAC9C,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,cAAc,EAAE;YACjB,OAAO,IAAI,CAAC;SACf;QACD,OAAO;YACH,GAAG,IAAI;YACP,GAAG,cAAc;SACiC,CAAC;KAC1D;SAAM;QACH,OAAO,KAAK,CAAC;KAChB;AACL,CAAC;AApBD,gEAoBC"}
|