Skip to content

Commit

Permalink
chore: resolve pr conflicts (#2739)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: chandumlg <[email protected]>
  • Loading branch information
3 people authored Oct 18, 2023
1 parent 46b66da commit e1410eb
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 e1410eb

Please sign in to comment.