Skip to content

Commit

Permalink
chore: resolve pr conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
mihir-4116 committed Oct 18, 2023
2 parents 46b66da + c9e8bdb commit d132926
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/services/userTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
ProcessorTransformationResponse,
UserTransformationResponse,
UserTransformationServiceResponse,
MessageIdMetadataMap,
} from '../types/index';
import {
RespStatusError,
Expand Down Expand Up @@ -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<string>(messageIds);
const messageIds: string[] = [];
const messageIdsSet = new Set<string>();
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<string>();

const commonMetadata = {
Expand Down Expand Up @@ -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,
},
Expand Down
5 changes: 5 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ type Metadata = {
transformationId: string;
};

type MessageIdMetadataMap = {
[key: string]: Metadata;
};

type UserTransformationInput = {
VersionID: string;
ID: string;
Expand Down Expand Up @@ -223,6 +227,7 @@ type ComparatorInput = {

export {
Metadata,
MessageIdMetadataMap,
UserTransformationLibrary,
ProcessorTransformationRequest,
ProcessorTransformationResponse,
Expand Down

0 comments on commit d132926

Please sign in to comment.