Skip to content

Commit f71dce2

Browse files
committed
resloved bugs
1 parent b0d69a4 commit f71dce2

File tree

5 files changed

+35
-32
lines changed

5 files changed

+35
-32
lines changed

api/src/services/migration.service.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ const startTestMigration = async (req: Request): Promise<any> => {
230230
case CMS.SITECORE_V9:
231231
case CMS.SITECORE_V10: {
232232
if (packagePath) {
233-
await siteCoreService?.createEntry({ packagePath, contentTypes, master_locale: project?.stackDetails?.master_locale, destinationStackId: project?.current_test_stack_id, projectId, keyMapper: project?.mapperKey, project });
233+
await siteCoreService?.createEntry({ packagePath, contentTypes, master_locale: project?.stackDetails?.master_locale, destinationStackId: project?.current_test_stack_id, projectId, keyMapper: project?.mapperKeys, project });
234234
await siteCoreService?.createLocale(req, project?.current_test_stack_id, projectId, project);
235235
await siteCoreService?.createVersionFile(project?.current_test_stack_id);
236236
}
@@ -417,18 +417,18 @@ const getLogs = async (req: Request): Promise<any> => {
417417
*/
418418
export const createSourceLocales = async (req: Request) => {
419419

420-
const projectId = req.params.projectId;
421-
const locales = req.body.locale
420+
const projectId = req?.params?.projectId;
421+
const locales = req?.body?.locale;
422+
console.info("🚀 ~ createSourceLocales ~ locales:", locales);
422423

423424
try {
424425
// Find the project with the specified projectId
425426
await ProjectModelLowdb?.read?.();
426427
const index = ProjectModelLowdb?.chain?.get?.("projects")?.findIndex?.({ id: projectId })?.value?.();
427-
if (index > -1) {
428+
if (typeof index === "number" && index > -1) {
428429
ProjectModelLowdb?.update?.((data: any) => {
429430
data.projects[index].source_locales = locales;
430431
});
431-
// Write back the updated projects
432432
} else {
433433
logger.error(`Project with ID: ${projectId} not found`, {
434434
status: HTTP_CODES?.NOT_FOUND,

api/src/utils/content-type-creator.utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,9 @@ const mergeTwoCts = async (ct: any, mergeCts: any) => {
672672
...ct,
673673
title: mergeCts?.title,
674674
uid: mergeCts?.uid,
675+
options: {
676+
"singleton": false,
677+
}
675678
}
676679
for await (const field of ctData?.schema ?? []) {
677680
if (field?.data_type === 'group') {

upload-api/migration-contentful/libs/contentTypeMapper.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,14 @@ const extractAdvancedFields = (
100100
* // Outputs an object containing the field configuration for Contentstack and backup fields
101101
*/
102102
const createFieldObject = (item, contentstackFieldType, backupFieldType, referenceFields = []) => ({
103-
uid: item.id,
104-
otherCmsField: item.name,
105-
otherCmsType: item.widgetId,
106-
contentstackField: item.name,
107-
contentstackFieldUid: uidCorrector(item.id),
103+
uid: item?.id,
104+
otherCmsField: item?.name,
105+
otherCmsType: item?.widgetId,
106+
contentstackField: item?.name,
107+
contentstackFieldUid: uidCorrector(item?.id),
108108
contentstackFieldType: contentstackFieldType,
109109
backupFieldType: backupFieldType,
110+
backupFieldUid: uidCorrector(item?.id),
110111
advanced: extractAdvancedFields(item, referenceFields, contentstackFieldType, backupFieldType)
111112
});
112113

upload-api/migration-contentful/libs/createInitialMapper.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ const createInitialMapper = async () => {
8888
const uidTitle = [
8989
{
9090
uid: 'title',
91+
backupFieldUid: 'title',
9192
otherCmsField: 'title',
9293
otherCmsType: 'text',
9394
contentstackField: 'title',
@@ -99,6 +100,7 @@ const createInitialMapper = async () => {
99100
{
100101
uid: 'url',
101102
otherCmsField: 'url',
103+
backupFieldUid: 'url',
102104
otherCmsType: 'text',
103105
contentstackField: 'Url',
104106
contentstackFieldUid: 'url',

upload-api/src/controllers/sitecore/index.ts

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,26 @@ const createSitecoreMapper = async (filePath: string = "", projectId: string | s
5656
status: HTTP_CODES?.OK,
5757
message: HTTP_TEXTS?.MAPPER_SAVED,
5858
});
59+
const mapperConfig = {
60+
method: 'post',
61+
maxBodyLength: Infinity,
62+
url: `${process.env.NODE_BACKEND_API}/v2/migration/localeMapper/${projectId}`,
63+
headers: {
64+
app_token,
65+
'Content-Type': 'application/json'
66+
},
67+
data: {
68+
locale: Array?.from?.(localeData) ?? []
69+
},
70+
};
71+
const mapRes = await axios.request(mapperConfig);
72+
if (mapRes?.status == 200) {
73+
logger.info('Legacy CMS', {
74+
status: HTTP_CODES?.OK,
75+
message: HTTP_TEXTS?.LOCALE_SAVED,
76+
});
77+
}
5978
}
60-
61-
const mapperConfig = {
62-
method: 'post',
63-
maxBodyLength: Infinity,
64-
url: `${process.env.NODE_BACKEND_API}/v2/migration/localeMapper/${projectId}`,
65-
headers: {
66-
app_token,
67-
'Content-Type': 'application/json'
68-
},
69-
data: {
70-
locale: Array?.from?.(localeData) ?? []
71-
},
72-
};
73-
74-
const mapRes = await axios.request(mapperConfig)
75-
if (mapRes?.status == 200) {
76-
logger.info('Legacy CMS', {
77-
status: HTTP_CODES?.OK,
78-
message: HTTP_TEXTS?.LOCALE_SAVED,
79-
});
80-
}
81-
8279
}
8380
} catch (err: any) {
8481
console.error("🚀 ~ createSitecoreMapper ~ err:", err?.response?.data ?? err)

0 commit comments

Comments
 (0)