mirror of
https://github.com/dadosfera/maestro.git
synced 2026-10-25 00:29:09 +00:00
FEAT: GET One Pipelinev2
This commit is contained in:
@@ -17,6 +17,7 @@ import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||
import { Messages } from '@dadosfera/protospack-v2/dist/lib/PipelineV2';
|
||||
import { RequestUser, User } from 'src/authentication/user.decorator';
|
||||
import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
|
||||
import { pipe } from 'rxjs';
|
||||
|
||||
@ApiTags('Pipelines')
|
||||
@Controller('pipelinesV2')
|
||||
@@ -100,13 +101,34 @@ export class PipelinesController {
|
||||
}
|
||||
|
||||
@Get('/:id')
|
||||
async findOne(@Body() data, @Param() params) {
|
||||
const { id } = params;
|
||||
async findOne(
|
||||
@Headers('Dadosfera-Lang') language,
|
||||
@User() user: RequestUser,
|
||||
@Param('id') id,
|
||||
): Promise<Messages.PipelineV2FindOneResponse> {
|
||||
this.logger.info(process.env.DEV_URL + `/pipeline/${id} ON Find One ROUTE`);
|
||||
|
||||
const response = await this.pipelinesClientService.findOne({ id, ...data });
|
||||
const { customer_id, customer_name, user_id, username } = user;
|
||||
|
||||
return response;
|
||||
const metadata = PackTheMetadata({
|
||||
customer_id,
|
||||
customer_name,
|
||||
user_id,
|
||||
username,
|
||||
language,
|
||||
});
|
||||
|
||||
const result = await this.pipelinesClientService.findOne({ id }, metadata);
|
||||
|
||||
Object.assign(result.pipeline, {
|
||||
transformations: JSON.parse(result.pipeline.transformations),
|
||||
config: {
|
||||
cron: result.pipeline.config.cron,
|
||||
tables: JSON.parse(result.pipeline.config.tables),
|
||||
},
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Put('/:id')
|
||||
|
||||
@@ -85,11 +85,14 @@ export class PipelinesService implements OnModuleInit {
|
||||
return findAllPipelineResponse;
|
||||
}
|
||||
|
||||
async findOne(data: Messages.PipelineV2FindOneRequest) {
|
||||
async findOne(
|
||||
data: Messages.PipelineV2FindOneRequest,
|
||||
metadata,
|
||||
): Promise<Messages.PipelineV2FindOneResponse> {
|
||||
this.logger.info('PipelinesClientService - FindOne');
|
||||
|
||||
const findOnePipelineResponse = await lastValueFrom(
|
||||
this.pipelineReadService.PipelineV2FindOne(data),
|
||||
this.pipelineReadService.PipelineV2FindOne(data, metadata),
|
||||
)
|
||||
.then((res) => {
|
||||
this.logger.info('Done');
|
||||
|
||||
Reference in New Issue
Block a user