From 2225fad0da1f31a9d0e389e7bf772f0047d2fffe Mon Sep 17 00:00:00 2001 From: sandeepdigumarty Date: Mon, 1 Apr 2024 09:08:25 +0530 Subject: [PATCH] chore: removed code injections in legacy folder --- src/legacy/router.js | 22 +- src/util/fetchDestinationHandlers.ts | 342 ++++++++++++++++++++++++++- 2 files changed, 345 insertions(+), 19 deletions(-) diff --git a/src/legacy/router.js b/src/legacy/router.js index 9dd83b5988..1406742e3a 100644 --- a/src/legacy/router.js +++ b/src/legacy/router.js @@ -8,6 +8,13 @@ const lodash = require('lodash'); const fs = require('fs'); const path = require('path'); const { PlatformError, getErrorRespEvents } = require('@rudderstack/integrations-lib'); +const { + getDestTransformHandler, + getDestFileUploadHandler, + getJobStatusHandler, + getPollStatusHandler, + getDeletionUserHandler, +} = require('../util/fetchDestinationHandlers'); const logger = require('../logger'); const stats = require('../util/stats'); const { SUPPORTED_VERSIONS, API_VERSION } = require('../routes/utils/constants'); @@ -61,22 +68,11 @@ const PAYLOAD_PROC_ERR_MSG = 'Error occurred while processing payload'; */ const getDestHandler = (version, dest) => { if (Object.prototype.hasOwnProperty.call(DestHandlerMap, dest)) { - return require(`../${version}/destinations/${DestHandlerMap[dest]}/transform`); + return getDestTransformHandler(version, DestHandlerMap[dest]); } - return require(`../${version}/destinations/${dest}/transform`); + return getDestTransformHandler(version, dest); }; -const getDestFileUploadHandler = (version, dest) => - require(`../${version}/destinations/${dest}/fileUpload`); - -const getPollStatusHandler = (version, dest) => require(`../${version}/destinations/${dest}/poll`); - -const getJobStatusHandler = (version, dest) => - require(`../${version}/destinations/${dest}/fetchJobStatus`); - -const getDeletionUserHandler = (version, dest) => - require(`../${version}/destinations/${dest}/deleteUsers`); - const getSourceHandler = (version, source) => require(`../${version}/sources/${source}/transform`); let areFunctionsEnabled = -1; diff --git a/src/util/fetchDestinationHandlers.ts b/src/util/fetchDestinationHandlers.ts index 2661ef2e68..ab98966db3 100644 --- a/src/util/fetchDestinationHandlers.ts +++ b/src/util/fetchDestinationHandlers.ts @@ -1,22 +1,338 @@ -import * as V0MarketoBulkUploadFileUpload from '../v0/destinations/marketo_bulk_upload/fileUpload'; -import * as V0MarketoBulkUploadPollStatus from '../v0/destinations/marketo_bulk_upload/poll'; -import * as V0MarketoBulkUploadJobStatus from '../v0/destinations/marketo_bulk_upload/fetchJobStatus'; +import * as MarketoBulkUploadFileUpload from '../v0/destinations/marketo_bulk_upload/fileUpload'; +import * as MarketoBulkUploadPollStatus from '../v0/destinations/marketo_bulk_upload/poll'; +import * as MarketoBulkUploadJobStatus from '../v0/destinations/marketo_bulk_upload/fetchJobStatus'; + +import * as ActiveCampaignTransform from '../v0/destinations/active_campaign/transform'; +import * as AdjTransform from '../v0/destinations/adj/transform'; +import * as AfTransform from '../v0/destinations/af/transform'; +import * as AirshipTransform from '../v0/destinations/airship/transform'; +import * as AdobeAnalyticsTransform from '../v0/destinations/adobe_analytics/transform'; +import * as AlgoliaTransform from '../v0/destinations/algolia/transform'; +import * as AmTransform from '../v0/destinations/am/transform'; +import * as AppcuesTransform from '../v0/destinations/appcues/transform'; +import * as AttentiveTagTransform from '../v0/destinations/attentive_tag/transform'; +import * as AutopilotTransform from '../v0/destinations/autopilot/transform'; +import * as AttributionTransform from '../v0/destinations/attribution/transform'; +import * as AwinTransform from '../v0/destinations/awin/transform'; +import * as AzureBlobTransform from '../v0/destinations/azure_blob/transform'; +import * as AzureEventHubTransform from '../v0/destinations/azure_event_hub/transform'; +import * as AzureDatalakeTransform from '../v0/destinations/azure_datalake/transform'; +import * as BlueshiftTransform from '../v0/destinations/blueshift/transform'; +import * as AzureSynapseTransform from '../v0/destinations/azure_synapse/transform'; +import * as BqstreamTransform from '../v0/destinations/bqstream/transform'; +import * as BqTransform from '../v0/destinations/bq/transform'; +import * as BranchTransform from '../v0/destinations/branch/transform'; +import * as BrazeTransform from '../v0/destinations/braze/transform'; +import * as CanduTransform from '../v0/destinations/candu/transform'; +import * as CampaignManagerTransform from '../v0/destinations/campaign_manager/transform'; +import * as ClevertapTransform from '../v0/destinations/clevertap/transform'; +import * as CannyTransform from '../v0/destinations/canny/transform'; +import * as ClickhouseTransform from '../v0/destinations/clickhouse/transform'; +import * as ClickupTransform from '../v0/destinations/clickup/transform'; +import * as ConfluentCloudTransform from '../v0/destinations/confluent_cloud/transform'; +import * as CourierTransform from '../v0/destinations/courier/transform'; +import * as CustifyTransform from '../v0/destinations/custify/transform'; +import * as CriteoAudienceTransform from '../v0/destinations/criteo_audience/transform'; +import * as DelightedTransform from '../v0/destinations/delighted/transform'; +import * as CustomerioTransform from '../v0/destinations/customerio/transform'; +import * as DigitalOceanSpacesTransform from '../v0/destinations/digital_ocean_spaces/transform'; +import * as DeltalakeTransform from '../v0/destinations/deltalake/transform'; +import * as DripTransform from '../v0/destinations/drip/transform'; +import * as DiscordTransform from '../v0/destinations/discord/transform'; +import * as EventbridgeTransform from '../v0/destinations/eventbridge/transform'; +import * as EngageTransform from '../v0/destinations/engage/transform'; +import * as FacebookConversionsTransform from '../v0/destinations/facebook_conversions/transform'; +import * as FacebookOfflineConversionsTransform from '../v0/destinations/facebook_offline_conversions/transform'; +import * as FacebookPixelTransform from '../v0/destinations/facebook_pixel/transform'; +import * as FactorsaiTransform from '../v0/destinations/factorsai/transform'; +import * as FbCustomAudienceTransform from '../v0/destinations/fb_custom_audience/transform'; +import * as FbTransform from '../v0/destinations/fb/transform'; +import * as FirehoseTransform from '../v0/destinations/firehose/transform'; +import * as FreshmarketerTransform from '../v0/destinations/freshmarketer/transform'; +import * as Ga360Transform from '../v0/destinations/ga360/transform'; +import * as FreshsalesTransform from '../v0/destinations/freshsales/transform'; +import * as GaTransform from '../v0/destinations/ga/transform'; +import * as Ga4Transform from '../v0/destinations/ga4/transform'; +import * as GainsightTransform from '../v0/destinations/gainsight/transform'; +import * as GcsTransform from '../v0/destinations/gcs/transform'; +import * as GcsDatalakeTransform from '../v0/destinations/gcs_datalake/transform'; +import * as GainsightPxTransform from '../v0/destinations/gainsight_px/transform'; +import * as GoogleAdwordsRemarketingListsTransform from '../v0/destinations/google_adwords_remarketing_lists/transform'; +import * as GoogleAdwordsOfflineConversionsTransform from '../v0/destinations/google_adwords_offline_conversions/transform'; +import * as GoogleAdwordsEnhancedConversionsTransform from '../v0/destinations/google_adwords_enhanced_conversions/transform'; +import * as GoogleCloudFunctionTransform from '../v0/destinations/google_cloud_function/transform'; +import * as HsTransform from '../v0/destinations/hs/transform'; +import * as GooglesheetsTransform from '../v0/destinations/googlesheets/transform'; +import * as GooglepubsubTransform from '../v0/destinations/googlepubsub/transform'; +import * as HeapTransform from '../v0/destinations/heap/transform'; +import * as ImpactTransform from '../v0/destinations/impact/transform'; +import * as IntercomTransform from '../v0/destinations/intercom/transform'; +import * as JuneTransform from '../v0/destinations/june/transform'; +import * as IndicativeTransform from '../v0/destinations/indicative/transform'; +import * as IterableTransform from '../v0/destinations/iterable/transform'; +import * as KafkaTransform from '../v0/destinations/kafka/transform'; +import * as KeenTransform from '../v0/destinations/keen/transform'; +import * as KlaviyoTransform from '../v0/destinations/klaviyo/transform'; +import * as KinesisTransform from '../v0/destinations/kinesis/transform'; +import * as KissmetricsTransform from '../v0/destinations/kissmetrics/transform'; +import * as KochavaTransform from '../v0/destinations/kochava/transform'; +import * as KustomerTransform from '../v0/destinations/kustomer/transform'; +import * as LambdaTransform from '../v0/destinations/lambda/transform'; +import * as LeanplumTransform from '../v0/destinations/leanplum/transform'; +import * as LemniskTransform from '../v0/destinations/lemnisk/transform'; +import * as LyticsTransform from '../v0/destinations/lytics/transform'; +import * as MailchimpTransform from '../v0/destinations/mailchimp/transform'; +import * as MailmodoTransform from '../v0/destinations/mailmodo/transform'; +import * as MailjetTransform from '../v0/destinations/mailjet/transform'; +import * as MarketoTransform from '../v0/destinations/marketo/transform'; +import * as MarketoBulkUploadTransform from '../v0/destinations/marketo_bulk_upload/transform'; +import * as MinioTransform from '../v0/destinations/minio/transform'; +import * as MarketoStaticListTransform from '../v0/destinations/marketo_static_list/transform'; +import * as MoengageTransform from '../v0/destinations/moengage/transform'; +import * as MauticTransform from '../v0/destinations/mautic/transform'; +import * as MondayTransform from '../v0/destinations/monday/transform'; +import * as MssqlTransform from '../v0/destinations/mssql/transform'; +import * as MonetateTransform from '../v0/destinations/monetate/transform'; +import * as OmetriaTransform from '../v0/destinations/ometria/transform'; +import * as MpTransform from '../v0/destinations/mp/transform'; +import * as OneSignalTransform from '../v0/destinations/one_signal/transform'; +import * as PardotTransform from '../v0/destinations/pardot/transform'; +import * as PersistiqTransform from '../v0/destinations/persistiq/transform'; +import * as PersonalizeTransform from '../v0/destinations/personalize/transform'; +import * as PagerdutyTransform from '../v0/destinations/pagerduty/transform'; +import * as PinterestTagTransform from '../v0/destinations/pinterest_tag/transform'; +import * as PipedreamTransform from '../v0/destinations/pipedream/transform'; +import * as PostgresTransform from '../v0/destinations/postgres/transform'; +import * as ProfitwellTransform from '../v0/destinations/profitwell/transform'; +import * as PosthogTransform from '../v0/destinations/posthog/transform'; +import * as RedisTransform from '../v0/destinations/redis/transform'; +import * as RsTransform from '../v0/destinations/rs/transform'; +import * as RefinerTransform from '../v0/destinations/refiner/transform'; +import * as RevenueCatTransform from '../v0/destinations/revenue_cat/transform'; +import * as RockerboxTransform from '../v0/destinations/rockerbox/transform'; +import * as S3Transform from '../v0/destinations/s3/transform'; +import * as S3DatalakeTransform from '../v0/destinations/s3_datalake/transform'; +import * as SalesforceTransform from '../v0/destinations/salesforce/transform'; +import * as SegmentTransform from '../v0/destinations/segment/transform'; +import * as SendinblueTransform from '../v0/destinations/sendinblue/transform'; +import * as SendgridTransform from '../v0/destinations/sendgrid/transform'; +import * as SerenyticsTransform from '../v0/destinations/serenytics/transform'; +import * as SfmcTransform from '../v0/destinations/sfmc/transform'; +import * as ShynetTransform from '../v0/destinations/shynet/transform'; +import * as Signl4Transform from '../v0/destinations/signl4/transform'; +import * as SingularTransform from '../v0/destinations/singular/transform'; +import * as SlackTransform from '../v0/destinations/slack/transform'; +import * as SnapchatConversionTransform from '../v0/destinations/snapchat_conversion/transform'; +import * as SnapchatCustomAudienceTransform from '../v0/destinations/snapchat_custom_audience/transform'; +import * as SnowflakeTransform from '../v0/destinations/snowflake/transform'; +import * as SplitioTransform from '../v0/destinations/splitio/transform'; +import * as StatsigTransform from '../v0/destinations/statsig/transform'; +import * as StormlyTransform from '../v0/destinations/stormly/transform'; +import * as TiktokAdsTransform from '../v0/destinations/tiktok_ads/transform'; +import * as TiktokAdsOfflineEventsTransform from '../v0/destinations/tiktok_ads_offline_events/transform'; +import * as TrengoTransform from '../v0/destinations/trengo/transform'; +import * as UserTransform from '../v0/destinations/user/transform'; +import * as TwitterAdsTransform from '../v0/destinations/twitter_ads/transform'; +import * as VarianceTransform from '../v0/destinations/variance/transform'; +import * as UserlistTransform from '../v0/destinations/userlist/transform'; +import * as VeroTransform from '../v0/destinations/vero/transform'; +import * as WebengageTransform from '../v0/destinations/webengage/transform'; +import * as WoopraTransform from '../v0/destinations/woopra/transform'; +import * as WebhookTransform from '../v0/destinations/webhook/transform'; +import * as WootricTransform from '../v0/destinations/wootric/transform'; +import * as YahooDspTransform from '../v0/destinations/yahoo_dsp/transform'; +import * as ZendeskTransform from '../v0/destinations/zendesk/transform'; + +import * as AfDeleteUsers from '../v0/destinations/af/deleteUsers'; +import * as AmDeleteUsers from '../v0/destinations/am/deleteUsers'; +import * as BrazeDeleteUsers from '../v0/destinations/braze/deleteUsers'; +import * as ClevertapDeleteUsers from '../v0/destinations/clevertap/deleteUsers'; +import * as CustifyDeleteUsers from '../v0/destinations/custify/deleteUsers'; +import * as EngageDeleteUsers from '../v0/destinations/engage/deleteUsers'; +import * as GaDeleteUsers from '../v0/destinations/ga/deleteUsers'; +import * as IntercomDeleteUsers from '../v0/destinations/intercom/deleteUsers'; +import * as IterableDeleteUsers from '../v0/destinations/iterable/deleteUsers'; +import * as MpDeleteUsers from '../v0/destinations/mp/deleteUsers'; +import * as SendgridDeleteUsers from '../v0/destinations/sendgrid/deleteUsers'; +import * as SprigDeleteUsers from '../v0/destinations/sprig/deleteUsers'; const fileUploadHandlers = { v0: { - marketo_bulk_upload: V0MarketoBulkUploadFileUpload, + marketo_bulk_upload: MarketoBulkUploadFileUpload, }, }; const pollStatusHandlers = { v0: { - marketo_bulk_upload: V0MarketoBulkUploadPollStatus, + marketo_bulk_upload: MarketoBulkUploadPollStatus, }, }; const jobStatusHandlers = { v0: { - marketo_bulk_upload: V0MarketoBulkUploadJobStatus, + marketo_bulk_upload: MarketoBulkUploadJobStatus, + }, +}; + +const destinationHandlers = { + v0: { + adobe_analytics: AdobeAnalyticsTransform, + af: AfTransform, + active_campaign: ActiveCampaignTransform, + adj: AdjTransform, + airship: AirshipTransform, + attentive_tag: AttentiveTagTransform, + algolia: AlgoliaTransform, + am: AmTransform, + autopilot: AutopilotTransform, + azure_blob: AzureBlobTransform, + awin: AwinTransform, + attribution: AttributionTransform, + azure_datalake: AzureDatalakeTransform, + azure_event_hub: AzureEventHubTransform, + azure_synapse: AzureSynapseTransform, + bq: BqTransform, + bqstream: BqstreamTransform, + branch: BranchTransform, + braze: BrazeTransform, + appcues: AppcuesTransform, + blueshift: BlueshiftTransform, + campaign_manager: CampaignManagerTransform, + canny: CannyTransform, + candu: CanduTransform, + clickhouse: ClickhouseTransform, + confluent_cloud: ConfluentCloudTransform, + clickup: ClickupTransform, + clevertap: ClevertapTransform, + courier: CourierTransform, + customerio: CustomerioTransform, + custify: CustifyTransform, + criteo_audience: CriteoAudienceTransform, + deltalake: DeltalakeTransform, + digital_ocean_spaces: DigitalOceanSpacesTransform, + drip: DripTransform, + engage: EngageTransform, + eventbridge: EventbridgeTransform, + facebook_conversions: FacebookConversionsTransform, + facebook_offline_conversions: FacebookOfflineConversionsTransform, + discord: DiscordTransform, + facebook_pixel: FacebookPixelTransform, + delighted: DelightedTransform, + fb: FbTransform, + fb_custom_audience: FbCustomAudienceTransform, + firehose: FirehoseTransform, + ga: GaTransform, + factorsai: FactorsaiTransform, + ga360: Ga360Transform, + gainsight: GainsightTransform, + gainsight_px: GainsightPxTransform, + gcs: GcsTransform, + gcs_datalake: GcsDatalakeTransform, + google_adwords_enhanced_conversions: GoogleAdwordsEnhancedConversionsTransform, + freshmarketer: FreshmarketerTransform, + google_adwords_offline_conversions: GoogleAdwordsOfflineConversionsTransform, + google_adwords_remarketing_lists: GoogleAdwordsRemarketingListsTransform, + google_cloud_function: GoogleCloudFunctionTransform, + googlesheets: GooglesheetsTransform, + freshsales: FreshsalesTransform, + heap: HeapTransform, + hs: HsTransform, + impact: ImpactTransform, + indicative: IndicativeTransform, + iterable: IterableTransform, + intercom: IntercomTransform, + june: JuneTransform, + kafka: KafkaTransform, + keen: KeenTransform, + kinesis: KinesisTransform, + kissmetrics: KissmetricsTransform, + klaviyo: KlaviyoTransform, + kochava: KochavaTransform, + kustomer: KustomerTransform, + lambda: LambdaTransform, + leanplum: LeanplumTransform, + lemnisk: LemniskTransform, + lytics: LyticsTransform, + mailchimp: MailchimpTransform, + ga4: Ga4Transform, + mailmodo: MailmodoTransform, + marketo: MarketoTransform, + marketo_bulk_upload: MarketoBulkUploadTransform, + marketo_static_list: MarketoStaticListTransform, + mautic: MauticTransform, + minio: MinioTransform, + moengage: MoengageTransform, + monday: MondayTransform, + monetate: MonetateTransform, + mp: MpTransform, + mssql: MssqlTransform, + ometria: OmetriaTransform, + one_signal: OneSignalTransform, + pagerduty: PagerdutyTransform, + persistiq: PersistiqTransform, + personalize: PersonalizeTransform, + mailjet: MailjetTransform, + pinterest_tag: PinterestTagTransform, + postgres: PostgresTransform, + posthog: PosthogTransform, + profitwell: ProfitwellTransform, + pipedream: PipedreamTransform, + refiner: RefinerTransform, + googlepubsub: GooglepubsubTransform, + redis: RedisTransform, + revenue_cat: RevenueCatTransform, + rockerbox: RockerboxTransform, + rs: RsTransform, + s3: S3Transform, + s3_datalake: S3DatalakeTransform, + pardot: PardotTransform, + segment: SegmentTransform, + sendinblue: SendinblueTransform, + sendgrid: SendgridTransform, + serenytics: SerenyticsTransform, + sfmc: SfmcTransform, + shynet: ShynetTransform, + signl4: Signl4Transform, + salesforce: SalesforceTransform, + singular: SingularTransform, + snapchat_conversion: SnapchatConversionTransform, + slack: SlackTransform, + snowflake: SnowflakeTransform, + splitio: SplitioTransform, + snapchat_custom_audience: SnapchatCustomAudienceTransform, + statsig: StatsigTransform, + stormly: StormlyTransform, + tiktok_ads: TiktokAdsTransform, + trengo: TrengoTransform, + user: UserTransform, + userlist: UserlistTransform, + twitter_ads: TwitterAdsTransform, + tiktok_ads_offline_events: TiktokAdsOfflineEventsTransform, + variance: VarianceTransform, + vero: VeroTransform, + webengage: WebengageTransform, + wootric: WootricTransform, + webhook: WebhookTransform, + woopra: WoopraTransform, + zendesk: ZendeskTransform, + yahoo_dsp: YahooDspTransform, + }, +}; + +const deleteUserHandlers = { + v0: { + af: AfDeleteUsers, + am: AmDeleteUsers, + braze: BrazeDeleteUsers, + clevertap: ClevertapDeleteUsers, + custify: CustifyDeleteUsers, + engage: EngageDeleteUsers, + ga: GaDeleteUsers, + intercom: IntercomDeleteUsers, + iterable: IterableDeleteUsers, + mp: MpDeleteUsers, + sendgrid: SendgridDeleteUsers, + sprig: SprigDeleteUsers, }, }; @@ -40,3 +356,17 @@ export const getJobStatusHandler = (version, dest) => { } return undefined; }; + +export const getDestTransformHandler = (version, dest) => { + if (destinationHandlers[version] && destinationHandlers[version][dest]) { + return destinationHandlers[version][dest]; + } + return undefined; +}; + +export const getDeletionUserHandler = (version, dest) => { + if (deleteUserHandlers[version] && deleteUserHandlers[version][dest]) { + return deleteUserHandlers[version][dest]; + } + return undefined; +};