diff --git a/docsfera.json b/docsfera.json index 542facf..391d880 100644 --- a/docsfera.json +++ b/docsfera.json @@ -946,7 +946,7 @@ ], "responses": { "200": { - "description": "List of users of a customer", + "description": "", "content": { "application/json": { "schema": { diff --git a/src/main.ts b/src/main.ts index b2c84c6..7235e3b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -55,7 +55,6 @@ function configureSwagger(app: INestApplication) { const document = SwaggerModule.createDocument(app, config); if (process.env.ENV === 'local') SwaggerModule.setup('api', app, document); - writeFileSync( 'docsfera.json', JSON.stringify( diff --git a/src/modules/connector/client.service.ts b/src/modules/connector/client.service.ts index bac423c..a5f14d4 100644 --- a/src/modules/connector/client.service.ts +++ b/src/modules/connector/client.service.ts @@ -89,9 +89,9 @@ export class ConnectorClientService implements OnModuleInit { const connectorErrors = connectorsResponse .filter((i) => i.update.error) .map((i) => ({ - id: i.update._id, - reason: i.update.error, - status: i.error.status, + id: i.update?._id, + reason: i.update?.error, + status: i.error?.status, })); const connectorCreated = connectorsResponse .filter((i) => i.update.result === 'created') diff --git a/src/modules/pipelinesV2/pipelines.service.ts b/src/modules/pipelinesV2/pipelines.service.ts index 7162314..030c6a1 100644 --- a/src/modules/pipelinesV2/pipelines.service.ts +++ b/src/modules/pipelinesV2/pipelines.service.ts @@ -1,9 +1,4 @@ -import { - BadRequestException, - Inject, - InternalServerErrorException, - OnModuleInit, -} from '@nestjs/common'; +import { BadRequestException, Inject, OnModuleInit } from '@nestjs/common'; import { ClientGrpc } from '@nestjs/microservices'; import { Messages, @@ -23,6 +18,8 @@ import { InputsService } from '../inputs/inputs.service'; import { RequestUser } from 'src/authentication/user.decorator'; import { TransformationsService } from '../transformations/transformations.service'; import { getObjValueFromPath } from 'src/utils/ObjValueFromPath'; +import ErrorCodes from 'src/utils/errorCodes'; +import ErrorBuilder from 'src/utils/ErrorBuilder'; export class PipelinesService implements OnModuleInit { logger: DadosferaLogger; @@ -99,7 +96,7 @@ export class PipelinesService implements OnModuleInit { const [errorType, message] = error.details.split('|'); throw new BadRequestException(message); } - throw new InternalServerErrorException(error.details); + throw new ErrorBuilder(error.details); }); this.logger.info('Done'); @@ -164,45 +161,53 @@ export class PipelinesService implements OnModuleInit { customer_id: user.customer_id, customer: user.customer_name, }; + let existsInProduct = true; const { pipeline } = await lastValueFrom( this.pipelineReadService.PipelineV2FindOne({ id }, metadata), - ); + ).catch((e) => { + if (e.details === ErrorCodes.PIPELINE.NOT_FOUND) existsInProduct = false; + else throw new ErrorBuilder(e.details); + + return { pipeline: undefined }; + }); await lastValueFrom( this.pipelineWriteService.PipelineV2Remove({ id }, metadata), ); - //{pipeline:{tables: {tables: [], input_id: ''}}} - const input = pipeline.config.tables - ? JSON.parse(pipeline.config.tables) - : null; - if (input) - await this.inputsService - .remove({ - id: input.input_id, - info, - }) - .catch((error) => - this.logger.error('Could not delete input', { - data: { input, error }, - }), - ); - - const transformations: { id: string }[] = pipeline.transformations - ? JSON.parse(pipeline.transformations) - : null; - if (transformations && transformations.length) - for (const transformation of transformations) { - await this.transformationsService + if (existsInProduct) { + //{pipeline:{tables: {tables: [], input_id: ''}}} + const input = pipeline.config.tables + ? JSON.parse(pipeline.config.tables) + : null; + if (input) + await this.inputsService .remove({ - id: transformation.id, + id: input.input_id, info, }) .catch((error) => - this.logger.error('Could not delete transformation', { - data: { transformation, error }, + this.logger.error('Could not delete input', { + data: { input, error }, }), ); - } + + const transformations: { id: string }[] = pipeline.transformations + ? JSON.parse(pipeline.transformations) + : null; + if (transformations && transformations.length) + for (const transformation of transformations) { + await this.transformationsService + .remove({ + id: transformation.id, + info, + }) + .catch((error) => + this.logger.error('Could not delete transformation', { + data: { transformation, error }, + }), + ); + } + } } async findOneProperties(id: string, metadata: Metadata) { diff --git a/src/modules/users/users.controller.ts b/src/modules/users/users.controller.ts index 325953e..336d8f0 100644 --- a/src/modules/users/users.controller.ts +++ b/src/modules/users/users.controller.ts @@ -52,7 +52,6 @@ import { Metadata } from '@grpc/grpc-js'; import ErrorBuilder from 'src/utils/ErrorBuilder'; import ErrorCodes from 'src/utils/errorCodes'; -// TODO GET de hierarquias e do PATCH em usuário @ApiTags('Users') @Controller('users') @ApiHeader({ @@ -75,10 +74,6 @@ export class UsersController { } @Get() - @ApiOkResponse({ - type: GetAllUsersByCustomerIdRes, - description: 'List of users of a customer', - }) async getAllUsersByCustomerId( @User() user: RequestUser, @Headers('dadosfera-lang') language,