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: 2 additions & 0 deletions api/src/models/project-lowdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ interface Project {
created_at: string;
updated_at: string;
isDeleted: boolean;
isNewStack: boolean;
newStackId: string;
}

interface ProjectDocument {
Expand Down
41 changes: 41 additions & 0 deletions api/src/services/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ const createProject = async (req: Request) => {
updated_at: new Date().toISOString(),
created_at: new Date().toISOString(),
isDeleted: false,
isNewStack: false,
newStackId: "",
};

try {
Expand Down Expand Up @@ -170,6 +172,10 @@ const updateProject = async (req: Request) => {
ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].name = updateData?.name;
data.projects[projectIndex].description = updateData?.description;
if(data.projects[projectIndex].isNewStack === false && updateData?.isNewStack === true){
data.projects[projectIndex].isNewStack = updateData?.isNewStack ;
data.projects[projectIndex].newStackId = updateData?.newStackId;
}
data.projects[projectIndex].updated_by = user_id;
data.projects[projectIndex].updated_at = new Date().toISOString();
project = data.projects[projectIndex];
Expand Down Expand Up @@ -352,6 +358,38 @@ const affixConfirmation = async (req: Request) => {
};
};

const updateNewStack = async (req: Request) => {
const srcFunc = "updateNewStack";
const { orgId, projectId } = req.params;
const { token_payload } = req.body;

await ProjectModelLowdb.read();
const projectIndex = (await getProjectUtil(
projectId,
{
id: projectId,
org_id: orgId,
region: token_payload?.region,
owner: token_payload?.user_id,
},
srcFunc,
true
)) as number;

ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].isNewStack = true;
data.projects[projectIndex].updated_at = new Date().toISOString();
});

return {
status: HTTP_CODES.OK,
data: {
message: HTTP_TEXTS.NEW_STACK_CREATED,
},
};
};


const updateFileFormat = async (req: Request) => {
const { orgId, projectId } = req.params;
const {
Expand Down Expand Up @@ -813,6 +851,8 @@ const revertProject = async (req: Request) => {
};
}
};


export const projectService = {
getAllProjects,
getProject,
Expand All @@ -821,6 +861,7 @@ export const projectService = {
updateLegacyCMS,
updateAffix,
affixConfirmation,
updateNewStack,
updateFileFormat,
fileformatConfirmation,
updateDestinationStack,
Expand Down
15 changes: 10 additions & 5 deletions uplaode-api/src/controllers/sitecore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@ const createSitecoreMapper = async (filePath: string = "", projectId: string | s
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 fileContent = readFileSync(`${infoMap?.path}/global_fields/globalfields.json`, 'utf8');
const jsonfileContent = JSON.parse(fileContent);
for (const key in jsonfileContent) {
if (jsonfileContent.hasOwnProperty(key)) {
const element = jsonfileContent[key];
element.type = "global_field";
}
}
fieldMapping.contentTypes.push(jsonfileContent);

const config = {
method: 'post',
maxBodyLength: Infinity,
Expand Down