mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-30 17:10:06 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
667d3f874d | ||
|
|
11f1df5537 | ||
|
|
e3b02571c8 | ||
|
|
979a12aa7f | ||
|
|
8f0e851a88 | ||
|
|
6e6d03f302 | ||
|
|
3d5ce59b52 | ||
|
|
1c63271f64 | ||
|
|
31a51c20aa | ||
|
|
62730eb969 | ||
|
|
5a2c760bab | ||
|
|
28b4f3ac4b | ||
|
|
43d181a429 | ||
|
|
a72fe1b60d | ||
|
|
b52a1227b1 | ||
|
|
31478ed61d | ||
|
|
79b1ba910e | ||
|
|
7fd929915b |
Generated
+7
-7
@@ -12,7 +12,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-secrets-manager": "^3.112.0",
|
"@aws-sdk/client-secrets-manager": "^3.112.0",
|
||||||
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
||||||
"@dadosfera/protospack-v2": "3.18.8",
|
"@dadosfera/protospack-v2": "3.18.10",
|
||||||
"@grpc/grpc-js": "^1.6.7",
|
"@grpc/grpc-js": "^1.6.7",
|
||||||
"@grpc/proto-loader": "^0.6.13",
|
"@grpc/proto-loader": "^0.6.13",
|
||||||
"@nestjs/common": "^8.4.7",
|
"@nestjs/common": "^8.4.7",
|
||||||
@@ -1726,9 +1726,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@dadosfera/protospack-v2": {
|
"node_modules/@dadosfera/protospack-v2": {
|
||||||
"version": "3.18.8",
|
"version": "3.18.10",
|
||||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.18.8.tgz",
|
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.18.10.tgz",
|
||||||
"integrity": "sha512-pzvuIzCrIf/ZG//lwMdCxtZ7w/ZhiLFBA3VWyN9uM7AjeqVl7LllHKV08Fw6YjNNGBmQF3DLJQTK8kMCQja4hA==",
|
"integrity": "sha512-0bRUvo4p7cJJOL+B0hVTiSDaA2MGtirPkFVQW4lUfzsyY5vrsbAkMz6R3iPdPPwFSxGn5LwidHGkP3/l7hlEpA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@grpc/grpc-js": "^1.6.7",
|
"@grpc/grpc-js": "^1.6.7",
|
||||||
"rxjs": "^7.5.5",
|
"rxjs": "^7.5.5",
|
||||||
@@ -12306,9 +12306,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@dadosfera/protospack-v2": {
|
"@dadosfera/protospack-v2": {
|
||||||
"version": "3.18.8",
|
"version": "3.18.10",
|
||||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.18.8.tgz",
|
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.18.10.tgz",
|
||||||
"integrity": "sha512-pzvuIzCrIf/ZG//lwMdCxtZ7w/ZhiLFBA3VWyN9uM7AjeqVl7LllHKV08Fw6YjNNGBmQF3DLJQTK8kMCQja4hA==",
|
"integrity": "sha512-0bRUvo4p7cJJOL+B0hVTiSDaA2MGtirPkFVQW4lUfzsyY5vrsbAkMz6R3iPdPPwFSxGn5LwidHGkP3/l7hlEpA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@grpc/grpc-js": "^1.6.7",
|
"@grpc/grpc-js": "^1.6.7",
|
||||||
"rxjs": "^7.5.5",
|
"rxjs": "^7.5.5",
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-secrets-manager": "^3.112.0",
|
"@aws-sdk/client-secrets-manager": "^3.112.0",
|
||||||
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
||||||
"@dadosfera/protospack-v2": "3.18.8",
|
"@dadosfera/protospack-v2": "3.18.10",
|
||||||
"@grpc/grpc-js": "^1.6.7",
|
"@grpc/grpc-js": "^1.6.7",
|
||||||
"@grpc/proto-loader": "^0.6.13",
|
"@grpc/proto-loader": "^0.6.13",
|
||||||
"@nestjs/common": "^8.4.7",
|
"@nestjs/common": "^8.4.7",
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import { AuthClientService } from './auth.service';
|
|||||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||||
import { GrpcToHttpExceptionFilter } from '../../error/grpc-to-http-exception.filter';
|
import { GrpcToHttpExceptionFilter } from '../../error/grpc-to-http-exception.filter';
|
||||||
import { RequestUser, User } from 'src/authentication/user.decorator';
|
import { RequestUser, User } from 'src/authentication/user.decorator';
|
||||||
|
import { Metadata } from '@grpc/grpc-js';
|
||||||
|
|
||||||
@ApiTags('Auth')
|
@ApiTags('Auth')
|
||||||
@UseFilters(new GrpcToHttpExceptionFilter())
|
@UseFilters(new GrpcToHttpExceptionFilter())
|
||||||
@@ -59,20 +60,27 @@ export class AuthController {
|
|||||||
|
|
||||||
@Post('sign-in')
|
@Post('sign-in')
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
async signIn(@Body() { username, password, totp }: AuthSignInRequest) {
|
async signIn(
|
||||||
|
@Body() { username, password, totp }: AuthSignInRequest,
|
||||||
|
@Headers('Dadosfera-Lang') language: string,
|
||||||
|
) {
|
||||||
this.logger.info('/auth - SignIn');
|
this.logger.info('/auth - SignIn');
|
||||||
|
const metadata = new Metadata();
|
||||||
return this.authClient.signIn({ username, password, totp });
|
metadata.add('language', language || 'pt-br');
|
||||||
|
return this.authClient.signIn({ username, password, totp }, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('refresh-access-token')
|
@Post('refresh-access-token')
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
async refreshAccessToken(
|
async refreshAccessToken(
|
||||||
@Body() { refreshToken }: AuthRefreshAccessTokenRequest,
|
@Body() { refreshToken }: AuthRefreshAccessTokenRequest,
|
||||||
|
@Headers('Dadosfera-Lang') language: string,
|
||||||
) {
|
) {
|
||||||
this.logger.info('/auth - RefreshAccessToken');
|
this.logger.info('/auth - RefreshAccessToken');
|
||||||
|
const metadata = new Metadata();
|
||||||
|
metadata.add('language', language || 'pt-br');
|
||||||
|
|
||||||
return this.authClient.refreshAccessToken({ refreshToken });
|
return this.authClient.refreshAccessToken({ refreshToken }, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('change-password')
|
@Post('change-password')
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import {
|
|||||||
AuthConfirmResetPasswordRequest,
|
AuthConfirmResetPasswordRequest,
|
||||||
} from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages';
|
} from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages';
|
||||||
import { DucClient } from '../duc/client.config';
|
import { DucClient } from '../duc/client.config';
|
||||||
|
import { Metadata } from '@grpc/grpc-js';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AuthClientService implements OnModuleInit {
|
export class AuthClientService implements OnModuleInit {
|
||||||
@@ -51,19 +52,25 @@ export class AuthClientService implements OnModuleInit {
|
|||||||
return lastValueFrom(this.authService.AuthSnowflakeSignIn(input));
|
return lastValueFrom(this.authService.AuthSnowflakeSignIn(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
async signIn({ username, password, totp }: AuthSignInRequest) {
|
async signIn(
|
||||||
|
{ username, password, totp }: AuthSignInRequest,
|
||||||
|
metadata: Metadata,
|
||||||
|
) {
|
||||||
this.logger.info('SignIn');
|
this.logger.info('SignIn');
|
||||||
|
|
||||||
return lastValueFrom(
|
return lastValueFrom(
|
||||||
this.authService.AuthSignIn({ username, password, totp }),
|
this.authService.AuthSignIn({ username, password, totp }, metadata),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async refreshAccessToken({ refreshToken }: AuthRefreshAccessTokenRequest) {
|
async refreshAccessToken(
|
||||||
|
{ refreshToken }: AuthRefreshAccessTokenRequest,
|
||||||
|
metadata: Metadata,
|
||||||
|
) {
|
||||||
this.logger.info('RefreshAccessToken');
|
this.logger.info('RefreshAccessToken');
|
||||||
|
|
||||||
return lastValueFrom(
|
return lastValueFrom(
|
||||||
this.authService.AuthRefreshAccessToken({ refreshToken }),
|
this.authService.AuthRefreshAccessToken({ refreshToken }, metadata),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -207,7 +207,27 @@ class CatalogService implements OnModuleInit {
|
|||||||
|
|
||||||
const owner = result !== null ? result.user.username : null;
|
const owner = result !== null ? result.user.username : null;
|
||||||
|
|
||||||
Object.assign(asset, { ...asset, owner });
|
const roles = [];
|
||||||
|
const users = [];
|
||||||
|
|
||||||
|
for (const role of customer_roles) {
|
||||||
|
for (const role_id of asset.roles) {
|
||||||
|
if (role.id === role_id) roles.push(role);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const user of customer_users) {
|
||||||
|
for (const user_id of asset.users) {
|
||||||
|
if (user.id === user_id) users.push(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.assign(asset, {
|
||||||
|
...asset,
|
||||||
|
owner,
|
||||||
|
roles,
|
||||||
|
users,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return { data_assets };
|
return { data_assets };
|
||||||
@@ -387,7 +407,7 @@ class CatalogService implements OnModuleInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async createDataDescription(body, metadata) {
|
async createDataDescription(body, metadata) {
|
||||||
const response = await lastValueFrom(
|
await lastValueFrom(
|
||||||
this.catalogWriteService.UpdateDataAsset(
|
this.catalogWriteService.UpdateDataAsset(
|
||||||
{
|
{
|
||||||
id: `dataset-${body.table_id}`,
|
id: `dataset-${body.table_id}`,
|
||||||
|
|||||||
@@ -71,27 +71,174 @@ export class ConnectorClientService implements OnModuleInit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async uploadConnectorsFile(uploadFile) {
|
async uploadConnectorsFile(uploadFile: Express.Multer.File) {
|
||||||
const connectors = JSON.parse(uploadFile.file.buffer.toString('utf8'));
|
const res = await lastValueFrom(
|
||||||
|
this.connectorServiceWrite.RegisterMultipleConnectorsWithoutImage({
|
||||||
const body = connectors.map((connector) => {
|
connectors: uploadFile.buffer,
|
||||||
return JSON.stringify(connector);
|
}),
|
||||||
});
|
|
||||||
|
|
||||||
const request = {
|
|
||||||
connectors: body,
|
|
||||||
};
|
|
||||||
|
|
||||||
return lastValueFrom(
|
|
||||||
this.connectorServiceWrite.RegisterMultipleConnectorsWithoutImage(
|
|
||||||
request,
|
|
||||||
),
|
|
||||||
).catch((err) => {
|
).catch((err) => {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
err.details,
|
err.details,
|
||||||
err.code === 6 ? HttpStatus.CONFLICT : 400,
|
err.code === 6 ? HttpStatus.CONFLICT : 400,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
const responseParsed = JSON.parse(res.message);
|
||||||
|
const connectorErrors = responseParsed.items
|
||||||
|
.filter((i) => i.update._index === 'connector' && i.update.error)
|
||||||
|
.map((i) => ({
|
||||||
|
id: i.update._id,
|
||||||
|
reason: i.update.error,
|
||||||
|
status: i.error.status,
|
||||||
|
}));
|
||||||
|
const connectionControlsErrors = responseParsed.items
|
||||||
|
.filter(
|
||||||
|
(i) => i.update._index === 'connection_controls' && i.update.error,
|
||||||
|
)
|
||||||
|
.map((i) => ({
|
||||||
|
id: i.update._id,
|
||||||
|
reason: i.update.error,
|
||||||
|
status: i.error.status,
|
||||||
|
}));
|
||||||
|
const connectionStepsErrors = responseParsed.items
|
||||||
|
.filter((i) => i.update._index === 'connection_steps' && i.update.error)
|
||||||
|
.map((i) => ({
|
||||||
|
id: i.update._id,
|
||||||
|
reason: i.update.error,
|
||||||
|
status: i.error.status,
|
||||||
|
}));
|
||||||
|
const configControlsErrors = responseParsed.items
|
||||||
|
.filter((i) => i.update._index === 'config_controls' && i.update.error)
|
||||||
|
.map((i) => ({
|
||||||
|
id: i.update._id,
|
||||||
|
reason: i.update.error,
|
||||||
|
status: i.error.status,
|
||||||
|
}));
|
||||||
|
const connectorCreated = responseParsed.items
|
||||||
|
.filter(
|
||||||
|
(i) => i.update._index === 'connector' && i.update.result === 'created',
|
||||||
|
)
|
||||||
|
.map((i) => ({
|
||||||
|
id: i.update._id,
|
||||||
|
}));
|
||||||
|
const connectionControlsCreated = responseParsed.items
|
||||||
|
.filter(
|
||||||
|
(i) =>
|
||||||
|
i.update._index === 'connection_controls' &&
|
||||||
|
i.update.result === 'created',
|
||||||
|
)
|
||||||
|
.map((i) => ({
|
||||||
|
id: i.update._id,
|
||||||
|
}));
|
||||||
|
const connectionStepsCreated = responseParsed.items
|
||||||
|
.filter(
|
||||||
|
(i) =>
|
||||||
|
i.update._index === 'connection_steps' &&
|
||||||
|
i.update.result === 'created',
|
||||||
|
)
|
||||||
|
.map((i) => ({
|
||||||
|
id: i.update._id,
|
||||||
|
}));
|
||||||
|
const configControlsCreated = responseParsed.items
|
||||||
|
.filter(
|
||||||
|
(i) =>
|
||||||
|
i.update._index === 'config_controls' &&
|
||||||
|
i.update.result === 'created',
|
||||||
|
)
|
||||||
|
.map((i) => ({
|
||||||
|
id: i.update._id,
|
||||||
|
}));
|
||||||
|
const connectorUpdated = responseParsed.items
|
||||||
|
.filter(
|
||||||
|
(i) => i.update._index === 'connector' && i.update.result === 'updated',
|
||||||
|
)
|
||||||
|
.map((i) => ({
|
||||||
|
id: i.update._id,
|
||||||
|
}));
|
||||||
|
const connectionControlsUpdated = responseParsed.items
|
||||||
|
.filter(
|
||||||
|
(i) =>
|
||||||
|
i.update._index === 'connection_controls' &&
|
||||||
|
i.update.result === 'updated',
|
||||||
|
)
|
||||||
|
.map((i) => ({
|
||||||
|
id: i.update._id,
|
||||||
|
}));
|
||||||
|
const connectionStepsUpdated = responseParsed.items
|
||||||
|
.filter(
|
||||||
|
(i) =>
|
||||||
|
i.update._index === 'connection_steps' &&
|
||||||
|
i.update.result === 'updated',
|
||||||
|
)
|
||||||
|
.map((i) => ({
|
||||||
|
id: i.update._id,
|
||||||
|
}));
|
||||||
|
const configControlsUpdated = responseParsed.items
|
||||||
|
.filter(
|
||||||
|
(i) =>
|
||||||
|
i.update._index === 'config_controls' &&
|
||||||
|
i.update.result === 'updated',
|
||||||
|
)
|
||||||
|
.map((i) => ({
|
||||||
|
id: i.update._id,
|
||||||
|
}));
|
||||||
|
const connectorNoop = responseParsed.items
|
||||||
|
.filter(
|
||||||
|
(i) => i.update._index === 'connector' && i.update.result === 'noop',
|
||||||
|
)
|
||||||
|
.map((i) => ({
|
||||||
|
id: i.update._id,
|
||||||
|
}));
|
||||||
|
const connectionControlsNoop = responseParsed.items
|
||||||
|
.filter(
|
||||||
|
(i) =>
|
||||||
|
i.update._index === 'connection_controls' &&
|
||||||
|
i.update.result === 'noop',
|
||||||
|
)
|
||||||
|
.map((i) => ({
|
||||||
|
id: i.update._id,
|
||||||
|
}));
|
||||||
|
const connectionStepsNoop = responseParsed.items
|
||||||
|
.filter(
|
||||||
|
(i) =>
|
||||||
|
i.update._index === 'connection_steps' && i.update.result === 'noop',
|
||||||
|
)
|
||||||
|
.map((i) => ({
|
||||||
|
id: i.update._id,
|
||||||
|
}));
|
||||||
|
const configControlsNoop = responseParsed.items
|
||||||
|
.filter(
|
||||||
|
(i) =>
|
||||||
|
i.update._index === 'config_controls' && i.update.result === 'noop',
|
||||||
|
)
|
||||||
|
.map((i) => ({
|
||||||
|
id: i.update._id,
|
||||||
|
}));
|
||||||
|
return {
|
||||||
|
errors: {
|
||||||
|
connectors: connectorErrors,
|
||||||
|
connection_controls: connectionControlsErrors,
|
||||||
|
connection_steps: connectionStepsErrors,
|
||||||
|
config_controls: configControlsErrors,
|
||||||
|
},
|
||||||
|
created: {
|
||||||
|
connectors: connectorCreated,
|
||||||
|
connection_controls: connectionControlsCreated,
|
||||||
|
connection_steps: connectionStepsCreated,
|
||||||
|
config_controls: configControlsCreated,
|
||||||
|
},
|
||||||
|
updated: {
|
||||||
|
connectors: connectorUpdated,
|
||||||
|
connection_controls: connectionControlsUpdated,
|
||||||
|
connection_steps: connectionStepsUpdated,
|
||||||
|
config_controls: configControlsUpdated,
|
||||||
|
},
|
||||||
|
noop: {
|
||||||
|
connectors: connectorNoop,
|
||||||
|
connection_controls: connectionControlsNoop,
|
||||||
|
connection_steps: connectionStepsNoop,
|
||||||
|
config_controls: configControlsNoop,
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAllConnectors(body) {
|
async getAllConnectors(body) {
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import { ApiBearerAuth, ApiConsumes, ApiTags } from '@nestjs/swagger';
|
|||||||
import { ConnectorClientService } from './client.service';
|
import { ConnectorClientService } from './client.service';
|
||||||
import { AddTagDto } from './dtos/add-tag';
|
import { AddTagDto } from './dtos/add-tag';
|
||||||
import { CreateConnectorDto } from './dtos/create-connector';
|
import { CreateConnectorDto } from './dtos/create-connector';
|
||||||
import { UploadConnectorsFileDto } from './dtos/create-multiple-connector';
|
|
||||||
import { DeleteConnectorDto } from './dtos/delete-connector';
|
import { DeleteConnectorDto } from './dtos/delete-connector';
|
||||||
import { GetAllDto } from './dtos/get-all';
|
import { GetAllDto } from './dtos/get-all';
|
||||||
import { RemoveTagDto } from './dtos/remove-tag';
|
import { RemoveTagDto } from './dtos/remove-tag';
|
||||||
@@ -85,14 +84,10 @@ export class ConnectorController {
|
|||||||
@RequireAllPermissions(PERMISSIONS_GROUPS.CONNECTORS.permissions.CREATE)
|
@RequireAllPermissions(PERMISSIONS_GROUPS.CONNECTORS.permissions.CREATE)
|
||||||
@ApiConsumes('multipart/form-data')
|
@ApiConsumes('multipart/form-data')
|
||||||
@UseInterceptors(FileInterceptor('file'))
|
@UseInterceptors(FileInterceptor('file'))
|
||||||
async uploadConnectorsFile(@UploadedFile() file: UploadConnectorsFileDto) {
|
async uploadConnectorsFile(@UploadedFile() file: Express.Multer.File) {
|
||||||
this.logger.info(`/upload`, 'Upload Connector Route');
|
this.logger.info(`/upload`, 'Upload Connector Route');
|
||||||
|
|
||||||
const response = await this.connectorClientService.uploadConnectorsFile({
|
return await this.connectorClientService.uploadConnectorsFile(file);
|
||||||
file,
|
|
||||||
});
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ import { ConnectionClientService } from '../connection/client.service';
|
|||||||
import jwt from 'jsonwebtoken';
|
import jwt from 'jsonwebtoken';
|
||||||
import DadosferaLogger from '@dadosfera/dadosfera-logs/dist';
|
import DadosferaLogger from '@dadosfera/dadosfera-logs/dist';
|
||||||
import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
|
import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
|
||||||
import { Authenticated } from 'src/authentication/authentication.decorator';
|
|
||||||
@ApiTags('oauth')
|
@ApiTags('oauth')
|
||||||
@Authenticated()
|
|
||||||
@Controller('oauth')
|
@Controller('oauth')
|
||||||
export class OauthController {
|
export class OauthController {
|
||||||
redirectUrl: string;
|
redirectUrl: string;
|
||||||
|
|||||||
@@ -103,14 +103,9 @@ export class PipelinesController {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const response = await this.pipelinesClientService.findAll(data, metadata);
|
const response = await this.pipelinesClientService.findAll(data, metadata);
|
||||||
const oldResponse = await this.oldPipelinesService.findAll({
|
|
||||||
customer_name,
|
|
||||||
user_id,
|
|
||||||
customer_id,
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pipelines: [...response.pipelines, ...oldResponse.pipelines],
|
pipelines: [...response.pipelines],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,13 +144,6 @@ export class PipelinesController {
|
|||||||
: {},
|
: {},
|
||||||
});
|
});
|
||||||
return res;
|
return res;
|
||||||
})
|
|
||||||
.catch(async (err) => {
|
|
||||||
this.logger.error(err);
|
|
||||||
return await this.oldPipelinesService.findOne({
|
|
||||||
id,
|
|
||||||
info: { customer_id, customer: customer_name, user_id },
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
|||||||
|
|
||||||
import { GrpcToHttpExceptionFilter } from '../../error/grpc-to-http-exception.filter';
|
import { GrpcToHttpExceptionFilter } from '../../error/grpc-to-http-exception.filter';
|
||||||
import { RequestUser, User } from '../../authentication/user.decorator';
|
import { RequestUser, User } from '../../authentication/user.decorator';
|
||||||
|
import { Metadata } from '@grpc/grpc-js';
|
||||||
|
|
||||||
@ApiTags('TermsOfUse')
|
@ApiTags('TermsOfUse')
|
||||||
@UseFilters(new GrpcToHttpExceptionFilter())
|
@UseFilters(new GrpcToHttpExceptionFilter())
|
||||||
@@ -33,10 +34,15 @@ export class TermsOfUseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get('token')
|
@Get('token')
|
||||||
async getToken(@User({ required: true }) user: RequestUser) {
|
async getToken(
|
||||||
|
@User({ required: true }) user: RequestUser,
|
||||||
|
@Headers('Dadosfera-Lang') language: string,
|
||||||
|
) {
|
||||||
this.logger.info('/terms-of-use - get token');
|
this.logger.info('/terms-of-use - get token');
|
||||||
|
const metadata = new Metadata();
|
||||||
|
metadata.add('language', language || 'pt-br');
|
||||||
|
|
||||||
return this.termsOfUseClient.getToken({ userId: user.user_id });
|
return this.termsOfUseClient.getToken({ userId: user.user_id }, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('accept')
|
@Post('accept')
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
TermsOfUseAcceptRequest,
|
TermsOfUseAcceptRequest,
|
||||||
} from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages';
|
} from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages';
|
||||||
import { DucClient } from '../duc/client.config';
|
import { DucClient } from '../duc/client.config';
|
||||||
|
import { Metadata } from '@grpc/grpc-js';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TermsOfUseClientService implements OnModuleInit {
|
export class TermsOfUseClientService implements OnModuleInit {
|
||||||
@@ -31,8 +32,10 @@ export class TermsOfUseClientService implements OnModuleInit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getToken(data: TermsOfUseGetTokenRequest) {
|
async getToken(data: TermsOfUseGetTokenRequest, metadata: Metadata) {
|
||||||
return lastValueFrom(this.termsOfUseService.TermsOfUseGetToken(data));
|
return lastValueFrom(
|
||||||
|
this.termsOfUseService.TermsOfUseGetToken(data, metadata),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async accept(data: TermsOfUseAcceptRequest) {
|
async accept(data: TermsOfUseAcceptRequest) {
|
||||||
|
|||||||
@@ -55,7 +55,10 @@ export class UserNoRoles extends OmitType(User, ['roles']) {}
|
|||||||
export class UserNoRolesAndCustomer extends OmitType(UserNoRoles, [
|
export class UserNoRolesAndCustomer extends OmitType(UserNoRoles, [
|
||||||
'customer',
|
'customer',
|
||||||
]) {}
|
]) {}
|
||||||
export class UserByCustomer extends OmitType(User, ['customer']) {}
|
export class IUserByCustomer extends OmitType(User, ['customer']) {
|
||||||
|
@ApiPropertyOptional()
|
||||||
|
permissions?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
export class CreateUserReq {
|
export class CreateUserReq {
|
||||||
@ApiPropertyOptional()
|
@ApiPropertyOptional()
|
||||||
@@ -111,11 +114,11 @@ export class UpdateUserReq {
|
|||||||
|
|
||||||
export class UpdateUserRes {
|
export class UpdateUserRes {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
user: UserByCustomer;
|
user: IUserByCustomer;
|
||||||
}
|
}
|
||||||
export class GetAllUsersByCustomerIdRes {
|
export class GetAllUsersByCustomerIdRes {
|
||||||
@ApiProperty({ type: [UserByCustomer] })
|
@ApiProperty({ type: [IUserByCustomer] })
|
||||||
users: UserByCustomer[];
|
users: IUserByCustomer[];
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
departments: string[];
|
departments: string[];
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
@@ -153,7 +156,7 @@ export class SetUserRolesReq {
|
|||||||
|
|
||||||
export class SetUserRolesRes {
|
export class SetUserRolesRes {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
user: UserByCustomer;
|
user: IUserByCustomer;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SearchUserRes extends GetAllUsersByCustomerIdRes {}
|
export class SearchUserRes extends GetAllUsersByCustomerIdRes {}
|
||||||
|
|||||||
@@ -45,10 +45,12 @@ import {
|
|||||||
UnassignRoleToUserReq,
|
UnassignRoleToUserReq,
|
||||||
UpdateUserReq,
|
UpdateUserReq,
|
||||||
UpdateUserRes,
|
UpdateUserRes,
|
||||||
UserByCustomer,
|
IUserByCustomer,
|
||||||
} from './dtos/entities';
|
} from './dtos/entities';
|
||||||
import { UsersService } from './users.service';
|
import { UsersService } from './users.service';
|
||||||
import { Metadata } from '@grpc/grpc-js';
|
import { Metadata } from '@grpc/grpc-js';
|
||||||
|
import ErrorBuilder from 'src/utils/ErrorBuilder';
|
||||||
|
import ErrorCodes from 'src/utils/errorCodes';
|
||||||
|
|
||||||
// TODO GET de hierarquias e do PATCH em usuário
|
// TODO GET de hierarquias e do PATCH em usuário
|
||||||
@ApiTags('Users')
|
@ApiTags('Users')
|
||||||
@@ -123,9 +125,8 @@ export class UsersController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
@RequireAllPermissions(PERMISSIONS_GROUPS.USERS.permissions.ADMIN)
|
|
||||||
@ApiOkResponse({
|
@ApiOkResponse({
|
||||||
type: UserByCustomer,
|
type: IUserByCustomer,
|
||||||
})
|
})
|
||||||
async findOneById(
|
async findOneById(
|
||||||
@User() user: RequestUser,
|
@User() user: RequestUser,
|
||||||
@@ -134,6 +135,14 @@ export class UsersController {
|
|||||||
) {
|
) {
|
||||||
this.logger.info('findOneById', { user });
|
this.logger.info('findOneById', { user });
|
||||||
this.userService.setLanguage(language);
|
this.userService.setLanguage(language);
|
||||||
|
if (
|
||||||
|
id !== user.user_id &&
|
||||||
|
!user.permissions.includes(
|
||||||
|
PERMISSIONS_GROUPS.USERS.permissions.ADMIN.seqid,
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
throw new ErrorBuilder(ErrorCodes.AUTH.FORBIDDEN);
|
||||||
|
}
|
||||||
return await this.userService.findOneById(id);
|
return await this.userService.findOneById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
BatchCreateUserReq,
|
BatchCreateUserReq,
|
||||||
CreateUserReq,
|
CreateUserReq,
|
||||||
Hierarchy,
|
Hierarchy,
|
||||||
|
IUserByCustomer,
|
||||||
SetUserRolesReq,
|
SetUserRolesReq,
|
||||||
UpdateUserReq,
|
UpdateUserReq,
|
||||||
} from './dtos/entities';
|
} from './dtos/entities';
|
||||||
@@ -77,11 +78,21 @@ export class UsersService implements OnModuleInit {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async findOneById(id: string) {
|
async findOneById(id: string): Promise<{ user: IUserByCustomer }> {
|
||||||
const { user } = await lastValueFrom(
|
const { user } = await lastValueFrom(
|
||||||
this.usersClientService.UserFindOneById({ id }),
|
this.usersClientService.UserFindOneById({ id }),
|
||||||
);
|
);
|
||||||
return { user: this.adjustUsersPayload([user])[0] };
|
const res: { user: IUserByCustomer } = {
|
||||||
|
user: this.adjustUsersPayload([user])[0],
|
||||||
|
};
|
||||||
|
if (res.user.roles?.length) {
|
||||||
|
const allPermissions = res.user.roles.flatMap((r) => r.permissions);
|
||||||
|
const distinctPermissions = Array.from(
|
||||||
|
new Set(allPermissions.map((p) => p.claim)),
|
||||||
|
);
|
||||||
|
res.user.permissions = distinctPermissions;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
async createUser(req: CreateUserReq, meta?: Metadata) {
|
async createUser(req: CreateUserReq, meta?: Metadata) {
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user