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
2 changes: 1 addition & 1 deletion api/src/config/dev.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export const devConfig = {
},
LOG_FILE_PATH:
process.platform === "win32" ? ".\\combine.log" : "./combine.log", // Replace with the actual path to your log file
};
};
9 changes: 6 additions & 3 deletions api/src/controllers/projects.contentMapper.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ const resetContentType = async (req: Request, res: Response): Promise<void> => {
// res.status(200).json(resp);
// };

const removeContentMapper = async (req: Request, res: Response): Promise<void> => {
const removeContentMapper = async (
req: Request,
res: Response
): Promise<void> => {
const resp = await contentMapperService.removeContentMapper(req);
res.status(200).json(resp);
}
};

const getSingleContentTypes = async (
req: Request,
Expand All @@ -59,5 +62,5 @@ export const contentMapperController = {
resetContentType,
// removeMapping,
getSingleContentTypes,
removeContentMapper
removeContentMapper,
};
1 change: 1 addition & 0 deletions api/src/models/contentTypesMapper-lowdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface ContentTypesMapper {
contentstackUid: string;
status: number;
fieldMapping: [];
type : string;
}

// interface ContentTypesMapper {
Expand Down
2 changes: 1 addition & 1 deletion api/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,4 @@ try {
} catch (e) {
logger.error("Error while starting the server!");
logger.error(e);
}
}
27 changes: 14 additions & 13 deletions api/src/services/contentMapper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { ContentTypesMapper } from "../models/contentTypesMapper-lowdb.js";
// Developer service to create dummy contentmapping data
const putTestData = async (req: Request) => {
const projectId = req.params.projectId;
const contentTypes = req.body.contentTypes;
const contentTypes = req.body.contentTypes;

await FieldMapperModel.read();
contentTypes.map((type: any, index: any) => {
Expand All @@ -35,7 +35,7 @@ const putTestData = async (req: Request) => {
const id = field?.id || uuidv4();
fieldIds.push(id);
return { id, isDeleted: true, ...field };
});
}) ?? [];
FieldMapperModel.update((data: any) => {
data.field_mapper = [...(data?.field_mapper ?? []), ...fields];
});
Expand All @@ -45,7 +45,7 @@ const putTestData = async (req: Request) => {
await ContentTypesMapperModelLowdb.read();
const contentIds: string[] = [];
const contentType = contentTypes.map((item: any) => {
const id = item?.id || uuidv4();
const id = item?.id || uuidv4();
contentIds.push(id);
return { ...item, id };
});
Expand Down Expand Up @@ -532,7 +532,7 @@ const resetAllContentTypesMapping = async (projectId: string) => {
try {
const contentTypes = cData;
for (const contentType of contentTypes) {
if (contentType && !isEmpty(contentType.fieldMapping)) {
if (contentType && !isEmpty(contentType.fieldMapping)) {
for (const field of contentType.fieldMapping) {
await FieldMapperModel.read();
const fieldData = FieldMapperModel.chain
Expand Down Expand Up @@ -569,10 +569,8 @@ const resetAllContentTypesMapping = async (projectId: string) => {
});
}
}

}


return projectDetails;
} catch (error: any) {
logger.error(
Expand Down Expand Up @@ -735,13 +733,16 @@ const removeContentMapper = async (req: Request) => {
throw new BadRequestError(HTTP_TEXTS.PROJECT_NOT_FOUND);
}
await ContentTypesMapperModelLowdb.read();
const cData: ContentTypesMapper[] = projectDetails?.content_mapper.map((cId: string) => {
const contentTypeData: ContentTypesMapper = ContentTypesMapperModelLowdb.chain
.get("ContentTypesMappers")
.find({ id: cId })
.value();
return contentTypeData;
});
const cData: ContentTypesMapper[] = projectDetails?.content_mapper.map(
(cId: string) => {
const contentTypeData: ContentTypesMapper =
ContentTypesMapperModelLowdb.chain
.get("ContentTypesMappers")
.find({ id: cId })
.value();
return contentTypeData;
}
);

try {
const contentTypes: ContentTypesMapper[] = cData;
Expand Down
13 changes: 10 additions & 3 deletions api/src/services/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const getAllProjects = async (req: Request) => {
const orgId = req?.params?.orgId;

const decodedToken = req.body.token_payload;
const { user_id = "", region = "" } = decodedToken;
const { user_id = "", region = "" } = decodedToken;

await ProjectModelLowdb.read();
const projects = ProjectModelLowdb.chain
.get("projects")
Expand Down Expand Up @@ -354,7 +354,14 @@ const affixConfirmation = async (req: Request) => {

const updateFileFormat = async (req: Request) => {
const { orgId, projectId } = req.params;
const { token_payload, file_format,file_path,is_localPath,is_fileValid,awsDetails } = req.body;
const {
token_payload,
file_format,
file_path,
is_localPath,
is_fileValid,
awsDetails,
} = req.body;
const srcFunc = "updateFileFormat";
const projectIndex = (await getProjectUtil(
projectId,
Expand Down
2 changes: 1 addition & 1 deletion uplaode-api/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export default {
bucketName: 'migartion-test',
buketKey: 'project/package 45.zip'
},
localPath: '/Users/snehal.pimple/Desktop/package 45.zip'
localPath: '/Users/rohit/Desktop/package 45.zip'
};
14 changes: 11 additions & 3 deletions uplaode-api/src/controllers/sitecore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,17 @@ const createSitecoreMapper = async (filePath: string = "", projectId: string | s
if (infoMap?.contentTypeUids?.length) {
const fieldMapping: any = { contentTypes: [] };
for await (const contentType of infoMap?.contentTypeUids ?? []) {
fieldMapping?.contentTypes?.push(
JSON.parse(readFileSync(`${infoMap?.path}/content_types/${contentType}`, 'utf8'))
);
const fileContent = readFileSync(`${infoMap?.path}/content_types/${contentType}`, 'utf8');
const jsonfileContent = JSON.parse(fileContent);
jsonfileContent.type = "content_type";
fieldMapping?.contentTypes?.push(jsonfileContent);
}

for await (const contentType of infoMap?.globalFieldUids ?? []) {
const fileContent = readFileSync(`${infoMap?.path}/global_fields/${contentType}`, 'utf8');
const jsonfileContent = JSON.parse(fileContent);
jsonfileContent.type = "global_field";
fieldMapping?.contentTypes?.push(jsonfileContent);
}
const config = {
method: 'post',
Expand Down