new protospack

This commit is contained in:
Gabriel Rosa
2022-09-28 11:20:17 -03:00
parent e724ef5ccc
commit 4877fab945
6 changed files with 56 additions and 24 deletions
+24 -9
View File
@@ -14,6 +14,7 @@ import { PERMISSIONS_GROUPS } from '../../authentication/permissions.enum';
import { CatalogService } from './catalog.service';
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
import { RequestUser, User } from 'src/authentication/user.decorator';
@ApiTags('Catalog')
@Controller('catalog')
@@ -120,17 +121,31 @@ export class CatalogController {
}
@Get('table-metadata')
async getAllTableMetadata(@Body() body, @Query() query) {
async getAllTableMetadata(
@Body() body,
@Query() query,
@User() user: RequestUser,
) {
this.logger.info(`/catalog - ON GET ALL TABLES METADATA ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
user: user.user_id,
customer: user.customer_name,
});
const { user_id, customer_name, customer_id } = user;
const metadata = PackTheMetadata({
user_id,
customer_id,
customer_name,
});
if (!query) {
const res = await this.catalogService.getAllTableMetadata(body);
return res;
} else {
const res = await this.catalogService.getOneTableMetadata(body, query);
const res = await this.catalogService.getOneTableMetadata(
body,
query,
metadata,
);
return res;
}
}
@@ -333,16 +348,16 @@ export class CatalogController {
}
@Post('tags')
async createTags(@Body() body) {
async createTags(@Body() body, @User() user: RequestUser) {
this.logger.info(`/catalog - ON CREATE TAG ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
user: user.user_id,
customer: user.customer_name,
});
const { user_id, customer, customer_id } = body.info;
const { user_id, customer_name, customer_id } = user;
const metadata = PackTheMetadata({
user_id,
customer_id,
customer_name: customer,
customer_name,
});
const res = await this.catalogService.createTags(body, metadata);
+2 -1
View File
@@ -4,10 +4,10 @@ import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
import { CatalogController } from './catalog.controller';
import { CatalogService } from './catalog.service';
import { PipelinesService } from '../pipelinesV2/pipelines.service';
import { CatalogClientConfiguration } from './catalog-client';
import { ClientsModule } from '@nestjs/microservices';
import { PipelinesModule as OldPipelineModule } from 'src/modules/pipelines/pipelines.module';
import { UsersModule } from '../users/users.module';
const client = new CatalogClientConfiguration();
@@ -15,6 +15,7 @@ const client = new CatalogClientConfiguration();
imports: [
ClientsModule.register([client.providerOptions]),
OldPipelineModule,
UsersModule,
],
controllers: [CatalogController],
providers: [CatalogService, DadosferaLogger],
+21 -5
View File
@@ -40,7 +40,10 @@ class CatalogService implements OnModuleInit {
return `https://nimbus-${customer}.dadosfera.ai`;
}
return `https://nimbus-${customer}.${process.env.ENV}.dadosfera.ai`;
return `https://nimbus-${customer}.${process.env.ENV.replace(
'local',
'stg',
)}.dadosfera.ai`;
}
async catalogAll(body) {
@@ -115,13 +118,26 @@ class CatalogService implements OnModuleInit {
return data;
}
async getOneTableMetadata(body, params) {
async getOneTableMetadata(body, params, metadata) {
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.get(
`${nimbusUrl}/api/catalog/table-metadata/`,
{ params: params },
);
return data;
const { data_asset } = await lastValueFrom(
this.catalogReadService.GetOneDataAsset(
{ id: data[0].id, type: 'dataset' },
metadata,
),
);
const opensearchTable = JSON.parse(data_asset);
return [
{
...data[0],
tags: opensearchTable.tags,
table_description: opensearchTable.description,
},
];
}
async deleteOneTableMetadata(id, body) {
@@ -272,7 +288,7 @@ class CatalogService implements OnModuleInit {
this.logger.info('CatalogService - findAllCustomerTags');
const response = await lastValueFrom(
this.catalogWriteService.GetCustomerTags(data, metadata),
this.catalogReadService.GetCustomerTags(data, metadata),
)
.then((res) => {
this.logger.info('Done');
@@ -290,7 +306,7 @@ class CatalogService implements OnModuleInit {
this.logger.info('CatalogService - findAllTableTags');
const response = await lastValueFrom(
this.catalogWriteService.GetTableTags(data, metadata),
this.catalogReadService.GetTableTags(data, metadata),
)
.then((res) => {
this.logger.info('Done');