Skip to content

Commit b324659

Browse files
Merge pull request #671 from contentstack/feature/rohit-contentful
Feature/rohit contentful
2 parents c5e664c + a2aa4e4 commit b324659

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

upload-api/migration-contentful/libs/contentTypeMapper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const appDetails = require('../utils/apps/appDetails.json')
2323
*/
2424
const uidCorrector = (uid, affix) => {
2525
let newId = uid;
26-
if (restrictedUid?.includes?.(uid)) {
26+
if (restrictedUid?.includes?.(uid) || uid?.startsWith?.('_ids') || uid?.endsWith?.('_ids')) {
2727
newId = uid?.replace?.(uid, `${affix}_${uid}`);
2828
newId = newId?.replace?.(/[^a-zA-Z0-9]+/g, '_');
2929
}

upload-api/migration-contentful/libs/createInitialMapper.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const idArray = require('../utils/restrictedKeyWords');
3636
*/
3737
const uidCorrector = (uid, prefix) => {
3838
let newId = uid;
39-
if (idArray.includes(uid)) {
39+
if (idArray.includes(uid) || uid.startsWith('_ids') || uid.endsWith('_ids')) {
4040
newId = uid.replace(uid, `${prefix}_${uid}`);
4141
newId = newId.replace(/[^a-zA-Z0-9]+/g, '_');
4242
}
@@ -62,7 +62,7 @@ const uidCorrector = (uid, prefix) => {
6262
*
6363
* // Outputs: an array of content type objects, each containing metadata and field mappings.
6464
*/
65-
const createInitialMapper = async () => {
65+
const createInitialMapper = async (affix="") => {
6666
try {
6767
const initialMapper = [];
6868
const files = await fs.readdir(
@@ -82,7 +82,7 @@ const createInitialMapper = async () => {
8282
otherCmsTitle: title,
8383
otherCmsUid: data[0]?.contentfulID,
8484
contentstackTitle: title.charAt(0).toUpperCase() + title.slice(1),
85-
contentstackUid: uidCorrector(data[0]?.contentUid),
85+
contentstackUid: uidCorrector(data[0]?.contentUid,affix),
8686
type: 'content_type',
8787
fieldMapping: []
8888
};

upload-api/src/services/contentful/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const createContentfulMapper = async (
1919
const fetchedLocales: [] = await extractLocale(cleanLocalPath);
2020

2121
await extractContentTypes(cleanLocalPath, affix);
22-
const initialMapper = await createInitialMapper();
22+
const initialMapper = await createInitialMapper(affix);
2323
const req = {
2424
method: 'post',
2525
maxBodyLength: Infinity,

0 commit comments

Comments
 (0)