Skip to content
Merged

stage #907

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
697f660
[CMG-769]
sayalijoshi27 Nov 24, 2025
f410c69
Merge branch 'dev' of https://github.com/contentstack/migration-v2-no…
sayalijoshi27 Nov 26, 2025
8bfd79a
Merge branch 'dev' of https://github.com/contentstack/migration-v2-no…
sayalijoshi27 Dec 2, 2025
d9f9508
[CMG-782] - Existing stack | Select CT from dropdown | Global field -…
sayalijoshi27 Dec 5, 2025
af3b496
[CMG-783]
sayalijoshi27 Dec 8, 2025
ce87b2c
fix: Update buildSchemaTree to handle old parent UID and improve fiel…
AishDani Dec 9, 2025
42bf4cf
fix: Enhance buildFieldSchema and buildSchemaTree functions to handle…
AishDani Dec 10, 2025
289ebc8
fix: Refactor buildSchemaTree function to improve null safety and han…
AishDani Dec 10, 2025
b68ef8d
fix: Improve null safety in buildSchemaTree by adding optional chaini…
AishDani Dec 10, 2025
8a24239
Merge pull request #877 from contentstack/bugfix/sitecore-bugs/cmg-785
sayalijoshi27 Dec 10, 2025
5268638
windows support added by adding path separator and dev pull taken
yashin4112 Dec 11, 2025
5490183
comment-resolved: space added after comma
yashin4112 Dec 17, 2025
89c08a6
Merge pull request #879 from contentstack/feature/aem-final
sayalijoshi27 Dec 17, 2025
e3f9a6c
Merge pull request #878 from contentstack/feature/windows
sayalijoshi27 Dec 17, 2025
563e5ac
feat: Enhance migration service with stack ID sanitization and path v…
sauravraw Jan 5, 2026
eaf4ef0
chore: Update dependencies and add Snyk policy file
shobhitupadhyayy Jan 5, 2026
ae679b0
chore: Update @contentstack/cli-utilities and related dependencies
sauravraw Jan 5, 2026
68f0110
snyk fixes
sayalijoshi27 Jan 5, 2026
5bcbbdc
snyk fixes merged
sayalijoshi27 Jan 5, 2026
ec1e9ef
license year updated
sayalijoshi27 Jan 5, 2026
e258bc3
Merge pull request #891 from contentstack/hotfix/path-issue
sayalijoshi27 Jan 5, 2026
f160d43
Merge pull request #892 from contentstack/dev
sayalijoshi27 Jan 5, 2026
ad88af7
chore: Update dependencies in package.json and package-lock.json
shobhitupadhyayy Jan 6, 2026
9f17da8
checkbox reset bug resolved
yashin4112 Jan 6, 2026
24f704c
HTML RTE embed object fix
sayalijoshi27 Jan 6, 2026
3d1263e
Merge branch 'dev' of https://github.com/contentstack/migration-v2-no…
sayalijoshi27 Jan 6, 2026
9743d3b
Merge pull request #893 from contentstack/hotfix/path-issue
sayalijoshi27 Jan 6, 2026
9f48856
Merge pull request #894 from contentstack/bugfix/cmg-770
sayalijoshi27 Jan 6, 2026
bc1e9e1
feat:reolved global field issue in siteocore,when mapped with existin…
AishDani Jan 6, 2026
69bb4a2
Merge pull request #895 from contentstack/dev
sayalijoshi27 Jan 6, 2026
c08a6c1
Merge pull request #896 from contentstack/bugfix/cmg-624
umeshmore45 Jan 6, 2026
4611800
snyk fix: Open Redirect and eslint version upgrade
sayalijoshi27 Jan 6, 2026
f54cf50
feat: add initial reference handling in content mapping service and i…
AishDani Jan 7, 2026
4f99a8c
Unsanitized input - Prototype Pollution snyk fix added
sayalijoshi27 Jan 7, 2026
1562cae
Merge pull request #899 from contentstack/bugfix/cmg-624
sayalijoshi27 Jan 7, 2026
6a9509b
Merge branch 'dev' of https://github.com/contentstack/migration-v2-no…
sayalijoshi27 Jan 7, 2026
a131743
Removed extra space
sayalijoshi27 Jan 7, 2026
c417b6c
Merge pull request #900 from contentstack/hotfix/path-issue
umeshmore45 Jan 7, 2026
de27cd7
Removed unwanted line
sayalijoshi27 Jan 7, 2026
e5afce2
Merge branch 'dev' of https://github.com/contentstack/migration-v2-no…
sayalijoshi27 Jan 7, 2026
ef405ab
Merge pull request #901 from contentstack/dev
umeshmore45 Jan 7, 2026
310fe0b
Fixed group fields null issue
sayalijoshi27 Jan 8, 2026
a2ad963
Merge pull request #905 from contentstack/hotfix/path-issue
sayalijoshi27 Jan 8, 2026
68f7f23
Merge pull request #906 from contentstack/dev
sayalijoshi27 Jan 8, 2026
91d5c44
Delete ui/.snyk
aravindbuilt Jan 9, 2026
98ecace
Merge branch 'main' into pre-stage
aravindbuilt Jan 9, 2026
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
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2025 Contentstack
Copyright (c) 2026 Contentstack

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2,932 changes: 1,120 additions & 1,812 deletions api/package-lock.json

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,27 @@
},
"homepage": "https://github.com/contentstack/migration-v2.git#readme",
"dependencies": {
"@contentstack/cli": "^1.51.1",
"@contentstack/cli-utilities": "^1.14.2",
"@contentstack/cli": "^1.53.1",
"@contentstack/cli-utilities": "^1.15.0",
"@contentstack/json-rte-serializer": "^3.0.4",
"@contentstack/marketplace-sdk": "^1.4.0",
"@contentstack/marketplace-sdk": "^1.4.1",
"axios": "^1.12.0",
"chokidar": "^3.6.0",
"cors": "^2.8.5",
"dayjs": "^1.11.18",
"dotenv": "^16.3.1",
"express": "^4.21.0",
"express-validator": "^7.3.0",
"express": "^4.22.0",
"express-validator": "^7.3.1",
"express-winston": "^4.2.0",
"fs-extra": "^11.2.0",
"fs-readdir-recursive": "^1.1.0",
"helmet": "^8.0.0",
"html-to-json-parser": "^2.0.1",
"http": "^0.0.1-security",
"js-yaml": "^4.1.1",
"jsdom": "^24.1.0",
"jsonpath": "^1.1.1",
"jsonwebtoken": "^9.0.2",
"jsonwebtoken": "^9.0.3",
"lowdb": "^7.0.1",
"mkdirp": "^3.0.1",
"p-limit": "^6.2.0",
Expand Down
65 changes: 51 additions & 14 deletions api/src/services/contentMapper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,26 @@ const putTestData = async (req: Request) => {
if (item?.advanced) {
item.advanced.initial = structuredClone(item?.advanced);
}
if(item?.refrenceTo) {
item.initialRefrenceTo = item?.refrenceTo;
}
});
});



const sanitizeObject = (obj: Record<string, any>) => {
const blockedKeys = ['__proto__', 'prototype', 'constructor'];
const safeObj: Record<string, any> = {};

for (const key in obj) {
if (!blockedKeys.includes(key)) {
safeObj[key] = obj[key];
}
}
return safeObj;
};

/*
this code snippet iterates over an array of contentTypes and performs
some operations on each element.
Expand All @@ -75,18 +90,38 @@ const putTestData = async (req: Request) => {
Finally, it updates the fieldMapping property of each type in the contentTypes array with the fieldIds array.
*/
await FieldMapperModel.read();
contentTypes.map((type: any, index: any) => {
contentTypes.forEach((type: any, index: number) => {
const fieldIds: string[] = [];
const fields = Array?.isArray?.(type?.fieldMapping) ? type?.fieldMapping?.filter((field: any) => field)?.map?.((field: any) => {
const id = field?.id ? field?.id?.replace(/[{}]/g, "")?.toLowerCase() : uuidv4();
field.id = id;
fieldIds.push(id);
return { id, projectId, contentTypeId: type?.id, isDeleted: false, ...field };
}) : [];


const fields = Array.isArray(type?.fieldMapping) ?
type.fieldMapping
.filter(Boolean)
.map((field: any) => {
const safeField = sanitizeObject(field);

const id =
safeField?.id ?
safeField.id.replace(/[{}]/g, '').toLowerCase()
: uuidv4();

fieldIds.push(id);

return {
...safeField,
id,
projectId,
contentTypeId: type?.id,
isDeleted: false,
};
})
: [];

FieldMapperModel.update((data: any) => {
data.field_mapper = [...(data?.field_mapper ?? []), ...(fields ?? [])];
});
data.field_mapper = [
...(Array.isArray(data?.field_mapper) ? data.field_mapper : []),
...fields,
];
});
if (
Array?.isArray?.(contentType) &&
Number?.isInteger?.(index) &&
Expand Down Expand Up @@ -277,8 +312,7 @@ const getFieldMapping = async (req: Request) => {

const fieldMapping: any = fieldData?.map((field: any) => {
if (field?.advanced?.initial) {
const { initial, ...restAdvanced } = field?.advanced;
return { ...field, advanced: restAdvanced };
return { ...field, advanced: field?.advanced };
}
return field;
});
Expand Down Expand Up @@ -775,7 +809,6 @@ const resetToInitialMapping = async (req: Request) => {
);
if (fieldIndex > -1) {
FieldMapperModel.update((data: any) => {

data.field_mapper[fieldIndex] = {
...field,
contentstackField: field?.otherCmsField,
Expand All @@ -784,7 +817,11 @@ const resetToInitialMapping = async (req: Request) => {
advanced: {
...field?.advanced?.initial,
initial: field?.advanced?.initial,
}
},
...(field?.referenceTo && {
referenceTo: field?.initialRefrenceTo
}),
isDeleted: false,
}
});
}
Expand Down
16 changes: 11 additions & 5 deletions api/src/services/globalField.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,19 @@ const createGlobalField = async ({
}
}

const safeFileGlobalFields = fileGlobalFields;

const existingUids = new Set(
safeFileGlobalFields?.map?.((gf: { uid: string }) => gf?.uid)
);

const mergedGlobalFields = [
...globalfields,
...(fileGlobalFields?.filter(
(fileField: { uid: string }) =>
!globalfields?.some((gf: { uid: string }) => gf?.uid === fileField?.uid)
) || [])
...globalfields.filter(
(fileField: { uid: string }) => !existingUids?.has(fileField?.uid)
),
...safeFileGlobalFields,
];

await fs.promises.mkdir(path.dirname(filePath), { recursive: true });
await fs.promises.writeFile(filePath, JSON.stringify(mergedGlobalFields, null, 2));

Expand Down
Loading