diff --git a/api/package-lock.json b/api/package-lock.json index a055e579..a2f69dd2 100644 --- a/api/package-lock.json +++ b/api/package-lock.json @@ -33,7 +33,7 @@ "html-to-json-parser": "^2.0.1", "jsdom": "^24.1.0", "jsonwebtoken": "^9.0.3", - "lodash": "^4.17.21", + "lodash": "^4.18.1", "lowdb": "^7.0.1", "mkdirp": "^3.0.1", "mysql2": "^3.16.2", @@ -11126,9 +11126,9 @@ } }, "node_modules/lodash": { - "version": "4.17.23", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz", - "integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==", + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz", + "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==", "license": "MIT" }, "node_modules/lodash.clonedeep": { @@ -14483,6 +14483,12 @@ "node": ">=0.10.0" } }, + "node_modules/omit-deep-lodash/node_modules/lodash": { + "version": "4.17.23", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz", + "integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==", + "license": "MIT" + }, "node_modules/on-finished": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", diff --git a/api/package.json b/api/package.json index da7f0773..5722bbf8 100644 --- a/api/package.json +++ b/api/package.json @@ -51,7 +51,7 @@ "html-to-json-parser": "^2.0.1", "jsdom": "^24.1.0", "jsonwebtoken": "^9.0.3", - "lodash": "^4.17.21", + "lodash": "^4.18.1", "lowdb": "^7.0.1", "mkdirp": "^3.0.1", "mysql2": "^3.16.2", diff --git a/api/src/services/migration.service.ts b/api/src/services/migration.service.ts index f00d3327..cc9283d3 100644 --- a/api/src/services/migration.service.ts +++ b/api/src/services/migration.service.ts @@ -278,7 +278,15 @@ const deleteTestStack = async (req: Request): Promise => { */ const startTestMigration = async (req: Request): Promise => { const { orgId, projectId } = req?.params ?? {}; - const { region, user_id } = req?.body?.token_payload ?? {}; + const { region, user_id, is_sso } = req?.body?.token_payload ?? {}; + + + if (is_sso !== true && is_sso !== false) { + throw new BadRequestError( + 'Invalid token_payload.is_sso; expected a boolean value.', + ); + } + await ProjectModelLowdb.read(); const project: any = ProjectModelLowdb.chain .get('projects') @@ -406,6 +414,7 @@ const startTestMigration = async (req: Request): Promise => { destinationStackId: project?.current_test_stack_id, region, user_id, + is_sso, }); await marketPlaceAppService?.createAppManifest({ @@ -652,7 +661,14 @@ const startTestMigration = async (req: Request): Promise => { */ const startMigration = async (req: Request): Promise => { const { orgId, projectId } = req?.params ?? {}; - const { region, user_id } = req?.body?.token_payload ?? {}; + const { region, user_id, is_sso } = req?.body?.token_payload ?? {}; + + if (typeof is_sso !== 'boolean') { + throw new BadRequestError( + 'Missing or invalid SSO flag in token payload: expected boolean "is_sso".', + ); + } + await ProjectModelLowdb.read(); const project: any = ProjectModelLowdb.chain .get('projects') @@ -793,6 +809,7 @@ const startMigration = async (req: Request): Promise => { destinationStackId: project?.destination_stack_id, region, user_id, + is_sso, }); await marketPlaceAppService?.createAppManifest({ orgId, diff --git a/api/src/utils/content-type-creator.utils.ts b/api/src/utils/content-type-creator.utils.ts index 76bd531f..1ef7f1aa 100644 --- a/api/src/utils/content-type-creator.utils.ts +++ b/api/src/utils/content-type-creator.utils.ts @@ -1026,8 +1026,27 @@ const writeGlobalField = async (schema: any, globalSave: string) => { } }; -const existingCtMapper = async ({ keyMapper, contentTypeUid, projectId, region, user_id, type}: any) => { +const resolveIsSsoFlag = (is_sso: any): boolean => { + if (typeof is_sso === 'boolean') { + return is_sso; + } + + if (is_sso === 'true') { + return true; + } + + if (is_sso === 'false') { + return false; + } + + throw new Error( + `Invalid token_payload.is_sso in existingCtMapper; expected boolean, received: ${JSON.stringify(is_sso)}` + ); +}; + +const existingCtMapper = async ({ keyMapper, contentTypeUid, projectId, region, user_id, is_sso, type}: any) => { try { + const normalizedIsSso = resolveIsSsoFlag(is_sso); const ctUid = keyMapper?.[contentTypeUid]; if(type === 'global_field') { @@ -1040,7 +1059,8 @@ const existingCtMapper = async ({ keyMapper, contentTypeUid, projectId, region, body: { token_payload: { region, - user_id + user_id, + is_sso: normalizedIsSso } } } @@ -1055,7 +1075,8 @@ const existingCtMapper = async ({ keyMapper, contentTypeUid, projectId, region, body: { token_payload: { region, - user_id + user_id, + is_sso: normalizedIsSso } } } @@ -1141,7 +1162,7 @@ const mergeTwoCts = async (ct: any, mergeCts: any) => { return ctData; } -export const contenTypeMaker = async ({ contentType, destinationStackId, projectId, newStack, keyMapper, region, user_id }: any) => { +export const contenTypeMaker = async ({ contentType, destinationStackId, projectId, newStack, keyMapper, region, user_id, is_sso }: any) => { const marketPlacePath = path.join(process.cwd(), MIGRATION_DATA_CONFIG.DATA, destinationStackId); const srcFunc = 'contenTypeMaker'; @@ -1155,7 +1176,7 @@ export const contenTypeMaker = async ({ contentType, destinationStackId, project if (Object?.keys?.(keyMapper)?.length && keyMapper?.[contentType?.contentstackUid] !== "" && keyMapper?.[contentType?.contentstackUid] !== undefined) { - currentCt = await existingCtMapper({ keyMapper, contentTypeUid: contentType?.contentstackUid, projectId, region, user_id , type: contentType?.type}); + currentCt = await existingCtMapper({ keyMapper, contentTypeUid: contentType?.contentstackUid, projectId, region, user_id, is_sso, type: contentType?.type}); } // Safe: ensures we never pass undefined to the builder diff --git a/api/src/utils/field-attacher.utils.ts b/api/src/utils/field-attacher.utils.ts index 7d8c42ee..532f69ac 100644 --- a/api/src/utils/field-attacher.utils.ts +++ b/api/src/utils/field-attacher.utils.ts @@ -3,7 +3,7 @@ import ContentTypesMapperModelLowdb from "../models/contentTypesMapper-lowdb.js" import FieldMapperModel from "../models/FieldMapper.js"; import { contenTypeMaker } from "./content-type-creator.utils.js"; -export const fieldAttacher = async ({ projectId, orgId, destinationStackId, region, user_id }: any) => { +export const fieldAttacher = async ({ projectId, orgId, destinationStackId, region, user_id, is_sso }: any) => { await ProjectModelLowdb.read(); const projectData: any = ProjectModelLowdb.chain.get("projects").find({ id: projectId, @@ -27,7 +27,7 @@ export const fieldAttacher = async ({ projectId, orgId, destinationStackId, regi return field; }) } - await contenTypeMaker({ contentType, destinationStackId, projectId, newStack: projectData?.stackDetails?.isNewStack, keyMapper: projectData?.mapperKeys, region, user_id }) + await contenTypeMaker({ contentType, destinationStackId, projectId, newStack: projectData?.stackDetails?.isNewStack, keyMapper: projectData?.mapperKeys, region, user_id, is_sso }) contentTypes?.push?.(contentType); } } diff --git a/package-lock.json b/package-lock.json index 8771770f..6703cfbe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3045,9 +3045,9 @@ } }, "node_modules/lodash": { - "version": "4.17.23", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz", - "integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==", + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz", + "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==", "license": "MIT" }, "node_modules/log-symbols": { diff --git a/package.json b/package.json index b05d48fd..9ccf33e2 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,8 @@ "postcss": ">=8.4.31", "serialize-javascript": ">=6.0.2", "@babel/runtime": ">=7.26.10", - "lodash": "^4.17.23", - "lodash-es": "^4.17.23", + "lodash": "^4.18.1", + "lodash-es": "^4.18.1", "undici": "^7.18.2", "tmp": ">=0.2.4", "minimatch": ">=10.2.3", diff --git a/ui/package-lock.json b/ui/package-lock.json index 7221b3ae..e6f6b801 100644 --- a/ui/package-lock.json +++ b/ui/package-lock.json @@ -6236,15 +6236,15 @@ "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==" }, "node_modules/lodash": { - "version": "4.17.23", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz", - "integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==", + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz", + "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==", "license": "MIT" }, "node_modules/lodash-es": { - "version": "4.17.23", - "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.23.tgz", - "integrity": "sha512-kVI48u3PZr38HdYz98UmfPnXl2DXrpdctLrFLCd3kOx1xUkOmpFPx7gCWWM5MPkL/fD8zb+Ph0QzjGFs4+hHWg==", + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.18.1.tgz", + "integrity": "sha512-J8xewKD/Gk22OZbhpOVSwcs60zhd95ESDwezOFuA3/099925PdHJ7OFHNTGtajL3AlZkykD32HykiMo+BIBI8A==", "license": "MIT" }, "node_modules/lodash.clonedeep": { diff --git a/ui/package.json b/ui/package.json index f4b8325a..5339c3e1 100644 --- a/ui/package.json +++ b/ui/package.json @@ -59,9 +59,10 @@ "overrides": { "@babel/runtime": ">=7.26.10", "immutable": ">=5.1.5", - "lodash-es": ">=4.17.23", + "lodash-es": "^4.18.1", "minimatch": ">=10.2.3", - "rollup": ">=4.59.0" + "rollup": ">=4.59.0", + "lodash": "^4.18.1" }, "eslintConfig": { "extends": [ diff --git a/ui/src/components/ContentMapper/index.tsx b/ui/src/components/ContentMapper/index.tsx index 0ab8ef46..4b22641c 100644 --- a/ui/src/components/ContentMapper/index.tsx +++ b/ui/src/components/ContentMapper/index.tsx @@ -396,7 +396,11 @@ const ContentMapper = forwardRef(({ handleStepChange }: contentMapperProps, ref: }, [tableData]); useEffect(() => { - const mappedContentType = contentModels && contentModels?.find((item) => item?.uid === newMigrationData?.content_mapping?.content_type_mapping?.[selectedContentType?.contentstackUid || '']); + const selectedSourceUid = selectedContentType?.contentstackUid || ''; + const mappedDestinationUid = + contentTypeMapped?.[selectedSourceUid] ?? + newMigrationData?.content_mapping?.content_type_mapping?.[selectedSourceUid]; + const mappedContentType = contentModels?.find((item) => item?.uid === mappedDestinationUid); if (mappedContentType?.uid) { setOtherContentType((prev) => { @@ -409,7 +413,12 @@ const ContentMapper = forwardRef(({ handleStepChange }: contentMapperProps, ref: }); setIsContentDeleted(false); } - }, [contentTypeMapped, otherCmsTitle, contentModels]); + }, [ + contentTypeMapped, + contentModels, + selectedContentType?.contentstackUid, + newMigrationData?.content_mapping?.content_type_mapping + ]); useEffect(() => { if (isContentDeleted) { diff --git a/upload-api/package-lock.json b/upload-api/package-lock.json index 5010b588..ab92fb83 100644 --- a/upload-api/package-lock.json +++ b/upload-api/package-lock.json @@ -26,7 +26,7 @@ "helmet": "^7.1.0", "jsdom": "^23.0.0", "jszip": "^3.10.1", - "lodash": "^4.17.21", + "lodash": "^4.18.1", "lodash.isempty": "^4.4.0", "migration-aem": "file:migration-aem", "migration-contentful": "file:migration-contentful", @@ -13142,7 +13142,9 @@ } }, "node_modules/lodash": { - "version": "4.17.23", + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz", + "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==", "license": "MIT" }, "node_modules/lodash.isempty": { diff --git a/upload-api/package.json b/upload-api/package.json index e6218c26..2d61e117 100644 --- a/upload-api/package.json +++ b/upload-api/package.json @@ -62,7 +62,7 @@ "helmet": "^7.1.0", "jsdom": "^23.0.0", "jszip": "^3.10.1", - "lodash": "^4.17.21", + "lodash": "^4.18.1", "lodash.isempty": "^4.4.0", "migration-aem": "file:migration-aem", "migration-contentful": "file:migration-contentful",