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
14 changes: 10 additions & 4 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
21 changes: 19 additions & 2 deletions api/src/services/migration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,15 @@ const deleteTestStack = async (req: Request): Promise<LoginServiceType> => {
*/
const startTestMigration = async (req: Request): Promise<any> => {
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')
Expand Down Expand Up @@ -406,6 +414,7 @@ const startTestMigration = async (req: Request): Promise<any> => {
destinationStackId: project?.current_test_stack_id,
region,
user_id,
is_sso,
});

await marketPlaceAppService?.createAppManifest({
Expand Down Expand Up @@ -652,7 +661,14 @@ const startTestMigration = async (req: Request): Promise<any> => {
*/
const startMigration = async (req: Request): Promise<any> => {
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')
Expand Down Expand Up @@ -793,6 +809,7 @@ const startMigration = async (req: Request): Promise<any> => {
destinationStackId: project?.destination_stack_id,
region,
user_id,
is_sso,
});
await marketPlaceAppService?.createAppManifest({
orgId,
Expand Down
31 changes: 26 additions & 5 deletions api/src/utils/content-type-creator.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -1040,7 +1059,8 @@ const existingCtMapper = async ({ keyMapper, contentTypeUid, projectId, region,
body: {
token_payload: {
region,
user_id
user_id,
is_sso: normalizedIsSso
}
}
}
Expand All @@ -1055,7 +1075,8 @@ const existingCtMapper = async ({ keyMapper, contentTypeUid, projectId, region,
body: {
token_payload: {
region,
user_id
user_id,
is_sso: normalizedIsSso
}
}
}
Expand Down Expand Up @@ -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';

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions api/src/utils/field-attacher.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
}
}
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 6 additions & 6 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
13 changes: 11 additions & 2 deletions ui/src/components/ContentMapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions upload-api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion upload-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading