Skip to content

Commit

Permalink
chore: add types for source trasform event
Browse files Browse the repository at this point in the history
  • Loading branch information
koladilip committed Sep 2, 2024
1 parent 55401a5 commit 80afb86
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/services/source/nativeIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
ErrorDetailer,
MetaTransferObject,
RudderMessage,
SourceTransformationEvent,
SourceTransformationResponse,
} from '../../types/index';
import stats from '../../util/stats';
Expand All @@ -27,7 +28,7 @@ export class NativeIntegrationSourceService implements SourceService {
}

public async sourceTransformRoutine(
sourceEvents: NonNullable<unknown>[],
sourceEvents: NonNullable<SourceTransformationEvent>[],
sourceType: string,
version: string,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand All @@ -38,7 +39,7 @@ export class NativeIntegrationSourceService implements SourceService {
const respList: SourceTransformationResponse[] = await Promise.all<FixMe>(
sourceEvents.map(async (sourceEvent) => {
try {
const newSourceEvent = sourceEvent as { headers: any };
const newSourceEvent = sourceEvent;
const { headers } = newSourceEvent;
delete newSourceEvent.headers;
const respEvents: RudderMessage | RudderMessage[] | SourceTransformationResponse =
Expand Down
7 changes: 7 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ type RouterTransformationResponse = {
statTags?: object;
};

type SourceTransformationEvent = {
headers?: Record<string, string>;
query_params?: Record<string, string>;
[key: string]: any;
};

type SourceTransformationOutput = {
batch: RudderMessage[];
};
Expand Down Expand Up @@ -360,6 +366,7 @@ export {
RouterTransformationRequestData,
RouterTransformationResponse,
RudderMessage,
SourceTransformationEvent,
SourceTransformationResponse,
UserDeletionRequest,
UserDeletionResponse,
Expand Down
4 changes: 2 additions & 2 deletions src/v0/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ const getDestinationExternalIDInfoForRetl = (message, destination) => {
if (externalIdArray) {
externalIdArray.forEach((extIdObj) => {
const { type, id } = extIdObj;
if (type && type.includes(`${destination}-`)) {
if (type?.includes(`${destination}-`)) {
destinationExternalId = id;
objectType = type.replace(`${destination}-`, '');
identifierType = extIdObj.identifierType;
Expand All @@ -1195,7 +1195,7 @@ const getDestinationExternalIDObjectForRetl = (message, destination) => {
// some stops the execution when the element is found
externalIdArray.some((extIdObj) => {
const { type } = extIdObj;
if (type && type.includes(`${destination}-`)) {
if (type?.includes(`${destination}-`)) {
obj = extIdObj;
return true;
}
Expand Down

0 comments on commit 80afb86

Please sign in to comment.