Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions api/src/services/migration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ const startTestMigration = async (req: Request): Promise<any> => {
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);
}
Expand Down Expand Up @@ -417,18 +417,18 @@ const getLogs = async (req: Request): Promise<any> => {
*/
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,
Expand Down
3 changes: 3 additions & 0 deletions api/src/utils/content-type-creator.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
11 changes: 6 additions & 5 deletions upload-api/migration-contentful/libs/contentTypeMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
});

Expand Down
2 changes: 2 additions & 0 deletions upload-api/migration-contentful/libs/createInitialMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const createInitialMapper = async () => {
const uidTitle = [
{
uid: 'title',
backupFieldUid: 'title',
otherCmsField: 'title',
otherCmsType: 'text',
contentstackField: 'title',
Expand All @@ -99,6 +100,7 @@ const createInitialMapper = async () => {
{
uid: 'url',
otherCmsField: 'url',
backupFieldUid: 'url',
otherCmsType: 'text',
contentstackField: 'Url',
contentstackFieldUid: 'url',
Expand Down
41 changes: 19 additions & 22 deletions upload-api/src/controllers/sitecore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading