mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-16 08:49:08 +00:00
FIX: connection test ping and connection test credentials
This commit is contained in:
@@ -15,7 +15,10 @@ import {
|
||||
GetTableMetadataRes,
|
||||
} from './dto/connection-test';
|
||||
import { ConnectionClientService } from '../connection/client.service';
|
||||
import { CreateConnectionDto } from '../connection/dtos/connection';
|
||||
import {
|
||||
CreateConnectionDto,
|
||||
DatabaseConnectionPropertiesDto,
|
||||
} from '../connection/dtos/connection';
|
||||
import { RequestUser } from 'src/authentication/user.decorator';
|
||||
|
||||
@Injectable()
|
||||
@@ -35,14 +38,14 @@ export class ConnectionTestService {
|
||||
body: ConnectionTestPingReq,
|
||||
customer_name: string,
|
||||
): Promise<ConnectionTestPingRes> {
|
||||
const { endpoint, plugin, port, network_config_id } = body;
|
||||
const { host: endpoint, plugin, port, network_config_id } = body;
|
||||
return lastValueFrom(
|
||||
this.connectionTestReadClient.ConnectionTestPing({
|
||||
customer_name,
|
||||
endpoint,
|
||||
network_config_id,
|
||||
plugin,
|
||||
port,
|
||||
port: port.toString(),
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -56,11 +59,14 @@ export class ConnectionTestService {
|
||||
|
||||
/********* CREATE CONNECTION *********/
|
||||
if (!connection_id) {
|
||||
if (!connectionBody.properties.credentials_type)
|
||||
connectionBody.properties.credentials_type = 'basic_auth';
|
||||
|
||||
const properties: DatabaseConnectionPropertiesDto = {
|
||||
...connectionBody.properties,
|
||||
plugin,
|
||||
credentials_type: 'basic_auth',
|
||||
};
|
||||
const createConnectionBody: CreateConnectionDto = {
|
||||
...body,
|
||||
properties,
|
||||
};
|
||||
const { connection } = await this.connectionsService.createConnection(
|
||||
createConnectionBody,
|
||||
@@ -82,11 +88,13 @@ export class ConnectionTestService {
|
||||
});
|
||||
throw e;
|
||||
});
|
||||
if (!operation_result)
|
||||
if (!operation_result) {
|
||||
await this.connectionsService.deleteConnection({
|
||||
body: { id: connection_id },
|
||||
info: { customer_id, customer_name, user_id },
|
||||
});
|
||||
connection_id = null;
|
||||
}
|
||||
return { operation_result, connection_id };
|
||||
}
|
||||
async connectionTestListSchemas(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ApiProperty, ApiPropertyOptional, OmitType } from '@nestjs/swagger';
|
||||
import { IsString, IsOptional } from 'class-validator';
|
||||
import { IsString, IsOptional, IsNumber, Max } from 'class-validator';
|
||||
import { DatabaseConnectionPropertiesDto } from 'src/modules/connection/dtos/connection';
|
||||
import { CreateConnectionDto } from 'src/modules/connection/dtos/connection';
|
||||
export class ColumnDto {
|
||||
@@ -22,11 +22,12 @@ export class ConnectionTestPingReq {
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
endpoint: string;
|
||||
host: string;
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
port: string;
|
||||
@IsNumber()
|
||||
@Max(65535)
|
||||
port: number;
|
||||
|
||||
@ApiPropertyOptional()
|
||||
@IsOptional()
|
||||
@@ -39,16 +40,16 @@ export class ConnectionTestPingRes {
|
||||
operation_result: boolean;
|
||||
}
|
||||
|
||||
export class ConnectionTestCredentialsProperties extends OmitType(
|
||||
DatabaseConnectionPropertiesDto,
|
||||
['plugin', 'credentials_type'],
|
||||
) {}
|
||||
export class ConnectionTestCredentialsReq extends OmitType(
|
||||
CreateConnectionDto,
|
||||
['properties'],
|
||||
) {
|
||||
@ApiProperty()
|
||||
plugin: string;
|
||||
|
||||
@ApiProperty()
|
||||
properties: DatabaseConnectionPropertiesDto;
|
||||
|
||||
properties: ConnectionTestCredentialsProperties;
|
||||
@ApiPropertyOptional()
|
||||
connection_id?: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user