mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-24 10:39:08 +00:00
FIX: Solve merge conflicts
This commit is contained in:
Generated
+8
-8
@@ -3032,7 +3032,7 @@
|
||||
},
|
||||
"node_modules/@types/object-hash": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@types/object-hash/-/object-hash-1.3.4.tgz",
|
||||
"resolved": "https://registry.npmjs.org/@types/object-hash/-/object-hash-1.3.4.tgz",
|
||||
"integrity": "sha512-xFdpkAkikBgqBdG9vIlsqffDV8GpvnPEzs0IUtr1v3BEB97ijsFQ4RXVbUZwjFThhB4MDSTUfvmxUD5PGx0wXA=="
|
||||
},
|
||||
"node_modules/@types/parse-json": {
|
||||
@@ -4600,7 +4600,7 @@
|
||||
},
|
||||
"node_modules/dataloader": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/dataloader/-/dataloader-1.4.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/dataloader/-/dataloader-1.4.0.tgz",
|
||||
"integrity": "sha512-68s5jYdlvasItOJnCuI2Q9s4q98g0pCyL3HrcKJu8KNugUl8ahgmZYg38ysLTgQjjXX3H8CJLkAvWrclWfcalw=="
|
||||
},
|
||||
"node_modules/debug": {
|
||||
@@ -10354,7 +10354,7 @@
|
||||
},
|
||||
"node_modules/ts-proto-descriptors": {
|
||||
"version": "1.7.1",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/ts-proto-descriptors/-/ts-proto-descriptors-1.7.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/ts-proto-descriptors/-/ts-proto-descriptors-1.7.1.tgz",
|
||||
"integrity": "sha512-oIKUh3K4Xts4v29USGLfUG+2mEk32MsqpgZAOUyUlkrcIdv34yE+k2oZ2Nzngm6cV/JgFdOxRCqeyvmWHuYAyw==",
|
||||
"dependencies": {
|
||||
"long": "^4.0.0",
|
||||
@@ -10363,7 +10363,7 @@
|
||||
},
|
||||
"node_modules/ts-proto/node_modules/object-hash": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/object-hash/-/object-hash-1.3.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/object-hash/-/object-hash-1.3.1.tgz",
|
||||
"integrity": "sha512-OSuu/pU4ENM9kmREg0BdNrUDIl1heYa4mBZacJc+vVWz4GtAwu7jO8s4AIt2aGRUTqxykpWzI3Oqnsm13tTMDA==",
|
||||
"engines": {
|
||||
"node": ">= 0.10.0"
|
||||
@@ -13187,7 +13187,7 @@
|
||||
},
|
||||
"@types/object-hash": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@types/object-hash/-/object-hash-1.3.4.tgz",
|
||||
"resolved": "https://registry.npmjs.org/@types/object-hash/-/object-hash-1.3.4.tgz",
|
||||
"integrity": "sha512-xFdpkAkikBgqBdG9vIlsqffDV8GpvnPEzs0IUtr1v3BEB97ijsFQ4RXVbUZwjFThhB4MDSTUfvmxUD5PGx0wXA=="
|
||||
},
|
||||
"@types/parse-json": {
|
||||
@@ -14289,7 +14289,7 @@
|
||||
},
|
||||
"dataloader": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/dataloader/-/dataloader-1.4.0.tgz",
|
||||
"resolved": "https://registry.npmjs.org/dataloader/-/dataloader-1.4.0.tgz",
|
||||
"integrity": "sha512-68s5jYdlvasItOJnCuI2Q9s4q98g0pCyL3HrcKJu8KNugUl8ahgmZYg38ysLTgQjjXX3H8CJLkAvWrclWfcalw=="
|
||||
},
|
||||
"debug": {
|
||||
@@ -18144,14 +18144,14 @@
|
||||
"dependencies": {
|
||||
"object-hash": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/object-hash/-/object-hash-1.3.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/object-hash/-/object-hash-1.3.1.tgz",
|
||||
"integrity": "sha512-OSuu/pU4ENM9kmREg0BdNrUDIl1heYa4mBZacJc+vVWz4GtAwu7jO8s4AIt2aGRUTqxykpWzI3Oqnsm13tTMDA=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"ts-proto-descriptors": {
|
||||
"version": "1.7.1",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/ts-proto-descriptors/-/ts-proto-descriptors-1.7.1.tgz",
|
||||
"resolved": "https://registry.npmjs.org/ts-proto-descriptors/-/ts-proto-descriptors-1.7.1.tgz",
|
||||
"integrity": "sha512-oIKUh3K4Xts4v29USGLfUG+2mEk32MsqpgZAOUyUlkrcIdv34yE+k2oZ2Nzngm6cV/JgFdOxRCqeyvmWHuYAyw==",
|
||||
"requires": {
|
||||
"long": "^4.0.0",
|
||||
|
||||
@@ -149,6 +149,7 @@ export class ConnectionController {
|
||||
@Get('/:id')
|
||||
// @RequireAllPermissions(Permissions.CONNECTIONS.CREATE)
|
||||
async getConnectionDetails(
|
||||
@Headers('Dadosfera-Lang') language,
|
||||
@User() user: RequestUser,
|
||||
@Param('id') id,
|
||||
@Query('details') details,
|
||||
@@ -162,6 +163,7 @@ export class ConnectionController {
|
||||
customer_name,
|
||||
username,
|
||||
details,
|
||||
language,
|
||||
});
|
||||
|
||||
const response: any = await this.clientService.getConnectionDetails({
|
||||
@@ -172,12 +174,6 @@ export class ConnectionController {
|
||||
if (details === 'true') {
|
||||
const properties = JSON.parse(response.connection.properties);
|
||||
|
||||
properties.connection_controls.map((cont) => {
|
||||
if (cont.default_value != false) {
|
||||
cont.default_value = JSON.parse(cont.default_value);
|
||||
}
|
||||
});
|
||||
|
||||
Object.assign(response.connection, {
|
||||
pipelines: JSON.parse(response.connection.pipelines),
|
||||
connection_controls: properties.connection_controls,
|
||||
|
||||
@@ -1,20 +1,7 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { ApiProperty, ApiPropertyOptional, OmitType } from '@nestjs/swagger';
|
||||
import { Info } from 'protospack/dist/lib/interfaces';
|
||||
|
||||
export class InputModel {
|
||||
category: string;
|
||||
plugin: string;
|
||||
name: string;
|
||||
cron?: string;
|
||||
credentials?: {
|
||||
connection_type: string;
|
||||
oauth: string;
|
||||
oauth_code: string;
|
||||
start_date: string;
|
||||
};
|
||||
}
|
||||
|
||||
class GoogleAnalyticsClientSecrets {
|
||||
export class GoogleAnalyticsClientSecrets {
|
||||
@ApiProperty()
|
||||
type: string;
|
||||
@ApiProperty()
|
||||
@@ -36,7 +23,7 @@ class GoogleAnalyticsClientSecrets {
|
||||
@ApiProperty()
|
||||
client_x509_cert_url: string;
|
||||
}
|
||||
class OauthObject {
|
||||
export class OauthObject {
|
||||
@ApiPropertyOptional()
|
||||
get_tokens_url: string;
|
||||
@ApiPropertyOptional()
|
||||
@@ -46,7 +33,7 @@ class OauthObject {
|
||||
@ApiPropertyOptional()
|
||||
content_type: string;
|
||||
}
|
||||
class InputOptions {
|
||||
export class InputOptions {
|
||||
@ApiPropertyOptional()
|
||||
oauth: OauthObject;
|
||||
@ApiPropertyOptional()
|
||||
@@ -56,8 +43,22 @@ class InputOptions {
|
||||
@ApiPropertyOptional()
|
||||
skip_transformation: true;
|
||||
}
|
||||
export class FileFormatParams {
|
||||
@ApiProperty()
|
||||
sep: string;
|
||||
@ApiProperty()
|
||||
header: boolean;
|
||||
@ApiProperty()
|
||||
encoding: string;
|
||||
}
|
||||
|
||||
class CredentialsJdbc {
|
||||
export class AuthParameters {
|
||||
@ApiProperty()
|
||||
aws_access_key_id: string;
|
||||
@ApiProperty()
|
||||
aws_secret_access_key: string;
|
||||
}
|
||||
export class CredentialsJdbc {
|
||||
@ApiPropertyOptional()
|
||||
jdbc_user: string;
|
||||
@ApiPropertyOptional()
|
||||
@@ -73,14 +74,7 @@ class CredentialsJdbc {
|
||||
@ApiPropertyOptional()
|
||||
schema: string;
|
||||
}
|
||||
class FileFormatParams {
|
||||
@ApiPropertyOptional()
|
||||
file_format: string;
|
||||
@ApiPropertyOptional()
|
||||
encoding: string;
|
||||
}
|
||||
|
||||
class Credentials extends CredentialsJdbc {
|
||||
export class Credentials extends CredentialsJdbc {
|
||||
@ApiProperty()
|
||||
connection_type: string;
|
||||
|
||||
@@ -107,13 +101,13 @@ class Credentials extends CredentialsJdbc {
|
||||
@ApiPropertyOptional()
|
||||
oauth_code: string;
|
||||
}
|
||||
class Column {
|
||||
export class Column {
|
||||
@ApiProperty()
|
||||
name: string;
|
||||
@ApiProperty()
|
||||
type: string;
|
||||
}
|
||||
class TableColumns {
|
||||
export class TableColumns {
|
||||
@ApiProperty()
|
||||
name: string;
|
||||
@ApiProperty()
|
||||
@@ -121,6 +115,45 @@ class TableColumns {
|
||||
@ApiProperty()
|
||||
references: Column[];
|
||||
}
|
||||
|
||||
export class Input {
|
||||
@ApiProperty()
|
||||
id: string;
|
||||
@ApiProperty({ type: [TableColumns] })
|
||||
tables: TableColumns[];
|
||||
@ApiProperty()
|
||||
name: string;
|
||||
@ApiProperty()
|
||||
description: string;
|
||||
@ApiProperty()
|
||||
plugin: string;
|
||||
@ApiPropertyOptional()
|
||||
type?: string;
|
||||
@ApiProperty()
|
||||
created_at: string;
|
||||
@ApiProperty()
|
||||
updated_at: string;
|
||||
|
||||
//deprecated attributes (for retro compatibility)
|
||||
@ApiPropertyOptional({ deprecated: true })
|
||||
category: string;
|
||||
@ApiPropertyOptional({ deprecated: true })
|
||||
credentials: Credentials;
|
||||
@ApiPropertyOptional({ deprecated: true })
|
||||
options: InputOptions;
|
||||
@ApiPropertyOptional({ deprecated: true })
|
||||
info: Info;
|
||||
@ApiPropertyOptional({ deprecated: true })
|
||||
cron: string;
|
||||
@ApiPropertyOptional({ deprecated: true })
|
||||
source_bucket: string;
|
||||
@ApiPropertyOptional({ deprecated: true })
|
||||
source_prefix: string;
|
||||
@ApiPropertyOptional({ deprecated: true })
|
||||
auth_parameters: AuthParameters;
|
||||
@ApiPropertyOptional({ deprecated: true })
|
||||
file_format_params: FileFormatParams;
|
||||
}
|
||||
export class GetAvailableEntitiesReq {
|
||||
@ApiProperty()
|
||||
plugin: string;
|
||||
@@ -144,7 +177,7 @@ export class TestConnectionGetColumnsReq {
|
||||
info: Info;
|
||||
}
|
||||
export class TestConnectionGetColumnsRes {
|
||||
@ApiProperty()
|
||||
@ApiProperty({ type: [TableColumns] })
|
||||
tables: TableColumns[];
|
||||
}
|
||||
|
||||
@@ -164,42 +197,8 @@ export class TestConnectionRes {
|
||||
@ApiProperty()
|
||||
database_tables: string[];
|
||||
}
|
||||
export class CreateInputReq {
|
||||
@ApiPropertyOptional()
|
||||
id: string;
|
||||
@ApiProperty()
|
||||
plugin: string;
|
||||
@ApiProperty()
|
||||
category: string;
|
||||
@ApiProperty()
|
||||
credentials: Credentials;
|
||||
@ApiProperty()
|
||||
name: string;
|
||||
@ApiPropertyOptional()
|
||||
options: InputOptions;
|
||||
@ApiPropertyOptional()
|
||||
info: Info;
|
||||
}
|
||||
|
||||
export class Input {
|
||||
@ApiProperty()
|
||||
id: string;
|
||||
@ApiProperty()
|
||||
category: string;
|
||||
@ApiProperty()
|
||||
plugin: string;
|
||||
@ApiProperty()
|
||||
name: string;
|
||||
@ApiProperty()
|
||||
cron: string;
|
||||
@ApiProperty()
|
||||
credentials: Credentials;
|
||||
@ApiProperty()
|
||||
client_id: string;
|
||||
@ApiProperty()
|
||||
created_at: string;
|
||||
@ApiProperty()
|
||||
updated_at: string;
|
||||
@ApiPropertyOptional()
|
||||
info: Info;
|
||||
}
|
||||
export class CreateInputReq extends OmitType(Input, [
|
||||
'id',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
]) {}
|
||||
|
||||
@@ -105,24 +105,18 @@ export class InputsController {
|
||||
|
||||
@Post()
|
||||
@ApiOkResponse({ type: Input })
|
||||
async create(@Body() createInputDto: CreateInputReq) {
|
||||
async create(@Body() body: CreateInputReq, @User() user: RequestUser) {
|
||||
const info: Info = {
|
||||
user_id: user.user_id,
|
||||
customer: user.customer_name,
|
||||
customer_id: user.customer_id,
|
||||
};
|
||||
this.logger.info(`/input - ON CREATE ROUTE`, {
|
||||
user: createInputDto.info.user_id,
|
||||
customer: createInputDto.info.customer,
|
||||
user: info.user_id,
|
||||
customer: info.customer,
|
||||
});
|
||||
|
||||
const response = await this.inputService.create(createInputDto);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Post(':id')
|
||||
@ApiOkResponse({ type: Input })
|
||||
async reCreate(@Param('id') id: string, @Body() input: CreateInputReq) {
|
||||
if (!input.id) input.id = id;
|
||||
this.logger.info(`POST /${id}`, 'ON RECREATE ROUTE');
|
||||
|
||||
const response = await this.inputService.reCreate(input);
|
||||
const response = await this.inputService.create({ body, info });
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
Body,
|
||||
ForbiddenException,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
@@ -15,12 +14,14 @@ import { objectCamelToSnake } from 'src/utils/CaseConverter';
|
||||
import { IIdRequest, UpdateInputRequest } from './dtos/old_interfaces';
|
||||
import { Input } from '@dadosfera/protospack-v2';
|
||||
import {
|
||||
InputCreateGenericRequest,
|
||||
InputCreateS3Request,
|
||||
InputNewCreateRequest,
|
||||
TestConnectionGetColumnsRequest,
|
||||
TestConnectionRequest,
|
||||
} from '@dadosfera/protospack-v2/dist/lib/Input/interfaces/messages';
|
||||
import { Info } from '@dadosfera/protospack-v2/dist/lib/Input/interfaces/entities';
|
||||
import { CreateInputReq } from './dtos/input.model';
|
||||
|
||||
@Injectable()
|
||||
|
||||
@@ -59,28 +60,6 @@ export class InputsService {
|
||||
objectCamelToSnake(input);
|
||||
return input;
|
||||
},
|
||||
createGeneric: async (createInputGeneric) => {
|
||||
this.logger.info('InputClientService - Create');
|
||||
const { info, ...data } = createInputGeneric;
|
||||
|
||||
if (data.options) delete data.options;
|
||||
if (data.credentials.oauth_code) delete data.credentials.oauth_code;
|
||||
|
||||
if (data.credentials) data.credentials = JSON.stringify(data.credentials);
|
||||
|
||||
const input = await lastValueFrom(
|
||||
this.inputWriteService.InputCreate({ info, input: data }),
|
||||
);
|
||||
// .catch((err: { details: string }) => {
|
||||
// if (err.details === 'Item Not found!') {
|
||||
// throw new NotFoundException('Input not found');
|
||||
// }
|
||||
// throw new InternalServerErrorException(err.details);
|
||||
// });
|
||||
// objectCamelToSnake(structReturn);
|
||||
// const inputCreated = DecodeGrpcStruct(structReturn.input);
|
||||
return { input };
|
||||
},
|
||||
createS3Inputs: async (createInputDto: InputCreateS3Request) => {
|
||||
this.logger.info('InputClientService - Create');
|
||||
createInputDto;
|
||||
@@ -109,80 +88,22 @@ export class InputsService {
|
||||
const updateInputResponse = await lastValueFrom(
|
||||
this.inputWriteService.InputUpdate(updateInputDTO),
|
||||
);
|
||||
// const updateInputResponse = await new Promise((resolve, reject) => {
|
||||
// this.inputWriteService.InputUpdate(updateInputDTO).subscribe({
|
||||
// next(x) {
|
||||
// resolve(objectCamelToSnake(x));
|
||||
// },
|
||||
// error(err) {
|
||||
// reject(err);
|
||||
// },
|
||||
// complete() {
|
||||
// // console.log('done');
|
||||
// },
|
||||
// });
|
||||
// })
|
||||
// .then((res) => {
|
||||
// this.logger.info('Done');
|
||||
// return res;
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// this.logger.error(err.message);
|
||||
// throw new Error(err);
|
||||
// });
|
||||
|
||||
return updateInputResponse;
|
||||
},
|
||||
remove: async (idRequest: IIdRequest) => {
|
||||
this.logger.info('InputClientService - Remove');
|
||||
|
||||
const removeInputResponse = await new Promise((resolve, reject) => {
|
||||
this.inputWriteService.InputRemove(idRequest).subscribe({
|
||||
next(x) {
|
||||
resolve(objectCamelToSnake(x));
|
||||
},
|
||||
error(err) {
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
// console.log('done');
|
||||
},
|
||||
});
|
||||
})
|
||||
.then((res) => {
|
||||
this.logger.info('Done');
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
this.logger.error(err.message);
|
||||
throw new Error(err);
|
||||
});
|
||||
const removeInputResponse = await lastValueFrom(
|
||||
this.inputWriteService.InputRemove(idRequest),
|
||||
);
|
||||
|
||||
return removeInputResponse;
|
||||
},
|
||||
testConnection: async (data: TestConnectionRequest) => {
|
||||
this.logger.info('InputClientService - TestConnection');
|
||||
const testConnectionResponse = await new Promise((resolve, reject) => {
|
||||
this.inputReadService.NewTestConnection(data).subscribe({
|
||||
next(x) {
|
||||
resolve(objectCamelToSnake(x));
|
||||
},
|
||||
error(err) {
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
// console.log('done');
|
||||
},
|
||||
});
|
||||
})
|
||||
.then((res) => {
|
||||
this.logger.info('Done');
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
this.logger.error(err.message);
|
||||
throw new Error(err);
|
||||
});
|
||||
const testConnectionResponse = await lastValueFrom(
|
||||
this.inputReadService.NewTestConnection(data),
|
||||
);
|
||||
|
||||
return testConnectionResponse;
|
||||
},
|
||||
@@ -228,6 +149,7 @@ export class InputsService {
|
||||
return response;
|
||||
},
|
||||
};
|
||||
|
||||
secondsInADay = 60 * 60 * 24;
|
||||
secondsInAnHour = 60 * 60;
|
||||
|
||||
@@ -242,6 +164,12 @@ export class InputsService {
|
||||
}
|
||||
if (payload.input_s3) return payload.input_s3;
|
||||
if (payload.input_jdbc) return payload.input_jdbc;
|
||||
|
||||
const { credentials } = payload;
|
||||
return {
|
||||
...payload,
|
||||
credentials: credentials && JSON.parse(credentials),
|
||||
};
|
||||
}
|
||||
return payload;
|
||||
}
|
||||
@@ -275,44 +203,31 @@ export class InputsService {
|
||||
);
|
||||
}
|
||||
}
|
||||
async create(@Body() data) {
|
||||
this.validateCron(data);
|
||||
let response;
|
||||
switch (data.plugin.toLowerCase()) {
|
||||
case 'csv':
|
||||
case 'json':
|
||||
case 'parquet': {
|
||||
const { info, ...input } = data;
|
||||
const inputPayload = this.generateInputS3Payload(input);
|
||||
response = await this.OLD_inputClient.createS3Inputs({
|
||||
input: inputPayload,
|
||||
info,
|
||||
});
|
||||
break;
|
||||
}
|
||||
case 'oracle':
|
||||
case 'mysql':
|
||||
case 'postgresql':
|
||||
case 'sqlserver':
|
||||
response = await this.OLD_inputClient.newCreate(data);
|
||||
break;
|
||||
default:
|
||||
response = await this.OLD_inputClient.createGeneric(data);
|
||||
break;
|
||||
}
|
||||
const adjustedInput = this.adjustInputPayload(response.input);
|
||||
return { ...response, input: adjustedInput };
|
||||
}
|
||||
async reCreate(data) {
|
||||
const { info, cron } = data;
|
||||
if (cron) this.validateCron({ info, cron });
|
||||
const response = await this.OLD_inputClient.createGeneric(data);
|
||||
const adjustedInput = this.adjustInputPayload(response.input);
|
||||
return { ...response, input: adjustedInput };
|
||||
async create(data: { body: CreateInputReq; info: Info }) {
|
||||
// this.validateCron(data);
|
||||
const { body, info } = data;
|
||||
|
||||
if (body.info) delete body.info;
|
||||
|
||||
const inputCreateGenericRequest: any | InputCreateGenericRequest = {
|
||||
input: {
|
||||
...body,
|
||||
credentials: body.credentials && JSON.stringify(body.credentials),
|
||||
},
|
||||
info,
|
||||
};
|
||||
|
||||
const { input } = await lastValueFrom(
|
||||
this.inputWriteService.InputCreate(inputCreateGenericRequest),
|
||||
);
|
||||
const adjustedInput = this.adjustInputPayload(input);
|
||||
return { input: adjustedInput };
|
||||
}
|
||||
|
||||
async getAvailableEntities(data): Promise<{ entities: string[] }> {
|
||||
return await this.OLD_inputClient.getAvailableEntities(data);
|
||||
}
|
||||
|
||||
async findAll(info: Info) {
|
||||
const { inputs } = await lastValueFrom(
|
||||
this.inputReadService.InputFindAll({ info }),
|
||||
@@ -321,31 +236,6 @@ export class InputsService {
|
||||
|
||||
const inputsReturn = inputs.map((i) => this.adjustInputPayload(i));
|
||||
return { inputs: inputsReturn };
|
||||
// findAll: async (data) => {
|
||||
// this.logger.info('InputClientService - FindAll');
|
||||
// const findAllInputResponse = await lastValueFrom(
|
||||
// this.inputReadService.InputFindAll(data),
|
||||
// ).catch((e) => {
|
||||
// this.logger.error(e.details);
|
||||
// throw new HttpException(e.details, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
// });
|
||||
// findAllInputResponse.inputs.forEach((input) => objectCamelToSnake(input));
|
||||
|
||||
// return findAllInputResponse;
|
||||
// },
|
||||
// try {
|
||||
// const findAllInputResponse: any = await this.OLD_inputClient.findAll(
|
||||
// body,
|
||||
// );
|
||||
// if (findAllInputResponse?.inputs?.length) {
|
||||
// findAllInputResponse.inputs = findAllInputResponse.inputs.map((input) =>
|
||||
// this.adjustInputPayload(input),
|
||||
// );
|
||||
// }
|
||||
// return findAllInputResponse;
|
||||
// } catch (err) {
|
||||
// throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
// }
|
||||
}
|
||||
|
||||
async findOne(idRequest: IIdRequest) {
|
||||
|
||||
@@ -10,11 +10,25 @@ export class PipelinesService {
|
||||
constructor(private pipelineClient: PipelinesClientService) {}
|
||||
|
||||
adjustPayload(payload) {
|
||||
if (payload.input?.input_generic) {
|
||||
payload.input = DecodeGrpcStruct(payload.input?.input_generic);
|
||||
} else {
|
||||
payload.input = payload.input?.input_s3 || payload.input?.input_jdbc;
|
||||
const { input } = payload;
|
||||
if (input) {
|
||||
if (input.input_generic) {
|
||||
const { credentials } = input.input_generic;
|
||||
return {
|
||||
...input.input_generic,
|
||||
credentials: credentials && JSON.parse(credentials),
|
||||
};
|
||||
}
|
||||
if (input.input_s3) return input.input_s3;
|
||||
if (input.input_jdbc) return input.input_jdbc;
|
||||
|
||||
const { credentials } = input;
|
||||
return {
|
||||
...input,
|
||||
credentials: credentials && JSON.parse(credentials),
|
||||
};
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
async create(createPipelineDto) {
|
||||
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
import { Info } from 'protospack/dist/lib/interfaces';
|
||||
|
||||
export interface ICreatePipelineDto {
|
||||
input: IdRequest;
|
||||
transformations: IdRequest[];
|
||||
output: IdRequest;
|
||||
tags: string[];
|
||||
name: string;
|
||||
description: string;
|
||||
info: Info;
|
||||
}
|
||||
|
||||
export interface IdRequest {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface IIdRequest {
|
||||
id: string;
|
||||
info: Info;
|
||||
}
|
||||
|
||||
export interface IUpdatePipelineRequest {
|
||||
input: IdRequest;
|
||||
transformations: IdRequest[];
|
||||
output: IdRequest;
|
||||
tags: string[];
|
||||
name: string;
|
||||
description: string;
|
||||
id: string;
|
||||
info: Info;
|
||||
}
|
||||
|
||||
export interface IGetPipelineLogsRequest {
|
||||
id: string;
|
||||
details: string;
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import { ApiProperty, ApiPropertyOptional, OmitType } from '@nestjs/swagger';
|
||||
import { Info } from 'protospack/dist/lib/interfaces';
|
||||
|
||||
export class IPipelineV2 {
|
||||
@ApiProperty()
|
||||
id: string;
|
||||
|
||||
@ApiProperty()
|
||||
name: string;
|
||||
@ApiProperty()
|
||||
description: string;
|
||||
@ApiProperty()
|
||||
connection_id: string;
|
||||
@ApiProperty()
|
||||
cron: string;
|
||||
@ApiPropertyOptional()
|
||||
input_id?: string;
|
||||
@ApiPropertyOptional()
|
||||
transformations_ids?: string[];
|
||||
@ApiPropertyOptional()
|
||||
tags?: string[];
|
||||
@ApiPropertyOptional()
|
||||
properties?: any;
|
||||
|
||||
@ApiProperty()
|
||||
connector_name: string;
|
||||
@ApiProperty()
|
||||
connector_plugin: string;
|
||||
@ApiProperty()
|
||||
connector_version: string;
|
||||
@ApiProperty()
|
||||
image_url: string;
|
||||
|
||||
@ApiProperty()
|
||||
created_at: string;
|
||||
@ApiProperty()
|
||||
updated_at: string;
|
||||
}
|
||||
export class ICreatePipelineV2Req extends OmitType(IPipelineV2, [
|
||||
'id',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
]) {}
|
||||
|
||||
export interface IdRequest {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface IIdRequest {
|
||||
id: string;
|
||||
info: Info;
|
||||
}
|
||||
|
||||
export interface IUpdatePipelineRequest {
|
||||
input: IdRequest;
|
||||
transformations: IdRequest[];
|
||||
output: IdRequest;
|
||||
tags: string[];
|
||||
name: string;
|
||||
description: string;
|
||||
id: string;
|
||||
info: Info;
|
||||
}
|
||||
|
||||
export interface IGetPipelineLogsRequest {
|
||||
id: string;
|
||||
details: string;
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
Put,
|
||||
Headers,
|
||||
} from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { ApiCreatedResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { AuthenticateCondition } from 'src/authentication/authentication.decorator';
|
||||
import { PERMISSIONS } from '../../authentication/permissions.enum';
|
||||
import { PipelinesService } from './pipelines.service';
|
||||
@@ -19,6 +19,7 @@ import { RequestUser, User } from 'src/authentication/user.decorator';
|
||||
import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
|
||||
|
||||
import { PipelinesService as OldPipelineService } from 'src/modules/pipelines/pipelines.service';
|
||||
import { ICreatePipelineV2Req, IPipelineV2 } from './interfaces';
|
||||
@ApiTags('Pipelines')
|
||||
@Controller('pipelinesV2')
|
||||
@AuthenticateCondition((req, user) => {
|
||||
@@ -53,10 +54,11 @@ export class PipelinesController {
|
||||
}
|
||||
|
||||
@Post()
|
||||
@ApiCreatedResponse({ type: IPipelineV2 })
|
||||
async create(
|
||||
@Headers('Dadosfera-Lang') language,
|
||||
@User() user: RequestUser,
|
||||
@Body() createPipelineDto: Messages.PipelineV2CreateRequest,
|
||||
@Body() createPipelineDto: ICreatePipelineV2Req,
|
||||
) {
|
||||
this.logger.info(process.env.DEV_URL + `/pipelines ON CREATE ROUTE`);
|
||||
const { customer_id, customer_name, username, user_id } = user;
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
InternalServerErrorException,
|
||||
OnModuleInit,
|
||||
} from '@nestjs/common';
|
||||
import { ClientGrpc, Payload } from '@nestjs/microservices';
|
||||
import { ClientGrpc } from '@nestjs/microservices';
|
||||
import {
|
||||
Messages,
|
||||
WriteService,
|
||||
@@ -15,6 +15,8 @@ import { lastValueFrom } from 'rxjs';
|
||||
|
||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||
import { PipelinesClientConfiguration } from './pipelines-client';
|
||||
import { ICreatePipelineV2Req } from './interfaces';
|
||||
import { PipelineV2CreateRequest } from '@dadosfera/protospack-v2/dist/lib/PipelineV2/interfaces/messages';
|
||||
|
||||
export class PipelinesService implements OnModuleInit {
|
||||
logger: DadosferaLogger;
|
||||
@@ -42,25 +44,33 @@ export class PipelinesService implements OnModuleInit {
|
||||
}
|
||||
|
||||
async create(
|
||||
@Payload() createPipelineDto: Messages.PipelineV2CreateRequest,
|
||||
body: ICreatePipelineV2Req,
|
||||
metadata,
|
||||
): Promise<Messages.PipelineV2CreateResponse> {
|
||||
this.logger.info('PipelinesClientService - Create');
|
||||
this.logger.info('PipelinesV2ClientService - Create');
|
||||
|
||||
const pipelineV2CreateRequest: PipelineV2CreateRequest = {
|
||||
...body,
|
||||
input_id: body.input_id,
|
||||
transformations_ids: body.transformations_ids,
|
||||
tags: body.tags,
|
||||
properties: body.properties && JSON.stringify(body.properties),
|
||||
};
|
||||
|
||||
const createPipelineResponse = await lastValueFrom(
|
||||
this.pipelineWriteService.PipelineV2Create(createPipelineDto, metadata),
|
||||
)
|
||||
.then((res) => {
|
||||
this.logger.info('Done');
|
||||
return res;
|
||||
})
|
||||
.catch((error: { details: string }) => {
|
||||
if (error.details.includes('INVALID_REQUEST')) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const [errorType, message] = error.details.split('|');
|
||||
throw new BadRequestException(message);
|
||||
}
|
||||
throw new InternalServerErrorException(error.details);
|
||||
});
|
||||
this.pipelineWriteService.PipelineV2Create(
|
||||
pipelineV2CreateRequest,
|
||||
metadata,
|
||||
),
|
||||
).catch((error: { details: string }) => {
|
||||
if (error.details.includes('INVALID_REQUEST')) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const [errorType, message] = error.details.split('|');
|
||||
throw new BadRequestException(message);
|
||||
}
|
||||
throw new InternalServerErrorException(error.details);
|
||||
});
|
||||
this.logger.info('Done');
|
||||
|
||||
return createPipelineResponse;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Metadata } from '@grpc/grpc-js';
|
||||
|
||||
interface Info {
|
||||
interface IMetadata {
|
||||
customer_id?: string;
|
||||
customer_name?: string;
|
||||
username?: string;
|
||||
@@ -9,14 +9,11 @@ interface Info {
|
||||
details?: string;
|
||||
}
|
||||
|
||||
export const PackTheMetadata = (info: Info): Metadata => {
|
||||
export function PackTheMetadata(info: IMetadata): Metadata {
|
||||
const meta = new Metadata();
|
||||
meta.add('customer_id', info.customer_id);
|
||||
meta.add('customer_name', info.customer_name);
|
||||
meta.add('user_id', info.user_id);
|
||||
meta.add('username', info.username);
|
||||
meta.add('details', info.details);
|
||||
meta.add('language', info.language);
|
||||
for (const key in info) {
|
||||
meta.add(key, info[key]);
|
||||
}
|
||||
|
||||
return meta;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -196,6 +196,15 @@ export function EnrichErrorCode(code: string) {
|
||||
code,
|
||||
};
|
||||
|
||||
case ErrorCodes.CONNECTION_TEST.BAD_REQUEST:
|
||||
return {
|
||||
statusCode: HttpStatus.BAD_REQUEST,
|
||||
error: 'Erro ao testar conexão',
|
||||
message:
|
||||
'Verifique se todas as informações foram preenchidas corretamente',
|
||||
code,
|
||||
};
|
||||
|
||||
case ErrorCodes.INTERNAL:
|
||||
case ErrorCodes.UNKNOWN:
|
||||
default:
|
||||
|
||||
@@ -42,6 +42,7 @@ const CONNECTION_TEST = {
|
||||
ERROR: 'CONNECTION_TEST.ERROR',
|
||||
EXPIRED: 'CONNECTION_TEST.EXPIRED',
|
||||
TIMEOUT: 'CONNECTION_TEST.TIMEOUT',
|
||||
BAD_REQUEST: 'CONNECTION_TEST.BAD_REQUEST',
|
||||
UNKNOWN: 'CONNECTION_TEST.UNKNOWN',
|
||||
};
|
||||
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user