Skip to content

Commit

Permalink
final changes for handling v1 and v0 handpoint in any order
Browse files Browse the repository at this point in the history
  • Loading branch information
anantjain45823 committed Sep 27, 2023
1 parent 76f969c commit ae0f121
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
13 changes: 5 additions & 8 deletions src/helpers/fetchHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
15 changes: 5 additions & 10 deletions src/services/source/nativeIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>(
sourceEvents.map(async (sourceEvent) => {
try {
Expand Down

0 comments on commit ae0f121

Please sign in to comment.