Compare commits

...
17 Commits
Author SHA1 Message Date
Gabriel Amorim faf6b1df75 Merge pull request #210 from dadosfera/fix/delete-connector
Fix/delete connector
2023-03-09 18:14:14 -03:00
Gabriel Amorim 422be4a422 swaggers 2023-03-06 12:11:13 -03:00
Gabriel Amorim da136e0ef0 FIX: better swagger generation strategy (Only PRD server on external docs) 2023-03-06 12:10:12 -03:00
Gabriel Amorim 737cc9b8ea FIX: removed wrong JSON.parse on connector delete response 2023-03-06 12:09:29 -03:00
Gabriel Amorim 23f6b179fd Merge pull request #209 from dadosfera/feat/google-sheets-link
Feat/google sheets link
2023-02-27 16:03:52 -03:00
Gabriel Amorim 03e451c21d Merge branch 'main' into feat/google-sheets-link 2023-02-27 11:26:03 -03:00
Gabriel Amorim be061a0fb9 Merge pull request #208 from dadosfera/fix/upload-files
FIX: create pipeline from any file type on upload
2023-02-24 17:10:08 -03:00
Gabriel Amorim c83f6a68d1 update protospack version 2023-02-24 16:50:29 -03:00
Gabriel Amorim 2646e3e4f6 FEAT: return google sheets entire link 2023-02-24 15:58:06 -03:00
Gabriel Amorim 06424d6bcf FIX: docs 2023-02-24 14:47:49 -03:00
Gabriel Amorim 45b82515fc FIX: do not return config_controls that the pipeline don't have 2023-02-24 14:31:50 -03:00
Gabriel Amorim a9cc951e34 FIX: new error codes 2023-02-23 17:14:47 -03:00
Gabriel Amorim 93ccf506fb FIX: csv import with header=false 2023-02-22 15:13:36 -03:00
Gabriel Amorim 706d0ccfa0 FIX: get right image url 2023-02-22 14:32:41 -03:00
Beatriz Antunes c2eec4e95c Merge pull request #207 from dadosfera/fix/hubspot-chat-permission
FIX: change permission to access support chat
2023-02-22 13:10:54 -03:00
Gabriel Amorim ac3132b6eb FIX: create pipeline from any file type on upload 2023-02-22 10:18:28 -03:00
Gabriel Rosa a2c1f2da6f FIX: new zendesk permission 2023-02-17 14:33:14 -03:00
13 changed files with 226 additions and 75 deletions
+50 -10
View File
@@ -534,6 +534,46 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "search",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "filters",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "size",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "page",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "type",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -1504,24 +1544,16 @@
} }
}, },
"info": { "info": {
"title": "Maestro - feat/docs-refactor", "title": "Maestro - fix/delete-connector",
"description": "This is the Maestro API", "description": "This is the Maestro API",
"version": "1.0.0", "version": "1.0.0",
"contact": {} "contact": {}
}, },
"tags": [], "tags": [],
"servers": [ "servers": [
{
"url": "https://maestro.stg.dadosfera.ai",
"description": "Ambiente STG"
},
{
"url": "https://maestro-2.stg.dadosfera.ai",
"description": "Ambiente STG2"
},
{ {
"url": "https://maestro.dadosfera.ai", "url": "https://maestro.dadosfera.ai",
"description": "Ambiente PRD" "description": "Dadosfera API"
} }
], ],
"components": { "components": {
@@ -2173,6 +2205,9 @@
"description": { "description": {
"type": "string" "type": "string"
}, },
"type": {
"type": "string"
},
"connection_id": { "connection_id": {
"type": "string" "type": "string"
}, },
@@ -2213,6 +2248,7 @@
"required": [ "required": [
"name", "name",
"description", "description",
"type",
"connection_id", "connection_id",
"cron", "cron",
"connector_name", "connector_name",
@@ -2233,6 +2269,9 @@
"description": { "description": {
"type": "string" "type": "string"
}, },
"type": {
"type": "string"
},
"connection_id": { "connection_id": {
"type": "string" "type": "string"
}, },
@@ -2280,6 +2319,7 @@
"id", "id",
"name", "name",
"description", "description",
"type",
"connection_id", "connection_id",
"cron", "cron",
"connector_name", "connector_name",
+55 -16
View File
@@ -2707,6 +2707,46 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "search",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "filters",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "size",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "page",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "type",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -4676,26 +4716,13 @@
} }
}, },
"info": { "info": {
"title": "Maestro - feat/docs-refactor", "title": "Maestro - fix/delete-connector",
"description": "This is the Maestro API", "description": "This is the Maestro API",
"version": "1.0.0", "version": "1.0.0",
"contact": {} "contact": {}
}, },
"tags": [], "tags": [],
"servers": [ "servers": [],
{
"url": "https://maestro.stg.dadosfera.ai",
"description": "Ambiente STG"
},
{
"url": "https://maestro-2.stg.dadosfera.ai",
"description": "Ambiente STG2"
},
{
"url": "https://maestro.dadosfera.ai",
"description": "Ambiente PRD"
}
],
"components": { "components": {
"securitySchemes": { "securitySchemes": {
"access-token": { "access-token": {
@@ -6346,6 +6373,9 @@
"description": { "description": {
"type": "string" "type": "string"
}, },
"type": {
"type": "string"
},
"connection_id": { "connection_id": {
"type": "string" "type": "string"
}, },
@@ -6386,6 +6416,7 @@
"required": [ "required": [
"name", "name",
"description", "description",
"type",
"connection_id", "connection_id",
"cron", "cron",
"connector_name", "connector_name",
@@ -6406,6 +6437,9 @@
"description": { "description": {
"type": "string" "type": "string"
}, },
"type": {
"type": "string"
},
"connection_id": { "connection_id": {
"type": "string" "type": "string"
}, },
@@ -6453,6 +6487,7 @@
"id", "id",
"name", "name",
"description", "description",
"type",
"connection_id", "connection_id",
"cron", "cron",
"connector_name", "connector_name",
@@ -6520,6 +6555,9 @@
}, },
"header": { "header": {
"type": "boolean" "type": "boolean"
},
"engine": {
"type": "string"
} }
}, },
"required": [ "required": [
@@ -6528,7 +6566,8 @@
"description", "description",
"encoding", "encoding",
"sep", "sep",
"header" "header",
"engine"
] ]
}, },
"IRole": { "IRole": {
+7 -7
View File
@@ -12,7 +12,7 @@
"dependencies": { "dependencies": {
"@aws-sdk/client-secrets-manager": "^3.112.0", "@aws-sdk/client-secrets-manager": "^3.112.0",
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4", "@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
"@dadosfera/protospack-v2": "3.29.0", "@dadosfera/protospack-v2": "3.29.1",
"@grpc/grpc-js": "^1.6.7", "@grpc/grpc-js": "^1.6.7",
"@grpc/proto-loader": "^0.6.13", "@grpc/proto-loader": "^0.6.13",
"@nestjs/common": "^8.4.7", "@nestjs/common": "^8.4.7",
@@ -1727,9 +1727,9 @@
} }
}, },
"node_modules/@dadosfera/protospack-v2": { "node_modules/@dadosfera/protospack-v2": {
"version": "3.29.0", "version": "3.29.1",
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.29.0.tgz", "resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.29.1.tgz",
"integrity": "sha512-G66u9V+/+5rQb+fpJdDXydTaji2Mlr0Ro5TTYcQleITKU9DjF1WZs/jP/Qu0Y224nCb8HhePvaVl/Rr0wtLt4w==", "integrity": "sha512-uVswwXltdG0aX8cYVSFPRcROPWjOlW5bJGFfn5RNodKyHeBiTVDWBB3/YgocKrWV4mYBSbZ11ctBzjSAOkf/0Q==",
"dependencies": { "dependencies": {
"@grpc/grpc-js": "^1.6.7", "@grpc/grpc-js": "^1.6.7",
"rxjs": "^7.5.5", "rxjs": "^7.5.5",
@@ -12284,9 +12284,9 @@
} }
}, },
"@dadosfera/protospack-v2": { "@dadosfera/protospack-v2": {
"version": "3.29.0", "version": "3.29.1",
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.29.0.tgz", "resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.29.1.tgz",
"integrity": "sha512-G66u9V+/+5rQb+fpJdDXydTaji2Mlr0Ro5TTYcQleITKU9DjF1WZs/jP/Qu0Y224nCb8HhePvaVl/Rr0wtLt4w==", "integrity": "sha512-uVswwXltdG0aX8cYVSFPRcROPWjOlW5bJGFfn5RNodKyHeBiTVDWBB3/YgocKrWV4mYBSbZ11ctBzjSAOkf/0Q==",
"requires": { "requires": {
"@grpc/grpc-js": "^1.6.7", "@grpc/grpc-js": "^1.6.7",
"rxjs": "^7.5.5", "rxjs": "^7.5.5",
+2 -2
View File
@@ -29,7 +29,7 @@
"dependencies": { "dependencies": {
"@aws-sdk/client-secrets-manager": "^3.112.0", "@aws-sdk/client-secrets-manager": "^3.112.0",
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4", "@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
"@dadosfera/protospack-v2": "3.29.0", "@dadosfera/protospack-v2": "3.29.1",
"@grpc/grpc-js": "^1.6.7", "@grpc/grpc-js": "^1.6.7",
"@grpc/proto-loader": "^0.6.13", "@grpc/proto-loader": "^0.6.13",
"@nestjs/common": "^8.4.7", "@nestjs/common": "^8.4.7",
@@ -96,4 +96,4 @@
"tsconfig-paths": "^3.14.1", "tsconfig-paths": "^3.14.1",
"typescript": "^4.6.3" "typescript": "^4.6.3"
} }
} }
+4 -4
View File
@@ -428,12 +428,12 @@ export const PERMISSIONS_GROUPS = {
permissions: { permissions: {
OPEN: { OPEN: {
seqid: 16, seqid: 16,
claim: 'GET /zendesk', claim: 'support-chat:access',
usage: PermissionUsages.INTERNAL, usage: PermissionUsages.INTERNAL,
name: { name: {
'pt-br': 'Acessar Zendesk', 'pt-br': 'Acessar chat de suporte',
'en-us': 'Access Zendesk', 'en-us': 'Access support chat',
'es-es': 'Acceso Zendesk', 'es-es': 'Acceder al chat de soporte',
}, },
}, },
}, },
+7 -6
View File
@@ -42,7 +42,7 @@ function configureSwagger(app: INestApplication) {
} }
const swaggerTitle = branchName ? `Maestro - ${branchName}` : 'Maestro'; const swaggerTitle = branchName ? `Maestro - ${branchName}` : 'Maestro';
const config = new DocumentBuilder() const swaggerConfig = new DocumentBuilder()
.setTitle(swaggerTitle) .setTitle(swaggerTitle)
.setDescription('Documentation for Maestro gateway') .setDescription('Documentation for Maestro gateway')
.addSecurity('access-token', { .addSecurity('access-token', {
@@ -50,11 +50,12 @@ function configureSwagger(app: INestApplication) {
name: 'Authorization', name: 'Authorization',
in: 'header', in: 'header',
}) })
.setDescription('This is the Maestro API') .setDescription('This is the Maestro API');
.addServer('https://maestro.stg.dadosfera.ai', 'Ambiente STG')
.addServer('https://maestro-2.stg.dadosfera.ai', 'Ambiente STG2') if (process.env.INTERNAL_SWAGGER !== 'true')
.addServer('https://maestro.dadosfera.ai', 'Ambiente PRD') swaggerConfig.addServer('https://maestro.dadosfera.ai', 'Dadosfera API');
.build();
const config = swaggerConfig.build();
const document = SwaggerModule.createDocument(app, config); const document = SwaggerModule.createDocument(app, config);
@@ -273,16 +273,13 @@ export class ConnectorController {
@Param('plugin') plugin: string, @Param('plugin') plugin: string,
@Query('version') version: string, @Query('version') version: string,
) { ) {
this.logger.info('/upload - Upload Connector Route'); this.logger.info('DELETE /:plugin - Delete Connector Route');
const response: any = await this.connectorClientService.deleteConnector( const response = await this.connectorClientService.deleteConnector(
plugin, plugin,
version, version,
); );
return { return { message: response.message, connector: response.connector };
message: response.message || 'ok',
connector: { ...JSON.parse(response.connector) },
};
} }
} }
+18
View File
@@ -10,6 +10,8 @@ export class IPipelineV2 {
@ApiProperty() @ApiProperty()
description: string; description: string;
@ApiProperty() @ApiProperty()
type: string;
@ApiProperty()
connection_id: string; connection_id: string;
@ApiProperty() @ApiProperty()
cron: string; cron: string;
@@ -104,4 +106,20 @@ export class ICreatePipelineCSVFile {
@ApiProperty() @ApiProperty()
header: boolean; header: boolean;
@ApiProperty()
engine: string;
}
export class PipelineFindAllReq {
@ApiPropertyOptional()
search?: string | undefined;
@ApiPropertyOptional()
filters?: string | undefined;
@ApiPropertyOptional()
size?: string | undefined;
@ApiPropertyOptional()
page?: string | undefined;
@ApiPropertyOptional()
type?: string | undefined;
} }
@@ -40,6 +40,7 @@ import {
ICreatePipelineV2Req, ICreatePipelineV2Req,
IPipelineV2, IPipelineV2,
IInitUploadCSVFile, IInitUploadCSVFile,
PipelineFindAllReq,
} from './interfaces'; } from './interfaces';
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter'; import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
import { LanguageEnum } from 'src/utils/languages.enum'; import { LanguageEnum } from 'src/utils/languages.enum';
@@ -115,7 +116,7 @@ export class PipelinesController {
async findAll( async findAll(
@User() user: RequestUser, @User() user: RequestUser,
@Language() language: LanguageEnum, @Language() language: LanguageEnum,
@Query() data, @Query() data: PipelineFindAllReq,
) { ) {
this.logger.info('PipelinesController - findAll', { user }); this.logger.info('PipelinesController - findAll', { user });
@@ -370,30 +371,37 @@ export class PipelinesController {
@User() user: RequestUser, @User() user: RequestUser,
@Body() body: ICreatePipelineCSVFile, @Body() body: ICreatePipelineCSVFile,
) { ) {
this.logger.info('/upload - Upload Connector Route'); this.logger.info('/file - Upload Connector Route');
const metadata = PackTheMetadata({ ...user }); const metadata = PackTheMetadata({ ...user });
const { name, sep, header, encoding, description, file_name } = body; const { name, sep, header, encoding, description, file_name, engine } =
body;
const file_format_params = {
...(sep && { sep }),
...(encoding && { encoding }),
...(header !== undefined ? { header } : {}),
};
const source_prefix = `${user.customer_name}/${file_name}`; const source_prefix = `${user.customer_name}/${file_name}`;
const upload_pipeline = { const upload_pipeline: ICreatePipelineV2Req = {
connection_id: process.env.UPLOAD_FILE_AGENT_CONNECTION, connection_id: process.env.UPLOAD_FILE_AGENT_CONNECTION,
connector_name: 'Amazon S3', connector_name: 'Amazon S3',
connector_plugin: 'aws_s3', connector_plugin: 'aws_s3',
connector_version: '1.0.0', connector_version: '1.0.0',
image_url: 'https://assets.dadosfera.ai/images/connectors/csv.svg', image_url: `https://assets.dadosfera.ai/images/connectors/${engine}.svg`,
name, name,
description, description,
transformations_ids: [], transformations_ids: [],
tags: [], tags: [],
cron: '@once', cron: '@once',
config: { cron: '@once', tables: [] }, type: 'upload',
properties: { properties: {
engine: 'csv', engine,
source_bucket: process.env.BUCKET_CUSTOMER_CSV_ASSETS, source_bucket: process.env.BUCKET_CUSTOMER_CSV_ASSETS,
source_prefix, source_prefix,
file_format_params: { sep, encoding, header: Boolean(header) }, file_format_params,
is_a_upload_csv: true,
}, },
input_id: undefined, input_id: undefined,
}; };
+28 -14
View File
@@ -23,7 +23,7 @@ import { ConnectorClientService } from '../connector/client.service';
import { InputsService } from '../inputs/inputs.service'; import { InputsService } from '../inputs/inputs.service';
import { RequestUser } from 'src/decorators/user.decorator'; import { RequestUser } from 'src/decorators/user.decorator';
import { TransformationsService } from '../transformations/transformations.service'; import { TransformationsService } from '../transformations/transformations.service';
import { getObjValueFromPath } from 'src/utils/ObjValueFromPath'; import { getObjValueFromPath, objHasPath } from 'src/utils/ObjValueFromPath';
import ErrorCodes from 'src/utils/errorCodes'; import ErrorCodes from 'src/utils/errorCodes';
import ErrorBuilder from 'src/utils/ErrorBuilder'; import ErrorBuilder from 'src/utils/ErrorBuilder';
@@ -220,7 +220,7 @@ export class PipelinesService implements OnModuleInit {
this.logger.info('PipelinesClientService - findOneProperties'); this.logger.info('PipelinesClientService - findOneProperties');
const { pipeline } = await this.findOne({ id }, metadata); const { pipeline } = await this.findOne({ id }, metadata);
const pipelineProperties = JSON.parse(pipeline.properties); const properties = JSON.parse(pipeline.properties);
const connectorId = `${pipeline.connector_plugin}-${pipeline.connector_version}`; const connectorId = `${pipeline.connector_plugin}-${pipeline.connector_version}`;
@@ -228,24 +228,38 @@ export class PipelinesService implements OnModuleInit {
connectorId, connectorId,
metadata.get('language')[0].toString(), metadata.get('language')[0].toString(),
); );
const connector = JSON.parse(res.connector); const connector: { [key: string]: any; config_controls: any[] } =
const config_controls = connector.config_controls || []; JSON.parse(res.connector);
const config_controls = (connector.config_controls || []).filter(
(config_control) => {
const path: string = config_control.name;
if (!objHasPath({ object: { properties }, path })) return false;
for (const config_control of config_controls) { let default_value = getObjValueFromPath({
const path: string = config_control.name; object: { properties },
const default_value = getObjValueFromPath({ path,
object: { properties: pipelineProperties }, });
path,
}); if (default_value != undefined) {
if (default_value != undefined) if (
config_control.default_value = default_value; path === 'properties.spreadsheet_id' &&
} typeof default_value === 'string'
)
default_value = 'https://docs.google.com/spreadsheets/d/'.concat(
default_value,
);
config_control.default_value = default_value;
}
return true;
},
);
return { return {
pipeline: { pipeline: {
...pipeline, ...pipeline,
config_controls, config_controls,
properties: pipelineProperties, properties,
}, },
}; };
} }
+14
View File
@@ -308,6 +308,20 @@ export function EnrichErrorCode(code: string) {
'Tente realizar a ação novamente. Caso o erro persista, entre em contato com o suporte', 'Tente realizar a ação novamente. Caso o erro persista, entre em contato com o suporte',
code, code,
}; };
case ErrorCodes.CATALOG.PREVIEW_TOO_BIG:
return {
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
error: 'Erro ao buscar prévia',
message: 'Ocorreu um erro devido ao tamanho da prévia do ativo.',
code,
};
case ErrorCodes.CATALOG.METADATA_TOO_BIG:
return {
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
error: 'Erro ao buscar informações',
message: 'Ocorreu um erro devido ao tamanho das informações do ativo.',
code,
};
case ErrorCodes.INTERNAL: case ErrorCodes.INTERNAL:
case ErrorCodes.UNKNOWN: case ErrorCodes.UNKNOWN:
default: default:
+19 -1
View File
@@ -1,4 +1,7 @@
export function getObjValueFromPath<T>(data: { object: T; path: string }): T { export function getObjValueFromPath<T extends object>(data: {
object: T;
path: string;
}): any {
const { object, path } = data; const { object, path } = data;
const keys = path.split('.'); const keys = path.split('.');
@@ -8,3 +11,18 @@ export function getObjValueFromPath<T>(data: { object: T; path: string }): T {
} }
return value; return value;
} }
export function objHasPath<T extends object>(data: {
object: T;
path: string;
}): boolean {
const { object, path } = data;
const keys = path.split('.');
let value = JSON.parse(JSON.stringify(object));
for (const key of keys) {
if (!(key in value)) return false;
value = value[key];
}
return true;
}
+2
View File
@@ -70,6 +70,8 @@ const TRANSFORMATION = {
}; };
const CATALOG = { const CATALOG = {
DATA_ASSET_NOT_FOUND: 'CATALOG.DATA_ASSET_NOT_FOUND', DATA_ASSET_NOT_FOUND: 'CATALOG.DATA_ASSET_NOT_FOUND',
PREVIEW_TOO_BIG: 'CATALOG.PREVIEW_TOO_BIG',
METADATA_TOO_BIG: 'CATALOG.METADATA_TOO_BIG',
}; };
const ErrorCodes = { const ErrorCodes = {
UNKNOWN: 'UNKNOWN', UNKNOWN: 'UNKNOWN',