mirror of
https://github.com/dadosfera/maestro.git
synced 2026-09-27 02:54:48 +00:00
202 lines
4.0 KiB
TypeScript
202 lines
4.0 KiB
TypeScript
import {
|
|
ApiProperty,
|
|
ApiPropertyOptional,
|
|
OmitType,
|
|
PickType,
|
|
} from '@nestjs/swagger';
|
|
import {
|
|
Connection,
|
|
ConnectionToCatalog,
|
|
} from '@dadosfera/protospack-v2/dist/lib/ConnectionManager/interfaces/entities';
|
|
import {
|
|
GetAllConnectionRequest,
|
|
GetAllConnectionResponse,
|
|
GetConnectionDetailsResponse,
|
|
GetConnectionResponse,
|
|
} from '@dadosfera/protospack-v2/dist/lib/ConnectionManager/interfaces/messages';
|
|
export type ConnectionTypes = 'database' | 'file' | 'application';
|
|
export type ConnectionCredentialsType =
|
|
| 'basic_auth'
|
|
| 'iam_user'
|
|
| 'role_name'
|
|
| 'oauth'
|
|
| 'api_key'
|
|
| 'service_account'
|
|
| 'headers_auth';
|
|
export interface ConnectionApiConnection {
|
|
config_id: string;
|
|
plugin: string;
|
|
secret_id: string;
|
|
created_at: string;
|
|
network_config_id: null;
|
|
type: ConnectionTypes;
|
|
credentials_type: ConnectionCredentialsType;
|
|
credentials: Record<string, any>;
|
|
sensitive_fields: string[];
|
|
name: string;
|
|
customer_name: string;
|
|
description: string;
|
|
updated_at: string;
|
|
}
|
|
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--- //
|
|
customer_id: string;
|
|
updated_at: string;
|
|
created_at: string;
|
|
// ---Information extracted from token--- //
|
|
user_id: string;
|
|
username: string;
|
|
customer_name: string;
|
|
|
|
// ---Information sent by the frontend--- //
|
|
@ApiPropertyOptional()
|
|
id: string;
|
|
|
|
@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 GetAllConnectionsReq implements GetAllConnectionRequest {
|
|
@ApiPropertyOptional()
|
|
search?: string;
|
|
@ApiPropertyOptional()
|
|
page?: string;
|
|
@ApiPropertyOptional()
|
|
size?: string;
|
|
}
|
|
|
|
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;
|
|
}
|