diff --git a/utilities/project-factory/src/server/api/campaignApis.ts b/utilities/project-factory/src/server/api/campaignApis.ts index c047954c920..7f0d5778a2f 100644 --- a/utilities/project-factory/src/server/api/campaignApis.ts +++ b/utilities/project-factory/src/server/api/campaignApis.ts @@ -4,7 +4,7 @@ import { httpRequest } from "../utils/request"; import { getFormattedStringForDebug, logger } from "../utils/logger"; import createAndSearch from '../config/createAndSearch'; import { getDataFromSheet, generateActivityMessage, throwError, translateSchema, replicateRequest } from "../utils/genericUtils"; -import { immediateValidationForTargetSheet, validateSheetData, validateTargetSheetData } from '../validators/campaignValidators'; +import { validateSheetData, validateTargetSheetData } from '../validators/campaignValidators'; import { callMdmsTypeSchema, getCampaignNumber } from "./genericApis"; import { boundaryBulkUpload, convertToTypeData, generateHierarchy, generateProcessedFileAndPersist, getLocalizedName, reorderBoundariesOfDataAndValidate } from "../utils/campaignUtils"; const _ = require('lodash'); @@ -494,7 +494,7 @@ async function processValidate(request: any, localizationMap?: { [key: string]: const dataFromSheet = await getDataFromSheet(request, request?.body?.ResourceDetails?.fileStoreId, request?.body?.ResourceDetails?.tenantId, createAndSearchConfig, null, localizationMap) if (type == 'boundaryWithTarget') { logger.info("target sheet format validation started"); - immediateValidationForTargetSheet(dataFromSheet, localizationMap); + // immediateValidationForTargetSheet(dataFromSheet, localizationMap); logger.info("target sheet format validation completed and starts with data validation"); validateTargetSheetData(dataFromSheet, request, createAndSearchConfig?.boundaryValidation, localizationMap); logger.info("target sheet data validation completed"); diff --git a/utilities/project-factory/src/server/config/index.ts b/utilities/project-factory/src/server/config/index.ts index e5126d2a476..95ceca0a118 100644 --- a/utilities/project-factory/src/server/config/index.ts +++ b/utilities/project-factory/src/server/config/index.ts @@ -3,7 +3,7 @@ import { getErrorCodes } from "./constants"; // Defining the HOST variable const HOST = process.env.EGOV_HOST || - "https://unified-dev.digit.org/"; + "https://unified-qa.digit.org/"; // Checking if HOST is set, if not, exiting the process if (!HOST) { console.log("You need to set the HOST variable"); @@ -48,8 +48,8 @@ const config = { DB_CONFIG: { DB_USER: process.env.DB_USER || "postgres", DB_HOST: process.env.DB_HOST?.split(':')[0] || "localhost", - DB_NAME: process.env.DB_NAME || "postgres", - DB_PASSWORD: process.env.DB_PASSWORD || "postgres", + DB_NAME: process.env.DB_NAME || "postgres2", + DB_PASSWORD: process.env.DB_PASSWORD || "1234", DB_PORT: process.env.DB_PORT || "5432", }, // Application configuration @@ -73,20 +73,20 @@ const config = { host: { serverHost: HOST, // Kafka broker host - KAFKA_BROKER_HOST: process.env.KAFKA_BROKER_HOST || "kafka-v2.kafka-cluster:9092", - mdms: process.env.EGOV_MDMS_HOST || "https://unified-dev.digit.org/", - mdmsV2: process.env.EGOV_MDMS_V2_HOST || "https://unified-dev.digit.org/", - filestore: process.env.EGOV_FILESTORE_SERVICE_HOST || "https://unified-dev.digit.org/", + KAFKA_BROKER_HOST: process.env.KAFKA_BROKER_HOST || "localhost:9092", + mdms: process.env.EGOV_MDMS_HOST || "https://unified-qa.digit.org/", + mdmsV2: process.env.EGOV_MDMS_V2_HOST || "https://unified-qa.digit.org/", + filestore: process.env.EGOV_FILESTORE_SERVICE_HOST || "https://unified-qa.digit.org/", projectFactoryBff: "http://localhost:8080/", - idGenHost: process.env.EGOV_IDGEN_HOST || "https://unified-dev.digit.org/", - facilityHost: process.env.EGOV_FACILITY_HOST || "https://unified-dev.digit.org/", - boundaryHost: process.env.EGOV_BOUNDARY_HOST || "https://unified-dev.digit.org/", - projectHost: process.env.EGOV_PROJECT_HOST || "https://unified-dev.digit.org/", - userHost: process.env.EGOV_USER_HOST || "https://unified-dev.digit.org/", - productHost: process.env.EGOV_PRODUCT_HOST || "https://unified-dev.digit.org/", - hrmsHost: process.env.EGOV_HRMS_HOST || "https://unified-dev.digit.org/", - localizationHost: process.env.EGOV_LOCALIZATION_HOST || "https://unified-dev.digit.org/", - healthIndividualHost: process.env.EGOV_HEALTH_INDIVIDUAL_HOST || "https://unified-dev.digit.org/", + idGenHost: process.env.EGOV_IDGEN_HOST || "https://unified-qa.digit.org/", + facilityHost: process.env.EGOV_FACILITY_HOST || "https://unified-qa.digit.org/", + boundaryHost: process.env.EGOV_BOUNDARY_HOST || "https://unified-qa.digit.org/", + projectHost: process.env.EGOV_PROJECT_HOST || "https://unified-qa.digit.org/", + userHost: process.env.EGOV_USER_HOST || "https://unified-qa.digit.org/", + productHost: process.env.EGOV_PRODUCT_HOST || "https://unified-qa.digit.org/", + hrmsHost: process.env.EGOV_HRMS_HOST || "https://unified-qa.digit.org/", + localizationHost: process.env.EGOV_LOCALIZATION_HOST || "https://unified-qa.digit.org/", + healthIndividualHost: process.env.EGOV_HEALTH_INDIVIDUAL_HOST || "https://unified-qa.digit.org/", }, // Paths for different services paths: { diff --git a/utilities/project-factory/src/server/utils/campaignUtils.ts b/utilities/project-factory/src/server/utils/campaignUtils.ts index 5f158560cc5..496ba1bf507 100644 --- a/utilities/project-factory/src/server/utils/campaignUtils.ts +++ b/utilities/project-factory/src/server/utils/campaignUtils.ts @@ -1760,7 +1760,6 @@ async function getDifferentTabGeneratedBasedOnConfig(request: any, boundaryDataG const differentTabsBasedOnLevel = getLocalizedName(config?.boundary?.generateDifferentTabsOnBasisOf, localizationMap); logger.info(`Boundaries are seperated based on hierarchy type ${differentTabsBasedOnLevel}`) const isKeyOfThatTypePresent = boundaryData.some((data: any) => data.hasOwnProperty(differentTabsBasedOnLevel)); - console.group(isKeyOfThatTypePresent, ";;;;;;;;;;;;;;;;;;") const boundaryTypeOnWhichWeSplit = boundaryData.filter((data: any) => data[differentTabsBasedOnLevel]); if (isKeyOfThatTypePresent && boundaryTypeOnWhichWeSplit.length >= parseInt(config?.boundary?.numberOfBoundaryDataOnWhichWeSplit)) { logger.info(`sinces the conditions are matched boundaries are getting splitted into different tabs`) diff --git a/utilities/project-factory/src/server/utils/excelUtils.ts b/utilities/project-factory/src/server/utils/excelUtils.ts index b6277fa752a..42ce4a9237d 100644 --- a/utilities/project-factory/src/server/utils/excelUtils.ts +++ b/utilities/project-factory/src/server/utils/excelUtils.ts @@ -171,13 +171,11 @@ function lockTargetFields(newSheet: any, columnsNotToBeFreezed: any, boundaryCod // // Get headers in the first row and filter out empty items const headers = newSheet.getRow(1).values.filter((header: any) => header); - console.log(headers, "Filtered Headers in the first row"); // Unlock cells in the target columns if (Array.isArray(columnsNotToBeFreezed) && columnsNotToBeFreezed.length > 0) { columnsNotToBeFreezed.forEach((header) => { const targetColumnNumber = headers.indexOf(header) + 1; // Excel columns are 1-based - console.log(`Header: ${header}, Target Column Index: ${targetColumnNumber}`); if (targetColumnNumber > -1) { newSheet.eachRow((row: any, rowNumber: number) => { changeFirstRowColumnColour(newSheet, 'B6D7A8', targetColumnNumber); @@ -203,7 +201,6 @@ function lockTargetFields(newSheet: any, columnsNotToBeFreezed: any, boundaryCod selectLockedCells: true, selectUnlockedCells: true, }); - console.log('Sheet protection applied:', newSheet.sheetProtection); } diff --git a/utilities/project-factory/src/server/utils/genericUtils.ts b/utilities/project-factory/src/server/utils/genericUtils.ts index 180af4b2143..8bb639bcc0e 100644 --- a/utilities/project-factory/src/server/utils/genericUtils.ts +++ b/utilities/project-factory/src/server/utils/genericUtils.ts @@ -351,7 +351,6 @@ async function fullProcessFlowForNewEntry(newEntryResponse: any, generatedResour // get boundary sheet data after being generated logger.info("generating different tabs logic ") const boundaryDataSheetGeneratedAfterDifferentTabSeparation = await getDifferentTabGeneratedBasedOnConfig(request, boundaryDataSheetGeneratedBeforeDifferentTabSeparation, localizationMap) - console.log(boundaryDataSheetGeneratedAfterDifferentTabSeparation,"afffffffffffff") logger.info(`Different tabs based on level configured generated, ${JSON.stringify(boundaryDataSheetGeneratedAfterDifferentTabSeparation)}`) const finalResponse = await getFinalUpdatedResponse(boundaryDataSheetGeneratedAfterDifferentTabSeparation, newEntryResponse, request); const generatedResourceNew: any = { generatedResource: finalResponse } diff --git a/utilities/project-factory/src/server/validators/campaignValidators.ts b/utilities/project-factory/src/server/validators/campaignValidators.ts index 68a5a32b9c2..22607f9bd37 100644 --- a/utilities/project-factory/src/server/validators/campaignValidators.ts +++ b/utilities/project-factory/src/server/validators/campaignValidators.ts @@ -5,15 +5,15 @@ import { httpRequest } from "../utils/request"; import { getHeadersOfBoundarySheet, getHierarchy, handleResouceDetailsError } from "../api/campaignApis"; import { campaignDetailsSchema } from "../config/models/campaignDetails"; import Ajv from "ajv"; -import { calculateKeyIndex, getDifferentDistrictTabs, getLocalizedHeaders, getLocalizedMessagesHandler, modifyTargetData, replicateRequest, throwError } from "../utils/genericUtils"; -import { createBoundaryMap, generateProcessedFileAndPersist, getFinalValidHeadersForTargetSheetAsPerCampaignType, getLocalizedName, getTargetBoundariesRelatedToCampaignId } from "../utils/campaignUtils"; +import { getDifferentDistrictTabs, getLocalizedHeaders, getLocalizedMessagesHandler, replicateRequest, throwError } from "../utils/genericUtils"; +import { createBoundaryMap, generateProcessedFileAndPersist, getFinalValidHeadersForTargetSheetAsPerCampaignType, getLocalizedName } from "../utils/campaignUtils"; import { validateBodyViaSchema, validateCampaignBodyViaSchema, validateHierarchyType } from "./genericValidator"; import { searchCriteriaSchema } from "../config/models/SearchCriteria"; import { searchCampaignDetailsSchema } from "../config/models/searchCampaignDetails"; import { campaignDetailsDraftSchema } from "../config/models/campaignDetailsDraftSchema"; import { downloadRequestSchema } from "../config/models/downloadRequestSchema"; import { createRequestSchema } from "../config/models/createRequestSchema" -import { getSheetData, getTargetWorkbook } from "../api/genericApis"; +import { getSheetData } from "../api/genericApis"; const _ = require('lodash'); import { searchDataService } from "../service/dataManageService"; import { searchProjectTypeCampaignService } from "../service/campaignManageService"; @@ -144,113 +144,113 @@ async function validateBoundaryData(data: any[], request: any, boundaryColumn: a await validateUniqueBoundaries(uniqueBoundaries, request); } -async function validateTargetBoundaryData(data: any[], request: any, boundaryColumn: any, errors: any[], localizationMap?: any) { - // const responseBoundaries = await fetchBoundariesInChunks(request); - const responseBoundaries = await getTargetBoundariesRelatedToCampaignId(request, localizationMap); - const responseBoundaryCodes = responseBoundaries.map((boundary: any) => boundary.code); - // Iterate through each array of objects - for (const key in data) { - const isNotBoundaryOrReadMeTab = key !== getLocalizedName(getBoundaryTabName(), localizationMap) && key !== getLocalizedName(config?.values?.readMeTab, localizationMap); - if (isNotBoundaryOrReadMeTab) { - if (Array.isArray(data[key])) { - const boundaryData = data[key]; - const boundarySet = new Set(); // Create a Set to store unique boundaries for given sheet - boundaryData.forEach((element: any, index: number) => { - const boundaries = element?.[boundaryColumn]; // Access "Boundary Code" property directly - if (!boundaries) { - errors.push({ status: "INVALID", rowNumber: element["!row#number!"], errorDetails: `Boundary Code is required for element at row ${element["!row#number!"]} for sheet ${key}`, sheetName: key }) - } else { - if (typeof boundaries !== 'string') { - errors.push({ status: "INVALID", rowNumber: element["!row#number!"], errorDetails: `Boundary Code is not of type string at row ${element["!row#number!"]} in boundary sheet ${key}`, sheetName: key }); - } else { - const boundaryList = boundaries.split(",").map((boundary: any) => boundary.trim()); - if (boundaryList.length === 0 || boundaryList.includes('')) { - errors.push({ status: "INVALID", rowNumber: element["!row#number!"], errorDetails: `No boundary code found for row ${element["!row#number!"]} in boundary sheet ${key}`, sheetName: key }) - } - if (boundaryList.length > 1) { - errors.push({ status: "INVALID", rowNumber: element["!row#number!"], errorDetails: `More than one Boundary Code found at row ${element["!row#number!"]} of sheet ${key}`, sheetName: key }) - } - if (boundaryList.length === 1) { - const boundaryCode = boundaryList[0]; - if (boundarySet.has(boundaryCode)) { - errors.push({ status: "INVALID", rowNumber: element["!row#number!"], errorDetails: `Duplicacy of boundary Code at row ${element["!row#number!"]} of sheet ${key}`, sheetName: key }) - } - if (!responseBoundaryCodes.includes(boundaryCode)) { - errors.push({ status: "INVALID", rowNumber: element["!row#number!"], errorDetails: `Boundary Code at row ${element["!row#number!"]} of sheet ${key} is not present in the selected boundaries`, sheetName: key }) - } - boundarySet.add(boundaryCode); - } - } - } - }); - } - } - } -} - - - -async function validateTargetsAtLowestLevelPresentOrNot(data: any[], request: any, errors: any[], localizationMap?: any) { - const hierarchy = await getHierarchy(request, request?.body?.ResourceDetails?.tenantId, request?.body?.ResourceDetails?.hierarchyType); - const modifiedHierarchy = hierarchy.map(ele => `${request?.body?.ResourceDetails?.hierarchyType}_${ele}`.toUpperCase()) - const localizedHierarchy = getLocalizedHeaders(modifiedHierarchy, localizationMap); - const dataToBeValidated = modifyTargetData(data); - let maxKeyIndex = -1; - dataToBeValidated.forEach(obj => { - const keyIndex = calculateKeyIndex(obj, localizedHierarchy, localizationMap); - if (keyIndex > maxKeyIndex) { - maxKeyIndex = keyIndex; - } - }) - const lowestLevelHierarchy = localizedHierarchy[maxKeyIndex]; - validateTargets(data, lowestLevelHierarchy, errors, localizationMap); -} +// async function validateTargetBoundaryData(data: any[], request: any, boundaryColumn: any, errors: any[], localizationMap?: any) { +// // const responseBoundaries = await fetchBoundariesInChunks(request); +// const responseBoundaries = await getTargetBoundariesRelatedToCampaignId(request, localizationMap); +// const responseBoundaryCodes = responseBoundaries.map((boundary: any) => boundary.code); +// // Iterate through each array of objects +// for (const key in data) { +// const isNotBoundaryOrReadMeTab = key !== getLocalizedName(getBoundaryTabName(), localizationMap) && key !== getLocalizedName(config?.values?.readMeTab, localizationMap); +// if (isNotBoundaryOrReadMeTab) { +// if (Array.isArray(data[key])) { +// const boundaryData = data[key]; +// const boundarySet = new Set(); // Create a Set to store unique boundaries for given sheet +// boundaryData.forEach((element: any, index: number) => { +// const boundaries = element?.[boundaryColumn]; // Access "Boundary Code" property directly +// if (!boundaries) { +// errors.push({ status: "INVALID", rowNumber: element["!row#number!"], errorDetails: `Boundary Code is required for element at row ${element["!row#number!"]} for sheet ${key}`, sheetName: key }) +// } else { +// if (typeof boundaries !== 'string') { +// errors.push({ status: "INVALID", rowNumber: element["!row#number!"], errorDetails: `Boundary Code is not of type string at row ${element["!row#number!"]} in boundary sheet ${key}`, sheetName: key }); +// } else { +// const boundaryList = boundaries.split(",").map((boundary: any) => boundary.trim()); +// if (boundaryList.length === 0 || boundaryList.includes('')) { +// errors.push({ status: "INVALID", rowNumber: element["!row#number!"], errorDetails: `No boundary code found for row ${element["!row#number!"]} in boundary sheet ${key}`, sheetName: key }) +// } +// if (boundaryList.length > 1) { +// errors.push({ status: "INVALID", rowNumber: element["!row#number!"], errorDetails: `More than one Boundary Code found at row ${element["!row#number!"]} of sheet ${key}`, sheetName: key }) +// } +// if (boundaryList.length === 1) { +// const boundaryCode = boundaryList[0]; +// if (boundarySet.has(boundaryCode)) { +// errors.push({ status: "INVALID", rowNumber: element["!row#number!"], errorDetails: `Duplicacy of boundary Code at row ${element["!row#number!"]} of sheet ${key}`, sheetName: key }) +// } +// if (!responseBoundaryCodes.includes(boundaryCode)) { +// errors.push({ status: "INVALID", rowNumber: element["!row#number!"], errorDetails: `Boundary Code at row ${element["!row#number!"]} of sheet ${key} is not present in the selected boundaries`, sheetName: key }) +// } +// boundarySet.add(boundaryCode); +// } +// } +// } +// }); +// } +// } +// } +// } + + + +// async function validateTargetsAtLowestLevelPresentOrNot(data: any[], request: any, errors: any[], localizationMap?: any) { +// const hierarchy = await getHierarchy(request, request?.body?.ResourceDetails?.tenantId, request?.body?.ResourceDetails?.hierarchyType); +// const modifiedHierarchy = hierarchy.map(ele => `${request?.body?.ResourceDetails?.hierarchyType}_${ele}`.toUpperCase()) +// const localizedHierarchy = getLocalizedHeaders(modifiedHierarchy, localizationMap); +// const dataToBeValidated = modifyTargetData(data); +// let maxKeyIndex = -1; +// dataToBeValidated.forEach(obj => { +// const keyIndex = calculateKeyIndex(obj, localizedHierarchy, localizationMap); +// if (keyIndex > maxKeyIndex) { +// maxKeyIndex = keyIndex; +// } +// }) +// const lowestLevelHierarchy = localizedHierarchy[maxKeyIndex]; +// validateTargets(data, lowestLevelHierarchy, errors, localizationMap); +// } // -function validateTargets(data: any[], lowestLevelHierarchy: any, errors: any[], localizationMap?: any) { - for (const key in data) { - if (key !== getLocalizedName(getBoundaryTabName(), localizationMap) && key !== getLocalizedName(config?.values?.readMeTab, localizationMap)) { - if (Array.isArray(data[key])) { - const boundaryData = data[key]; - boundaryData.forEach((obj: any, index: number) => { - if (obj.hasOwnProperty(lowestLevelHierarchy) && obj[lowestLevelHierarchy]) { - const localizedTargetColumnName = getLocalizedName("ADMIN_CONSOLE_TARGET", localizationMap); - const target = obj[localizedTargetColumnName]; - if (!target) { - errors.push({ - status: "INVALID", - rowNumber: obj["!row#number!"], - errorDetails: `Target value is missing at row ${obj['!row#number!']} in sheet ${key}. Please provide a numeric integer between 1 and 100000.`, - sheetName: key - }); - } else if (typeof target !== 'number') { - errors.push({ - status: "INVALID", - rowNumber: obj["!row#number!"], - errorDetails: `Target value at row ${obj['!row#number!']} in sheet ${key} is not a number. Target values must be numeric integers between 1 and 100000.`, - sheetName: key - }); - } else if (target <= 0 || target > 100000) { - errors.push({ - status: "INVALID", - rowNumber: obj["!row#number!"], - errorDetails: `Target value ${target} at row ${obj['!row#number!']} in sheet ${key} is out of range. Target values must be numeric integers between 1 and 100000.`, - sheetName: key - }); - } else if (!Number.isInteger(target)) { - errors.push({ - status: "INVALID", - rowNumber: obj["!row#number!"], - errorDetails: `Target value ${target} at row ${obj['!row#number!']} in sheet ${key} is not an integer. Target values must be whole numbers between 1 and 100000.`, - sheetName: key - }); - } - - } - }); - } - } - } -} +// function validateTargets(data: any[], lowestLevelHierarchy: any, errors: any[], localizationMap?: any) { +// for (const key in data) { +// if (key !== getLocalizedName(getBoundaryTabName(), localizationMap) && key !== getLocalizedName(config?.values?.readMeTab, localizationMap)) { +// if (Array.isArray(data[key])) { +// const boundaryData = data[key]; +// boundaryData.forEach((obj: any, index: number) => { +// if (obj.hasOwnProperty(lowestLevelHierarchy) && obj[lowestLevelHierarchy]) { +// const localizedTargetColumnName = getLocalizedName("ADMIN_CONSOLE_TARGET", localizationMap); +// const target = obj[localizedTargetColumnName]; +// if (!target) { +// errors.push({ +// status: "INVALID", +// rowNumber: obj["!row#number!"], +// errorDetails: `Target value is missing at row ${obj['!row#number!']} in sheet ${key}. Please provide a numeric integer between 1 and 100000.`, +// sheetName: key +// }); +// } else if (typeof target !== 'number') { +// errors.push({ +// status: "INVALID", +// rowNumber: obj["!row#number!"], +// errorDetails: `Target value at row ${obj['!row#number!']} in sheet ${key} is not a number. Target values must be numeric integers between 1 and 100000.`, +// sheetName: key +// }); +// } else if (target <= 0 || target > 100000) { +// errors.push({ +// status: "INVALID", +// rowNumber: obj["!row#number!"], +// errorDetails: `Target value ${target} at row ${obj['!row#number!']} in sheet ${key} is out of range. Target values must be numeric integers between 1 and 100000.`, +// sheetName: key +// }); +// } else if (!Number.isInteger(target)) { +// errors.push({ +// status: "INVALID", +// rowNumber: obj["!row#number!"], +// errorDetails: `Target value ${target} at row ${obj['!row#number!']} in sheet ${key} is not an integer. Target values must be whole numbers between 1 and 100000.`, +// sheetName: key +// }); +// } + +// } +// }); +// } +// } +// } +// } async function validateUnique(schema: any, data: any[], request: any) { const localizationMap = await getLocalizedMessagesHandler(request, request?.body?.ResourceDetails?.tenantId); @@ -385,11 +385,11 @@ async function validateSheetData(data: any, request: any, schema: any, boundaryV async function validateTargetSheetData(data: any, request: any, boundaryValidation: any, localizationMap?: any) { try { const errors: any[] = []; - if (boundaryValidation) { - const localizedBoundaryValidationColumn = getLocalizedName(boundaryValidation?.column, localizationMap) - await validateTargetBoundaryData(data, request, localizedBoundaryValidationColumn, errors, localizationMap); - await validateTargetsAtLowestLevelPresentOrNot(data, request, errors, localizationMap); - } + // if (boundaryValidation) { + // const localizedBoundaryValidationColumn = getLocalizedName(boundaryValidation?.column, localizationMap) + // await validateTargetBoundaryData(data, request, localizedBoundaryValidationColumn, errors, localizationMap); + // await validateTargetsAtLowestLevelPresentOrNot(data, request, errors, localizationMap); + // } request.body.sheetErrorDetails = request?.body?.sheetErrorDetails ? [...request?.body?.sheetErrorDetails, ...errors] : errors; if (request?.body?.sheetErrorDetails && Array.isArray(request?.body?.sheetErrorDetails) && request?.body?.sheetErrorDetails?.length > 0) { request.body.ResourceDetails.status = resourceDataStatuses.invalid; @@ -491,27 +491,28 @@ async function validateCreateRequest(request: any, localizationMap?: any) { await validateBoundarySheetData(request, fileUrl, localizationMap); } if (request?.body?.ResourceDetails?.type == 'boundaryWithTarget') { - const targetWorkbook: any = await getTargetWorkbook(fileUrl); + // const targetWorkbook: any = await getTargetWorkbook(fileUrl); const hierarchy = await getHierarchy(request, request?.body?.ResourceDetails?.tenantId, request?.body?.ResourceDetails?.hierarchyType); const finalValidHeadersForTargetSheetAsPerCampaignType = await getFinalValidHeadersForTargetSheetAsPerCampaignType(request, hierarchy, localizationMap); - validateTabsWithTargetInTargetSheet(targetWorkbook, finalValidHeadersForTargetSheetAsPerCampaignType); + console.log(finalValidHeadersForTargetSheetAsPerCampaignType,"finalllllllllllll") + // validateTabsWithTargetInTargetSheet(targetWorkbook, finalValidHeadersForTargetSheetAsPerCampaignType); } } } -function validateTabsWithTargetInTargetSheet(targetWorkbook: any, expectedHeadersForTargetSheet: any) { - targetWorkbook.eachSheet((worksheet: any, sheetId: any) => { - if (sheetId > 2) { // Starting from the second sheet - // Convert the sheet to an array of headers - const headersToValidate = worksheet.getRow(1).values - .filter((header: any) => header !== undefined && header !== null && header.toString().trim() !== '') - .map((header: any) => header.toString().trim()); - if (!_.isEqual(expectedHeadersForTargetSheet, headersToValidate)) { - throwError("COMMON", 400, "VALIDATION_ERROR", `Headers not according to the template in Target sheet ${worksheet.name}`); - } - } - }); -} +// function validateTabsWithTargetInTargetSheet(targetWorkbook: any, expectedHeadersForTargetSheet: any) { +// targetWorkbook.eachSheet((worksheet: any, sheetId: any) => { +// if (sheetId > 2) { // Starting from the second sheet +// // Convert the sheet to an array of headers +// const headersToValidate = worksheet.getRow(1).values +// .filter((header: any) => header !== undefined && header !== null && header.toString().trim() !== '') +// .map((header: any) => header.toString().trim()); +// if (!_.isEqual(expectedHeadersForTargetSheet, headersToValidate)) { +// throwError("COMMON", 400, "VALIDATION_ERROR", `Headers not according to the template in Target sheet ${worksheet.name}`); +// } +// } +// }); +// } async function validateBoundarySheetData(request: any, fileUrl: any, localizationMap?: any) { const localizedBoundaryTab = getLocalizedName(getBoundaryTabName(), localizationMap);