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
10 changes: 10 additions & 0 deletions api/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,13 @@ export const PREDEFINED_STATUS = [
"Success",
];
export const PREDEFINED_STEPS = [1, 2, 3, 4, 5];

export const NEW_PROJECT_STATUS = {
0: 0, //DRAFT
1: 1, //READY_TO_TEST
2: 2, //TESTING_IN_PROGRESS
3: 3, //READY_FOR_MIGRATION
4: 4, //MIGRATION_IN_PROGRESS
5: 5, //MIGRATION_SUCCESSFUL
6: 6 //MIGRATION_TERMINATED
};
2 changes: 1 addition & 1 deletion api/src/models/project-lowdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface Project {
former_owner_ids: [];
name: string;
description: string;
status: string;
status: number;
current_step: number;
destination_stack_id: string;
test_stacks: [];
Expand Down
17 changes: 9 additions & 8 deletions api/src/services/contentMapper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
import {
HTTP_TEXTS,
HTTP_CODES,
PROJECT_STATUS,
STEPPER_STEPS,
NEW_PROJECT_STATUS
} from "../constants/index.js";
import logger from "../utils/logger.js";
import { config } from "../config/index.js";
Expand Down Expand Up @@ -251,12 +251,13 @@ const updateContentType = async (req: Request) => {

if (
[
PROJECT_STATUS.DRAFT,
PROJECT_STATUS.SUCCESS,
PROJECT_STATUS.INPROGRESS,
NEW_PROJECT_STATUS[0],
NEW_PROJECT_STATUS[5],
NEW_PROJECT_STATUS[4],
].includes(project.status) ||
project.current_step < STEPPER_STEPS.CONTENT_MAPPING
) {
)
{
logger.error(
getLogMessage(
srcFun,
Expand Down Expand Up @@ -366,9 +367,9 @@ const resetToInitialMapping = async (req: Request) => {

if (
[
PROJECT_STATUS.DRAFT,
PROJECT_STATUS.SUCCESS,
PROJECT_STATUS.INPROGRESS,
NEW_PROJECT_STATUS[0],
NEW_PROJECT_STATUS[5],
NEW_PROJECT_STATUS[4],
].includes(project.status) ||
project.current_step < STEPPER_STEPS.CONTENT_MAPPING
) {
Expand Down
28 changes: 14 additions & 14 deletions api/src/services/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
import {
HTTP_TEXTS,
HTTP_CODES,
PROJECT_STATUS,
STEPPER_STEPS,
NEW_PROJECT_STATUS
} from "../constants/index.js";
import { config } from "../config/index.js";
import { getLogMessage, safePromise } from "../utils/index.js";
Expand Down Expand Up @@ -74,7 +74,7 @@ const createProject = async (req: Request) => {
former_owner_ids: [],
name,
description,
status: PROJECT_STATUS.DRAFT,
status: NEW_PROJECT_STATUS[0],
current_step: STEPPER_STEPS.LEGACY_CMS,
destination_stack_id: "",
test_stacks: [],
Expand Down Expand Up @@ -219,8 +219,8 @@ const updateLegacyCMS = async (req: Request) => {
const project = ProjectModelLowdb.data.projects[projectIndex];

if (
project.status === PROJECT_STATUS.INPROGRESS ||
project.status === PROJECT_STATUS.SUCCESS
project.status === NEW_PROJECT_STATUS[4] ||
project.status === NEW_PROJECT_STATUS[5]
) {
logger.error(
getLogMessage(srcFunc, HTTP_TEXTS.CANNOT_UPDATE_LEGACY_CMS, token_payload)
Expand All @@ -243,7 +243,7 @@ const updateLegacyCMS = async (req: Request) => {
ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].legacy_cms.cms = legacy_cms;
data.projects[projectIndex].current_step = STEPPER_STEPS.LEGACY_CMS;
data.projects[projectIndex].status = PROJECT_STATUS.DRAFT;
data.projects[projectIndex].status = NEW_PROJECT_STATUS[0];
data.projects[projectIndex].updated_at = new Date().toISOString();
});

Expand Down Expand Up @@ -360,8 +360,8 @@ const updateFileFormat = async (req: Request) => {
const project = ProjectModelLowdb.data.projects[projectIndex];

if (
project.status === PROJECT_STATUS.INPROGRESS ||
project.status === PROJECT_STATUS.SUCCESS
project.status === NEW_PROJECT_STATUS[4] ||
project.status === NEW_PROJECT_STATUS[5]
) {
logger.error(
getLogMessage(
Expand All @@ -388,7 +388,7 @@ const updateFileFormat = async (req: Request) => {
ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].legacy_cms.file_format = file_format;
data.projects[projectIndex].current_step = STEPPER_STEPS.LEGACY_CMS;
data.projects[projectIndex].status = PROJECT_STATUS.DRAFT;
data.projects[projectIndex].status = NEW_PROJECT_STATUS[0];
data.projects[projectIndex].updated_at = new Date().toISOString();
});

Expand Down Expand Up @@ -479,8 +479,8 @@ const updateDestinationStack = async (req: Request) => {
);

if (
project.status === PROJECT_STATUS.INPROGRESS ||
project.status === PROJECT_STATUS.SUCCESS ||
project.status === NEW_PROJECT_STATUS[4] ||
project.status === NEW_PROJECT_STATUS[5] ||
project.current_step < STEPPER_STEPS.DESTINATION_STACK
) {
logger.error(
Expand Down Expand Up @@ -531,7 +531,7 @@ const updateDestinationStack = async (req: Request) => {
data.projects[projectIndex].destination_stack_id = stack_api_key;
data.projects[projectIndex].current_step =
STEPPER_STEPS.DESTINATION_STACK;
data.projects[projectIndex].status = PROJECT_STATUS.DRAFT;
data.projects[projectIndex].status = NEW_PROJECT_STATUS[0];
data.projects[projectIndex].updated_at = new Date().toISOString();
});

Expand Down Expand Up @@ -590,7 +590,7 @@ const updateCurrentStep = async (req: Request) => {

switch (project.current_step) {
case STEPPER_STEPS.LEGACY_CMS: {
if (project.status !== PROJECT_STATUS.DRAFT || !isStepCompleted) {
if (project.status !== NEW_PROJECT_STATUS[0] || !isStepCompleted) {
logger.error(
getLogMessage(
srcFunc,
Expand All @@ -610,7 +610,7 @@ const updateCurrentStep = async (req: Request) => {
}
case STEPPER_STEPS.DESTINATION_STACK: {
if (
project.status !== PROJECT_STATUS.DRAFT ||
project.status !== NEW_PROJECT_STATUS[0] ||
!isStepCompleted ||
!project?.destination_stack_id
) {
Expand All @@ -629,7 +629,7 @@ const updateCurrentStep = async (req: Request) => {
ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].current_step =
STEPPER_STEPS.CONTENT_MAPPING;
data.projects[projectIndex].status = PROJECT_STATUS.READY;
data.projects[projectIndex].status = NEW_PROJECT_STATUS[3];
data.projects[projectIndex].updated_at = new Date().toISOString();
});
break;
Expand Down