Skip to content

Commit

Permalink
chore: resolve build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeepdsvs committed Apr 1, 2024
1 parent 6ff1761 commit cb5114d
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/controllers/bulkUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
getJobStatusHandler,
getPollStatusHandler,
getDestFileUploadHandler,
} from '../util/fetchDestinationHandlers';
} from '../util/fetchBulkUploadHandlers';
import { CatchErr, ContextBodySimple } from '../util/types';
// TODO: To be refactored and redisgned

Expand Down
42 changes: 42 additions & 0 deletions src/util/fetchBulkUploadHandlers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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';

const fileUploadHandlers = {
v0: {
marketo_bulk_upload: V0MarketoBulkUploadFileUpload,
},
};

const pollStatusHandlers = {
v0: {
marketo_bulk_upload: V0MarketoBulkUploadPollStatus,
},
};

const jobStatusHandlers = {
v0: {
marketo_bulk_upload: V0MarketoBulkUploadJobStatus,
},
};

export const getDestFileUploadHandler = (version, dest) => {
if (fileUploadHandlers[version] && fileUploadHandlers[version][dest]) {
return fileUploadHandlers[version][dest];
}
return undefined;
};

export const getPollStatusHandler = (version, dest) => {
if (pollStatusHandlers[version] && pollStatusHandlers[version][dest]) {
return pollStatusHandlers[version][dest];
}
return undefined;
};

export const getJobStatusHandler = (version, dest) => {
if (jobStatusHandlers[version] && jobStatusHandlers[version][dest]) {
return jobStatusHandlers[version][dest];
}
return undefined;
};
28 changes: 18 additions & 10 deletions src/util/fetchDestinationHandlers.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* eslint-disable import/no-dynamic-require,global-require */
import fs from 'fs';
import path from 'path';
import { set } from 'lodash';
const fs = require('fs');
const path = require('path');
const { set } = require('lodash');

// Define the directory path
const destinationsPath = path.join(__dirname, '..', 'v0', 'destinations');

// Read the contents of the directory synchronously
const destinations: string[] = fs
.readdirSync(destinationsPath, { withFileTypes: true })
const destinationsDirectories = fs.readdirSync(destinationsPath, { withFileTypes: true });
const destinations = destinationsDirectories
.filter((item) => item.isDirectory())
.map((item) => item.name);

Expand All @@ -35,37 +35,45 @@ destinations.forEach((destination) => {
});
});

export const getDestFileUploadHandler = (version, dest) => {
const getDestFileUploadHandler = (version, dest) => {
if (fileUploadHandlers[version] && fileUploadHandlers[version][dest]) {
return fileUploadHandlers[version][dest];
}
return undefined;
};

export const getPollStatusHandler = (version, dest) => {
const getPollStatusHandler = (version, dest) => {
if (pollStatusHandlers[version] && pollStatusHandlers[version][dest]) {
return pollStatusHandlers[version][dest];
}
return undefined;
};

export const getJobStatusHandler = (version, dest) => {
const getJobStatusHandler = (version, dest) => {
if (jobStatusHandlers[version] && jobStatusHandlers[version][dest]) {
return jobStatusHandlers[version][dest];
}
return undefined;
};

export const getDestTransformHandler = (version, dest) => {
const getDestTransformHandler = (version, dest) => {
if (destinationHandlers[version] && destinationHandlers[version][dest]) {
return destinationHandlers[version][dest];
}
return undefined;
};

export const getDeletionUserHandler = (version, dest) => {
const getDeletionUserHandler = (version, dest) => {
if (deleteUserHandlers[version] && deleteUserHandlers[version][dest]) {
return deleteUserHandlers[version][dest];
}
return undefined;
};

module.exports = {
getDestTransformHandler,
getDeletionUserHandler,
getDestFileUploadHandler,
getPollStatusHandler,
getJobStatusHandler,
};

0 comments on commit cb5114d

Please sign in to comment.