diff --git a/api/src/services/migration.service.ts b/api/src/services/migration.service.ts index 06acc564e..6147fdd58 100644 --- a/api/src/services/migration.service.ts +++ b/api/src/services/migration.service.ts @@ -230,7 +230,7 @@ const startTestMigration = async (req: Request): Promise => { case CMS.SITECORE_V9: case CMS.SITECORE_V10: { if (packagePath) { - await siteCoreService?.createEntry({ packagePath, contentTypes, master_locale: project?.stackDetails?.master_locale, destinationStackId: project?.current_test_stack_id, projectId, keyMapper: project?.mapperKey, project }); + await siteCoreService?.createEntry({ packagePath, contentTypes, master_locale: project?.stackDetails?.master_locale, destinationStackId: project?.current_test_stack_id, projectId, keyMapper: project?.mapperKeys, project }); await siteCoreService?.createLocale(req, project?.current_test_stack_id, projectId, project); await siteCoreService?.createVersionFile(project?.current_test_stack_id); } @@ -417,18 +417,18 @@ const getLogs = async (req: Request): Promise => { */ export const createSourceLocales = async (req: Request) => { - const projectId = req.params.projectId; - const locales = req.body.locale + const projectId = req?.params?.projectId; + const locales = req?.body?.locale; + console.info("🚀 ~ createSourceLocales ~ locales:", locales); try { // Find the project with the specified projectId await ProjectModelLowdb?.read?.(); const index = ProjectModelLowdb?.chain?.get?.("projects")?.findIndex?.({ id: projectId })?.value?.(); - if (index > -1) { + if (typeof index === "number" && index > -1) { ProjectModelLowdb?.update?.((data: any) => { data.projects[index].source_locales = locales; }); - // Write back the updated projects } else { logger.error(`Project with ID: ${projectId} not found`, { status: HTTP_CODES?.NOT_FOUND, diff --git a/api/src/utils/content-type-creator.utils.ts b/api/src/utils/content-type-creator.utils.ts index 664240182..e00b14c14 100644 --- a/api/src/utils/content-type-creator.utils.ts +++ b/api/src/utils/content-type-creator.utils.ts @@ -672,6 +672,9 @@ const mergeTwoCts = async (ct: any, mergeCts: any) => { ...ct, title: mergeCts?.title, uid: mergeCts?.uid, + options: { + "singleton": false, + } } for await (const field of ctData?.schema ?? []) { if (field?.data_type === 'group') { diff --git a/upload-api/migration-contentful/libs/contentTypeMapper.js b/upload-api/migration-contentful/libs/contentTypeMapper.js index 42966b228..5327948ed 100644 --- a/upload-api/migration-contentful/libs/contentTypeMapper.js +++ b/upload-api/migration-contentful/libs/contentTypeMapper.js @@ -100,13 +100,14 @@ const extractAdvancedFields = ( * // Outputs an object containing the field configuration for Contentstack and backup fields */ const createFieldObject = (item, contentstackFieldType, backupFieldType, referenceFields = []) => ({ - uid: item.id, - otherCmsField: item.name, - otherCmsType: item.widgetId, - contentstackField: item.name, - contentstackFieldUid: uidCorrector(item.id), + uid: item?.id, + otherCmsField: item?.name, + otherCmsType: item?.widgetId, + contentstackField: item?.name, + contentstackFieldUid: uidCorrector(item?.id), contentstackFieldType: contentstackFieldType, backupFieldType: backupFieldType, + backupFieldUid: uidCorrector(item?.id), advanced: extractAdvancedFields(item, referenceFields, contentstackFieldType, backupFieldType) }); diff --git a/upload-api/migration-contentful/libs/createInitialMapper.js b/upload-api/migration-contentful/libs/createInitialMapper.js index 173b311d7..77b6a986b 100644 --- a/upload-api/migration-contentful/libs/createInitialMapper.js +++ b/upload-api/migration-contentful/libs/createInitialMapper.js @@ -88,6 +88,7 @@ const createInitialMapper = async () => { const uidTitle = [ { uid: 'title', + backupFieldUid: 'title', otherCmsField: 'title', otherCmsType: 'text', contentstackField: 'title', @@ -99,6 +100,7 @@ const createInitialMapper = async () => { { uid: 'url', otherCmsField: 'url', + backupFieldUid: 'url', otherCmsType: 'text', contentstackField: 'Url', contentstackFieldUid: 'url', diff --git a/upload-api/src/controllers/sitecore/index.ts b/upload-api/src/controllers/sitecore/index.ts index 266535f42..a46dce7de 100644 --- a/upload-api/src/controllers/sitecore/index.ts +++ b/upload-api/src/controllers/sitecore/index.ts @@ -56,29 +56,26 @@ const createSitecoreMapper = async (filePath: string = "", projectId: string | s status: HTTP_CODES?.OK, message: HTTP_TEXTS?.MAPPER_SAVED, }); + const mapperConfig = { + method: 'post', + maxBodyLength: Infinity, + url: `${process.env.NODE_BACKEND_API}/v2/migration/localeMapper/${projectId}`, + headers: { + app_token, + 'Content-Type': 'application/json' + }, + data: { + locale: Array?.from?.(localeData) ?? [] + }, + }; + const mapRes = await axios.request(mapperConfig); + if (mapRes?.status == 200) { + logger.info('Legacy CMS', { + status: HTTP_CODES?.OK, + message: HTTP_TEXTS?.LOCALE_SAVED, + }); + } } - - const mapperConfig = { - method: 'post', - maxBodyLength: Infinity, - url: `${process.env.NODE_BACKEND_API}/v2/migration/localeMapper/${projectId}`, - headers: { - app_token, - 'Content-Type': 'application/json' - }, - data: { - locale: Array?.from?.(localeData) ?? [] - }, - }; - - const mapRes = await axios.request(mapperConfig) - if (mapRes?.status == 200) { - logger.info('Legacy CMS', { - status: HTTP_CODES?.OK, - message: HTTP_TEXTS?.LOCALE_SAVED, - }); - } - } } catch (err: any) { console.error("🚀 ~ createSitecoreMapper ~ err:", err?.response?.data ?? err)