FIX: Manage Permissions Catalog

This commit is contained in:
Victor Radael
2022-09-28 16:58:52 -03:00
parent a28781423c
commit d42584fcfc
5 changed files with 37 additions and 25 deletions
+7 -7
View File
@@ -12,7 +12,7 @@
"dependencies": {
"@aws-sdk/client-secrets-manager": "^3.112.0",
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
"@dadosfera/protospack-v2": "3.18.4",
"@dadosfera/protospack-v2": "3.18.5",
"@grpc/grpc-js": "^1.6.7",
"@grpc/proto-loader": "^0.6.13",
"@nestjs/common": "^8.4.7",
@@ -1726,9 +1726,9 @@
}
},
"node_modules/@dadosfera/protospack-v2": {
"version": "3.18.4",
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.18.4.tgz",
"integrity": "sha512-OqnYuwY8gV9/GFtJt4ftv2CQBOuNKpTAimCMPZVMB95CF95npD1Fj+Au5mTctt/hTOkF9gNsd8mcS67SeLn3jg==",
"version": "3.18.5",
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.18.5.tgz",
"integrity": "sha512-Pj2MTk2ok86kXOybpnWnm+/Ew7feKhNmE4UL6xWMmYy2eywoGOWvYcBblI+EB2NrnWDAFKP/3rbVycVyIkafJg==",
"dependencies": {
"@grpc/grpc-js": "^1.6.7",
"rxjs": "^7.5.5",
@@ -12306,9 +12306,9 @@
}
},
"@dadosfera/protospack-v2": {
"version": "3.18.4",
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.18.4.tgz",
"integrity": "sha512-OqnYuwY8gV9/GFtJt4ftv2CQBOuNKpTAimCMPZVMB95CF95npD1Fj+Au5mTctt/hTOkF9gNsd8mcS67SeLn3jg==",
"version": "3.18.5",
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.18.5.tgz",
"integrity": "sha512-Pj2MTk2ok86kXOybpnWnm+/Ew7feKhNmE4UL6xWMmYy2eywoGOWvYcBblI+EB2NrnWDAFKP/3rbVycVyIkafJg==",
"requires": {
"@grpc/grpc-js": "^1.6.7",
"rxjs": "^7.5.5",
+1 -1
View File
@@ -27,7 +27,7 @@
"dependencies": {
"@aws-sdk/client-secrets-manager": "^3.112.0",
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
"@dadosfera/protospack-v2": "3.18.4",
"@dadosfera/protospack-v2": "3.18.5",
"@grpc/grpc-js": "^1.6.7",
"@grpc/proto-loader": "^0.6.13",
"@nestjs/common": "^8.4.7",
+13 -2
View File
@@ -55,8 +55,19 @@ export class CatalogController {
@User() user: RequestUser,
@Body() body,
) {
const response = await this.catalogService.managePermissions(body, user);
return { message: { id, body } };
const { customer_id, customer_name, user_id, username } = user;
const metadata = PackTheMetadata({
customer_id,
customer_name,
user_id,
username,
});
const response = await this.catalogService.managePermissions(
{ ...body, id },
metadata,
);
return { data_asset: JSON.parse(response.data_asset) };
}
@Get('all')
+15 -14
View File
@@ -3,7 +3,12 @@ import { ReadService } from '@dadosfera/protospack-v2/dist/lib/Catalog';
import { ProtoServices } from '@dadosfera/protospack-v2/dist/lib/Catalog';
import { Messages } from '@dadosfera/protospack-v2/dist/lib/Catalog';
import { WriteService } from '@dadosfera/protospack-v2/dist/lib/Catalog';
import { Inject, OnModuleInit } from '@nestjs/common';
import {
HttpException,
HttpStatus,
Inject,
OnModuleInit,
} from '@nestjs/common';
import { ClientGrpc } from '@nestjs/microservices';
import axios from 'axios';
import { lastValueFrom } from 'rxjs';
@@ -47,21 +52,17 @@ class CatalogService implements OnModuleInit {
}
async managePermissions(data: Messages.ManagePermissionRequest, metadata) {
this.logger.info('CatalogService - getAllOpenSearchDashboard');
this.logger.info('CatalogService - Manage Data assets permissions');
const response = await lastValueFrom(
return lastValueFrom(
this.catalogWriteService.ManagePermission(data, metadata),
)
.then((res) => {
this.logger.info('Done');
return res;
})
.catch((err) => {
this.logger.error(err.message);
throw new Error(err);
});
return { data_assets: response };
).catch((err) => {
console.log(err.details);
throw new HttpException(
err.details,
err.code === 6 ? HttpStatus.CONFLICT : 404,
);
});
}
async catalogAll(body) {
+1 -1
View File
File diff suppressed because one or more lines are too long