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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const appDetails = require('../utils/apps/appDetails.json')
*/
const uidCorrector = (uid, affix) => {
let newId = uid;
if (restrictedUid?.includes?.(uid)) {
if (restrictedUid?.includes?.(uid) || uid?.startsWith?.('_ids') || uid?.endsWith?.('_ids')) {
newId = uid?.replace?.(uid, `${affix}_${uid}`);
newId = newId?.replace?.(/[^a-zA-Z0-9]+/g, '_');
}
Expand Down
6 changes: 3 additions & 3 deletions upload-api/migration-contentful/libs/createInitialMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const idArray = require('../utils/restrictedKeyWords');
*/
const uidCorrector = (uid, prefix) => {
let newId = uid;
if (idArray.includes(uid)) {
if (idArray.includes(uid) || uid.startsWith('_ids') || uid.endsWith('_ids')) {
newId = uid.replace(uid, `${prefix}_${uid}`);
newId = newId.replace(/[^a-zA-Z0-9]+/g, '_');
}
Expand All @@ -62,7 +62,7 @@ const uidCorrector = (uid, prefix) => {
*
* // Outputs: an array of content type objects, each containing metadata and field mappings.
*/
const createInitialMapper = async () => {
const createInitialMapper = async (affix="") => {
try {
const initialMapper = [];
const files = await fs.readdir(
Expand All @@ -82,7 +82,7 @@ const createInitialMapper = async () => {
otherCmsTitle: title,
otherCmsUid: data[0]?.contentfulID,
contentstackTitle: title.charAt(0).toUpperCase() + title.slice(1),
contentstackUid: uidCorrector(data[0]?.contentUid),
contentstackUid: uidCorrector(data[0]?.contentUid,affix),
type: 'content_type',
fieldMapping: []
};
Expand Down
2 changes: 1 addition & 1 deletion upload-api/src/services/contentful/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const createContentfulMapper = async (
const fetchedLocales: [] = await extractLocale(cleanLocalPath);

await extractContentTypes(cleanLocalPath, affix);
const initialMapper = await createInitialMapper();
const initialMapper = await createInitialMapper(affix);
const req = {
method: 'post',
maxBodyLength: Infinity,
Expand Down