FIX: Manage Permissions Catalog

This commit is contained in:
Victor Radael
2022-09-28 17:02:22 -03:00
3 changed files with 55 additions and 27 deletions
+10 -6
View File
@@ -259,15 +259,19 @@ export class CatalogController {
}
@Post('data-description')
async createDataDescription(@Body() body) {
async createDataDescription(@Body() body, @User() user: RequestUser) {
this.logger.info(`/catalog - ON CREATE DATA DESCRIPTION ROUTE`, {
user: body.info.user_id,
customer: body.info.customer,
user: user.user_id,
customer: user.customer_name,
});
const res = await this.catalogService.createDataDescription(body);
return res;
const { user_id, customer_name, customer_id } = user;
const metadata = PackTheMetadata({
user_id,
customer_id,
customer_name,
});
return await this.catalogService.createDataDescription(body, metadata);
}
@Get('data-docs')
+44 -20
View File
@@ -143,20 +143,23 @@ class CatalogService implements OnModuleInit {
`${nimbusUrl}/api/catalog/table-metadata/`,
{ params: params },
);
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,
},
];
if (data?.length === 1) {
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,
},
];
}
return data;
}
async deleteOneTableMetadata(id, body) {
@@ -215,13 +218,34 @@ class CatalogService implements OnModuleInit {
return data;
}
async createDataDescription(body) {
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.post(
`${nimbusUrl}/api/catalog/data-description/`,
body,
async createDataDescription(body, metadata) {
const response = await lastValueFrom(
this.catalogWriteService.UpdateDataAsset(
{
id: `dataset-${body.table_id}`,
description: body.description,
tags: undefined,
},
metadata,
),
);
return data;
// {
// description: 'descrição nova';
// id: 5;
// table_id: 4;
// }
// const nimbusUrl = this._getNimbusUrl(body);
// const { data } = await axios.post(
// `${nimbusUrl}/api/catalog/data-description/`,
// body,
// );
// {"id":5,"description":"descrição nova","updated_at":"2022-09-28T14:35:15.618750Z","table_id":4}
return {
id: 0,
description: body.description,
updated_at: new Date().toISOString(),
table_id: body.table_id,
};
}
async getDataDocs(body) {