Compare commits

...
Author SHA1 Message Date
Arthur Simas 1c5b929c1b REFACTOR: nimbus URL 2022-05-18 13:57:19 -03:00
rodrigo.zamboni 3e21c308f6 UPDATE: Added S3 Input Creation 2022-05-17 15:58:18 -03:00
6 changed files with 9343 additions and 212 deletions
+9262 -16
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -31,7 +31,7 @@
"@nestjs/platform-express": "^8.4.3",
"@nestjs/schedule": "^1.1.0",
"@nestjs/swagger": "^5.2.1",
"@victorradael/protospack": "^1.7.4",
"@victorradael/protospack": "^1.8.0",
"axios": "^0.25.0",
"dotenv": "^14.2.0",
"helmet": "^5.0.2",
+2 -2
View File
@@ -162,11 +162,11 @@ export class AuthClientService implements OnModuleInit {
async resendeConfirmationCode({
username,
}: AuthResendConfirmationCodeRequest): Promise<any> {
console.log('AuthClientService', 'resendeConfirmationCode');
console.log('AuthClientService', 'resendConfirmationCode');
const authResendConfirmationCodeRequestReturn = await new Promise(
(resolve, reject) => {
this.authService.resendeConfirmationCode({ username }).subscribe({
this.authService.resendConfirmationCode({ username }).subscribe({
next(x) {
resolve(x);
},
+26
View File
@@ -1,6 +1,7 @@
import { OnModuleInit, Inject } from '@nestjs/common';
import { ClientGrpc } from '@nestjs/microservices';
import {
InputCreateS3Request,
InputNewCreateRequest,
InputService,
TestConnectionGetColumnsRequest,
@@ -50,6 +51,31 @@ export class InputsClientService implements OnModuleInit {
return createInputResponse;
}
async createS3Inputs(createInputDto: InputCreateS3Request) {
console.log('InputClientService', 'Create');
const createInputResponse = await new Promise((resolve, reject) => {
this.inputService.CreateS3(objectSnakeToCamel(createInputDto)).subscribe({
next(x) {
resolve(objectCamelToSnake(x));
},
error(err) {
console.log('Observable Error');
reject(err);
},
complete() {
console.log('done');
},
});
})
.then((res) => res)
.catch((err) => {
throw new Error(err);
});
return createInputResponse;
}
async findOne(data: IIdRequest) {
console.log('InputClientService', 'FindOne');
+40 -188
View File
@@ -1,39 +1,31 @@
import axios from 'axios';
class CatalogService {
async catalogAll(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
_getNimbusUrl(body) {
const customer = body.info.customer.toLowerCase();
if (process.env.ENV === 'prd') {
return `https://nimbus-${customer}.dadosfera.ai`;
}
return `https://nimbus-${customer}.${process.env.ENV}.dadosfera.ai`;
}
async catalogAll(body) {
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.get(`${nimbusUrl}/api/catalog/all/`);
return data;
}
async dataAppsAll(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.get(`${nimbusUrl}/api/catalog/data_apps/`);
return data;
}
async dataAppsOne(id, body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.get(
`${nimbusUrl}/api/catalog/data_apps/${id}/`,
);
@@ -42,12 +34,7 @@ class CatalogService {
}
async getAllDashboardMetabase(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.get(
`${nimbusUrl}/api/catalog/dashboard-metabase/`,
);
@@ -55,12 +42,7 @@ class CatalogService {
}
async getOneDashboardMetabase(id, body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.get(
`${nimbusUrl}/api/catalog/dashboard-metabase/${id}`,
);
@@ -74,12 +56,7 @@ class CatalogService {
}
async getAllTableMetadata(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.get(
`${nimbusUrl}/api/catalog/table-metadata/`,
);
@@ -87,12 +64,7 @@ class CatalogService {
}
async getOneTableMetadata(body, params) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.get(
`${nimbusUrl}/api/catalog/table-metadata/`,
{ params: params },
@@ -101,12 +73,7 @@ class CatalogService {
}
async deleteOneTableMetadata(id, body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.delete(
`${nimbusUrl}/api/catalog/table-metadata/${id}`,
);
@@ -114,12 +81,7 @@ class CatalogService {
}
async getOneColumnMetadata(body, params) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.get(
`${nimbusUrl}/api/catalog/column-metadata/`,
{ params: params },
@@ -128,12 +90,7 @@ class CatalogService {
}
async deleteOneColumnMetadata(id, body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.delete(
`${nimbusUrl}/api/catalog/column-metadata/${id}/`,
);
@@ -141,12 +98,7 @@ class CatalogService {
}
async getOneDataPreview(body, params) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-preview/`, {
params: params,
});
@@ -154,23 +106,13 @@ class CatalogService {
}
async getDataStatus(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-status/`);
return data;
}
async createDataStatus(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.post(
`${nimbusUrl}/api/catalog/data-status/`,
body,
@@ -179,12 +121,7 @@ class CatalogService {
}
async getDataDescription(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.get(
`${nimbusUrl}/api/catalog/data-description/`,
);
@@ -192,12 +129,7 @@ class CatalogService {
}
async createDataDescription(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.post(
`${nimbusUrl}/api/catalog/data-description/`,
body,
@@ -206,23 +138,13 @@ class CatalogService {
}
async getDataDocs(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-docs/`);
return data;
}
async createDataDocs(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.post(
`${nimbusUrl}/api/catalog/data-docs/`,
body,
@@ -231,23 +153,13 @@ class CatalogService {
}
async getDataRating(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-rating/`);
return data;
}
async createDataRating(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.post(
`${nimbusUrl}/api/catalog/data-rating/`,
body,
@@ -256,12 +168,7 @@ class CatalogService {
}
async getSummaryRating(id, body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.get(
`${nimbusUrl}/api/catalog/summary-rating/${id}`,
);
@@ -269,23 +176,13 @@ class CatalogService {
}
async getDataComment(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-comment/`);
return data;
}
async createDataComment(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.post(
`${nimbusUrl}/api/catalog/data-comment/`,
body,
@@ -294,12 +191,7 @@ class CatalogService {
}
async getDataReview(body, params) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-review/`, {
params: params,
});
@@ -307,34 +199,19 @@ class CatalogService {
}
async createTags(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.post(`${nimbusUrl}/api/catalog/tags/`, body);
return data;
}
async findAllTags(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.get(`${nimbusUrl}/api/catalog/tags/`, body);
return data;
}
async findAllTableTags(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.get(
`${nimbusUrl}/api/catalog/table-tags/`,
body,
@@ -343,23 +220,13 @@ class CatalogService {
}
async deleteTags(id, body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.delete(`${nimbusUrl}/api/catalog/tags/${id}`);
return data;
}
async createTableTags(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.post(
`${nimbusUrl}/api/catalog/table-tags/`,
body,
@@ -368,12 +235,7 @@ class CatalogService {
}
async deleteTableTags(id, body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.delete(
`${nimbusUrl}/api/catalog/table-tags/${id}`,
);
@@ -381,12 +243,7 @@ class CatalogService {
}
async getTableRules(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.get(
`${nimbusUrl}/api/catalog/table-rules/`,
body,
@@ -395,12 +252,7 @@ class CatalogService {
}
async deleteTableRules(id, body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`;
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.delete(
`${nimbusUrl}/api/catalog/table-rules/${id}`,
);
+12 -5
View File
@@ -1,6 +1,5 @@
import { Body, HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { Timeout } from '@nestjs/schedule';
import { InputNewCreateRequest } from '@victorradael/protospack';
import { InputsClientService } from 'src/clients/inputs/client.service';
import { IIdRequest, Info } from 'src/clients/inputs/interfaces';
@@ -8,11 +7,19 @@ import { IIdRequest, Info } from 'src/clients/inputs/interfaces';
export class InputsService {
constructor(private inputClient: InputsClientService) {}
async create(@Body() data: InputNewCreateRequest) {
async create(@Body() data) {
try {
const createInputResponse = await this.inputClient.create(data);
return createInputResponse;
if (
data.plugin == 'csv' ||
data.plugin == 'json' ||
data.plugin == 'parquet'
) {
const createInputResponse = await this.inputClient.createS3Inputs(data);
return createInputResponse;
} else {
const createInputResponse = await this.inputClient.create(data);
return createInputResponse;
}
} catch (err) {
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
}