mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-04 20:29:08 +00:00
get entities
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
import { OnModuleInit, Inject, HttpException } from '@nestjs/common';
|
||||
import {
|
||||
OnModuleInit,
|
||||
Inject,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
} from '@nestjs/common';
|
||||
import { ClientGrpc } from '@nestjs/microservices';
|
||||
import {
|
||||
DecodeGrpcStruct,
|
||||
@@ -268,4 +273,20 @@ export class InputsClientService implements OnModuleInit {
|
||||
// getOauthTokens(input){
|
||||
|
||||
// }
|
||||
|
||||
async getAvailableEntities(data) {
|
||||
console.log('InputClientService', 'GetAvailableEntities');
|
||||
objectSnakeToCamel(data);
|
||||
const response = await lastValueFrom(
|
||||
this.inputService.GetAvailableEntities(data),
|
||||
).catch((err) => {
|
||||
console.log(err);
|
||||
if (err.details && err.details.includes('400'))
|
||||
throw new HttpException('Plugin inválido', HttpStatus.BAD_REQUEST);
|
||||
throw new HttpException(err.details, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
});
|
||||
objectCamelToSnake(response);
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,16 @@ import { InputNewCreateRequest } from '@victorradael/protospack';
|
||||
|
||||
@Controller('inputs')
|
||||
export class InputsController {
|
||||
constructor(private inputsClientService: InputsClientService) {}
|
||||
inputService: InputsService;
|
||||
constructor(private inputsClientService: InputsClientService) {
|
||||
this.inputService = new InputsService(this.inputsClientService);
|
||||
}
|
||||
@Get('available-entities/:plugin')
|
||||
async getAvailableEntities(@Body() body, @Param() params) {
|
||||
const { info } = body;
|
||||
const { plugin } = params;
|
||||
return await this.inputService.getAvailableEntities({ info, plugin });
|
||||
}
|
||||
|
||||
@Post('/test-connection')
|
||||
async testConnection(@Body() data) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Body, HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||
import { Timeout } from '@nestjs/schedule';
|
||||
import CronParser, { CronExpression } from 'cron-parser';
|
||||
import { lastValueFrom } from 'rxjs';
|
||||
import { InputsClientService } from 'src/clients/inputs/client.service';
|
||||
import { IIdRequest, Info } from 'src/clients/inputs/interfaces';
|
||||
|
||||
@@ -70,7 +71,9 @@ export class InputsService {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
async getAvailableEntities(data): Promise<{ entities: string[] }> {
|
||||
return await this.inputClient.getAvailableEntities(data);
|
||||
}
|
||||
async findAll(body) {
|
||||
try {
|
||||
const findAllInputResponse: any = await this.inputClient.findAll(body);
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user