Compare commits

...
11 Commits
11 changed files with 9412 additions and 39 deletions
+9292 -16
View File
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -29,8 +29,9 @@
"@nestjs/mapped-types": "*", "@nestjs/mapped-types": "*",
"@nestjs/microservices": "^8.4.3", "@nestjs/microservices": "^8.4.3",
"@nestjs/platform-express": "^8.4.3", "@nestjs/platform-express": "^8.4.3",
"@nestjs/schedule": "^1.1.0",
"@nestjs/swagger": "^5.2.1", "@nestjs/swagger": "^5.2.1",
"@victorradael/protospack": "^1.6.1", "@victorradael/protospack": "^1.6.5",
"axios": "^0.25.0", "axios": "^0.25.0",
"dotenv": "^14.2.0", "dotenv": "^14.2.0",
"helmet": "^5.0.2", "helmet": "^5.0.2",
+2 -2
View File
@@ -20,11 +20,11 @@ export class AuthClientService implements OnModuleInit {
); );
} }
async signIn({ username, password }: ILogin): Promise<any> { async signIn({ username, password, totp }: ILogin): Promise<any> {
console.log('AuthClientService', 'SignIn'); console.log('AuthClientService', 'SignIn');
const tokens = await new Promise((resolve, reject) => { const tokens = await new Promise((resolve, reject) => {
this.authService.signIn({ username, password }).subscribe({ this.authService.signIn({ username, password, totp }).subscribe({
next(x) { next(x) {
resolve(x); resolve(x);
}, },
+1
View File
@@ -1,4 +1,5 @@
export interface ILogin { export interface ILogin {
username: string; username: string;
password: string; password: string;
totp: string;
} }
+1 -1
View File
@@ -10,7 +10,7 @@ export class TransformationsClientConfiguration {
return { return {
transport: Transport.GRPC, transport: Transport.GRPC,
options: { options: {
url: process.env.TRFACTORY_URL, url: process.env.INFACTORY_URL,
package: TransformationPackages, package: TransformationPackages,
credentials: credentials.createSsl(), credentials: credentials.createSsl(),
protoPath: TransformationProtoFilePath, protoPath: TransformationProtoFilePath,
+4 -2
View File
@@ -17,9 +17,11 @@ export class LoggerMiddleware implements NestMiddleware {
const idToken = request.get('Dadosfera-User'); const idToken = request.get('Dadosfera-User');
const accessToken = request.get('Authorization'); const accessToken = request.get('Authorization');
const privateKey = process.env.JWT_PRIVATE_KEY; const privateKey = process.env.JWT_PRIVATE_KEY;
let requiredRoute = '';
const requiredMethod = request.method.trim(); const requiredMethod = request.method.trim();
const requiredRoute = request.route.path.split('/')[1].trim(); if (request.route.path.split('/').length >= 2) {
requiredRoute = request.route.path.split('/')[1].trim();
}
verify(idToken, privateKey, (err) => { verify(idToken, privateKey, (err) => {
if (err) { if (err) {
+3 -2
View File
@@ -5,6 +5,7 @@ import { AuthClientService } from 'src/clients/auth/client.service';
interface ISignIn { interface ISignIn {
username: string; username: string;
password: string; password: string;
totp: string;
} }
@Controller('auth') @Controller('auth')
@@ -12,11 +13,11 @@ export class AuthController {
constructor(private authClient: AuthClientService) {} constructor(private authClient: AuthClientService) {}
@Post() @Post()
async signIn(@Body() { username, password }: ISignIn) { async signIn(@Body() { username, password, totp }: ISignIn) {
console.log(`/auth`, 'SignIn'); console.log(`/auth`, 'SignIn');
const tokens = await this.authClient const tokens = await this.authClient
.signIn({ username, password }) .signIn({ username, password, totp })
.then((result) => result) .then((result) => result)
.catch((err) => { .catch((err) => {
throw new UnauthorizedException(err.message); throw new UnauthorizedException(err.message);
+41 -5
View File
@@ -140,6 +140,17 @@ export class CatalogController {
return res; return res;
} }
@Get('data-status')
async createDataStatus(@Body() body) {
console.log(`/catalog`, 'ON CREATE DATA STATUS ROUTE');
const catalogService = new CatalogService();
const res = await catalogService.createDataStatus(body);
return res;
}
@Get('data-description') @Get('data-description')
async getDataDescription(@Body() body) { async getDataDescription(@Body() body) {
console.log(`/catalog`, 'ON GET DATA DESCRIPTION ROUTE'); console.log(`/catalog`, 'ON GET DATA DESCRIPTION ROUTE');
@@ -151,6 +162,17 @@ export class CatalogController {
return res; return res;
} }
@Post('data-description')
async createDataDescription(@Body() body) {
console.log(`/catalog`, 'ON CREATE DATA DESCRIPTION ROUTE');
const catalogService = new CatalogService();
const res = await catalogService.createDataDescription(body);
return res;
}
@Get('data-docs') @Get('data-docs')
async getDataDocs(@Body() body) { async getDataDocs(@Body() body) {
console.log(`/catalog`, 'ON GET DATA DOCS ROUTE'); console.log(`/catalog`, 'ON GET DATA DOCS ROUTE');
@@ -162,6 +184,17 @@ export class CatalogController {
return res; return res;
} }
@Post('data-docs')
async createDataDocs(@Body() body) {
console.log(`/catalog`, 'ON CREATE DATA DOCS ROUTE');
const catalogService = new CatalogService();
const res = await catalogService.createDataDocs(body);
return res;
}
@Get('data-rating') @Get('data-rating')
async getDataRating(@Body() body) { async getDataRating(@Body() body) {
console.log(`/catalog`, 'ON GET DATA RATING ROUTE'); console.log(`/catalog`, 'ON GET DATA RATING ROUTE');
@@ -185,15 +218,18 @@ export class CatalogController {
} }
@Get('summary-rating/:id') @Get('summary-rating/:id')
async getSummaryRating(@Param() params, @Body() body) { async getSummaryRating() {
console.log(`/catalog`, 'ON GET SUMMARY RATING ROUTE'); console.log(`/catalog`, 'ON GET SUMMARY RATING ROUTE');
const { id } = params; //const { id } = params;
const catalogService = new CatalogService(); //const catalogService = new CatalogService();
const res = await catalogService.getSummaryRating(id, body); //const res = await catalogService.getSummaryRating(id, body);
return res; return {
avg_rating: 0,
rating_count: 0,
};
} }
@Get('data-comment') @Get('data-comment')
+63 -9
View File
@@ -136,7 +136,7 @@ class CatalogService {
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai` ? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`; : `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
const { data } = await axios.get( const { data } = await axios.delete(
`${nimbusUrl}/api/catalog/table-metadata/${id}`, `${nimbusUrl}/api/catalog/table-metadata/${id}`,
); );
return data; return data;
@@ -171,7 +171,7 @@ class CatalogService {
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai` ? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`; : `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
const { data } = await axios.get( const { data } = await axios.delete(
`${nimbusUrl}/api/catalog/column-metadata/${id}/`, `${nimbusUrl}/api/catalog/column-metadata/${id}/`,
); );
return data; return data;
@@ -209,6 +209,24 @@ class CatalogService {
return data; return data;
} }
async createDataStatus(body) {
const customer =
body.info.customer.toLowerCase() === 'dadosfera'
? ``
: `-${body.info.customer.toLowerCase()}`;
const nimbusUrl =
process.env.ENV === 'prd'
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
const { data } = await axios.post(
`${nimbusUrl}/api/catalog/data-status/`,
body,
);
return data;
}
async getDataDescription(body) { async getDataDescription(body) {
const customer = const customer =
body.info.customer.toLowerCase() === 'dadosfera' body.info.customer.toLowerCase() === 'dadosfera'
@@ -226,6 +244,24 @@ class CatalogService {
return data; return data;
} }
async createDataDescription(body) {
const customer =
body.info.customer.toLowerCase() === 'dadosfera'
? ``
: `-${body.info.customer.toLowerCase()}`;
const nimbusUrl =
process.env.ENV === 'prd'
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
const { data } = await axios.post(
`${nimbusUrl}/api/catalog/data-description/`,
body,
);
return data;
}
async getDataDocs(body) { async getDataDocs(body) {
const customer = const customer =
body.info.customer.toLowerCase() === 'dadosfera' body.info.customer.toLowerCase() === 'dadosfera'
@@ -241,6 +277,24 @@ class CatalogService {
return data; return data;
} }
async createDataDocs(body) {
const customer =
body.info.customer.toLowerCase() === 'dadosfera'
? ``
: `-${body.info.customer.toLowerCase()}`;
const nimbusUrl =
process.env.ENV === 'prd'
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
const { data } = await axios.post(
`${nimbusUrl}/api/catalog/data-docs/`,
body,
);
return data;
}
async getDataRating(body) { async getDataRating(body) {
const customer = const customer =
body.info.customer.toLowerCase() === 'dadosfera' body.info.customer.toLowerCase() === 'dadosfera'
@@ -267,7 +321,7 @@ class CatalogService {
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai` ? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`; : `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
const { data } = await axios.get( const { data } = await axios.post(
`${nimbusUrl}/api/catalog/data-rating/`, `${nimbusUrl}/api/catalog/data-rating/`,
body, body,
); );
@@ -317,7 +371,7 @@ class CatalogService {
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai` ? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`; : `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
const { data } = await axios.get( const { data } = await axios.post(
`${nimbusUrl}/api/catalog/data-comment/`, `${nimbusUrl}/api/catalog/data-comment/`,
body, body,
); );
@@ -352,7 +406,7 @@ class CatalogService {
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai` ? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`; : `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
const { data } = await axios.get(`${nimbusUrl}/api/catalog/tags/`, body); const { data } = await axios.post(`${nimbusUrl}/api/catalog/tags/`, body);
return data; return data;
} }
@@ -400,7 +454,7 @@ class CatalogService {
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai` ? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`; : `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
const { data } = await axios.get(`${nimbusUrl}/api/catalog/tags/${id}`); const { data } = await axios.delete(`${nimbusUrl}/api/catalog/tags/${id}`);
return data; return data;
} }
@@ -415,7 +469,7 @@ class CatalogService {
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai` ? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`; : `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
const { data } = await axios.get( const { data } = await axios.post(
`${nimbusUrl}/api/catalog/table-tags/`, `${nimbusUrl}/api/catalog/table-tags/`,
body, body,
); );
@@ -433,7 +487,7 @@ class CatalogService {
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai` ? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`; : `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
const { data } = await axios.get( const { data } = await axios.delete(
`${nimbusUrl}/api/catalog/table-tags/${id}`, `${nimbusUrl}/api/catalog/table-tags/${id}`,
); );
return data; return data;
@@ -468,7 +522,7 @@ class CatalogService {
? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai` ? `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`
: `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`; : `${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera`;
const { data } = await axios.get( const { data } = await axios.delete(
`${nimbusUrl}/api/catalog/table-rules/${id}`, `${nimbusUrl}/api/catalog/table-rules/${id}`,
); );
return data; return data;
+2
View File
@@ -1,4 +1,5 @@
import { Body, HttpException, HttpStatus, Injectable } from '@nestjs/common'; import { Body, HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { Timeout } from '@nestjs/schedule';
import { InputNewCreateRequest } from '@victorradael/protospack'; import { InputNewCreateRequest } from '@victorradael/protospack';
import { InputsClientService } from 'src/clients/inputs/client.service'; import { InputsClientService } from 'src/clients/inputs/client.service';
import { IIdRequest, Info } from 'src/clients/inputs/interfaces'; import { IIdRequest, Info } from 'src/clients/inputs/interfaces';
@@ -60,6 +61,7 @@ export class InputsService {
} }
} }
@Timeout(60000 * 10) // Timeout set for 10 minutes
async testConnection(data) { async testConnection(data) {
try { try {
const testConnectionInputResponse = await this.inputClient.testConnection( const testConnectionInputResponse = await this.inputClient.testConnection(
+1 -1
View File
File diff suppressed because one or more lines are too long