Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove requirement for list resource id when importing inventories #47

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions src/app/dollar-imports/helpers/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { realm, keycloakBaseUrl } from '../../helpers/utils';
import { winstonLogger } from '../../../configs/winston';

export function getImportScriptArgs(jobData: JobData) {
const { workflowType, filePath: rawFilePath, productListId, inventoryListId } = jobData;
const { workflowType, filePath: rawFilePath, productListId } = jobData;
const filePath = `"${rawFilePath}"`;
const commonFlags = ['--log_level', 'info'];
switch (workflowType) {
Expand Down Expand Up @@ -39,15 +39,7 @@ export function getImportScriptArgs(jobData: JobData) {
case UploadWorkflowTypes.Products:
return ['--csv_file', filePath, '--setup', 'products', '--list_resource_id', `${productListId}`, ...commonFlags];
case UploadWorkflowTypes.Inventories:
return [
'--csv_file',
filePath,
'--setup',
'inventories',
'--list_resource_id',
`${inventoryListId}`,
...commonFlags,
];
return ['--csv_file', filePath, '--setup', 'inventories', ...commonFlags];
default:
return [];
}
Expand Down
4 changes: 0 additions & 4 deletions src/app/dollar-imports/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export interface JobData {
accessToken: string;
refreshToken: string;
productListId?: string;
inventoryListId?: string;
}

export const resourceUploadCodeToTemplatePathLookup = {
Expand Down Expand Up @@ -113,8 +112,5 @@ export function validateWorkflowArgs(args: JobData[]) {
if (arg.workflowType === UploadWorkflowTypes.Products && !arg.productListId) {
throw new Error('Product list id for the product upload workflow was not provided');
}
if (arg.workflowType === UploadWorkflowTypes.Inventories && !arg.inventoryListId) {
throw new Error('inventory list id for the inventory upload workflow was not provided');
}
}
}
3 changes: 1 addition & 2 deletions src/app/dollar-imports/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ importerRouter.post('/', upload.any(), async (req, res, next) => {
const files = req.files as Express.Multer.File[] | undefined;
const user = req.session.preloadedState?.session?.user?.username;

const { productListId, inventoryListId } = req.query;
const { productListId } = req.query;

const uploadId = randomUUID();
const workflowArgs =
Expand All @@ -117,7 +117,6 @@ importerRouter.post('/', upload.any(), async (req, res, next) => {
accessToken: req.session.preloadedState?.session?.extraData?.oAuth2Data?.access_token,
refreshToken: req.session.preloadedState?.session?.extraData?.oAuth2Data?.refresh_token,
productListId,
inventoryListId,
} as JobData;
}) ?? [];

Expand Down
12 changes: 1 addition & 11 deletions src/app/dollar-imports/tests/job.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ test('generates correct script args for the different workflows', () => {
workflowType: UploadWorkflowTypes.Locations,
filePath: sampleCsv,
productListId: 'productId',
inventoryListId: 'inventoryId',
workflowId: 'id',
author: 'JK Rowling',
accessToken: 'at',
Expand Down Expand Up @@ -60,14 +59,5 @@ test('generates correct script args for the different workflows', () => {
'info',
]);
result = getImportScriptArgs({ ...commonWorkflowArgs, workflowType: UploadWorkflowTypes.Inventories });
expect(result).toEqual([
'--csv_file',
`"${sampleCsv}"`,
'--setup',
'inventories',
'--list_resource_id',
'inventoryId',
'--log_level',
'info',
]);
expect(result).toEqual(['--csv_file', `"${sampleCsv}"`, '--setup', 'inventories', '--log_level', 'info']);
});
Loading