Skip to content
Merged

Dev #1028

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2f891c7
refactor: enhance locale extraction process with async handling and i…
umeshmore45 Mar 27, 2026
20dff1e
refactor: optimize language extraction logic in extractLocales.js
umeshmore45 Mar 27, 2026
2f822d1
refactor: improve input validation and error handling in extractLocal…
umeshmore45 Mar 27, 2026
e0a2ab6
chore: add .gitattributes to enforce LF line endings for shell script…
shobhitupadhyayy Mar 27, 2026
9d4691a
Merge branch 'dev' into bugfix/CMG-833
shobhitupadhyayy Mar 27, 2026
4cb24e1
refactor: enhance error handling and input validation in extractLocal…
umeshmore45 Mar 27, 2026
e909b51
Merge pull request #1014 from contentstack/bugfix/CMG-833
vikrantraut Mar 27, 2026
790e4ce
Merge branch 'dev' into feat/sitecore-locales-env
umeshmore45 Mar 27, 2026
f7e7da5
refactor: enhance input validation with optional chaining in extractL…
umeshmore45 Mar 27, 2026
6524a0a
refactor: enhance input validation with optional chaining in extractL…
umeshmore45 Mar 27, 2026
225996f
fix: ensure newMigrationData is dispatched correctly after processing
aishwarya-cstk Mar 28, 2026
66bb7a7
refactor: update MySQL details structure in LoadUploadFile component …
aishwarya-cstk Mar 30, 2026
fad1080
Merge branch 'dev' of https://github.com/contentstack/migration-v2 in…
aishwarya-cstk Mar 30, 2026
374f542
chore: update package-lock.json files to reflect dependency version c…
aishwarya-cstk Mar 30, 2026
42af9d1
chore: update package.json to include undici dependency and clean up …
aishwarya-cstk Mar 30, 2026
753577a
chore: update package-lock.json to reflect dependency version upgrade…
aishwarya-cstk Mar 30, 2026
c49c205
chore: update package-lock.json to include license information and up…
aishwarya-cstk Mar 30, 2026
510d9b0
chore: remove unnecessary dev flags from package-lock.json entries
aishwarya-cstk Mar 30, 2026
dc3ca14
chore: add @testing-library/dom dependency and update related test to…
aishwarya-cstk Mar 30, 2026
d19167f
chore: mark json-parse-even-better-errors and text-table as developme…
aishwarya-cstk Mar 30, 2026
1c0fe7f
chore: remove development flags from json-parse-even-better-errors an…
aishwarya-cstk Mar 30, 2026
a71e151
chore: downgrade several dependencies in package-lock.json and remove…
aishwarya-cstk Mar 30, 2026
952c362
chore: update package-lock.json to upgrade @apollo/client and @babel …
aishwarya-cstk Mar 30, 2026
d619502
chore: update package-lock.json to add support for additional platfor…
aishwarya-cstk Mar 30, 2026
2100686
chore: mark json-parse-even-better-errors and text-table as developme…
aishwarya-cstk Mar 30, 2026
b9877c4
chore: clean up package-lock.json by removing unused esbuild platform…
aishwarya-cstk Mar 30, 2026
fd0b6c2
chore: update package-lock.json to add new esbuild platform entries f…
aishwarya-cstk Mar 31, 2026
4b32bea
chore: update yaml dependency version in package-lock.json from 1.10.…
aishwarya-cstk Mar 31, 2026
eaddf66
chore: update package-lock.json to mark yaml as a development depende…
aishwarya-cstk Mar 31, 2026
ac22d27
chore: add @emnapi dependencies to package.json and package-lock.json
aishwarya-cstk Mar 31, 2026
47332d8
refactor:changed the mysql spelling
aishwarya-cstk Mar 31, 2026
1b1e46f
refactor: update MySQL configuration keys to use mySQLDetails
aishwarya-cstk Mar 31, 2026
ff3bd8e
Merge pull request #1019 from contentstack/feature/wordpress
vikrantraut Mar 31, 2026
5e0afa1
Merge branch 'dev' into feat/sitecore-locales-env
umeshmore45 Mar 31, 2026
80f8ece
Merge pull request #1013 from contentstack/feat/sitecore-locales-env
umeshmore45 Mar 31, 2026
925f875
feat: add is_sso parameter to migration and content type handling fun…
aishwarya-cstk Apr 1, 2026
5fd69e0
refactor:resolved PR comments
aishwarya-cstk Apr 2, 2026
416a6d5
chore: update lodash and lodash-es dependencies to version 4.18.1 acr…
aishwarya-cstk Apr 2, 2026
8c4e12d
Merge pull request #1024 from contentstack/feature/cmg-774
umeshmore45 Apr 2, 2026
05cc1a3
refactor: update client import and variable naming in market-app.util…
aishwarya-cstk Apr 2, 2026
08e818a
refactor: simplify client import and update usage in market-app.utils…
aishwarya-cstk Apr 2, 2026
3bfa644
Merge pull request #1026 from contentstack/bugfix/cmg-865
vikrantraut-cstk Apr 2, 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
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Windows checkouts must not use CRLF on shell scripts — breaks Linux shebang/exec
# (symptom: exec /usr/local/bin/docker-entrypoint.sh: no such file or directory)
*.sh text eol=lf
5,000 changes: 3,576 additions & 1,424 deletions api/package-lock.json

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,18 @@
"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",
"p-limit": "^6.2.0",
"php-serialize": "^5.1.3",
"socket.io": "^4.7.5",
"uuid": "^9.0.1",
"winston": "^3.11.0"
"winston": "^3.11.0",
"@emnapi/core": "1.9.1",
"@emnapi/runtime" : "1.9.1",
"@emnapi/wasi-threads": "1.2.0"
},
"devDependencies": {
"@types/cors": "^2.8.17",
Expand Down Expand Up @@ -95,7 +98,8 @@
"glob": ">=11.1.0",
"rollup": ">=4.59.0",
"tar": ">=7.5.8",
"@tootallnate/once": ">=3.0.1"
"@tootallnate/once": ">=3.0.1",
"undici": ">=7.24.0"
},
"keywords": []
}
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
10 changes: 5 additions & 5 deletions api/src/utils/market-app.utils.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import contentstack from '@contentstack/marketplace-sdk';
import {client} from '@contentstack/marketplace-sdk';
import { DEVURLS } from '../constants/index.js';




export const getAllApps = async ({ organizationUid, authtoken, region }: any) => {
try {
const client = contentstack.client({ authtoken, host: DEVURLS?.[region] ?? DEVURLS?.NA });
const data = await client.marketplace(organizationUid).findAllApps();
const contentstackclient = client({ authtoken, host: DEVURLS?.[region] ?? DEVURLS?.NA });
const data = await contentstackclient.marketplace(organizationUid).findAllApps();
return data?.items;
} catch (err) {
console.info("🚀 ~ getAllApps ~ err:", err)
Expand All @@ -16,8 +16,8 @@ export const getAllApps = async ({ organizationUid, authtoken, region }: any) =>

export const getAppManifestAndAppConfig = async ({ organizationUid, authtoken, region, manifestUid }: any) => {
try {
const client = contentstack.client({ authtoken, host: DEVURLS?.[region] ?? DEVURLS?.NA });
const data = await client.marketplace(organizationUid).app(manifestUid).fetch();
const contentstackclient = client({ authtoken, host: DEVURLS?.[region] ?? DEVURLS?.NA });
const data = await contentstackclient.marketplace(organizationUid).app(manifestUid).fetch();
return data;
} catch (err: any) {
console.info("🚀 ~ getAppManifestAndAppConfig ~ err:", err)
Expand Down
10 changes: 4 additions & 6 deletions api/tests/unit/utils/market-app.utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ const mockClient = {
};

vi.mock('@contentstack/marketplace-sdk', () => ({
default: {
client: vi.fn(() => mockClient),
},
client: vi.fn(() => mockClient),
}));

vi.mock('../../../src/constants/index.js', () => ({
Expand All @@ -17,7 +15,7 @@ vi.mock('../../../src/constants/index.js', () => ({
},
}));

import contentstack from '@contentstack/marketplace-sdk';
import { client as marketplaceClient } from '@contentstack/marketplace-sdk';
import {
getAllApps,
getAppManifestAndAppConfig,
Expand Down Expand Up @@ -48,7 +46,7 @@ describe('market-app.utils', () => {
});

expect(result).toEqual(mockItems);
expect(contentstack.client).toHaveBeenCalledWith({
expect(marketplaceClient).toHaveBeenCalledWith({
authtoken: 'token-xyz',
host: 'developerhub-api.contentstack.com',
});
Expand All @@ -66,7 +64,7 @@ describe('market-app.utils', () => {
region: 'EU',
});

expect(contentstack.client).toHaveBeenCalledWith({
expect(marketplaceClient).toHaveBeenCalledWith({
authtoken: 'token',
host: 'eu-developerhub-api.contentstack.com',
});
Expand Down
Loading
Loading