mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-06 18:19:07 +00:00
Connected Connection Test routes to microservice
This commit is contained in:
Generated
+7
-7
@@ -38,7 +38,7 @@
|
||||
"passport-hubspot-oauth2": "^1.0.3",
|
||||
"passport-mailchimp": "^1.1.0",
|
||||
"protospack": "2.5.2",
|
||||
"protospack-v2": "^3.9.0-beta.4",
|
||||
"protospack-v2": "^3.9.0-beta.6",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"rxjs": "^7.5.5",
|
||||
@@ -9018,9 +9018,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/protospack-v2": {
|
||||
"version": "3.9.0-beta.4",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/protospack-v2/-/protospack-v2-3.9.0-beta.4.tgz",
|
||||
"integrity": "sha512-T1T6g1+qusecCGySLA4FSn5O1u+RyZkhIaO6De1701HrNcJM7jBZjYsN1qHr49vQ7TMeibtKyiVqpqZSoPeBBg==",
|
||||
"version": "3.9.0-beta.6",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/protospack-v2/-/protospack-v2-3.9.0-beta.6.tgz",
|
||||
"integrity": "sha512-2Pv6uL6laRpVyEkuX6IMpAsmE15SxlrxpteAzz7Vli5HytDNK/Azyt375dWQC379K+OX2hv9Y5ji7YOeUmku7g==",
|
||||
"dependencies": {
|
||||
"@grpc/grpc-js": "^1.6.7",
|
||||
"rxjs": "^7.5.5",
|
||||
@@ -17247,9 +17247,9 @@
|
||||
}
|
||||
},
|
||||
"protospack-v2": {
|
||||
"version": "3.9.0-beta.4",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/protospack-v2/-/protospack-v2-3.9.0-beta.4.tgz",
|
||||
"integrity": "sha512-T1T6g1+qusecCGySLA4FSn5O1u+RyZkhIaO6De1701HrNcJM7jBZjYsN1qHr49vQ7TMeibtKyiVqpqZSoPeBBg==",
|
||||
"version": "3.9.0-beta.6",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/protospack-v2/-/protospack-v2-3.9.0-beta.6.tgz",
|
||||
"integrity": "sha512-2Pv6uL6laRpVyEkuX6IMpAsmE15SxlrxpteAzz7Vli5HytDNK/Azyt375dWQC379K+OX2hv9Y5ji7YOeUmku7g==",
|
||||
"requires": {
|
||||
"@grpc/grpc-js": "^1.6.7",
|
||||
"rxjs": "^7.5.5",
|
||||
|
||||
+1
-1
@@ -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.4",
|
||||
"protospack-v2": "^3.9.0-beta.6",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"rxjs": "^7.5.5",
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { credentials } from '@grpc/grpc-js';
|
||||
import {
|
||||
ClientProviderOptions,
|
||||
GrpcOptions,
|
||||
Transport,
|
||||
} from '@nestjs/microservices';
|
||||
import { ConnectionTest } from 'protospack-v2';
|
||||
|
||||
export class ConnectionTestClientConfiguration {
|
||||
private config: GrpcOptions = {
|
||||
transport: Transport.GRPC,
|
||||
options: {
|
||||
url: process.env.INFACTORY_URL,
|
||||
package: [ConnectionTest.ProtoPackages.ReadPackage],
|
||||
credentials:
|
||||
process.env.ENV === 'local' ? undefined : credentials.createSsl(),
|
||||
protoPath: [ConnectionTest.ProtoPaths.ReadFilePath],
|
||||
loader: {
|
||||
keepCase: true,
|
||||
enums: String,
|
||||
objects: true,
|
||||
arrays: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
providerOptions: ClientProviderOptions = {
|
||||
name: 'ConnectionTestGrpcClient',
|
||||
...this.config,
|
||||
};
|
||||
}
|
||||
@@ -47,7 +47,10 @@ export class ConnectionTestController {
|
||||
user: user.user_id,
|
||||
customer: user.customer_name,
|
||||
});
|
||||
await this.connectionTestService.connectionTestPing(body);
|
||||
return this.connectionTestService.connectionTestPing(
|
||||
body,
|
||||
user.customer_name,
|
||||
);
|
||||
}
|
||||
|
||||
@Post('credentials')
|
||||
@@ -61,7 +64,10 @@ export class ConnectionTestController {
|
||||
user: user.user_id,
|
||||
customer: user.customer_name,
|
||||
});
|
||||
await this.connectionTestService.connectionTestCredentials(body);
|
||||
return this.connectionTestService.connectionTestCredentials(
|
||||
body,
|
||||
user.customer_name,
|
||||
);
|
||||
}
|
||||
|
||||
@Post('schemas')
|
||||
@@ -75,7 +81,10 @@ export class ConnectionTestController {
|
||||
user: user.user_id,
|
||||
customer: user.customer_name,
|
||||
});
|
||||
await this.connectionTestService.connectionTestListSchemas(body);
|
||||
return this.connectionTestService.connectionTestListSchemas(
|
||||
body,
|
||||
user.customer_name,
|
||||
);
|
||||
}
|
||||
|
||||
@Post('tables')
|
||||
@@ -89,7 +98,10 @@ export class ConnectionTestController {
|
||||
user: user.user_id,
|
||||
customer: user.customer_name,
|
||||
});
|
||||
await this.connectionTestService.connectionTestListTables(body);
|
||||
return this.connectionTestService.connectionTestListTables(
|
||||
body,
|
||||
user.customer_name,
|
||||
);
|
||||
}
|
||||
|
||||
@Post('table-metadata')
|
||||
@@ -103,6 +115,9 @@ export class ConnectionTestController {
|
||||
user: user.user_id,
|
||||
customer: user.customer_name,
|
||||
});
|
||||
await this.connectionTestService.getTableMetadata(body);
|
||||
return this.connectionTestService.getTableMetadata(
|
||||
body,
|
||||
user.customer_name,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,12 @@ import { Module } from '@nestjs/common';
|
||||
import { ConnectionTestController } from './connection-test.controller';
|
||||
import { ConnectionTestService } from './connection-test.service';
|
||||
import { DadosferaLogger } from 'dadosfera-logs';
|
||||
|
||||
import { ClientsModule } from '@nestjs/microservices';
|
||||
import { ConnectionTestClientConfiguration } from './connection-test-client.config';
|
||||
const client = new ConnectionTestClientConfiguration();
|
||||
@Module({
|
||||
controllers: [ConnectionTestController],
|
||||
providers: [ConnectionTestService, DadosferaLogger],
|
||||
imports: [ClientsModule.register([client.providerOptions])],
|
||||
})
|
||||
export class ConnectionTestModule {}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { ClientGrpc } from '@nestjs/microservices';
|
||||
import { ConnectionTest } from 'protospack-v2';
|
||||
import { lastValueFrom } from 'rxjs';
|
||||
import {
|
||||
ConnectionTestCredentialsReq,
|
||||
ConnectionTestCredentialsRes,
|
||||
@@ -14,29 +17,89 @@ import {
|
||||
|
||||
@Injectable()
|
||||
export class ConnectionTestService {
|
||||
private connectionTestReadClient: ConnectionTest.ReadService.ConnectionTestReadServices;
|
||||
constructor(
|
||||
@Inject('ConnectionTestGrpcClient') private readonly grpcClient: ClientGrpc,
|
||||
) {
|
||||
this.connectionTestReadClient =
|
||||
grpcClient.getService<ConnectionTest.ReadService.ConnectionTestReadServices>(
|
||||
ConnectionTest.ProtoServices.ConnectionTestReadServices,
|
||||
);
|
||||
}
|
||||
|
||||
async connectionTestPing(
|
||||
body: ConnectionTestPingReq,
|
||||
customer_name: string,
|
||||
): Promise<ConnectionTestPingRes> {
|
||||
return { operation_result: true };
|
||||
const { endpoint, plugin, port, network_config_id } = body;
|
||||
return lastValueFrom(
|
||||
this.connectionTestReadClient.ConnectionTestPing({
|
||||
customer_name,
|
||||
endpoint,
|
||||
network_config_id,
|
||||
plugin,
|
||||
port,
|
||||
}),
|
||||
);
|
||||
}
|
||||
async connectionTestCredentials(
|
||||
body: ConnectionTestCredentialsReq,
|
||||
customer_name: string,
|
||||
): Promise<ConnectionTestCredentialsRes> {
|
||||
return { operation_result: true, connection_id: '' };
|
||||
const { connector_id, plugin } = body;
|
||||
//CREATE CONNECTION
|
||||
const connection_id = '';
|
||||
/***********************/
|
||||
const { operation_result } = await lastValueFrom(
|
||||
this.connectionTestReadClient.ConnectionTestCredentials({
|
||||
connection_id,
|
||||
customer_name,
|
||||
plugin,
|
||||
}),
|
||||
);
|
||||
return { operation_result, connection_id };
|
||||
}
|
||||
async connectionTestListSchemas(
|
||||
body: ConnectionTestListSchemasReq,
|
||||
customer_name: string,
|
||||
): Promise<ConnectionTestListSchemasRes> {
|
||||
return { operation_result: true, schema_list: [] };
|
||||
const { connection_id, plugin } = body;
|
||||
return lastValueFrom(
|
||||
this.connectionTestReadClient.ListSchemas({
|
||||
connection_id,
|
||||
customer_name,
|
||||
plugin,
|
||||
}),
|
||||
);
|
||||
}
|
||||
async connectionTestListTables(
|
||||
body: ConnectionTestListTablesReq,
|
||||
customer_name: string,
|
||||
): Promise<ConnectionTestListTablesRes> {
|
||||
return { operation_result: true, table_list: [] };
|
||||
const { connection_id, plugin, schema } = body;
|
||||
return lastValueFrom(
|
||||
this.connectionTestReadClient.ListTables({
|
||||
connection_id,
|
||||
customer_name,
|
||||
plugin,
|
||||
schema,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
async getTableMetadata(
|
||||
body: GetTableMetadataReq,
|
||||
customer_name: string,
|
||||
): Promise<GetTableMetadataRes> {
|
||||
return { table_metadata: [{ columns: [], table_name: '' }] };
|
||||
const { schema, plugin, table_list, connection_id } = body;
|
||||
return lastValueFrom(
|
||||
this.connectionTestReadClient.GetTableMetadata({
|
||||
connection_id,
|
||||
customer_name,
|
||||
plugin,
|
||||
schema,
|
||||
table_list,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ApiProperty, ApiPropertyOptional, OmitType } from '@nestjs/swagger';
|
||||
import { IsString, IsObject } from 'class-validator';
|
||||
import { IsString, IsObject, IsOptional } from 'class-validator';
|
||||
import { DatabaseConnectionPropertiesDto } from 'src/modules/connection/dtos/connection';
|
||||
import { CreateConnectionDto } from 'src/modules/connection/dtos/create-connection';
|
||||
export class ColumnDto {
|
||||
@@ -29,6 +29,7 @@ export class ConnectionTestPingReq {
|
||||
port: string;
|
||||
|
||||
@ApiPropertyOptional()
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
network_config_id?: string;
|
||||
}
|
||||
@@ -42,6 +43,9 @@ export class ConnectionTestCredentialsReq extends OmitType(
|
||||
CreateConnectionDto,
|
||||
['properties'],
|
||||
) {
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
plugin: string;
|
||||
@ApiProperty()
|
||||
@IsObject()
|
||||
properties: DatabaseConnectionPropertiesDto;
|
||||
@@ -82,7 +86,7 @@ export class ConnectionTestListTablesReq {
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
schema_name: string;
|
||||
schema: string;
|
||||
}
|
||||
|
||||
export class ConnectionTestListTablesRes {
|
||||
@@ -93,6 +97,10 @@ export class ConnectionTestListTablesRes {
|
||||
}
|
||||
|
||||
export class GetTableMetadataReq {
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
connection_id: string;
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
plugin: string;
|
||||
@@ -102,7 +110,7 @@ export class GetTableMetadataReq {
|
||||
schema: string;
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
@IsString({ each: true })
|
||||
table_list: string[];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user