From b7be26518f4f68e171a105f8abec4157406536d3 Mon Sep 17 00:00:00 2001 From: Yashasvi Bajpai <33063622+yashasvibajpai@users.noreply.github.com> Date: Tue, 28 May 2024 13:46:35 +0530 Subject: [PATCH] chore: fix exports, tests, rtflow removed --- .../klaviyo_bulk_upload/procWorkflow.yaml | 4 +- .../klaviyo_bulk_upload/rtWorkflow.yaml | 53 ----- .../destinations/klaviyo_bulk_upload/utils.js | 2 +- .../klaviyo_bulk_upload/processor/data.ts | 157 +------------ .../klaviyo_bulk_upload/router/data.ts | 213 ------------------ 5 files changed, 12 insertions(+), 417 deletions(-) delete mode 100644 src/cdk/v2/destinations/klaviyo_bulk_upload/rtWorkflow.yaml delete mode 100644 test/integrations/destinations/klaviyo_bulk_upload/router/data.ts diff --git a/src/cdk/v2/destinations/klaviyo_bulk_upload/procWorkflow.yaml b/src/cdk/v2/destinations/klaviyo_bulk_upload/procWorkflow.yaml index 0f30113cc2..44290ff520 100644 --- a/src/cdk/v2/destinations/klaviyo_bulk_upload/procWorkflow.yaml +++ b/src/cdk/v2/destinations/klaviyo_bulk_upload/procWorkflow.yaml @@ -17,9 +17,9 @@ steps: .message.type.toLowerCase(); - name: validateInput template: | - let messageType = $.outputs.messageType; + let messageType = .message.type; $.assert(messageType, "message Type is not present. Aborting"); - $.assert(messageType in {{$.EventType.([.IDENTIFY])}}, "message type " + messageType + " is not supported"); + $.assert(.message.type.toLowerCase() ==='identify', "Event type " + .message.type.toLowerCase() + " is not supported. Aborting message."); $.assertConfig(.destination.Config.privateApiKey, "Private Api Key is not present. Aborting"); - name: generatePayload diff --git a/src/cdk/v2/destinations/klaviyo_bulk_upload/rtWorkflow.yaml b/src/cdk/v2/destinations/klaviyo_bulk_upload/rtWorkflow.yaml deleted file mode 100644 index 437452acd5..0000000000 --- a/src/cdk/v2/destinations/klaviyo_bulk_upload/rtWorkflow.yaml +++ /dev/null @@ -1,53 +0,0 @@ -bindings: - - name: EventType - path: ../../../../constants - - path: ../../bindings/jsontemplate - exportAll: true - - path: ./config - - name: removeUndefinedAndNullValues - path: ../../../../v0/util - - name: defaultRequestConfig - path: ../../../../v0/util - - path: ./utils - - name: handleRtTfSingleEventError - path: ../../../../v0/util/index - -steps: - - name: validateInput - template: | - $.assert(Array.isArray(^) && ^.length > 0, "Invalid event array") - - - name: finalJsonPayload - template: | - const finalJsonPayload = $.combinePayloads(^.{.message.type === $.EventType.IDENTIFY}[], ^[0].destination) - finalJsonPayload - - - name: constructRouterPayload - template: | - const routerPayload = { - "batchedRequest": { - version: '1', - type: 'REST', - method: 'POST', - endpoint: '', - headers: { - 'Content-Type': 'application/json', - }, - params: {}, - body: { - JSON: $.outputs.finalJsonPayload.payload, - JSON_ARRAY: {}, - XML: {}, - FORM: {}, - }, - "files": {}, - }, - "batched": false, - "destination": $.outputs.finalJsonPayload.destination, - "metadata": $.outputs.finalJsonPayload.successMetadata, - "statusCode": 200 - } - routerPayload - - name: finalPayload - template: | - [$.outputs.constructRouterPayload] diff --git a/src/cdk/v2/destinations/klaviyo_bulk_upload/utils.js b/src/cdk/v2/destinations/klaviyo_bulk_upload/utils.js index d74ce77b46..95173a0ba2 100644 --- a/src/cdk/v2/destinations/klaviyo_bulk_upload/utils.js +++ b/src/cdk/v2/destinations/klaviyo_bulk_upload/utils.js @@ -118,4 +118,4 @@ function combinePayloads(inputs) { return { ...payload }; } -export { transformSingleMessage, combinePayloads }; +module.exports = { transformSingleMessage, combinePayloads }; diff --git a/test/integrations/destinations/klaviyo_bulk_upload/processor/data.ts b/test/integrations/destinations/klaviyo_bulk_upload/processor/data.ts index 1ef98f4a77..eacb360c40 100644 --- a/test/integrations/destinations/klaviyo_bulk_upload/processor/data.ts +++ b/test/integrations/destinations/klaviyo_bulk_upload/processor/data.ts @@ -55,6 +55,7 @@ export const data = [ metadata: { destinationId: 'destId', workspaceId: 'wspId', + jobId: 1, }, }, ], @@ -94,6 +95,7 @@ export const data = [ ip: '213.5.6.41', }, anonymous_id: 'user1', + jobIdentifier: 'user1:1', }, }, ], @@ -122,6 +124,7 @@ export const data = [ metadata: { destinationId: 'destId', workspaceId: 'wspId', + jobId: 1, }, }, ], @@ -180,6 +183,7 @@ export const data = [ metadata: { destinationId: 'destId', workspaceId: 'wspId', + jobId: 1, }, }, ], @@ -215,6 +219,7 @@ export const data = [ ip: '213.5.6.41', }, anonymous_id: 'user1', + jobIdentifier: 'user1:1', }, }, ], @@ -243,6 +248,7 @@ export const data = [ metadata: { destinationId: 'destId', workspaceId: 'wspId', + jobId: 1, }, }, ], @@ -300,6 +306,7 @@ export const data = [ metadata: { destinationId: 'destId', workspaceId: 'wspId', + jobId: 1, }, }, ], @@ -335,6 +342,7 @@ export const data = [ ip: '213.5.6.41', }, anonymous_id: 'user1', + jobIdentifier: 'user1:1', }, }, ], @@ -353,158 +361,11 @@ export const data = [ metadata: { destinationId: 'destId', workspaceId: 'wspId', + jobId: 1, }, }, ], }, }, }, - { - name: 'klaviyo_bulk_upload', - description: 'Failed identify event with missing Private Api Key', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - channel: 'sources', - context: { - externalId: [ - { - id: 'user1', - identifierType: 'userId', - type: 'KLAVIYO_BULK_UPLOAD-userProfiles', - }, - ], - mappedToDestination: 'true', - sources: { - job_id: '2gif2bMzsX1Nt0rbV1vcbAE3cxC', - job_run_id: 'cp5p5ilq47pqg38v2nfg', - task_run_id: 'cp5p5ilq47pqg38v2ng0', - version: '2051/merge', - }, - }, - traits: { - email: 'qwe22@mail.com', - first_name: 'Testqwe0022', - last_name: 'user', - phone_number: '+919902330123', - ip: '213.5.6.41', - }, - type: 'identify', - userId: '1', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - privateApiKey: '', - listId: 'list101', - }, - }, - metadata: { - destinationId: 'destId', - workspaceId: 'wspId', - }, - }, - ], - }, - }, - output: { - metadata: { - jobId: 1, - }, - statusCode: 400, - error: - 'Private Api Key is not present. Aborting: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: Private Api Key is not present. Aborting', - statTags: { - errorCategory: 'dataValidation', - errorType: 'configuration', - implementation: 'cdkV2', - destType: 'KLAVIYO_BULK_UPLOAD', - module: 'destination', - feature: 'processor', - }, - }, - }, - { - name: 'klaviyo_bulk_upload', - description: 'Failed event with invalid event type', - feature: 'processor', - module: 'destination', - version: 'v0', - input: { - request: { - body: [ - { - message: { - channel: 'sources', - context: { - externalId: [ - { - id: 'user1', - identifierType: 'userId', - type: 'KLAVIYO_BULK_UPLOAD-userProfiles', - }, - ], - mappedToDestination: 'true', - sources: { - job_id: '2gif2bMzsX1Nt0rbV1vcbAE3cxC', - job_run_id: 'cp5p5ilq47pqg38v2nfg', - task_run_id: 'cp5p5ilq47pqg38v2ng0', - version: '2051/merge', - }, - }, - traits: { - email: 'qwe22@mail.com', - first_name: 'Testqwe0022', - last_name: 'user', - phone_number: '+919902330123', - ip: '213.5.6.41', - }, - type: 'identify', - userId: '1', - }, - destination: { - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - privateApiKey: 'pk_dummy_123', - listId: 'list101', - }, - }, - metadata: { - destinationId: 'destId', - workspaceId: 'wspId', - }, - }, - ], - }, - }, - output: { - metadata: { - jobId: 1, - }, - statusCode: 400, - error: - 'message type track is not supported: Workflow: procWorkflow, Step: validateInput, ChildStep: undefined, OriginalError: message type track is not supported', - statTags: { - errorCategory: 'dataValidation', - errorType: 'instrumentation', - implementation: 'cdkV2', - destType: 'KLAVIYO_BULK_UPLOAD', - module: 'destination', - feature: 'processor', - }, - }, - }, ]; diff --git a/test/integrations/destinations/klaviyo_bulk_upload/router/data.ts b/test/integrations/destinations/klaviyo_bulk_upload/router/data.ts deleted file mode 100644 index 5e726bc14f..0000000000 --- a/test/integrations/destinations/klaviyo_bulk_upload/router/data.ts +++ /dev/null @@ -1,213 +0,0 @@ -export const data = [ - { - name: 'klaviyo_bulk_upload', - description: 'Multiple jobs with different metadata', - feature: 'router', - module: 'destination', - version: 'v0', - input: { - request: { - body: { - input: [ - { - destination: { - ID: '1pYpzzvcn7AQ2W9GGIAZSsN6Mfq', - Name: 'KLAVIYO_BULK_UPLOAD', - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - privateApiKey: 'privateKey', - }, - Enabled: true, - Transformations: [], - }, - metadata: { - jobId: 1, - }, - message: { - channel: 'web', - context: { - app: { - build: '1.0.0', - name: 'RudderLabs JavaScript SDK', - namespace: 'com.rudderlabs.javascript', - version: '1.3.4', - }, - traits: { - email: 'slonefox2@gmail.com', - firstName: 'slone', - lastName: 'fox2', - leadSource: 'clone fox inc.2', - company: 'buggati baygon', - }, - library: { - name: 'RudderLabs JavaScript SDK', - version: '1.3.4', - }, - userAgent: - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36', - locale: 'en-IN', - os: { - name: '', - version: '', - }, - }, - traits: { - email: 'slonefox2@gmail.com', - firstName: 'slone', - lastName: 'fox2', - leadSource: 'clone fox inc.2', - company: 'buggati baygon', - }, - type: 'identify', - originalTimestamp: '2022-02-08T10:08:15.308Z', - anonymousId: 'ec8ae2b4-1cdf-4bdb-ac6f-594bdg40c4bc', - userId: 'li001tc', - integrations: { - All: true, - }, - sentAt: '2022-02-08T10:08:15.309Z', - }, - }, - { - destination: { - ID: '1pYpzzvcn7AQ2W9GGIAZSsN6Mfq', - Name: 'KLAVIYO_BULK_UPLOAD', - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - privateApiKey: 'privateKey', - }, - Enabled: true, - Transformations: [], - }, - metadata: { - jobId: 2, - }, - message: { - channel: 'web', - context: { - app: { - build: '1.0.0', - name: 'RudderLabs JavaScript SDK', - namespace: 'com.rudderlabs.javascript', - version: '1.3.4', - }, - traits: { - email: 'slonefox2@gmail.com', - firstName: 'slone', - lastName: 'fox2', - leadSource: 'clone fox inc.2', - company: 'buggati baygon', - }, - library: { - name: 'RudderLabs JavaScript SDK', - version: '1.3.4', - }, - userAgent: - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36', - locale: 'en-IN', - os: { - name: '', - version: '', - }, - }, - traits: { - email: 'slonefox2@gmail.com', - firstName: 'slone', - lastName: 'fox3', - leadSource: 'clone fox inc.2', - company: 'buggati baygon', - }, - type: 'identify', - originalTimestamp: '2022-02-08T10:08:15.308Z', - anonymousId: 'ec8ae2b4-1cdf-4bdb-ac6f-594bdg40c4bc', - userId: 'li001tc', - integrations: { - All: true, - }, - sentAt: '2022-02-08T10:08:15.309Z', - }, - }, - ], - destType: 'klaviyo_bulk_upload', - }, - method: 'POST', - }, - }, - output: { - response: { - status: 200, - body: { - output: [ - { - batchedRequest: [ - { - data: { - type: 'profile-bulk-import-job', - attributes: { - profiles: [ - { - type: 'profile', - attributes: { - email: 'slonefox2@gmail.com', - firstName: 'slone', - lastName: 'fox2', - leadSource: 'clone fox inc.2', - company: 'buggati baygon', - anonymous_id: 'li001tc', - }, - }, - { - type: 'profile', - attributes: { - email: 'slonefox2@gmail.com', - firstName: 'slone', - lastName: 'fox3', - leadSource: 'clone fox inc.2', - company: 'buggati baygon', - anonymous_id: 'li001tc', - }, - }, - ], - }, - }, - }, - ], - batched: true, - destination: { - ID: '1pYpzzvcn7AQ2W9GGIAZSsN6Mfq', - Name: 'KLAVIYO_BULK_UPLOAD', - DestinationDefinition: { - Config: { - cdkV2Enabled: true, - }, - }, - Config: { - privateApiKey: 'privateKey', - }, - Enabled: true, - Transformations: [], - }, - metadata: [ - { - jobId: 1, - }, - { - jobId: 2, - }, - ], - statusCode: 200, - }, - ], - }, - }, - }, - }, -];