From ae0f1219f845fd5d2831337a3b947600299f3bd3 Mon Sep 17 00:00:00 2001 From: Anant Jain Date: Wed, 27 Sep 2023 19:43:10 +0530 Subject: [PATCH] final changes for handling v1 and v0 handpoint in any order --- src/helpers/fetchHandlers.ts | 13 +++++-------- src/services/source/nativeIntegration.ts | 15 +++++---------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/helpers/fetchHandlers.ts b/src/helpers/fetchHandlers.ts index 33df4a5236..b9ab7dde56 100644 --- a/src/helpers/fetchHandlers.ts +++ b/src/helpers/fetchHandlers.ts @@ -20,16 +20,13 @@ export default class FetchHandler { public static getSourceHandler(source: string, version: string) { let sourceHandler: any; - let sourceVersion = version; - if (this.sourceHandlerMap.has(source)) { - const sourceHandlerAndVersion = this.sourceHandlerMap.get(source); - sourceHandler = sourceHandlerAndVersion.sourceHandler; - sourceVersion = sourceHandlerAndVersion.sourceVersion; + if (this.sourceHandlerMap.has(`${source}_${version}`)) { + sourceHandler = this.sourceHandlerMap.get(`${source}_${version}`); } else { - sourceHandler = MiscService.getSourceHandler(source, sourceVersion); - this.sourceHandlerMap.set(source, { sourceVersion, sourceHandler }); + sourceHandler = MiscService.getSourceHandler(source, version); + this.sourceHandlerMap.set(`${source}_${version}`, sourceHandler); } - return { sourceHandler, sourceVersion }; + return sourceHandler; } public static getDeletionHandler(dest: string, version: string) { diff --git a/src/services/source/nativeIntegration.ts b/src/services/source/nativeIntegration.ts index 17decc05ab..505c5cdba1 100644 --- a/src/services/source/nativeIntegration.ts +++ b/src/services/source/nativeIntegration.ts @@ -35,21 +35,16 @@ export default class NativeIntegrationSourceService implements IntegrationSource let sourceHandler: any; let sourceVersion = version; try { - const sourceHandlerAndVersion = FetchHandler.getSourceHandler(sourceType, version); - sourceHandler = sourceHandlerAndVersion.sourceHandler; - sourceVersion = sourceHandlerAndVersion.sourceVersion; - } catch (error) { - if (version === 'v1') { + sourceHandler = FetchHandler.getSourceHandler(sourceType, version); + } catch (error) { + if (version === 'v1') { + sourceEvents = (sourceEvents as SourceInput[]).map(sourceEvent => sourceEvent.event); sourceVersion = 'v0'; - const sourceHandlerAndVersion = FetchHandler.getSourceHandler(sourceType, sourceVersion); - sourceHandler = sourceHandlerAndVersion.sourceHandler; + sourceHandler = FetchHandler.getSourceHandler(sourceType, sourceVersion); } else { throw error; } } - if (version === "v1" && sourceVersion === "v0") { - sourceEvents = (sourceEvents as SourceInput[]).map(sourceEvent => sourceEvent.event); - } const respList: SourceTransformationResponse[] = await Promise.all( sourceEvents.map(async (sourceEvent) => { try {