import { ApiProperty, ApiPropertyOptional, OmitType, PickType, } from '@nestjs/swagger'; import { Connection, ConnectionToCatalog, } from '@dadosfera/protospack-v2/dist/lib/ConnectionManager/interfaces/entities'; import { GetAllConnectionResponse, GetConnectionDetailsResponse, GetConnectionResponse, } from '@dadosfera/protospack-v2/dist/lib/ConnectionManager/interfaces/messages'; export class ConnectionDto implements Connection { // ---Automatically generated information will not be sent by the frontend--- // @ApiProperty() id: string; @ApiProperty() customer_id: string; @ApiProperty() customer_name: string; @ApiProperty() user_id: string; @ApiProperty() updated_at: string; @ApiProperty() created_at: string; @ApiProperty() pipelines: string; // ---Information sent by the frontend--- // @ApiProperty() name: string; @ApiProperty() description: string; @ApiProperty() type: string; @ApiPropertyOptional() network_config_id: string | null; @ApiProperty() properties: DatabaseConnectionPropertiesDto | any; // ---Information sent by the frontend (Heirs of Connector)--- // @ApiProperty() connector_id: string; @ApiProperty() connector_name: string; @ApiProperty() plugin: string; @ApiProperty() image_url: string; } export class ConnectionToCatalogDto implements ConnectionToCatalog { // ---Automatically generated information will not be sent by the frontend--- // @ApiProperty() id: string; @ApiProperty() customer_id: string; @ApiProperty() updated_at: string; @ApiProperty() created_at: string; // ---Information sent by the frontend--- // @ApiProperty() name: string; @ApiProperty() description: string; @ApiProperty() type: string; @ApiPropertyOptional() network_config_id: string | null; // ---Information sent by the frontend (Heirs of Connector)--- // @ApiProperty() connector_id: string; @ApiProperty() connector_name: string; @ApiProperty() plugin: string; @ApiProperty() image_url: string; } export class CreateConnectionDto extends OmitType(ConnectionDto, [ 'id', 'customer_id', 'customer_name', 'user_id', 'created_at', 'updated_at', 'pipelines', ]) {} export class UpdateConnectionDto extends PickType(ConnectionDto, [ 'name', 'description', 'network_config_id', 'properties', ]) {} export class ConnectionsRes implements GetAllConnectionResponse { @ApiProperty({ type: [ConnectionToCatalogDto] }) connections: ConnectionToCatalogDto[]; @ApiProperty() message: string; } export class ConnectionRes implements GetConnectionResponse { @ApiProperty() connection?: ConnectionToCatalogDto; @ApiProperty() message: string; } export class ConnectionDetailsRes implements GetConnectionDetailsResponse { @ApiProperty() connection?: ConnectionDto; @ApiProperty() message: string; } export class DatabaseConnectionPropertiesDto { @ApiProperty() credentials_type: 'basic_auth'; @ApiProperty() plugin: string; @ApiProperty() host: string; @ApiProperty() port: string; @ApiProperty() username: string; @ApiProperty() password: string; @ApiProperty() database: string; }