diff --git a/api/src/constants/index.ts b/api/src/constants/index.ts index c397cff38..70cf53787 100644 --- a/api/src/constants/index.ts +++ b/api/src/constants/index.ts @@ -116,7 +116,7 @@ export const PROJECT_STATUS = { FAILED: "Failed", SUCCESS: "Success", }; -export const STEPPER_STEPS = { +export const STEPPER_STEPS: any = { LEGACY_CMS: 1, DESTINATION_STACK: 2, CONTENT_MAPPING: 3, diff --git a/api/src/routes/migration.routes.ts b/api/src/routes/migration.routes.ts index ac0ce8f69..a50ee9ec4 100644 --- a/api/src/routes/migration.routes.ts +++ b/api/src/routes/migration.routes.ts @@ -9,7 +9,7 @@ import { migrationController } from "../controllers/migration.controller.js"; const router = express.Router({ mergeParams: true }); /** - * Route for creating a new test stack. + * Route for test migration . * @route POST /test-stack/:orgId/:projectId * @group Migration * @param {string} orgId - The ID of the organization. @@ -46,4 +46,18 @@ router.post( ); +/** + * Route for final migration . + * @route POST /test-stack/:orgId/:projectId + * @group Migration + * @param {string} orgId - The ID of the organization. + * @param {string} projectId - The ID of the project. + * @returns {Promise} - A promise that resolves when the test stack is created. + */ +router.post( + "/start/:orgId/:projectId", + asyncRouter(migrationController.fieldMapping) +); + + export default router; diff --git a/api/src/services/migration.service.ts b/api/src/services/migration.service.ts index 133f27ac4..0e6004570 100644 --- a/api/src/services/migration.service.ts +++ b/api/src/services/migration.service.ts @@ -7,7 +7,7 @@ import https from "../utils/https.utils.js"; import { LoginServiceType } from "../models/types.js"; import getAuthtoken from "../utils/auth.utils.js"; import logger from "../utils/logger.js"; -import { HTTP_TEXTS, HTTP_CODES, CS_REGIONS, LOCALE_MAPPER } from "../constants/index.js"; +import { HTTP_TEXTS, HTTP_CODES, CS_REGIONS, LOCALE_MAPPER, STEPPER_STEPS } from "../constants/index.js"; import { ExceptionFunction } from "../utils/custom-errors.utils.js"; import { fieldAttacher } from "../utils/field-attacher.utils.js"; import ProjectModelLowdb from "../models/project-lowdb.js"; @@ -38,7 +38,6 @@ const createTestStack = async (req: Request): Promise => { const { token_payload } = req.body; const description = 'This is a system-generated test stack.' const name = 'Test'; - const master_locale = Object?.keys?.(LOCALE_MAPPER?.masterLocale)?.[0]; try { @@ -49,7 +48,7 @@ const createTestStack = async (req: Request): Promise => { await ProjectModelLowdb.read(); const projectData: any = ProjectModelLowdb.chain.get("projects").find({ id: projectId }).value(); - console.info("🚀 ~ createTestStack ~ projectData:", projectData) + const master_locale = projectData?.stackDetails?.master_locale ?? Object?.keys?.(LOCALE_MAPPER?.masterLocale)?.[0]; const testStackCount = projectData?.test_stacks?.length + 1; const newName = name + "-" + testStackCount; @@ -95,6 +94,7 @@ const createTestStack = async (req: Request): Promise => { .value(); if (index > -1) { ProjectModelLowdb.update((data: any) => { + data.projects[index].current_step = STEPPER_STEPS['TESTING']; data.projects[index].current_test_stack_id = res?.data?.stack?.api_key; data.projects[index].test_stacks.push({ stackUid: res?.data?.stack?.api_key, isMigrated: false }); });