mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-28 22:40:05 +00:00
FIX: pipeline accepting properties on payload
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user