mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-24 12:49:09 +00:00
FEAT: Managers
This commit is contained in:
@@ -8,8 +8,14 @@ import {
|
||||
import { ClientGrpc } from '@nestjs/microservices';
|
||||
import { ConnectionManager } from '@dadosfera/protospack-v2';
|
||||
import { lastValueFrom } from 'rxjs';
|
||||
import { GetConnectionsRes } from './dtos/connection';
|
||||
import {
|
||||
ConnectionRes,
|
||||
ConnectionsRes,
|
||||
CreateConnectionDto,
|
||||
UpdateConnectionDto,
|
||||
} from './dtos/connection';
|
||||
import { ConnectionClientConfiguration } from './client.config';
|
||||
import { GetConnectionDetailsResponse } from '@dadosfera/protospack-v2/dist/lib/ConnectionManager/interfaces/messages';
|
||||
|
||||
export class ConnectionClientService implements OnModuleInit {
|
||||
private connectionServiceRead: ConnectionManager.ReadService.ConnectionManagerReadServices;
|
||||
@@ -31,7 +37,10 @@ export class ConnectionClientService implements OnModuleInit {
|
||||
);
|
||||
}
|
||||
|
||||
async createConnection({ body, info }) {
|
||||
async createConnection(
|
||||
body: CreateConnectionDto,
|
||||
info: any,
|
||||
): Promise<ConnectionRes> {
|
||||
const meta = new Metadata();
|
||||
meta.add('customer_id', info.customer_id);
|
||||
meta.add('customer_name', info.customer_name);
|
||||
@@ -70,33 +79,27 @@ export class ConnectionClientService implements OnModuleInit {
|
||||
});
|
||||
}
|
||||
|
||||
async updateConnection({ body, info }) {
|
||||
async updateConnection(
|
||||
id: string,
|
||||
body: UpdateConnectionDto,
|
||||
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,
|
||||
description,
|
||||
image_url,
|
||||
name,
|
||||
network_config_id,
|
||||
properties,
|
||||
type,
|
||||
} = body;
|
||||
const { description, name, network_config_id, properties } = body;
|
||||
|
||||
return lastValueFrom(
|
||||
this.connectionServiceWrite.UpdateConnection(
|
||||
{
|
||||
id,
|
||||
description,
|
||||
image_url,
|
||||
name,
|
||||
network_config_id,
|
||||
properties: JSON.stringify(properties),
|
||||
type,
|
||||
},
|
||||
meta,
|
||||
),
|
||||
@@ -108,7 +111,7 @@ export class ConnectionClientService implements OnModuleInit {
|
||||
});
|
||||
}
|
||||
|
||||
async deleteConnection({ body, info }) {
|
||||
async deleteConnection({ body, info }): Promise<ConnectionRes> {
|
||||
const meta = new Metadata();
|
||||
meta.add('customer_id', info.customer_id);
|
||||
meta.add('customer_name', info.customer_name);
|
||||
@@ -131,7 +134,7 @@ export class ConnectionClientService implements OnModuleInit {
|
||||
});
|
||||
}
|
||||
|
||||
async getAllConnection({ body, info }): Promise<GetConnectionsRes> {
|
||||
async getAllConnection({ body, info }): Promise<ConnectionsRes> {
|
||||
const meta = new Metadata();
|
||||
meta.add('customer_id', info.customer_id);
|
||||
meta.add('customer_name', info.customer_name);
|
||||
@@ -153,7 +156,7 @@ export class ConnectionClientService implements OnModuleInit {
|
||||
});
|
||||
}
|
||||
|
||||
async getConnection({ body, info }) {
|
||||
async getConnection({ body, info }): Promise<ConnectionRes> {
|
||||
const meta = new Metadata();
|
||||
meta.add('customer_id', info.customer_id);
|
||||
meta.add('customer_name', info.customer_name);
|
||||
@@ -172,7 +175,10 @@ export class ConnectionClientService implements OnModuleInit {
|
||||
});
|
||||
}
|
||||
|
||||
async getConnectionDetails({ body, info }) {
|
||||
async getConnectionDetails({
|
||||
body,
|
||||
info,
|
||||
}): Promise<GetConnectionDetailsResponse> {
|
||||
const meta = new Metadata();
|
||||
meta.add('customer_id', info.customer_id);
|
||||
meta.add('customer_name', info.customer_name);
|
||||
|
||||
Reference in New Issue
Block a user