From dc035463f7700e719d33f570307f9a780d342663 Mon Sep 17 00:00:00 2001 From: AishDani Date: Wed, 21 Aug 2024 11:26:18 +0530 Subject: [PATCH 1/3] refactor:uncaught error on file validation --- ui/src/services/api/upload.service.ts | 19 ++++++------------- uplaode-api/src/services/fileProcessing.ts | 4 ++-- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/ui/src/services/api/upload.service.ts b/ui/src/services/api/upload.service.ts index 2c56606e3..3f447022b 100644 --- a/ui/src/services/api/upload.service.ts +++ b/ui/src/services/api/upload.service.ts @@ -8,12 +8,8 @@ export const getCall = async (url: string, options?: any) => { try { const response = await axios.get(url, { ...options }); return response; - } catch (error) { - if (error instanceof Error) { - throw new Error(`${error.message}`); - } else { - throw new Error('Unknown error in userSession'); - } + } catch (err: any) { + return err.response; } }; @@ -44,7 +40,7 @@ export const uploadFilePath = () => { return `${UPLOAD_FILE_RELATIVE_URL}upload`; }; -export const fileValidation = (projectId: string) => { +export const fileValidation = async(projectId: string) => { try { const options = { headers: { @@ -53,16 +49,13 @@ export const fileValidation = (projectId: string) => { }, }; - return getCall(`${UPLOAD_FILE_RELATIVE_URL}validator`, options); + return await getCall(`${UPLOAD_FILE_RELATIVE_URL}validator`, options); } catch (error) { - if (error instanceof Error) { - throw new Error(`${error.message}`); - } else { - throw new Error('Unknown error'); - } + return error; } }; + export const getConfig = async() => { try { return await getCall(`${UPLOAD_FILE_RELATIVE_URL}config`); diff --git a/uplaode-api/src/services/fileProcessing.ts b/uplaode-api/src/services/fileProcessing.ts index 5df0fe6bf..4a92b700b 100644 --- a/uplaode-api/src/services/fileProcessing.ts +++ b/uplaode-api/src/services/fileProcessing.ts @@ -10,7 +10,7 @@ const handleFileProcessing = async (fileExt: string, zipBuffer: any, cmsType: st if (fileExt === 'zip') { const zip = new JSZip(); await zip.loadAsync(zipBuffer); - if (validator({ data: zip, type: cmsType, extension: fileExt })) { + if (await validator({ data: zip, type: cmsType, extension: fileExt })) { const isSaved = await saveZip(zip); if (isSaved) { logger.info('Validation success:', { @@ -38,7 +38,7 @@ const handleFileProcessing = async (fileExt: string, zipBuffer: any, cmsType: st // if file is not zip // Convert the buffer to a string assuming it's UTF-8 encoded const jsonString = Buffer?.from?.(zipBuffer)?.toString?.('utf8'); - if (validator({ data: jsonString, type: cmsType, extension: fileExt })) { + if (await validator({ data: jsonString, type: cmsType, extension: fileExt })) { logger.info('Validation success:', { status: HTTP_CODES?.OK, message: HTTP_TEXTS?.VALIDATION_SUCCESSFULL, From e85f278dc3abdc4e489adb63b206d1a02a02ccee Mon Sep 17 00:00:00 2001 From: AishDani Date: Wed, 21 Aug 2024 11:31:11 +0530 Subject: [PATCH 2/3] refactor:nesdted group field mapping:[CMG-289] --- ui/src/components/ContentMapper/index.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ui/src/components/ContentMapper/index.tsx b/ui/src/components/ContentMapper/index.tsx index dbe038206..7ccfd0b27 100644 --- a/ui/src/components/ContentMapper/index.tsx +++ b/ui/src/components/ContentMapper/index.tsx @@ -886,11 +886,10 @@ const ContentMapper = forwardRef(({projectData}: ContentMapperComponentProps, re for (const item of array) { const fieldTypeToMatch = fieldsOfContentstack[item?.otherCmsType as keyof Mapping]; if (item.id === data?.id) { + for (const key of existingField[groupArray[0]?.uid]?.value.schema || []) { - - if (checkConditions(fieldTypeToMatch, key, item)) { + if (checkConditions(fieldTypeToMatch, key, item)) { OptionsForRow.push(getMatchingOption(key, true, `${updatedDisplayName} > ${key.display_name} || ''`)); - break; } // Recursively process nested groups From 4737e375ccb444c0dcbd83ff46f20ab97e1ca741 Mon Sep 17 00:00:00 2001 From: AishDani Date: Wed, 21 Aug 2024 12:16:56 +0530 Subject: [PATCH 3/3] refactor:[cmg-289] --- ui/src/components/ContentMapper/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/src/components/ContentMapper/index.tsx b/ui/src/components/ContentMapper/index.tsx index cac3a6d7c..31c999690 100644 --- a/ui/src/components/ContentMapper/index.tsx +++ b/ui/src/components/ContentMapper/index.tsx @@ -888,7 +888,6 @@ const ContentMapper = forwardRef(({projectData}: ContentMapperComponentProps, re if (checkConditions(fieldTypeToMatch, key, item)) { OptionsForRow.push(getMatchingOption(key, true, `${updatedDisplayName} > ${key.display_name}` || '')); - break; } // Recursively process nested groups