Update Protospack Name and Network Config

This commit is contained in:
Victor Radael
2022-08-02 11:47:13 -03:00
parent 00687dc84e
commit 4e6883a404
19 changed files with 180 additions and 72 deletions
+21 -21
View File
@@ -10,6 +10,7 @@
"license": "UNLICENSED",
"dependencies": {
"@aws-sdk/client-secrets-manager": "^3.112.0",
"@dadosfera/protospack-v2": "3.10.2",
"@grpc/grpc-js": "^1.6.7",
"@grpc/proto-loader": "^0.6.13",
"@nestjs/common": "^8.4.7",
@@ -38,7 +39,6 @@
"passport-hubspot-oauth2": "^1.0.3",
"passport-mailchimp": "^1.1.0",
"protospack": "2.5.2",
"protospack-v2": "^3.9.0-beta.11",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.5.5",
@@ -1714,6 +1714,16 @@
"kuler": "^2.0.0"
}
},
"node_modules/@dadosfera/protospack-v2": {
"version": "3.10.2",
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.10.2.tgz",
"integrity": "sha512-21rbav6VXVo+7Io82/O+350DLmf8ONQw8kkG728F7ySD9uEosJgTz3hzZFpTmVuSew822zS+iHcpGJBpVmq49w==",
"dependencies": {
"@grpc/grpc-js": "^1.6.7",
"rxjs": "^7.5.5",
"ts-proto": "^1.112.2"
}
},
"node_modules/@elastic/ecs-helpers": {
"version": "1.1.0",
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@elastic/ecs-helpers/-/ecs-helpers-1.1.0.tgz",
@@ -9017,16 +9027,6 @@
"rxjs": "^7.5.5"
}
},
"node_modules/protospack-v2": {
"version": "3.9.0-beta.11",
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/protospack-v2/-/protospack-v2-3.9.0-beta.11.tgz",
"integrity": "sha512-l2tU5vIlwnr7zgqsX8szMJoOzE9CdBYRJEj48yZc1AK9xVcXZa7+/Ik4n/N/JTAjKsCmQspbxuBezSbKcCpsvA==",
"dependencies": {
"@grpc/grpc-js": "^1.6.7",
"rxjs": "^7.5.5",
"ts-proto": "^1.112.2"
}
},
"node_modules/proxy-addr": {
"version": "2.0.7",
"license": "MIT",
@@ -12277,6 +12277,16 @@
"kuler": "^2.0.0"
}
},
"@dadosfera/protospack-v2": {
"version": "3.10.2",
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.10.2.tgz",
"integrity": "sha512-21rbav6VXVo+7Io82/O+350DLmf8ONQw8kkG728F7ySD9uEosJgTz3hzZFpTmVuSew822zS+iHcpGJBpVmq49w==",
"requires": {
"@grpc/grpc-js": "^1.6.7",
"rxjs": "^7.5.5",
"ts-proto": "^1.112.2"
}
},
"@elastic/ecs-helpers": {
"version": "1.1.0",
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@elastic/ecs-helpers/-/ecs-helpers-1.1.0.tgz",
@@ -17246,16 +17256,6 @@
"rxjs": "^7.5.5"
}
},
"protospack-v2": {
"version": "3.9.0-beta.11",
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/protospack-v2/-/protospack-v2-3.9.0-beta.11.tgz",
"integrity": "sha512-l2tU5vIlwnr7zgqsX8szMJoOzE9CdBYRJEj48yZc1AK9xVcXZa7+/Ik4n/N/JTAjKsCmQspbxuBezSbKcCpsvA==",
"requires": {
"@grpc/grpc-js": "^1.6.7",
"rxjs": "^7.5.5",
"ts-proto": "^1.112.2"
}
},
"proxy-addr": {
"version": "2.0.7",
"requires": {
+1 -1
View File
@@ -53,7 +53,7 @@
"passport-hubspot-oauth2": "^1.0.3",
"passport-mailchimp": "^1.1.0",
"protospack": "2.5.2",
"protospack-v2": "^3.9.0-beta.11",
"@dadosfera/protospack-v2": "3.10.2",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.5.5",
+4 -1
View File
@@ -1,6 +1,9 @@
import { credentials } from '@grpc/grpc-js';
import { ClientOptions, Transport } from '@nestjs/microservices';
import { ProtoPackages, ProtoPaths } from 'protospack-v2/dist/lib/Duc';
import {
ProtoPackages,
ProtoPaths,
} from '@dadosfera/protospack-v2/dist/lib/Duc';
export class DucClient {
config(): ClientOptions {
+1 -1
View File
@@ -19,7 +19,7 @@ import {
AuthEnableTotpMfaRequest,
AuthDisableTotpMfaRequest,
AuthVerifyTotpMfaRequest,
} from 'protospack-v2/dist/lib/Duc/interfaces/messages';
} from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages';
import { AuthClientService } from './auth.service';
import { DadosferaLogger } from 'dadosfera-logs';
+3 -3
View File
@@ -3,8 +3,8 @@ import { ClientGrpc } from '@nestjs/microservices';
import { DadosferaLogger } from 'dadosfera-logs';
import { lastValueFrom } from 'rxjs';
import { ProtoServices } from 'protospack-v2/dist/lib/Duc';
import { AuthProtoService as AuthServiceInterface } from 'protospack-v2/dist/lib/Duc/interfaces/write-service';
import { ProtoServices } from '@dadosfera/protospack-v2/dist/lib/Duc';
import { AuthProtoService as AuthServiceInterface } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/write-service';
import {
AuthSignInRequest,
AuthRefreshAccessTokenRequest,
@@ -16,7 +16,7 @@ import {
AuthResetPasswordRequest,
AuthVerifyResetPasswordCodeRequest,
AuthConfirmResetPasswordRequest,
} from 'protospack-v2/dist/lib/Duc/interfaces/messages';
} from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages';
@Injectable()
export class AuthClientService implements OnModuleInit {
@@ -4,7 +4,7 @@ import {
GrpcOptions,
Transport,
} from '@nestjs/microservices';
import { ConnectionTest } from 'protospack-v2';
import { ConnectionTest } from '@dadosfera/protospack-v2';
export class ConnectionTestClientConfiguration {
private config: GrpcOptions = {
@@ -1,6 +1,6 @@
import { Inject, Injectable } from '@nestjs/common';
import { ClientGrpc } from '@nestjs/microservices';
import { ConnectionTest } from 'protospack-v2';
import { ConnectionTest } from '@dadosfera/protospack-v2';
import { lastValueFrom } from 'rxjs';
import {
ConnectionTestCredentialsReq,
+1 -1
View File
@@ -1,6 +1,6 @@
import { credentials } from '@grpc/grpc-js';
import { ClientOptions, Transport } from '@nestjs/microservices';
import { ConnectionManager } from 'protospack-v2';
import { ConnectionManager } from '@dadosfera/protospack-v2';
export class ConnectionClientConfiguration {
config(): ClientOptions {
+1 -1
View File
@@ -6,7 +6,7 @@ import {
HttpStatus,
} from '@nestjs/common';
import { ClientGrpc } from '@nestjs/microservices';
import { ConnectionManager } from 'protospack-v2';
import { ConnectionManager } from '@dadosfera/protospack-v2';
import { lastValueFrom } from 'rxjs';
export class ConnectionClientService implements OnModuleInit {
@@ -48,7 +48,7 @@ export class ConnectionController {
const { user_id, customer_id, customer_name } = user;
const response = await this.clientService.createConnection({
const response: any = await this.clientService.createConnection({
body,
info: { user_id, customer_id, customer_name },
});
@@ -74,7 +74,7 @@ export class ConnectionController {
const { user_id, customer_id, customer_name } = user;
const response = await this.clientService.updateConnection({
const response: any = await this.clientService.updateConnection({
body: { ...body, id },
info: { user_id, customer_id, customer_name, language },
});
@@ -95,7 +95,7 @@ export class ConnectionController {
const { user_id, customer_id, customer_name } = user;
const response = await this.clientService.deleteConnection({
const response: any = await this.clientService.deleteConnection({
body: { id },
info: { user_id, customer_id, customer_name },
});
@@ -140,7 +140,7 @@ export class ConnectionController {
const { user_id, customer_id, customer_name } = user;
const response = await this.clientService.getConnection({
const response: any = await this.clientService.getConnection({
body: { id },
info: { user_id, customer_id, customer_name, language },
});
@@ -160,7 +160,7 @@ export class ConnectionController {
const { user_id, customer_id, customer_name } = user;
const response = await this.clientService.getConnectionDetails({
const response: any = await this.clientService.getConnectionDetails({
body: { id },
info: { user_id, customer_id, customer_name },
});
+1 -1
View File
@@ -1,6 +1,6 @@
import { credentials } from '@grpc/grpc-js';
import { ClientOptions, Transport } from '@nestjs/microservices';
import { ConnectorManager } from 'protospack-v2';
import { ConnectorManager } from '@dadosfera/protospack-v2';
export class ConnectorClientConfiguration {
config(): ClientOptions {
+1 -1
View File
@@ -6,7 +6,7 @@ import {
HttpStatus,
} from '@nestjs/common';
import { ClientGrpc } from '@nestjs/microservices';
import { ConnectorManager } from 'protospack-v2';
import { ConnectorManager } from '@dadosfera/protospack-v2';
import { lastValueFrom } from 'rxjs';
export class ConnectorClientService implements OnModuleInit {
@@ -32,6 +32,8 @@ export class NetworkConfigDto {
created_at: string;
@ApiProperty()
updated_at: string;
@ApiProperty()
network_type_id: string;
}
export class NetworkConfigNoSecrets extends OmitType(NetworkConfigDto, [
'secret_id',
@@ -58,10 +60,27 @@ export class FindNetworkConfigByidRes {
@ApiProperty()
network_config: NetworkConfigNoSecrets;
}
export class FindNetworkConfigByidDetails extends PickType(NetworkConfigDto, [
'id',
'name',
'description',
'type',
'network_type_id',
'customer_name',
]) {
@ApiProperty()
properties: NetworkConfigOpenVpnProperties | string;
}
export class FindNetworkConfigByidDetailsRes {
@ApiProperty()
network_config: FindNetworkConfigByidDetails;
}
export class CreateNetworkConfigReq extends PickType(NetworkConfigDto, [
'name',
'description',
'type',
'network_type_id',
]) {
@ApiProperty()
properties: NetworkConfigOpenVpnProperties;
@@ -4,7 +4,7 @@ import {
GrpcOptions,
Transport,
} from '@nestjs/microservices';
import { NetworkConfig } from 'protospack-v2';
import { NetworkConfig } from '@dadosfera/protospack-v2';
export class NetworkConfigClientConfiguration {
private config: GrpcOptions = {
@@ -15,6 +15,7 @@ export class NetworkConfigClientConfiguration {
NetworkConfig.ProtoPackages.ReadPackage,
NetworkConfig.ProtoPackages.WritePackage,
],
// credentials: undefined,
credentials:
process.env.ENV === 'local' ? undefined : credentials.createSsl(),
protoPath: [
@@ -3,10 +3,12 @@ import {
Controller,
Delete,
Get,
Headers,
Inject,
Param,
Patch,
Post,
Query,
} from '@nestjs/common';
import { NetworkConfigService } from './network-config.service';
import { DadosferaLogger } from 'dadosfera-logs';
@@ -33,12 +35,23 @@ export class NetworkConfigController {
}
@Get()
@ApiOkResponse({ type: FindAllNetworkConfigsRes })
async findAllNetworkConfigs(@User() user: RequestUser) {
async findAllNetworkConfigs(
@User() user: RequestUser,
@Headers('Dadosfera-Lang') language,
@Query() queries,
) {
this.logger.info('GET /network-config', {
user: user.user_id,
customer: user.customer_name,
});
return this.networkConfigService.findAllNetworkConfigs(user.customer_name);
const { user_id, customer_id, customer_name } = user;
const { search, size, page, ...filters } = queries;
return this.networkConfigService.findAllNetworkConfigs({
body: { search, size, page, filters },
info: { user_id, customer_id, customer_name, language },
});
}
@Get(':id')
@@ -54,6 +67,24 @@ export class NetworkConfigController {
return this.networkConfigService.findNetworkConfigById(id);
}
@Get(':id/details')
@ApiOkResponse({ type: FindAllNetworkConfigsRes })
async findNetworkConfigByIdDetails(
@User() user: RequestUser,
@Headers('Dadosfera-Lang') language,
@Param('id') id: string,
) {
this.logger.info('GET /network-config/:id', {
user: user.user_id,
customer: user.customer_name,
});
return this.networkConfigService.findNetworkConfigByIdDetails(id, {
customer_name: user.customer_name,
customer_id: user.customer_id,
language,
});
}
@Post()
@ApiOkResponse({ type: CreateNetworkConfigRes })
async createNetworkConfigs(
@@ -64,10 +95,10 @@ export class NetworkConfigController {
user: user.user_id,
customer: user.customer_name,
});
return this.networkConfigService.createNetworkConfig(
body,
user.customer_name,
);
return this.networkConfigService.createNetworkConfig(body, {
customer_name: user.customer_name,
customer_id: user.customer_id,
});
}
@Patch(':id')
@@ -97,6 +128,9 @@ export class NetworkConfigController {
user: user.user_id,
customer: user.customer_name,
});
return this.networkConfigService.deleteNetworkConfig(network_config_id);
return this.networkConfigService.deleteNetworkConfig(network_config_id, {
customer_name: user.customer_name,
customer_id: user.customer_id,
});
}
}
@@ -1,12 +1,14 @@
import { Metadata } from '@grpc/grpc-js';
import { Inject, Injectable } from '@nestjs/common';
import { ClientGrpc } from '@nestjs/microservices';
import { NetworkConfig } from 'protospack-v2';
import { NetworkConfig } from '@dadosfera/protospack-v2';
import { lastValueFrom } from 'rxjs';
import {
CreateNetworkConfigReq,
CreateNetworkConfigRes,
DeleteNetworkConfigRes,
FindAllNetworkConfigsRes,
FindNetworkConfigByidDetailsRes,
FindNetworkConfigByidRes,
UpdateNetworkConfigReq,
UpdateNetworkConfigRes,
@@ -28,13 +30,25 @@ export class NetworkConfigService {
NetworkConfig.ProtoServices.NetworkConfigWriteService,
);
}
async findAllNetworkConfigs(
customer_name: string,
): Promise<FindAllNetworkConfigsRes> {
async findAllNetworkConfigs({
body,
info,
}): Promise<FindAllNetworkConfigsRes> {
const { search, page, size, filters } = body;
const { language, customer_id, customer_name, user_id } = info;
const meta = new Metadata();
meta.add('language', language);
meta.add('customer_id', customer_id);
meta.add('customer_name', customer_name);
meta.add('user_id', user_id);
return lastValueFrom(
this.networkConfigReadClient.NetworkConfigFindByCustomer({
customer_name,
}),
this.networkConfigReadClient.NetworkConfigFindAll(
{ search, filters: JSON.stringify(filters), page, size },
meta,
),
);
}
@@ -47,19 +61,51 @@ export class NetworkConfigService {
return { network_config };
}
async findNetworkConfigByIdDetails(
id: string,
info?,
): Promise<FindNetworkConfigByidDetailsRes> {
const { customer_name, customer_id, language } = info;
const meta = new Metadata();
meta.add('customer_name', customer_name);
meta.add('customer_id', customer_id);
meta.add('language', language);
const { network_config } = await lastValueFrom(
this.networkConfigReadClient.NetworkConfigFindOneDetailsById(
{ id },
meta,
),
);
Object.assign(network_config, {
properties: JSON.parse(network_config.properties),
});
return { network_config };
}
async createNetworkConfig(
body: CreateNetworkConfigReq,
customer_name: string,
{ customer_name, customer_id },
): Promise<CreateNetworkConfigRes> {
const { description, name, properties, type } = body;
const { description, name, properties, type, network_type_id } = body;
const meta = new Metadata();
meta.add('customer_id', customer_id);
meta.add('customer_name', customer_name);
const { network_config } = await lastValueFrom(
this.networkConfigWriteClient.NetworkConfigCreate({
customer_name,
description,
name,
properties: JSON.stringify(properties),
type,
}),
this.networkConfigWriteClient.NetworkConfigCreate(
{
customer_name,
description,
name,
properties: JSON.stringify(properties),
type,
network_type_id,
},
meta,
),
);
return { network_config };
}
@@ -81,11 +127,16 @@ export class NetworkConfigService {
async deleteNetworkConfig(
network_config_id: string,
{ customer_name, customer_id },
): Promise<DeleteNetworkConfigRes> {
const meta = new Metadata();
meta.add('customer_id', customer_id);
meta.add('customer_name', customer_name);
return lastValueFrom(
this.networkConfigWriteClient.NetworkConfigDelete({
id: network_config_id,
}),
this.networkConfigWriteClient.NetworkConfigDelete(
{ id: network_config_id },
meta,
),
);
}
}
@@ -7,9 +7,9 @@ import {
import { ClientGrpc } from '@nestjs/microservices';
import { lastValueFrom } from 'rxjs';
import { ProtoServices } from 'protospack-v2/dist/lib/Duc';
import { PermissionsProtoService as PermissionsServiceInterface } from 'protospack-v2/dist/lib/Duc/interfaces/write-service';
import { InjectPermissionsRequest } from 'protospack-v2/dist/lib/Duc/interfaces/messages';
import { ProtoServices } from '@dadosfera/protospack-v2/dist/lib/Duc';
import { PermissionsProtoService as PermissionsServiceInterface } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/write-service';
import { InjectPermissionsRequest } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages';
import { DadosferaLogger } from 'dadosfera-logs';
import { Permissions } from '../../authentication/permissions.enum';
import ErrorBuilder from '../../utils/ErrorBuilder';
@@ -10,7 +10,7 @@ import {
UseFilters,
} from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { TermsOfUseAcceptRequest } from 'protospack-v2/dist/lib/Duc/interfaces/messages';
import { TermsOfUseAcceptRequest } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages';
import { TermsOfUseClientService } from './termsOfUse.service';
import { DadosferaLogger } from 'dadosfera-logs';
+3 -3
View File
@@ -3,12 +3,12 @@ import { ClientGrpc } from '@nestjs/microservices';
import { DadosferaLogger } from 'dadosfera-logs';
import { lastValueFrom } from 'rxjs';
import { ProtoServices } from 'protospack-v2/dist/lib/Duc';
import { TermsOfUseProtoService as TermsOfUseServiceInterface } from 'protospack-v2/dist/lib/Duc/interfaces/write-service';
import { ProtoServices } from '@dadosfera/protospack-v2/dist/lib/Duc';
import { TermsOfUseProtoService as TermsOfUseServiceInterface } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/write-service';
import {
TermsOfUseGetTokenRequest,
TermsOfUseAcceptRequest,
} from 'protospack-v2/dist/lib/Duc/interfaces/messages';
} from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages';
@Injectable()
export class TermsOfUseClientService implements OnModuleInit {