From e1410eb3bbc001a8cbac952bd11ace217ea0143a Mon Sep 17 00:00:00 2001 From: Mihir Bhalala <77438541+mihir-4116@users.noreply.github.com> Date: Wed, 18 Oct 2023 08:03:07 +0530 Subject: [PATCH] chore: resolve pr conflicts (#2739) * fix: add event metadata to 298 status code responses * chore(release): 1.45.2 * fix: ut metadata map ts type * chore(release): 1.45.3 --------- Co-authored-by: srikanth Co-authored-by: chandumlg <54652834+chandumlg@users.noreply.github.com> --- src/services/userTransform.ts | 14 +++++++++++--- src/types/index.ts | 5 +++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/services/userTransform.ts b/src/services/userTransform.ts index d54c105b023..5104418f6d8 100644 --- a/src/services/userTransform.ts +++ b/src/services/userTransform.ts @@ -7,6 +7,7 @@ import { ProcessorTransformationResponse, UserTransformationResponse, UserTransformationServiceResponse, + MessageIdMetadataMap, } from '../types/index'; import { RespStatusError, @@ -49,8 +50,15 @@ export default class UserTransformService { const eventsToProcess = destEvents as ProcessorTransformationRequest[]; const transformationVersionId = eventsToProcess[0]?.destination?.Transformations[0]?.VersionID; - const messageIds = eventsToProcess.map((ev) => ev.metadata?.messageId); - const messageIdsSet = new Set(messageIds); + const messageIds: string[] = []; + const messageIdsSet = new Set(); + const messageIdMetadataMap: MessageIdMetadataMap = {}; + eventsToProcess.forEach((ev) => { + messageIds.push(ev.metadata?.messageId); + messageIdsSet.add(ev.metadata?.messageId); + messageIdMetadataMap[ev.metadata?.messageId] = ev.metadata; + }); + const messageIdsInOutputSet = new Set(); const commonMetadata = { @@ -125,7 +133,7 @@ export default class UserTransformService { const droppedEvents = messageIdsNotInOutput.map((id) => ({ statusCode: HTTP_CUSTOM_STATUS_CODES.FILTERED, metadata: { - ...commonMetadata, + ...(isEmpty(messageIdMetadataMap[id]) ? commonMetadata : messageIdMetadataMap[id]), messageId: id, messageIds: null, }, diff --git a/src/types/index.ts b/src/types/index.ts index ff0c1f88b9e..5a35b697d6c 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -52,6 +52,10 @@ type Metadata = { transformationId: string; }; +type MessageIdMetadataMap = { + [key: string]: Metadata; +}; + type UserTransformationInput = { VersionID: string; ID: string; @@ -223,6 +227,7 @@ type ComparatorInput = { export { Metadata, + MessageIdMetadataMap, UserTransformationLibrary, ProcessorTransformationRequest, ProcessorTransformationResponse,