@stackbit/cms-core 0.6.3-develop.3 → 0.6.4-develop.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/content-store.d.ts.map +1 -1
- package/dist/content-store.js +4 -2
- package/dist/content-store.js.map +1 -1
- package/dist/utils/config-delegate.d.ts.map +1 -1
- package/dist/utils/config-delegate.js +27 -8
- package/dist/utils/config-delegate.js.map +1 -1
- package/dist/utils/site-map.d.ts +5 -2
- package/dist/utils/site-map.d.ts.map +1 -1
- package/dist/utils/site-map.js +27 -6
- package/dist/utils/site-map.js.map +1 -1
- package/dist/utils/store-to-csi-docs-converter.d.ts +21 -2
- package/dist/utils/store-to-csi-docs-converter.d.ts.map +1 -1
- package/dist/utils/store-to-csi-docs-converter.js +20 -4
- package/dist/utils/store-to-csi-docs-converter.js.map +1 -1
- package/package.json +5 -5
- package/src/content-store.ts +4 -2
- package/src/utils/config-delegate.ts +31 -9
- package/src/utils/site-map.ts +37 -6
- package/src/utils/store-to-csi-docs-converter.ts +41 -9
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
import * as CSITypes from '@stackbit/types';
|
|
2
2
|
import * as ContentStoreTypes from '../types';
|
|
3
|
-
export declare function mapStoreDocumentsToCSIDocumentsWithSource(documents
|
|
4
|
-
|
|
3
|
+
export declare function mapStoreDocumentsToCSIDocumentsWithSource({ documents, csiDocumentMap }: {
|
|
4
|
+
documents: ContentStoreTypes.Document[];
|
|
5
|
+
csiDocumentMap: Record<string, CSITypes.Document>;
|
|
6
|
+
}): CSITypes.DocumentWithSource[];
|
|
7
|
+
/**
|
|
8
|
+
* This method converts documents stored in an internal ContentStoreTypes.Document
|
|
9
|
+
* format to documents in a public CSITypes.DocumentWithSource format. These
|
|
10
|
+
* documents are then passed to document hook and sitemap functions defined in
|
|
11
|
+
* stackbit.config.ts.
|
|
12
|
+
*
|
|
13
|
+
* Most of the properties, including fields and their types, are taken from the
|
|
14
|
+
* internal documents that contain changes made by mapDocuments, mapModels and
|
|
15
|
+
* modelExtensions functions.
|
|
16
|
+
*
|
|
17
|
+
* The document's context is taken from the CSI Document because context is not
|
|
18
|
+
* included in the internal documents.
|
|
19
|
+
*/
|
|
20
|
+
export declare function mapStoreDocumentToCSIDocumentWithSource({ document, csiDocument }: {
|
|
21
|
+
document: ContentStoreTypes.Document;
|
|
22
|
+
csiDocument: CSITypes.Document;
|
|
23
|
+
}): CSITypes.DocumentWithSource;
|
|
5
24
|
//# sourceMappingURL=store-to-csi-docs-converter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store-to-csi-docs-converter.d.ts","sourceRoot":"","sources":["../../src/utils/store-to-csi-docs-converter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,iBAAiB,MAAM,UAAU,CAAC;AAE9C,wBAAgB,yCAAyC,CAAC,SAAS,EAAE,iBAAiB,CAAC,QAAQ,EAAE,GAAG,QAAQ,CAAC,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"store-to-csi-docs-converter.d.ts","sourceRoot":"","sources":["../../src/utils/store-to-csi-docs-converter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,iBAAiB,MAAM,UAAU,CAAC;AAE9C,wBAAgB,yCAAyC,CAAC,EACtD,SAAS,EACT,cAAc,EACjB,EAAE;IACC,SAAS,EAAE,iBAAiB,CAAC,QAAQ,EAAE,CAAC;IACxC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;CACrD,GAAG,QAAQ,CAAC,kBAAkB,EAAE,CAOhC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,uCAAuC,CAAC,EACpD,QAAQ,EACR,WAAW,EACd,EAAE;IACC,QAAQ,EAAE,iBAAiB,CAAC,QAAQ,CAAC;IACrC,WAAW,EAAE,QAAQ,CAAC,QAAQ,CAAC;CAClC,GAAG,QAAQ,CAAC,kBAAkB,CAiB9B"}
|
|
@@ -6,11 +6,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.mapStoreDocumentToCSIDocumentWithSource = exports.mapStoreDocumentsToCSIDocumentsWithSource = void 0;
|
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
8
|
const utils_1 = require("@stackbit/utils");
|
|
9
|
-
function mapStoreDocumentsToCSIDocumentsWithSource(documents) {
|
|
10
|
-
return documents.map((document) => mapStoreDocumentToCSIDocumentWithSource(
|
|
9
|
+
function mapStoreDocumentsToCSIDocumentsWithSource({ documents, csiDocumentMap }) {
|
|
10
|
+
return documents.map((document) => mapStoreDocumentToCSIDocumentWithSource({
|
|
11
|
+
document,
|
|
12
|
+
csiDocument: csiDocumentMap[document.srcObjectId]
|
|
13
|
+
}));
|
|
11
14
|
}
|
|
12
15
|
exports.mapStoreDocumentsToCSIDocumentsWithSource = mapStoreDocumentsToCSIDocumentsWithSource;
|
|
13
|
-
|
|
16
|
+
/**
|
|
17
|
+
* This method converts documents stored in an internal ContentStoreTypes.Document
|
|
18
|
+
* format to documents in a public CSITypes.DocumentWithSource format. These
|
|
19
|
+
* documents are then passed to document hook and sitemap functions defined in
|
|
20
|
+
* stackbit.config.ts.
|
|
21
|
+
*
|
|
22
|
+
* Most of the properties, including fields and their types, are taken from the
|
|
23
|
+
* internal documents that contain changes made by mapDocuments, mapModels and
|
|
24
|
+
* modelExtensions functions.
|
|
25
|
+
*
|
|
26
|
+
* The document's context is taken from the CSI Document because context is not
|
|
27
|
+
* included in the internal documents.
|
|
28
|
+
*/
|
|
29
|
+
function mapStoreDocumentToCSIDocumentWithSource({ document, csiDocument }) {
|
|
14
30
|
return {
|
|
15
31
|
type: document.type,
|
|
16
32
|
id: document.srcObjectId,
|
|
@@ -24,7 +40,7 @@ function mapStoreDocumentToCSIDocumentWithSource(document) {
|
|
|
24
40
|
updatedAt: document.updatedAt,
|
|
25
41
|
updatedBy: document.updatedBy,
|
|
26
42
|
locale: document.locale,
|
|
27
|
-
context:
|
|
43
|
+
context: csiDocument.context,
|
|
28
44
|
fields: mapStoreFieldsToCSIFields(document.fields)
|
|
29
45
|
};
|
|
30
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store-to-csi-docs-converter.js","sourceRoot":"","sources":["../../src/utils/store-to-csi-docs-converter.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAEvB,2CAA4C;AAG5C,SAAgB,yCAAyC,CAAC,
|
|
1
|
+
{"version":3,"file":"store-to-csi-docs-converter.js","sourceRoot":"","sources":["../../src/utils/store-to-csi-docs-converter.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAEvB,2CAA4C;AAG5C,SAAgB,yCAAyC,CAAC,EACtD,SAAS,EACT,cAAc,EAIjB;IACG,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAC9B,uCAAuC,CAAC;QACpC,QAAQ;QACR,WAAW,EAAE,cAAc,CAAC,QAAQ,CAAC,WAAW,CAAE;KACrD,CAAC,CACL,CAAC;AACN,CAAC;AAbD,8FAaC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,uCAAuC,CAAC,EACpD,QAAQ,EACR,WAAW,EAId;IACG,OAAO;QACH,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,EAAE,EAAE,QAAQ,CAAC,WAAW;QACxB,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,SAAS,EAAE,QAAQ,CAAC,YAAY;QAChC,SAAS,EAAE,QAAQ,CAAC,YAAY;QAChC,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,SAAS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gBACZ,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KAAwC,EAAE,IAAI,EAAE,EAAE;oBACjF,MAAM,OAAO,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAC;oBAC9C,iFAAiF;oBACjF,kDAAkD;oBAClD,IAAI,CAAC,OAAO,EAAE;wBACV,OAAO,KAAK,CAAC;qBAChB;oBACD,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBACjC,CAAC,EAAE,EAAE,CAAC;aACT,CAAC;SACL;QACD,OAAO,CAAC,CAAC;YACL,MAAM,gBAAgB,GAAU,aAAa,CAAC;YAC9C,OAAO,gBAAgB,CAAC;SAC3B;KACJ;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackbit/cms-core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4-develop.1",
|
|
4
4
|
"description": "stackbit-dev",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"@babel/parser": "^7.11.5",
|
|
26
26
|
"@babel/traverse": "^7.11.5",
|
|
27
27
|
"@iarna/toml": "^2.2.3",
|
|
28
|
-
"@stackbit/sdk": "0.5.
|
|
29
|
-
"@stackbit/types": "0.7.
|
|
30
|
-
"@stackbit/utils": "0.2.
|
|
28
|
+
"@stackbit/sdk": "0.5.7-develop.1",
|
|
29
|
+
"@stackbit/types": "0.7.4-develop.1",
|
|
30
|
+
"@stackbit/utils": "0.2.34-develop.1",
|
|
31
31
|
"chalk": "^4.0.1",
|
|
32
32
|
"esm": "^3.2.25",
|
|
33
33
|
"fs-extra": "^8.1.0",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"slugify": "^1.6.5",
|
|
43
43
|
"uuid": "^9.0.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "0494991c64c1ec788204e9e1dd2f66520bd47cdb"
|
|
46
46
|
}
|
package/src/content-store.ts
CHANGED
|
@@ -463,7 +463,8 @@ export class ContentStore {
|
|
|
463
463
|
// generate create site map entries
|
|
464
464
|
this.siteMapEntryGroups = await getSiteMapEntriesFromStackbitConfig({
|
|
465
465
|
stackbitConfig: this.stackbitConfig,
|
|
466
|
-
contentSourceDataById: this.contentSourceDataById
|
|
466
|
+
contentSourceDataById: this.contentSourceDataById,
|
|
467
|
+
logger: this.userLogger
|
|
467
468
|
});
|
|
468
469
|
|
|
469
470
|
if (!init) {
|
|
@@ -546,7 +547,8 @@ export class ContentStore {
|
|
|
546
547
|
siteMapEntryGroups: this.siteMapEntryGroups,
|
|
547
548
|
contentChanges: contentChanges,
|
|
548
549
|
stackbitConfig: this.stackbitConfig,
|
|
549
|
-
contentSourceDataById: this.contentSourceDataById
|
|
550
|
+
contentSourceDataById: this.contentSourceDataById,
|
|
551
|
+
logger: this.userLogger
|
|
550
552
|
});
|
|
551
553
|
// If presets were updated, call onSchemaChangeCallback to notify the Studio.
|
|
552
554
|
// The Studio will refresh the models and the documents, so no need to notify
|
|
@@ -35,19 +35,33 @@ export function createConfigDelegate({
|
|
|
35
35
|
srcProjectId,
|
|
36
36
|
logger
|
|
37
37
|
});
|
|
38
|
+
|
|
38
39
|
if (document) {
|
|
39
|
-
|
|
40
|
+
const contentSourceId = getContentSourceId(document.srcType, document.srcProjectId);
|
|
41
|
+
const csiDocument = contentSourceDataById[contentSourceId]!.csiDocumentMap[document.srcObjectId];
|
|
42
|
+
if (!csiDocument) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
return mapStoreDocumentToCSIDocumentWithSource({
|
|
46
|
+
document,
|
|
47
|
+
csiDocument
|
|
48
|
+
});
|
|
40
49
|
}
|
|
41
50
|
return undefined;
|
|
42
51
|
},
|
|
43
|
-
getDocuments: ({ srcType, srcProjectId }): CSITypes.DocumentWithSource[] => {
|
|
52
|
+
getDocuments: ({ srcType, srcProjectId } = {}): CSITypes.DocumentWithSource[] => {
|
|
44
53
|
const contentSourcesData = findContentSourcesDataForTypeOrId({
|
|
45
54
|
contentSourceDataById,
|
|
46
55
|
srcType,
|
|
47
56
|
srcProjectId
|
|
48
57
|
});
|
|
49
58
|
return contentSourcesData.reduce((matchingDocuments: CSITypes.DocumentWithSource[], contentSourceData) => {
|
|
50
|
-
return matchingDocuments.concat(
|
|
59
|
+
return matchingDocuments.concat(
|
|
60
|
+
mapStoreDocumentsToCSIDocumentsWithSource({
|
|
61
|
+
documents: contentSourceData.documents,
|
|
62
|
+
csiDocumentMap: contentSourceData.csiDocumentMap
|
|
63
|
+
})
|
|
64
|
+
);
|
|
51
65
|
}, []);
|
|
52
66
|
},
|
|
53
67
|
getModelByName: ({ modelName, srcType, srcProjectId }): CSITypes.ModelWithSource | undefined => {
|
|
@@ -59,13 +73,13 @@ export function createConfigDelegate({
|
|
|
59
73
|
logger
|
|
60
74
|
});
|
|
61
75
|
},
|
|
62
|
-
getSchemas: ({ srcType, srcProjectId }): CSITypes.SchemaWithSource[] => {
|
|
76
|
+
getSchemas: ({ srcType, srcProjectId } = {}): CSITypes.SchemaWithSource[] => {
|
|
63
77
|
const contentSourcesData = findContentSourcesDataForTypeOrId({
|
|
64
78
|
contentSourceDataById,
|
|
65
79
|
srcType,
|
|
66
80
|
srcProjectId
|
|
67
81
|
});
|
|
68
|
-
return contentSourcesData.reduce((schemas:
|
|
82
|
+
return contentSourcesData.reduce((schemas: CSITypes.SchemaWithSource[], contentSourceData) => {
|
|
69
83
|
return schemas.concat({
|
|
70
84
|
srcType: contentSourceData.srcType,
|
|
71
85
|
srcProjectId: contentSourceData.srcProjectId,
|
|
@@ -152,10 +166,14 @@ export function createConfigDelegate({
|
|
|
152
166
|
return getNestedFieldFromFieldsForPath(nonLocalizedField.fields, fieldPathArr, currentContentSource);
|
|
153
167
|
} else if (nonLocalizedField.type === 'reference') {
|
|
154
168
|
const refDocument = currentContentSource.documentMap[nonLocalizedField.refId];
|
|
155
|
-
|
|
169
|
+
const refCSIDocument = currentContentSource.csiDocumentMap[nonLocalizedField.refId];
|
|
170
|
+
if (!refDocument || !refCSIDocument) {
|
|
156
171
|
return undefined;
|
|
157
172
|
}
|
|
158
|
-
const fields = mapStoreDocumentToCSIDocumentWithSource(
|
|
173
|
+
const fields = mapStoreDocumentToCSIDocumentWithSource({
|
|
174
|
+
document: refDocument,
|
|
175
|
+
csiDocument: refCSIDocument
|
|
176
|
+
}).fields;
|
|
159
177
|
return getNestedFieldFromFieldsForPath(fields, fieldPathArr, currentContentSource);
|
|
160
178
|
} else if (nonLocalizedField.type === 'cross-reference') {
|
|
161
179
|
const contentSourceId = getContentSourceId(nonLocalizedField.refSrcType, nonLocalizedField.refProjectId);
|
|
@@ -164,10 +182,14 @@ export function createConfigDelegate({
|
|
|
164
182
|
return undefined;
|
|
165
183
|
}
|
|
166
184
|
const refDocument = contentSource.documentMap[nonLocalizedField.refId];
|
|
167
|
-
|
|
185
|
+
const refCSIDocument = contentSource.csiDocumentMap[nonLocalizedField.refId];
|
|
186
|
+
if (!refDocument || !refCSIDocument) {
|
|
168
187
|
return undefined;
|
|
169
188
|
}
|
|
170
|
-
const fields = mapStoreDocumentToCSIDocumentWithSource(
|
|
189
|
+
const fields = mapStoreDocumentToCSIDocumentWithSource({
|
|
190
|
+
document: refDocument,
|
|
191
|
+
csiDocument: refCSIDocument
|
|
192
|
+
}).fields;
|
|
171
193
|
return getNestedFieldFromFieldsForPath(fields, fieldPathArr, contentSource);
|
|
172
194
|
} else if (nonLocalizedField.type === 'list') {
|
|
173
195
|
const index = _.toNumber(fieldPathArr[0]);
|
package/src/utils/site-map.ts
CHANGED
|
@@ -6,6 +6,7 @@ import * as CSITypes from '@stackbit/types';
|
|
|
6
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
|
+
import { createConfigDelegate } from './config-delegate';
|
|
9
10
|
|
|
10
11
|
export const SiteMapStaticEntriesKey = Symbol.for('SiteMapStaticEntriesKey');
|
|
11
12
|
export type SiteMapEntriesSourceKeys = string | symbol;
|
|
@@ -28,10 +29,12 @@ export type SiteMapEntryGroups = Record<SiteMapEntriesSourceKeys, Record<string,
|
|
|
28
29
|
|
|
29
30
|
export async function getSiteMapEntriesFromStackbitConfig({
|
|
30
31
|
stackbitConfig,
|
|
31
|
-
contentSourceDataById
|
|
32
|
+
contentSourceDataById,
|
|
33
|
+
logger
|
|
32
34
|
}: {
|
|
33
35
|
stackbitConfig: Config | null;
|
|
34
36
|
contentSourceDataById: Record<string, ContentStoreTypes.ContentSourceData>;
|
|
37
|
+
logger: CSITypes.Logger;
|
|
35
38
|
}): Promise<SiteMapEntryGroups> {
|
|
36
39
|
if (!stackbitConfig?.siteMap) {
|
|
37
40
|
return {};
|
|
@@ -48,13 +51,26 @@ export async function getSiteMapEntriesFromStackbitConfig({
|
|
|
48
51
|
...model
|
|
49
52
|
}))
|
|
50
53
|
),
|
|
51
|
-
documents: accum.documents.concat(
|
|
54
|
+
documents: accum.documents.concat(
|
|
55
|
+
mapStoreDocumentsToCSIDocumentsWithSource({
|
|
56
|
+
documents: contentSourceData.documents,
|
|
57
|
+
csiDocumentMap: contentSourceData.csiDocumentMap
|
|
58
|
+
})
|
|
59
|
+
)
|
|
52
60
|
};
|
|
53
61
|
},
|
|
54
62
|
{ models: [], documents: [] }
|
|
55
63
|
);
|
|
56
64
|
|
|
57
|
-
const
|
|
65
|
+
const configDelegate = createConfigDelegate({
|
|
66
|
+
contentSourceDataById,
|
|
67
|
+
logger
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const rawSiteMapEntries = stackbitConfig.siteMap({
|
|
71
|
+
...siteMapOptions,
|
|
72
|
+
...configDelegate
|
|
73
|
+
});
|
|
58
74
|
|
|
59
75
|
// The rawSiteMapEntries entries are provided by the user, sanitize them and filter out illegal entries
|
|
60
76
|
return sanitizeAndGroupSiteMapEntries(rawSiteMapEntries);
|
|
@@ -84,12 +100,14 @@ export async function updateSiteMapEntriesWithContentChanges({
|
|
|
84
100
|
siteMapEntryGroups,
|
|
85
101
|
contentChanges,
|
|
86
102
|
stackbitConfig,
|
|
87
|
-
contentSourceDataById
|
|
103
|
+
contentSourceDataById,
|
|
104
|
+
logger
|
|
88
105
|
}: {
|
|
89
106
|
siteMapEntryGroups: SiteMapEntryGroups;
|
|
90
107
|
contentChanges: ContentStoreTypes.ContentChangeResult;
|
|
91
108
|
stackbitConfig: Config | null;
|
|
92
109
|
contentSourceDataById: Record<string, ContentStoreTypes.ContentSourceData>;
|
|
110
|
+
logger: CSITypes.Logger;
|
|
93
111
|
}): Promise<SiteMapEntryGroups> {
|
|
94
112
|
if (!stackbitConfig?.siteMap) {
|
|
95
113
|
return {};
|
|
@@ -125,13 +143,26 @@ export async function updateSiteMapEntriesWithContentChanges({
|
|
|
125
143
|
...model
|
|
126
144
|
}))
|
|
127
145
|
),
|
|
128
|
-
documents: accum.documents.concat(
|
|
146
|
+
documents: accum.documents.concat(
|
|
147
|
+
mapStoreDocumentsToCSIDocumentsWithSource({
|
|
148
|
+
documents: changedDocuments,
|
|
149
|
+
csiDocumentMap: contentSourceData.csiDocumentMap
|
|
150
|
+
})
|
|
151
|
+
)
|
|
129
152
|
};
|
|
130
153
|
},
|
|
131
154
|
{ models: [], documents: [] }
|
|
132
155
|
);
|
|
133
156
|
|
|
134
|
-
const
|
|
157
|
+
const configDelegate = createConfigDelegate({
|
|
158
|
+
contentSourceDataById,
|
|
159
|
+
logger
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const partialRawSiteMapEntries = stackbitConfig.siteMap({
|
|
163
|
+
...partialSiteMapOptions,
|
|
164
|
+
...configDelegate
|
|
165
|
+
});
|
|
135
166
|
|
|
136
167
|
// The partialRawSiteMapEntries entries are provided by the user, sanitize them and filter out illegal entries
|
|
137
168
|
const partialSiteMapEntryGroups = sanitizeAndGroupSiteMapEntries(partialRawSiteMapEntries);
|
|
@@ -3,11 +3,41 @@ import * as CSITypes from '@stackbit/types';
|
|
|
3
3
|
import { omitByNil } from '@stackbit/utils';
|
|
4
4
|
import * as ContentStoreTypes from '../types';
|
|
5
5
|
|
|
6
|
-
export function mapStoreDocumentsToCSIDocumentsWithSource(
|
|
7
|
-
|
|
6
|
+
export function mapStoreDocumentsToCSIDocumentsWithSource({
|
|
7
|
+
documents,
|
|
8
|
+
csiDocumentMap
|
|
9
|
+
}: {
|
|
10
|
+
documents: ContentStoreTypes.Document[];
|
|
11
|
+
csiDocumentMap: Record<string, CSITypes.Document>;
|
|
12
|
+
}): CSITypes.DocumentWithSource[] {
|
|
13
|
+
return documents.map((document) =>
|
|
14
|
+
mapStoreDocumentToCSIDocumentWithSource({
|
|
15
|
+
document,
|
|
16
|
+
csiDocument: csiDocumentMap[document.srcObjectId]!
|
|
17
|
+
})
|
|
18
|
+
);
|
|
8
19
|
}
|
|
9
20
|
|
|
10
|
-
|
|
21
|
+
/**
|
|
22
|
+
* This method converts documents stored in an internal ContentStoreTypes.Document
|
|
23
|
+
* format to documents in a public CSITypes.DocumentWithSource format. These
|
|
24
|
+
* documents are then passed to document hook and sitemap functions defined in
|
|
25
|
+
* stackbit.config.ts.
|
|
26
|
+
*
|
|
27
|
+
* Most of the properties, including fields and their types, are taken from the
|
|
28
|
+
* internal documents that contain changes made by mapDocuments, mapModels and
|
|
29
|
+
* modelExtensions functions.
|
|
30
|
+
*
|
|
31
|
+
* The document's context is taken from the CSI Document because context is not
|
|
32
|
+
* included in the internal documents.
|
|
33
|
+
*/
|
|
34
|
+
export function mapStoreDocumentToCSIDocumentWithSource({
|
|
35
|
+
document,
|
|
36
|
+
csiDocument
|
|
37
|
+
}: {
|
|
38
|
+
document: ContentStoreTypes.Document;
|
|
39
|
+
csiDocument: CSITypes.Document;
|
|
40
|
+
}): CSITypes.DocumentWithSource {
|
|
11
41
|
return {
|
|
12
42
|
type: document.type,
|
|
13
43
|
id: document.srcObjectId,
|
|
@@ -21,7 +51,7 @@ export function mapStoreDocumentToCSIDocumentWithSource(document: ContentStoreTy
|
|
|
21
51
|
updatedAt: document.updatedAt,
|
|
22
52
|
updatedBy: document.updatedBy,
|
|
23
53
|
locale: document.locale,
|
|
24
|
-
context:
|
|
54
|
+
context: csiDocument.context,
|
|
25
55
|
fields: mapStoreFieldsToCSIFields(document.fields)
|
|
26
56
|
};
|
|
27
57
|
}
|
|
@@ -97,11 +127,13 @@ function mapStoreFieldToCSIField(documentField: ContentStoreTypes.DocumentField)
|
|
|
97
127
|
type: 'image',
|
|
98
128
|
localized: true,
|
|
99
129
|
source: documentField.source,
|
|
100
|
-
locales: _.mapValues(documentField.locales, (locale) =>
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
130
|
+
locales: _.mapValues(documentField.locales, (locale) =>
|
|
131
|
+
omitByNil({
|
|
132
|
+
locale: locale.locale,
|
|
133
|
+
sourceData: locale.sourceData,
|
|
134
|
+
...(locale.sourceData ? null : { fields: mapStoreFieldsToCSIFields(locale.fields) })
|
|
135
|
+
})
|
|
136
|
+
)
|
|
105
137
|
}) as CSITypes.DocumentImageFieldLocalized;
|
|
106
138
|
}
|
|
107
139
|
if (documentField.isUnset) {
|