diff --git a/package-lock.json b/package-lock.json index d7f37ec..ef21489 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "@nestjs/platform-express": "^8.4.3", "@nestjs/schedule": "^1.1.0", "@nestjs/swagger": "^5.2.1", - "@victorradael/protospack": "^2.3.0", + "@victorradael/protospack": "2.3.0", "axios": "^0.25.0", "dotenv": "^14.2.0", "helmet": "^5.0.2", diff --git a/src/modules/inputs/inputs.service.ts b/src/modules/inputs/inputs.service.ts index e73c515..5e03cf4 100644 --- a/src/modules/inputs/inputs.service.ts +++ b/src/modules/inputs/inputs.service.ts @@ -15,8 +15,9 @@ export class InputsService { data.plugin == 'parquet' ) { const { info, ...input } = data; + const inputPayload = this.generateInputS3Payload(input); const createInputResponse = await this.inputClient.createS3Inputs({ - input, + input: inputPayload, info, }); return createInputResponse; @@ -95,4 +96,29 @@ export class InputsService { throw new HttpException(err.message, HttpStatus.NOT_FOUND); } } + + generateInputS3Payload(payload) { + const { credentials, plugin } = payload; + if (!credentials) return payload; + + const { + client_aws_access_key_id, + client_aws_secret_access_key, + file_format_params, + format_file_params, + client_bucket, + file_to_extract, + } = credentials; + const formatedPayload = { + plugin, + source_bucket: client_bucket, + source_prefix: file_to_extract, + auth_parameters: { + aws_access_key_id: client_aws_access_key_id, + aws_secret_access_key: client_aws_secret_access_key, + }, + file_format_params: file_format_params || format_file_params, + }; + return formatedPayload; + } }