mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-17 02:19:08 +00:00
FIX: fixed some merge conflicts
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { Metadata } from '@grpc/grpc-js';
|
||||
import {
|
||||
OnModuleInit,
|
||||
Inject,
|
||||
@@ -39,13 +38,8 @@ export class ConnectionClientService implements OnModuleInit {
|
||||
|
||||
async createConnection(
|
||||
body: CreateConnectionDto,
|
||||
info: any,
|
||||
metadata,
|
||||
): Promise<ConnectionRes> {
|
||||
const meta = new Metadata();
|
||||
meta.add('customer_id', info.customer_id);
|
||||
meta.add('customer_name', info.customer_name);
|
||||
meta.add('user_id', info.user_id);
|
||||
|
||||
const {
|
||||
connector_id,
|
||||
description,
|
||||
@@ -69,7 +63,7 @@ export class ConnectionClientService implements OnModuleInit {
|
||||
properties: JSON.stringify(properties),
|
||||
type,
|
||||
},
|
||||
meta,
|
||||
metadata,
|
||||
),
|
||||
).catch((err) => {
|
||||
throw new HttpException(
|
||||
@@ -82,14 +76,8 @@ export class ConnectionClientService implements OnModuleInit {
|
||||
async updateConnection(
|
||||
id: string,
|
||||
body: UpdateConnectionDto,
|
||||
info,
|
||||
metadata,
|
||||
): Promise<ConnectionRes> {
|
||||
const meta = new Metadata();
|
||||
meta.add('customer_id', info.customer_id);
|
||||
meta.add('customer_name', info.customer_name);
|
||||
meta.add('user_id', info.user_id);
|
||||
meta.add('language', info.language);
|
||||
|
||||
const { description, name, network_config_id, properties } = body;
|
||||
|
||||
return lastValueFrom(
|
||||
@@ -101,7 +89,7 @@ export class ConnectionClientService implements OnModuleInit {
|
||||
network_config_id,
|
||||
properties: JSON.stringify(properties),
|
||||
},
|
||||
meta,
|
||||
metadata,
|
||||
),
|
||||
).catch((err) => {
|
||||
throw new HttpException(
|
||||
@@ -111,12 +99,7 @@ export class ConnectionClientService implements OnModuleInit {
|
||||
});
|
||||
}
|
||||
|
||||
async deleteConnection({ body, info }): Promise<ConnectionRes> {
|
||||
const meta = new Metadata();
|
||||
meta.add('customer_id', info.customer_id);
|
||||
meta.add('customer_name', info.customer_name);
|
||||
meta.add('user_id', info.user_id);
|
||||
|
||||
async deleteConnection({ body, metadata }): Promise<ConnectionRes> {
|
||||
const { id } = body;
|
||||
|
||||
return lastValueFrom(
|
||||
@@ -124,7 +107,7 @@ export class ConnectionClientService implements OnModuleInit {
|
||||
{
|
||||
id,
|
||||
},
|
||||
meta,
|
||||
metadata,
|
||||
),
|
||||
).catch((err) => {
|
||||
throw new HttpException(
|
||||
@@ -134,19 +117,13 @@ export class ConnectionClientService implements OnModuleInit {
|
||||
});
|
||||
}
|
||||
|
||||
async getAllConnection({ body, info }): Promise<ConnectionsRes> {
|
||||
const meta = new Metadata();
|
||||
meta.add('customer_id', info.customer_id);
|
||||
meta.add('customer_name', info.customer_name);
|
||||
meta.add('user_id', info.user_id);
|
||||
meta.add('language', info.language);
|
||||
|
||||
async getAllConnection({ body, metadata }): Promise<ConnectionsRes> {
|
||||
const { search, filters, size, page } = body;
|
||||
|
||||
return lastValueFrom(
|
||||
this.connectionServiceRead.GetAllConnection(
|
||||
{ search, filters: JSON.stringify(filters), size, page },
|
||||
meta,
|
||||
metadata,
|
||||
),
|
||||
).catch((err) => {
|
||||
throw new HttpException(
|
||||
@@ -156,39 +133,14 @@ export class ConnectionClientService implements OnModuleInit {
|
||||
});
|
||||
}
|
||||
|
||||
async getConnection({ body, info }): Promise<ConnectionRes> {
|
||||
const meta = new Metadata();
|
||||
meta.add('customer_id', info.customer_id);
|
||||
meta.add('customer_name', info.customer_name);
|
||||
meta.add('user_id', info.user_id);
|
||||
meta.add('language', info.language);
|
||||
|
||||
const { id } = body;
|
||||
|
||||
return lastValueFrom(
|
||||
this.connectionServiceRead.GetConnection({ id }, meta),
|
||||
).catch((err) => {
|
||||
throw new HttpException(
|
||||
err.details,
|
||||
err.code === 6 ? HttpStatus.CONFLICT : 400,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
async getConnectionDetails({
|
||||
body,
|
||||
info,
|
||||
metadata,
|
||||
}): Promise<GetConnectionDetailsResponse> {
|
||||
const meta = new Metadata();
|
||||
meta.add('customer_id', info.customer_id);
|
||||
meta.add('customer_name', info.customer_name);
|
||||
meta.add('user_id', info.user_id);
|
||||
meta.add('details', info.details);
|
||||
|
||||
const id = body.connection_id || body.id;
|
||||
|
||||
return lastValueFrom(
|
||||
this.connectionServiceRead.GetConnectionDetails({ id }, meta),
|
||||
this.connectionServiceRead.GetConnectionDetails({ id }, metadata),
|
||||
).catch((err) => {
|
||||
throw new HttpException(
|
||||
err.details,
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
RequireAllPermissions,
|
||||
} from 'src/authentication/authentication.decorator';
|
||||
import { PERMISSIONS } from 'src/authentication/permissions.enum';
|
||||
import { User } from 'src/authentication/user.decorator';
|
||||
import { RequestUser, User } from 'src/authentication/user.decorator';
|
||||
import { ValidationPipe } from '../../pipes/object-validation.pipe';
|
||||
import {
|
||||
ConnectionDetailsRes,
|
||||
@@ -27,6 +27,7 @@ import {
|
||||
UpdateConnectionDto,
|
||||
} from './dtos/connection';
|
||||
import { CreateConnectionDto } from './dtos/connection';
|
||||
import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
|
||||
|
||||
@ApiTags('connections')
|
||||
@ApiBearerAuth()
|
||||
@@ -45,57 +46,74 @@ export class ConnectionController {
|
||||
@Post()
|
||||
// @RequireAllPermissions(Permissions.CONNECTIONS.CREATE)
|
||||
async createConnection(
|
||||
@User() user,
|
||||
@User() user: RequestUser,
|
||||
@Body(new ValidationPipe()) body: CreateConnectionDto,
|
||||
): Promise<ConnectionRes> {
|
||||
this.logger.info('/connections - Create Connection');
|
||||
|
||||
const { user_id, customer_id, customer_name } = user;
|
||||
|
||||
const response: any = await this.clientService.createConnection(body, {
|
||||
const { user_id, customer_id, customer_name, username } = user;
|
||||
const metadata = PackTheMetadata({
|
||||
user_id,
|
||||
customer_id,
|
||||
customer_name,
|
||||
username,
|
||||
});
|
||||
|
||||
const response: any = await this.clientService.createConnection(
|
||||
body,
|
||||
metadata,
|
||||
);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Put('/:id')
|
||||
// @RequireAllPermissions(Permissions.CONNECTIONS.CREATE)
|
||||
async updateConnection(
|
||||
@User() user,
|
||||
@User() user: RequestUser,
|
||||
@Headers('Dadosfera-Lang') language: string,
|
||||
@Param('id') id: string,
|
||||
@Body(new ValidationPipe()) body: UpdateConnectionDto,
|
||||
): Promise<ConnectionRes> {
|
||||
this.logger.info('/connections - Update Connection');
|
||||
|
||||
const { user_id, customer_id, customer_name } = user;
|
||||
|
||||
const response: any = await this.clientService.updateConnection(id, body, {
|
||||
const { user_id, customer_id, customer_name, username } = user;
|
||||
const metadata = PackTheMetadata({
|
||||
user_id,
|
||||
customer_id,
|
||||
customer_name,
|
||||
language,
|
||||
username,
|
||||
});
|
||||
|
||||
const response: any = await this.clientService.updateConnection(
|
||||
id,
|
||||
body,
|
||||
metadata,
|
||||
);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Delete('/:id')
|
||||
// @RequireAllPermissions(Permissions.CONNECTIONS.CREATE)
|
||||
async deleteConnection(
|
||||
@User() user,
|
||||
@User() user: RequestUser,
|
||||
@Param('id') id: string,
|
||||
): Promise<ConnectionRes> {
|
||||
this.logger.info('/connections - Delete Connection');
|
||||
|
||||
const { user_id, customer_id, customer_name } = user;
|
||||
const { user_id, customer_id, customer_name, username } = user;
|
||||
const metadata = PackTheMetadata({
|
||||
user_id,
|
||||
customer_id,
|
||||
customer_name,
|
||||
username,
|
||||
});
|
||||
|
||||
const response: any = await this.clientService.deleteConnection({
|
||||
body: { id },
|
||||
info: { user_id, customer_id, customer_name },
|
||||
metadata,
|
||||
});
|
||||
|
||||
return response;
|
||||
@@ -104,18 +122,25 @@ export class ConnectionController {
|
||||
@Get()
|
||||
// @RequireAllPermissions(Permissions.CONNECTIONS.CREATE)
|
||||
async getAllConnection(
|
||||
@User() user,
|
||||
@User() user: RequestUser,
|
||||
@Headers('Dadosfera-Lang') language,
|
||||
@Query() queries,
|
||||
): Promise<ConnectionsRes> {
|
||||
this.logger.info('/connections - Get All Connection');
|
||||
|
||||
const { user_id, customer_id, customer_name } = user;
|
||||
const { user_id, customer_id, customer_name, username } = user;
|
||||
const { search, size, page, ...filters } = queries;
|
||||
const metadata = PackTheMetadata({
|
||||
user_id,
|
||||
customer_id,
|
||||
customer_name,
|
||||
language,
|
||||
username,
|
||||
});
|
||||
|
||||
const response = await this.clientService.getAllConnection({
|
||||
body: { search, size, page, filters },
|
||||
info: { user_id, customer_id, customer_name, language },
|
||||
metadata,
|
||||
});
|
||||
|
||||
return response;
|
||||
@@ -124,17 +149,24 @@ export class ConnectionController {
|
||||
@Get('/:id')
|
||||
// @RequireAllPermissions(Permissions.CONNECTIONS.CREATE)
|
||||
async getConnectionDetails(
|
||||
@User() user,
|
||||
@User() user: RequestUser,
|
||||
@Param('id') id,
|
||||
@Query('details') details,
|
||||
): Promise<ConnectionDetailsRes> {
|
||||
this.logger.info('/connections - Get Connection Details');
|
||||
|
||||
const { user_id, customer_id, customer_name } = user;
|
||||
const { user_id, customer_id, customer_name, username } = user;
|
||||
const metadata = PackTheMetadata({
|
||||
user_id,
|
||||
customer_id,
|
||||
customer_name,
|
||||
username,
|
||||
details,
|
||||
});
|
||||
|
||||
const response: any = await this.clientService.getConnectionDetails({
|
||||
body: { id },
|
||||
info: { user_id, customer_id, customer_name, details },
|
||||
metadata,
|
||||
});
|
||||
|
||||
if (details === 'true') {
|
||||
|
||||
Reference in New Issue
Block a user