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/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 15 additions & 1 deletion api/src/routes/migration.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<void>} - A promise that resolves when the test stack is created.
*/
router.post(
"/start/:orgId/:projectId",
asyncRouter(migrationController.fieldMapping)
);


export default router;
6 changes: 3 additions & 3 deletions api/src/services/migration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -38,7 +38,6 @@ const createTestStack = async (req: Request): Promise<LoginServiceType> => {
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 {
Expand All @@ -49,7 +48,7 @@ const createTestStack = async (req: Request): Promise<LoginServiceType> => {

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;

Expand Down Expand Up @@ -95,6 +94,7 @@ const createTestStack = async (req: Request): Promise<LoginServiceType> => {
.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 });
});
Expand Down