mirror of
https://github.com/dadosfera/maestro.git
synced 2026-12-02 21:50:05 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b20f67e8b8 | ||
|
|
4a8a8eb463 | ||
|
|
d52f8b78c8 | ||
|
|
bfbe7cce87 | ||
|
|
1ab8c1dd10 | ||
|
|
dfa6222538 | ||
|
|
b64619ede1 | ||
|
|
92041f453c |
@@ -454,6 +454,28 @@ export class CatalogController {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Delete('data-asset/:id')
|
||||||
|
async deleteDataAsset(
|
||||||
|
@Param('id') data_asset_id: string,
|
||||||
|
@User() user: RequestUser,
|
||||||
|
) {
|
||||||
|
const { customer_id, customer_name, user_id, username } = user;
|
||||||
|
const metadata = PackTheMetadata({
|
||||||
|
customer_id,
|
||||||
|
customer_name,
|
||||||
|
user_id,
|
||||||
|
username,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [type, id] = data_asset_id.split('-');
|
||||||
|
const response = await this.catalogService.deleteDataAsset(
|
||||||
|
{ id, type },
|
||||||
|
metadata,
|
||||||
|
);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
@Delete('data-asset/:id/comment')
|
@Delete('data-asset/:id/comment')
|
||||||
async deleteComment(
|
async deleteComment(
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
|
|||||||
@@ -110,6 +110,19 @@ class CatalogService implements OnModuleInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async deleteDataAsset(data: Messages.DeleteDataAssetRequest, metadata) {
|
||||||
|
this.logger.info('CatalogService - Manage Data assets permissions');
|
||||||
|
|
||||||
|
return lastValueFrom(
|
||||||
|
this.catalogWriteService.DeleteDataAsset(data, metadata),
|
||||||
|
).catch((err) => {
|
||||||
|
throw new HttpException(
|
||||||
|
err.details,
|
||||||
|
err.code === 6 ? HttpStatus.CONFLICT : 404,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async getUserRolesIds(userId: string) {
|
async getUserRolesIds(userId: string) {
|
||||||
const result = await this.userService.findOneById(userId).catch(() => null);
|
const result = await this.userService.findOneById(userId).catch(() => null);
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,9 @@
|
|||||||
import {
|
import { ConflictException, Inject, OnModuleInit } from '@nestjs/common';
|
||||||
BadRequestException,
|
import { ClientGrpc } from '@nestjs/microservices';
|
||||||
ConflictException,
|
|
||||||
Inject,
|
|
||||||
InternalServerErrorException,
|
|
||||||
OnModuleInit,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { ClientGrpc, Payload } from '@nestjs/microservices';
|
|
||||||
import { PipelineServicesNames, PipelinesServiceInterface } from 'protospack';
|
import { PipelineServicesNames, PipelinesServiceInterface } from 'protospack';
|
||||||
import { lastValueFrom } from 'rxjs';
|
import { lastValueFrom } from 'rxjs';
|
||||||
import { objectSnakeToCamel } from 'src/utils/CaseConverter';
|
|
||||||
|
|
||||||
import {
|
import { IIdRequest } from './interfaces';
|
||||||
ICreatePipelineDto,
|
|
||||||
IGetPipelineLogsRequest,
|
|
||||||
IIdRequest,
|
|
||||||
IUpdatePipelineRequest,
|
|
||||||
} from './interfaces';
|
|
||||||
|
|
||||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||||
import { PipelinesClientConfiguration } from './pipelines-client';
|
import { PipelinesClientConfiguration } from './pipelines-client';
|
||||||
@@ -39,91 +27,6 @@ export class PipelinesClientService implements OnModuleInit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async create(@Payload() createPipelineDto: ICreatePipelineDto) {
|
|
||||||
this.logger.info('PipelinesClientService - Create');
|
|
||||||
const createPipelineResponse = await lastValueFrom(
|
|
||||||
this.pipelineService.Create(objectSnakeToCamel(createPipelineDto)),
|
|
||||||
).catch((error: { details: string }) => {
|
|
||||||
if (error.details.includes('INVALID_REQUEST')) {
|
|
||||||
const [, message] = error.details.split('|');
|
|
||||||
throw new BadRequestException(message);
|
|
||||||
}
|
|
||||||
throw new InternalServerErrorException(error.details);
|
|
||||||
});
|
|
||||||
this.logger.info('Done');
|
|
||||||
|
|
||||||
return createPipelineResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
async findAll(data) {
|
|
||||||
this.logger.info('PipelinesClientService - FindAll');
|
|
||||||
const findAllPipelineResponse = await lastValueFrom(
|
|
||||||
this.pipelineService.FindAll(data),
|
|
||||||
).catch((err) => {
|
|
||||||
this.logger.error(err.message);
|
|
||||||
throw new Error(err);
|
|
||||||
});
|
|
||||||
this.logger.info('Done');
|
|
||||||
|
|
||||||
return findAllPipelineResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
async findOne(data: IIdRequest) {
|
|
||||||
this.logger.info('PipelinesClientService - FindOne');
|
|
||||||
|
|
||||||
const findOnePipelineResponse = await lastValueFrom(
|
|
||||||
this.pipelineService.FindOne(data),
|
|
||||||
).catch((err) => {
|
|
||||||
this.logger.error(err.message);
|
|
||||||
throw new Error(err);
|
|
||||||
});
|
|
||||||
this.logger.info('Done');
|
|
||||||
|
|
||||||
return findOnePipelineResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
async update(UpdatePipelineRequest: IUpdatePipelineRequest) {
|
|
||||||
this.logger.info('PipelinesClientService - Update');
|
|
||||||
|
|
||||||
const updatePipelineResponse = await lastValueFrom(
|
|
||||||
this.pipelineService.Update(UpdatePipelineRequest),
|
|
||||||
).catch((err) => {
|
|
||||||
this.logger.error(err.message);
|
|
||||||
throw new Error(err);
|
|
||||||
});
|
|
||||||
this.logger.info('Done');
|
|
||||||
|
|
||||||
return updatePipelineResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
async remove(data: IIdRequest) {
|
|
||||||
this.logger.info('PipelinesClientService - Remove');
|
|
||||||
|
|
||||||
const removePipelineResponse = await lastValueFrom(
|
|
||||||
this.pipelineService.remove(data),
|
|
||||||
).catch((err) => {
|
|
||||||
this.logger.error(err.message);
|
|
||||||
throw new Error(err);
|
|
||||||
});
|
|
||||||
this.logger.info('Done');
|
|
||||||
|
|
||||||
return removePipelineResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
async getPipelineLogsMessages(data: IGetPipelineLogsRequest) {
|
|
||||||
this.logger.info('PipelinesClientService - GetPipelineLogsMessages');
|
|
||||||
|
|
||||||
const logsPipelineResponse = await lastValueFrom(
|
|
||||||
this.pipelineService.getPipelineLogs(data),
|
|
||||||
).catch((err) => {
|
|
||||||
this.logger.error(err.message);
|
|
||||||
throw new Error(err);
|
|
||||||
});
|
|
||||||
this.logger.info('Done');
|
|
||||||
|
|
||||||
return logsPipelineResponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
async getPipelineStatus(data) {
|
async getPipelineStatus(data) {
|
||||||
this.logger.info('PipelinesClientService - GetPipelineStatus');
|
this.logger.info('PipelinesClientService - GetPipelineStatus');
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,4 @@
|
|||||||
import {
|
import { Body, Controller, Get, Inject, Param, Post } from '@nestjs/common';
|
||||||
Body,
|
|
||||||
Controller,
|
|
||||||
Delete,
|
|
||||||
Get,
|
|
||||||
Inject,
|
|
||||||
Param,
|
|
||||||
Post,
|
|
||||||
Put,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
import {
|
import {
|
||||||
AuthenticateCondition,
|
AuthenticateCondition,
|
||||||
@@ -16,7 +7,6 @@ import {
|
|||||||
import { PERMISSIONS_GROUPS } from '../../authentication/permissions.enum';
|
import { PERMISSIONS_GROUPS } from '../../authentication/permissions.enum';
|
||||||
import { PipelinesService } from './pipelines.service';
|
import { PipelinesService } from './pipelines.service';
|
||||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||||
import { RequestUser, User } from 'src/authentication/user.decorator';
|
|
||||||
|
|
||||||
@ApiTags('Pipelines')
|
@ApiTags('Pipelines')
|
||||||
@Controller('pipelines')
|
@Controller('pipelines')
|
||||||
@@ -86,84 +76,4 @@ export class PipelinesController {
|
|||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id/:details')
|
|
||||||
async getPipelineLogs(@Param() params) {
|
|
||||||
const { id, details } = params;
|
|
||||||
this.logger.info(
|
|
||||||
process.env.DEV_URL + `/pipeline/${id} - ON GET PIPELINE LOGS ROUTE`,
|
|
||||||
{},
|
|
||||||
);
|
|
||||||
|
|
||||||
const response = await this.pipelineService.getPipelineLogsMessages(
|
|
||||||
id,
|
|
||||||
details,
|
|
||||||
);
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Post()
|
|
||||||
async create(@Body() createPipelineDto) {
|
|
||||||
this.logger.info(process.env.DEV_URL + `/pipelines ON CREATE ROUTE`);
|
|
||||||
|
|
||||||
const response = await this.pipelineService.create(createPipelineDto);
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get()
|
|
||||||
async findAll(@User() user: RequestUser) {
|
|
||||||
this.logger.info(process.env.DEV_URL + `/pipeline ON Find All ROUTE`, {
|
|
||||||
user: user.user_id,
|
|
||||||
customer: user.customer_id,
|
|
||||||
});
|
|
||||||
|
|
||||||
const { customer_id, user_id, customer_name } = user;
|
|
||||||
|
|
||||||
const response = await this.pipelineService.findAll({
|
|
||||||
customer_name,
|
|
||||||
customer_id,
|
|
||||||
user_id,
|
|
||||||
});
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get('/:id')
|
|
||||||
async findOne(@Body() data, @Param() params) {
|
|
||||||
const { id } = params;
|
|
||||||
this.logger.info(process.env.DEV_URL + `/pipeline/${id} ON Find One ROUTE`);
|
|
||||||
|
|
||||||
const response = await this.pipelineService.findOne({ id, ...data });
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Put(':id')
|
|
||||||
async update(@Body() updatePipelineDto, @Param() params) {
|
|
||||||
const { id } = params;
|
|
||||||
const { info } = updatePipelineDto;
|
|
||||||
delete updatePipelineDto.info;
|
|
||||||
|
|
||||||
this.logger.info(process.env.DEV_URL + `/pipeline/${id} ON UPDATE ROUTE`);
|
|
||||||
|
|
||||||
const response = await this.pipelineService.update(
|
|
||||||
id,
|
|
||||||
updatePipelineDto,
|
|
||||||
info,
|
|
||||||
);
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Delete(':id')
|
|
||||||
async delete(@Body() data, @Param() params) {
|
|
||||||
const { id } = params;
|
|
||||||
this.logger.info(process.env.DEV_URL + `/pipeline/${id} ON DELETE ROUTE`);
|
|
||||||
|
|
||||||
const response = await this.pipelineService.remove({ id, ...data });
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||||
import { DecodeGrpcStruct } from 'protospack';
|
|
||||||
import { Info } from 'protospack/dist/lib/interfaces';
|
|
||||||
import { PipelinesClientService } from './client.service';
|
import { PipelinesClientService } from './client.service';
|
||||||
import { IIdRequest } from './interfaces';
|
import { IIdRequest } from './interfaces';
|
||||||
import { objectCamelToSnake } from 'src/utils/CaseConverter';
|
import { objectCamelToSnake } from 'src/utils/CaseConverter';
|
||||||
@@ -9,91 +7,6 @@ import { objectCamelToSnake } from 'src/utils/CaseConverter';
|
|||||||
export class PipelinesService {
|
export class PipelinesService {
|
||||||
constructor(private pipelineClient: PipelinesClientService) {}
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async create(createPipelineDto) {
|
|
||||||
const createPipelineResponse = await this.pipelineClient.create(
|
|
||||||
createPipelineDto,
|
|
||||||
);
|
|
||||||
|
|
||||||
const pipeline = objectCamelToSnake(createPipelineResponse);
|
|
||||||
this.adjustPayload(pipeline.pipeline);
|
|
||||||
|
|
||||||
return pipeline;
|
|
||||||
}
|
|
||||||
|
|
||||||
async findOne(data: IIdRequest) {
|
|
||||||
try {
|
|
||||||
const findOnePipelineResponse = await this.pipelineClient.findOne(data);
|
|
||||||
|
|
||||||
const pipeline = objectCamelToSnake(findOnePipelineResponse);
|
|
||||||
this.adjustPayload(pipeline.pipeline);
|
|
||||||
|
|
||||||
return pipeline;
|
|
||||||
} catch (err) {
|
|
||||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async findAll(data) {
|
|
||||||
try {
|
|
||||||
const { pipelines } = await this.pipelineClient.findAll({
|
|
||||||
info: data,
|
|
||||||
});
|
|
||||||
if (pipelines)
|
|
||||||
pipelines.forEach((pipeline) => {
|
|
||||||
this.adjustPayload(pipeline);
|
|
||||||
});
|
|
||||||
return { pipelines: pipelines || [] };
|
|
||||||
} catch (err) {
|
|
||||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async update(id: string, data, info: Info) {
|
|
||||||
try {
|
|
||||||
const updatePipelineResponse = await this.pipelineClient.update({
|
|
||||||
id,
|
|
||||||
info,
|
|
||||||
...data,
|
|
||||||
});
|
|
||||||
|
|
||||||
const pipeline = objectCamelToSnake(updatePipelineResponse);
|
|
||||||
this.adjustPayload(pipeline);
|
|
||||||
|
|
||||||
return pipeline;
|
|
||||||
} catch (err) {
|
|
||||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async remove(data: IIdRequest) {
|
|
||||||
try {
|
|
||||||
const removePipelineResponse = await this.pipelineClient.remove(data);
|
|
||||||
|
|
||||||
return removePipelineResponse;
|
|
||||||
} catch (err) {
|
|
||||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async getPipelineLogsMessages(id: string, details: string) {
|
|
||||||
try {
|
|
||||||
const pipelineLogsResponse =
|
|
||||||
await this.pipelineClient.getPipelineLogsMessages({ id, details });
|
|
||||||
|
|
||||||
return objectCamelToSnake(pipelineLogsResponse);
|
|
||||||
} catch (err) {
|
|
||||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async getPipelineStatus(data: IIdRequest) {
|
async getPipelineStatus(data: IIdRequest) {
|
||||||
try {
|
try {
|
||||||
const pipelineStatusResponse =
|
const pipelineStatusResponse =
|
||||||
|
|||||||
@@ -159,6 +159,7 @@ export class PipelinesController {
|
|||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put('/:id')
|
@Put('/:id')
|
||||||
async update(
|
async update(
|
||||||
@Body() updatePipelineDto,
|
@Body() updatePipelineDto,
|
||||||
@@ -183,7 +184,12 @@ export class PipelinesController {
|
|||||||
const { id } = params;
|
const { id } = params;
|
||||||
this.logger.info('PipelinesController - findOne', { user });
|
this.logger.info('PipelinesController - findOne', { user });
|
||||||
|
|
||||||
const response = await this.pipelinesClientService.remove({ id, ...data });
|
const metadata = PackTheMetadata({ ...user });
|
||||||
|
|
||||||
|
const response = await this.pipelinesClientService.remove(
|
||||||
|
{ id, ...data },
|
||||||
|
metadata,
|
||||||
|
);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
BadRequestException,
|
BadRequestException,
|
||||||
|
HttpException,
|
||||||
Inject,
|
Inject,
|
||||||
InternalServerErrorException,
|
InternalServerErrorException,
|
||||||
OnModuleInit,
|
OnModuleInit,
|
||||||
@@ -155,11 +156,11 @@ export class PipelinesService implements OnModuleInit {
|
|||||||
return updatePipelineResponse;
|
return updatePipelineResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
async remove(data: Messages.PipelineV2RemoveRequest) {
|
async remove(data: Messages.PipelineV2RemoveRequest, metadata: Metadata) {
|
||||||
this.logger.info('PipelinesClientService - Remove');
|
this.logger.info('PipelinesClientService - Remove');
|
||||||
|
|
||||||
const removePipelineResponse = await lastValueFrom(
|
const removePipelineResponse = await lastValueFrom(
|
||||||
this.pipelineWriteService.PipelineV2Remove(data),
|
this.pipelineWriteService.PipelineV2Remove(data, metadata),
|
||||||
)
|
)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.logger.info('Done');
|
this.logger.info('Done');
|
||||||
@@ -167,7 +168,11 @@ export class PipelinesService implements OnModuleInit {
|
|||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
this.logger.error(err.message);
|
this.logger.error(err.message);
|
||||||
throw new Error(err);
|
console.log(err);
|
||||||
|
throw new HttpException(
|
||||||
|
err.details,
|
||||||
|
err.details === 'Erro ao pausar pipeline na plataforma.' ? 409 : 500,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
return removePipelineResponse;
|
return removePipelineResponse;
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user