mirror of
https://github.com/dadosfera/maestro.git
synced 2026-09-11 09:14:48 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e9b85537d7 | ||
|
|
17060332fd | ||
|
|
fde6d0a74c | ||
|
|
0ca6ed8636 | ||
|
|
2f006c607c | ||
|
|
9fbbfc2064 |
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug NestJs",
|
||||
"request": "launch",
|
||||
"runtimeArgs": [
|
||||
"run",
|
||||
"start:debug"
|
||||
],
|
||||
"runtimeExecutable": "npm",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"type": "node",
|
||||
"console": "integratedTerminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
Generated
+8
-8
@@ -10,8 +10,8 @@
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-secrets-manager": "^3.112.0",
|
||||
"@dadosfera/dadosfera-logs": "^1.0.0-beta.3",
|
||||
"@dadosfera/protospack-v2": "3.11.0-beta.4",
|
||||
"@dadosfera/dadosfera-logs": "1.0.0-beta.3",
|
||||
"@dadosfera/protospack-v2": "3.11.0",
|
||||
"@grpc/grpc-js": "^1.6.7",
|
||||
"@grpc/proto-loader": "^0.6.13",
|
||||
"@nestjs/common": "^8.4.7",
|
||||
@@ -1723,9 +1723,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@dadosfera/protospack-v2": {
|
||||
"version": "3.11.0-beta.4",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.11.0-beta.4.tgz",
|
||||
"integrity": "sha512-TbRiEkSh7TJXHPiwOD+k22gDV2YIkjL6rSlNzqRTpeWo7Qp3gdkNIiWhUKUMeSIJyeJ9Qo1OKyvE8N/MWfRxKQ==",
|
||||
"version": "3.11.0",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.11.0.tgz",
|
||||
"integrity": "sha512-BPjbH/CrYAH1jGEBNBr3W56frLu9gb9A+i2smKyM5vxVQpZgxZHEjSxfv92d4wtFWW6QnzeyMhcmCqaoVV4w2Q==",
|
||||
"dependencies": {
|
||||
"@grpc/grpc-js": "^1.6.7",
|
||||
"rxjs": "^7.5.5",
|
||||
@@ -12287,9 +12287,9 @@
|
||||
}
|
||||
},
|
||||
"@dadosfera/protospack-v2": {
|
||||
"version": "3.11.0-beta.4",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.11.0-beta.4.tgz",
|
||||
"integrity": "sha512-TbRiEkSh7TJXHPiwOD+k22gDV2YIkjL6rSlNzqRTpeWo7Qp3gdkNIiWhUKUMeSIJyeJ9Qo1OKyvE8N/MWfRxKQ==",
|
||||
"version": "3.11.0",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.11.0.tgz",
|
||||
"integrity": "sha512-BPjbH/CrYAH1jGEBNBr3W56frLu9gb9A+i2smKyM5vxVQpZgxZHEjSxfv92d4wtFWW6QnzeyMhcmCqaoVV4w2Q==",
|
||||
"requires": {
|
||||
"@grpc/grpc-js": "^1.6.7",
|
||||
"rxjs": "^7.5.5",
|
||||
|
||||
+2
-2
@@ -25,6 +25,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-secrets-manager": "^3.112.0",
|
||||
"@dadosfera/dadosfera-logs": "1.0.0-beta.3",
|
||||
"@dadosfera/protospack-v2": "3.11.0",
|
||||
"@grpc/grpc-js": "^1.6.7",
|
||||
"@grpc/proto-loader": "^0.6.13",
|
||||
"@nestjs/common": "^8.4.7",
|
||||
@@ -38,7 +40,6 @@
|
||||
"@nestjs/swagger": "^5.2.1",
|
||||
"axios": "^0.25.0",
|
||||
"cron-parser": "^4.4.0",
|
||||
"@dadosfera/dadosfera-logs": "^1.0.0-beta.3",
|
||||
"dotenv": "^14.3.2",
|
||||
"elastic-apm-node": "^3.36.0",
|
||||
"helmet": "^5.1.0",
|
||||
@@ -51,7 +52,6 @@
|
||||
"passport-hubspot-oauth2": "^1.0.3",
|
||||
"passport-mailchimp": "^1.1.0",
|
||||
"protospack": "2.5.2",
|
||||
"@dadosfera/protospack-v2": "3.11.0-beta.4",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"rxjs": "^7.5.5",
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
HttpStatus,
|
||||
Inject,
|
||||
UseFilters,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import {
|
||||
@@ -23,10 +22,7 @@ import {
|
||||
} from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages';
|
||||
|
||||
import { PERMISSIONS } from 'src/authentication/permissions.enum';
|
||||
import {
|
||||
Authenticated,
|
||||
RequireAllPermissions,
|
||||
} from 'src/authentication/authentication.decorator';
|
||||
import { RequireAllPermissions } from 'src/authentication/authentication.decorator';
|
||||
import { AuthClientService } from './auth.service';
|
||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||
import { GrpcToHttpExceptionFilter } from '../../error/grpc-to-http-exception.filter';
|
||||
|
||||
@@ -23,6 +23,8 @@ export class RoleDto {
|
||||
isPublic: boolean;
|
||||
@ApiProperty({ type: () => Customer })
|
||||
customer?: Customer;
|
||||
@ApiProperty()
|
||||
usage: string;
|
||||
}
|
||||
|
||||
export class CustomerRole extends OmitType(RoleDto, ['customer']) {}
|
||||
|
||||
@@ -28,6 +28,7 @@ interface GetRolesPermissionsName {
|
||||
isPublic?: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
usage: string;
|
||||
}
|
||||
@Injectable()
|
||||
export class RolesService {
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
Patch,
|
||||
Post,
|
||||
Put,
|
||||
Req,
|
||||
Query,
|
||||
UseFilters,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
@@ -172,6 +172,18 @@ export class UsersController {
|
||||
return this.userService.resendInvite({ id });
|
||||
}
|
||||
|
||||
@Delete('role')
|
||||
@RequireAllPermissions(PERMISSIONS.USERS.permissions.ADMIN)
|
||||
async unassignRoleToUser(
|
||||
@User() user: RequestUser,
|
||||
@Query() request: UnassignRoleToUserReq,
|
||||
@Headers('dadosfera-lang') language,
|
||||
) {
|
||||
this.logger.info('unassignRoleToUser', { user });
|
||||
this.userService.setLanguage(language);
|
||||
return await this.userService.unassignRoleFromUser(request);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@RequireAllPermissions(PERMISSIONS.USERS.permissions.ADMIN)
|
||||
@ApiOkResponse({ type: DeleteUserRes })
|
||||
@@ -210,18 +222,6 @@ export class UsersController {
|
||||
return await this.userService.assignRoleToUser(body);
|
||||
}
|
||||
|
||||
@Delete('role')
|
||||
@RequireAllPermissions(PERMISSIONS.USERS.permissions.ADMIN)
|
||||
async unassignRoleToUser(
|
||||
@User() user: RequestUser,
|
||||
@Req() request: UnassignRoleToUserReq,
|
||||
@Headers('dadosfera-lang') language,
|
||||
) {
|
||||
this.logger.info('unassignRoleToUser', { user });
|
||||
this.userService.setLanguage(language);
|
||||
return await this.userService.unassignRoleToUser(request);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
@RequireAllPermissions(PERMISSIONS.USERS.permissions.ADMIN)
|
||||
@ApiOkResponse({ type: UpdateUserRes })
|
||||
|
||||
@@ -161,7 +161,7 @@ export class UsersService implements OnModuleInit {
|
||||
return lastValueFrom(this.usersClientService.AssignRoleToUser(body));
|
||||
}
|
||||
|
||||
async unassignRoleToUser(body: UnassignRoleFromUserRequest) {
|
||||
async unassignRoleFromUser(body: UnassignRoleFromUserRequest) {
|
||||
return lastValueFrom(this.usersClientService.UnassignRoleFromUser(body));
|
||||
}
|
||||
|
||||
|
||||
@@ -128,13 +128,46 @@ export function EnrichErrorCode(code: string) {
|
||||
code,
|
||||
};
|
||||
|
||||
case ErrorCodes.ROLE.ALREADY_EXIST:
|
||||
case ErrorCodes.ROLE.ALREADY_EXISTS:
|
||||
return {
|
||||
statusCode: HttpStatus.BAD_REQUEST,
|
||||
error: 'Grupo já existe',
|
||||
message: 'Não é possível criar um grupo com esse nome',
|
||||
code,
|
||||
};
|
||||
|
||||
case ErrorCodes.ROLE.ALREADY_EXISTS_PUBLIC:
|
||||
return {
|
||||
statusCode: HttpStatus.BAD_REQUEST,
|
||||
error: 'Grupo já existe',
|
||||
message: 'Nome conflita com grupo público da Dadosfera',
|
||||
code,
|
||||
};
|
||||
|
||||
case ErrorCodes.ROLE.PERMISSION_ALREADY_GRANTED:
|
||||
return {
|
||||
statusCode: HttpStatus.BAD_REQUEST,
|
||||
error: 'Permissão já inclusa',
|
||||
message: 'Permissão já consta nesse grupo',
|
||||
code,
|
||||
};
|
||||
|
||||
case ErrorCodes.ROLE.PERMISSION_NOT_GRANTED:
|
||||
return {
|
||||
statusCode: HttpStatus.BAD_REQUEST,
|
||||
error: 'Permissão não inclusa',
|
||||
message: 'Permissão já consta nesse grupo',
|
||||
code,
|
||||
};
|
||||
|
||||
case ErrorCodes.ROLE.PRIVATE:
|
||||
return {
|
||||
statusCode: HttpStatus.FORBIDDEN,
|
||||
error: 'Não é possivel fazer alterações',
|
||||
message: 'Você não tem permissão para alterar esse grupo',
|
||||
code,
|
||||
};
|
||||
|
||||
case ErrorCodes.ROLE.NOT_FOUND:
|
||||
case ErrorCodes.ROLE.FROM_ANOTHER_CUSTOMER:
|
||||
return {
|
||||
@@ -143,6 +176,7 @@ export function EnrichErrorCode(code: string) {
|
||||
message: 'Grupo solicitado não encontrado',
|
||||
code: ErrorCodes.ROLE.NOT_FOUND,
|
||||
};
|
||||
|
||||
case ErrorCodes.ROLE.CANNOT_EDIT_PUBLIC_ROLE:
|
||||
return {
|
||||
statusCode: HttpStatus.FORBIDDEN,
|
||||
@@ -150,6 +184,7 @@ export function EnrichErrorCode(code: string) {
|
||||
message: 'Você não tem permissão para editar esse grupo',
|
||||
code,
|
||||
};
|
||||
|
||||
case ErrorCodes.USER.NOT_FOUND:
|
||||
return {
|
||||
statusCode: HttpStatus.NOT_FOUND,
|
||||
|
||||
@@ -14,10 +14,15 @@ export const AUTH = {
|
||||
WEAK_NEW_PASSWORD: 'AUTH.WEAK_NEW_PASSWORD',
|
||||
};
|
||||
export const ROLE = {
|
||||
ALREADY_EXIST: 'ROLE.ALREADY_EXISTS',
|
||||
INVALID_ID: 'ROLE.INVALID_ID',
|
||||
NOT_FOUND: 'ROLE.NOT_FOUND',
|
||||
ALREADY_EXISTS: 'ROLE.ALREADY_EXISTS',
|
||||
ALREADY_EXISTS_PUBLIC: 'ROLE.ALREADY_EXISTS_PUBLIC',
|
||||
PERMISSION_ALREADY_GRANTED: 'ROLE.PERMISSION_ALREADY_GRANTED',
|
||||
PERMISSION_NOT_GRANTED: 'ROLE.PERMISSION_NOT_GRANTED',
|
||||
FROM_ANOTHER_CUSTOMER: 'ROLE.FROM_ANOTHER_CUSTOMER',
|
||||
CANNOT_EDIT_PUBLIC_ROLE: 'ROLE.CANNOT_EDIT_PUBLIC_ROLE',
|
||||
PRIVATE: 'ROLE.PRIVATE',
|
||||
};
|
||||
|
||||
export const USER = {
|
||||
|
||||
Reference in New Issue
Block a user