finding inputs using generic strategy

This commit is contained in:
Gabriel Rosa
2022-06-15 08:44:21 -03:00
parent abbe88f45b
commit f6c7420f59
5 changed files with 27 additions and 47 deletions
+6 -6
View File
@@ -19,7 +19,7 @@
"@nestjs/platform-express": "^8.4.3",
"@nestjs/schedule": "^1.1.0",
"@nestjs/swagger": "^5.2.1",
"@victorradael/protospack": "2.5.0-4",
"@victorradael/protospack": "file:../protospack/victorradael-protospack-2.5.0-4.tgz",
"axios": "^0.25.0",
"cron-parser": "^4.4.0",
"dotenv": "^14.2.0",
@@ -2361,8 +2361,9 @@
},
"node_modules/@victorradael/protospack": {
"version": "2.5.0-4",
"resolved": "https://registry.npmjs.org/@victorradael/protospack/-/protospack-2.5.0-4.tgz",
"integrity": "sha512-WgcWv2VPST3IaJsuz9yrSgC+zxsV5rjVB/kAlgB0QAkKvtvS23uQBqWrbvyG4VcKQXG1rGiIwoQ6Fyf23NWG4g==",
"resolved": "file:../protospack/victorradael-protospack-2.5.0-4.tgz",
"integrity": "sha512-mtHLoi0/iMcMIlfcaSyEuD6nzh6ZYO61sJXb0oz2W+nZgcDGx9eSQA4gzGLKecVXix6sIuo2ZniUf3Z1BxuuvQ==",
"license": "ISC",
"dependencies": {
"rxjs": "^7.5.5"
}
@@ -10935,9 +10936,8 @@
}
},
"@victorradael/protospack": {
"version": "2.5.0-4",
"resolved": "https://registry.npmjs.org/@victorradael/protospack/-/protospack-2.5.0-4.tgz",
"integrity": "sha512-WgcWv2VPST3IaJsuz9yrSgC+zxsV5rjVB/kAlgB0QAkKvtvS23uQBqWrbvyG4VcKQXG1rGiIwoQ6Fyf23NWG4g==",
"version": "file:../protospack/victorradael-protospack-2.5.0-4.tgz",
"integrity": "sha512-mtHLoi0/iMcMIlfcaSyEuD6nzh6ZYO61sJXb0oz2W+nZgcDGx9eSQA4gzGLKecVXix6sIuo2ZniUf3Z1BxuuvQ==",
"requires": {
"rxjs": "^7.5.5"
}
+1 -1
View File
@@ -34,7 +34,7 @@
"@nestjs/platform-express": "^8.4.3",
"@nestjs/schedule": "^1.1.0",
"@nestjs/swagger": "^5.2.1",
"@victorradael/protospack": "2.5.0-4",
"@victorradael/protospack": "file:../protospack/victorradael-protospack-2.5.0-4.tgz",
"axios": "^0.25.0",
"cron-parser": "^4.4.0",
"dotenv": "^14.2.0",
+12 -39
View File
@@ -77,50 +77,23 @@ export class InputsClientService implements OnModuleInit {
async findOne(data: IIdRequest) {
console.log('InputClientService', 'FindOne');
const findOneInputResponse = await new Promise((resolve, reject) => {
this.inputService.FindOne(objectSnakeToCamel(data)).subscribe({
next(x) {
resolve(objectCamelToSnake(x));
},
error(err) {
console.log('Observable Error');
reject(err);
},
complete() {
console.log('done');
},
});
})
.then((res) => res)
.catch((err) => {
throw new Error(err);
});
const findOneInputResponse = await lastValueFrom(
this.inputService.FindOne(objectSnakeToCamel(data)),
).catch((e) => {
throw new HttpException(e.details, HttpStatus.INTERNAL_SERVER_ERROR);
});
objectCamelToSnake(findOneInputResponse);
return findOneInputResponse;
}
async findAll(data) {
console.log('InputClientService', 'FindAll');
const findAllInputResponse = await new Promise((resolve, reject) => {
this.inputService.FindAll(objectSnakeToCamel(data)).subscribe({
next(x) {
resolve(objectCamelToSnake(x));
},
error(err) {
console.log('Observable Error');
reject(err);
},
complete() {
console.log('done');
},
});
})
.then((res) => res)
.catch((err) => {
throw new Error(err);
});
const findAllInputResponse = await lastValueFrom(
this.inputService.FindAll(objectSnakeToCamel(data)),
).catch((e) => {
throw new HttpException(e.details, HttpStatus.INTERNAL_SERVER_ERROR);
});
findAllInputResponse.inputs.forEach((input) => objectCamelToSnake(input));
return findAllInputResponse;
}
+2
View File
@@ -1,5 +1,6 @@
import { Body, HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { Timeout } from '@nestjs/schedule';
import { DecodeGrpcStruct } from '@victorradael/protospack';
import CronParser, { CronExpression } from 'cron-parser';
import { InputsClientService } from 'src/clients/inputs/client.service';
import { IIdRequest, Info } from 'src/clients/inputs/interfaces';
@@ -11,6 +12,7 @@ export class InputsService {
secondsInAnHour = 60 * 60;
adjustInputPayload(payload) {
if (payload?.input_generic) return DecodeGrpcStruct(payload.input_generic);
return payload?.input_s3 || payload?.input_jdbc;
}
getDifferenceInSeconds(date1: Date, date2: Date) {
+6 -1
View File
@@ -1,4 +1,5 @@
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { DecodeGrpcStruct } from '@victorradael/protospack';
import { PipelinesClientService } from 'src/clients/pipelines/client.service';
import { IIdRequest, Info } from 'src/clients/pipelines/interfaces';
import { objectCamelToSnake } from 'src/utils/CaseConverter';
@@ -8,7 +9,11 @@ export class PipelinesService {
constructor(private pipelineClient: PipelinesClientService) {}
adjustPayload(payload) {
payload.input = payload.input?.input_s3 || payload.input?.input_jdbc;
if (payload.input?.input_generic) {
payload.input = DecodeGrpcStruct(payload.input?.input_generic);
} else {
payload.input = payload.input?.input_s3 || payload.input?.input_jdbc;
}
}
async create(createPipelineDto) {