Inputs models refactor

This commit is contained in:
Gabriel Rosa
2022-09-06 11:45:12 -03:00
parent 469f165cba
commit 2c8ed40bc6
6 changed files with 104 additions and 123 deletions
+66 -93
View File
@@ -1,29 +1,7 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { ApiProperty, ApiPropertyOptional, OmitType } from '@nestjs/swagger';
import { Info } from 'protospack/dist/lib/interfaces';
export class InputModel {
category: string;
plugin: string;
name: string;
cron?: string;
credentials?: {
connection_type: string;
oauth: string;
oauth_code: string;
start_date: string;
};
}
export class FileFormatParams {
@ApiProperty()
sep: string;
@ApiProperty()
header: boolean;
@ApiProperty()
encoding: string;
}
class GoogleAnalyticsClientSecrets {
export class GoogleAnalyticsClientSecrets {
@ApiProperty()
type: string;
@ApiProperty()
@@ -45,7 +23,7 @@ class GoogleAnalyticsClientSecrets {
@ApiProperty()
client_x509_cert_url: string;
}
class OauthObject {
export class OauthObject {
@ApiPropertyOptional()
get_tokens_url: string;
@ApiPropertyOptional()
@@ -55,7 +33,7 @@ class OauthObject {
@ApiPropertyOptional()
content_type: string;
}
class InputOptions {
export class InputOptions {
@ApiPropertyOptional()
oauth: OauthObject;
@ApiPropertyOptional()
@@ -65,8 +43,22 @@ class InputOptions {
@ApiPropertyOptional()
skip_transformation: true;
}
export class FileFormatParams {
@ApiProperty()
sep: string;
@ApiProperty()
header: boolean;
@ApiProperty()
encoding: string;
}
class CredentialsJdbc {
export class AuthParameters {
@ApiProperty()
aws_access_key_id: string;
@ApiProperty()
aws_secret_access_key: string;
}
export class CredentialsJdbc {
@ApiPropertyOptional()
jdbc_user: string;
@ApiPropertyOptional()
@@ -82,8 +74,7 @@ class CredentialsJdbc {
@ApiPropertyOptional()
schema: string;
}
class Credentials extends CredentialsJdbc {
export class Credentials extends CredentialsJdbc {
@ApiProperty()
connection_type: string;
@@ -110,13 +101,13 @@ class Credentials extends CredentialsJdbc {
@ApiPropertyOptional()
oauth_code: string;
}
class Column {
export class Column {
@ApiProperty()
name: string;
@ApiProperty()
type: string;
}
class TableColumns {
export class TableColumns {
@ApiProperty()
name: string;
@ApiProperty()
@@ -124,6 +115,45 @@ class TableColumns {
@ApiProperty()
references: Column[];
}
export class Input {
@ApiProperty()
id: string;
@ApiProperty({ type: [TableColumns] })
tables: TableColumns[];
@ApiProperty()
name: string;
@ApiProperty()
description: string;
@ApiProperty()
plugin: string;
@ApiPropertyOptional()
type?: string;
@ApiProperty()
created_at: string;
@ApiProperty()
updated_at: string;
//deprecated attributes (for retro compatibility)
@ApiPropertyOptional({ deprecated: true })
category: string;
@ApiPropertyOptional({ deprecated: true })
credentials: Credentials;
@ApiPropertyOptional({ deprecated: true })
options: InputOptions;
@ApiPropertyOptional({ deprecated: true })
info: Info;
@ApiPropertyOptional({ deprecated: true })
cron: string;
@ApiPropertyOptional({ deprecated: true })
source_bucket: string;
@ApiPropertyOptional({ deprecated: true })
source_prefix: string;
@ApiPropertyOptional({ deprecated: true })
auth_parameters: AuthParameters;
@ApiPropertyOptional({ deprecated: true })
file_format_params: FileFormatParams;
}
export class GetAvailableEntitiesReq {
@ApiProperty()
plugin: string;
@@ -167,65 +197,8 @@ export class TestConnectionRes {
@ApiProperty()
database_tables: string[];
}
export class AuthParameters {
@ApiProperty()
aws_access_key_id: string;
@ApiProperty()
aws_secret_access_key: string;
}
export class CreateInputReq {
@ApiProperty({ type: [TableColumns] })
tables: TableColumns[];
@ApiProperty()
name: string;
@ApiProperty()
description: string;
@ApiProperty()
plugin: string;
@ApiPropertyOptional()
type: string;
//deprecated attributes (for retro compatibility)
@ApiPropertyOptional({ deprecated: true })
category: string;
@ApiPropertyOptional({ deprecated: true })
credentials: Credentials;
@ApiPropertyOptional({ deprecated: true })
options: InputOptions;
@ApiPropertyOptional({ deprecated: true })
info: Info;
@ApiPropertyOptional({ deprecated: true })
cron: string;
@ApiPropertyOptional({ deprecated: true })
source_bucket: string;
@ApiPropertyOptional({ deprecated: true })
source_prefix: string;
@ApiPropertyOptional({ deprecated: true })
auth_parameters: AuthParameters;
@ApiPropertyOptional({ deprecated: true })
file_format_params: FileFormatParams;
}
export class Input {
@ApiProperty()
id: string;
@ApiProperty()
category: string;
@ApiProperty()
plugin: string;
@ApiProperty()
name: string;
@ApiProperty()
cron: string;
@ApiProperty()
credentials: Credentials;
@ApiProperty()
client_id: string;
@ApiProperty()
created_at: string;
@ApiProperty()
updated_at: string;
@ApiPropertyOptional()
info: Info;
}
export class CreateInputReq extends OmitType(Input, [
'id',
'created_at',
'updated_at',
]) {}