mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-27 23:30:05 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b52a1227b1 | ||
|
|
31478ed61d | ||
|
|
79b1ba910e | ||
|
|
7fd929915b | ||
|
|
e4b27c5f76 | ||
|
|
92e449d6d3 | ||
|
|
5073b2e188 | ||
|
|
8a11eda24d | ||
|
|
9d732d4a48 | ||
|
|
5fa10a939b | ||
|
|
4be3ffe3a2 | ||
|
|
8af9c638ef | ||
|
|
97d6f914cc | ||
|
|
9ad2e3770e | ||
|
|
ea2cc8809f | ||
|
|
410e190e7c |
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",
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import { HealthModule } from './modules/health/health.module';
|
|||||||
import { CatalogModule } from './modules/catalog/catalog.module';
|
import { CatalogModule } from './modules/catalog/catalog.module';
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { PipelinesV2Module } from './modules/pipelinesV2/pipelines.module';
|
import { PipelinesV2Module } from './modules/pipelinesV2/pipelines.module';
|
||||||
|
import { ProductboardModule } from './modules/productboard/productboard.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
controllers: [],
|
controllers: [],
|
||||||
@@ -54,6 +55,7 @@ import { PipelinesV2Module } from './modules/pipelinesV2/pipelines.module';
|
|||||||
OauthModule,
|
OauthModule,
|
||||||
PipelinesV2Module,
|
PipelinesV2Module,
|
||||||
CatalogModule,
|
CatalogModule,
|
||||||
|
ProductboardModule,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class AppModule {}
|
export class AppModule {}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import {
|
|||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
|
ForbiddenException,
|
||||||
Get,
|
Get,
|
||||||
HttpException,
|
HttpException,
|
||||||
Inject,
|
Inject,
|
||||||
@@ -11,7 +12,10 @@ import {
|
|||||||
Query,
|
Query,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
import { AuthenticateCondition } from '../../authentication/authentication.decorator';
|
import {
|
||||||
|
AuthenticateCondition,
|
||||||
|
Authenticated,
|
||||||
|
} from '../../authentication/authentication.decorator';
|
||||||
import { PERMISSIONS_GROUPS } from '../../authentication/permissions.enum';
|
import { PERMISSIONS_GROUPS } from '../../authentication/permissions.enum';
|
||||||
import { CatalogService } from './catalog.service';
|
import { CatalogService } from './catalog.service';
|
||||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||||
@@ -20,7 +24,9 @@ import { RequestUser, User } from 'src/authentication/user.decorator';
|
|||||||
|
|
||||||
@ApiTags('Catalog')
|
@ApiTags('Catalog')
|
||||||
@Controller('catalog')
|
@Controller('catalog')
|
||||||
|
@Authenticated()
|
||||||
@AuthenticateCondition((req, user) => {
|
@AuthenticateCondition((req, user) => {
|
||||||
|
if (req.path.includes('/manage_permissions/')) return true;
|
||||||
let action;
|
let action;
|
||||||
|
|
||||||
switch (req.method) {
|
switch (req.method) {
|
||||||
@@ -205,8 +211,8 @@ export class CatalogController {
|
|||||||
if (dashboard.p_users.includes(user_id)) has_permission = true;
|
if (dashboard.p_users.includes(user_id)) has_permission = true;
|
||||||
|
|
||||||
if (is_data_manager || has_permission) {
|
if (is_data_manager || has_permission) {
|
||||||
delete res[0].p_roles;
|
delete dashboard.p_roles;
|
||||||
delete res[0].p_users;
|
delete dashboard.p_users;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,14 +265,13 @@ export class CatalogController {
|
|||||||
if (table.p_users.includes(user_id)) has_permission = true;
|
if (table.p_users.includes(user_id)) has_permission = true;
|
||||||
|
|
||||||
if (is_data_manager || has_permission) {
|
if (is_data_manager || has_permission) {
|
||||||
delete res[0].p_roles;
|
delete table.p_roles;
|
||||||
delete res[0].p_users;
|
delete table.p_users;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new HttpException(
|
throw new ForbiddenException(
|
||||||
'You do not have permission to access this data asset.',
|
'You do not have permission to access this data asset.',
|
||||||
403,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
@@ -19,17 +19,18 @@ import { RequestUser, User } from 'src/authentication/user.decorator';
|
|||||||
import {
|
import {
|
||||||
CreateNetworkConfigReq,
|
CreateNetworkConfigReq,
|
||||||
CreateNetworkConfigRes,
|
CreateNetworkConfigRes,
|
||||||
DeleteNetworkConfigRes,
|
|
||||||
FindAllNetworkConfigsRes,
|
FindAllNetworkConfigsRes,
|
||||||
UpdateNetworkConfigReq,
|
|
||||||
UpdateNetworkConfigRes,
|
|
||||||
} from './dto/network-config';
|
} from './dto/network-config';
|
||||||
import { FileInterceptor } from '@nestjs/platform-express';
|
import { FileInterceptor } from '@nestjs/platform-express';
|
||||||
import { PERMISSIONS_GROUPS } from 'src/authentication/permissions.enum';
|
import { PERMISSIONS_GROUPS } from 'src/authentication/permissions.enum';
|
||||||
import { RequireAllPermissions } from 'src/authentication/authentication.decorator';
|
import {
|
||||||
|
Authenticated,
|
||||||
|
RequireAllPermissions,
|
||||||
|
} from 'src/authentication/authentication.decorator';
|
||||||
|
|
||||||
const networkConfigPermissions = PERMISSIONS_GROUPS.NETWORK_CONFIG.permissions;
|
const networkConfigPermissions = PERMISSIONS_GROUPS.NETWORK_CONFIG.permissions;
|
||||||
@ApiTags('Network Config')
|
@ApiTags('Network Config')
|
||||||
|
@Authenticated()
|
||||||
@Controller('network-config')
|
@Controller('network-config')
|
||||||
export class NetworkConfigController {
|
export class NetworkConfigController {
|
||||||
logger: any;
|
logger: any;
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ 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;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { GetPublicPermissionsRes } from './dto/entities';
|
|||||||
import { PermissionsService } from './permissions.service';
|
import { PermissionsService } from './permissions.service';
|
||||||
|
|
||||||
@ApiTags('Permissions')
|
@ApiTags('Permissions')
|
||||||
|
@Authenticated()
|
||||||
@Controller('permissions')
|
@Controller('permissions')
|
||||||
@ApiHeader({
|
@ApiHeader({
|
||||||
name: 'dadosfera-lang',
|
name: 'dadosfera-lang',
|
||||||
@@ -22,7 +23,6 @@ import { PermissionsService } from './permissions.service';
|
|||||||
required: false,
|
required: false,
|
||||||
description: 'Defaults to pt-br',
|
description: 'Defaults to pt-br',
|
||||||
})
|
})
|
||||||
@Authenticated()
|
|
||||||
export class PermissionsController {
|
export class PermissionsController {
|
||||||
logger: DadosferaLogger;
|
logger: DadosferaLogger;
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,10 @@ import {
|
|||||||
Put,
|
Put,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
import { AuthenticateCondition } from 'src/authentication/authentication.decorator';
|
import {
|
||||||
|
AuthenticateCondition,
|
||||||
|
Authenticated,
|
||||||
|
} from 'src/authentication/authentication.decorator';
|
||||||
import { PERMISSIONS_GROUPS } from '../../authentication/permissions.enum';
|
import { PERMISSIONS_GROUPS } from '../../authentication/permissions.enum';
|
||||||
import { PipelinesService } from './pipelines.service';
|
import { PipelinesService } from './pipelines.service';
|
||||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||||
@@ -17,6 +20,7 @@ import { RequestUser, User } from 'src/authentication/user.decorator';
|
|||||||
|
|
||||||
@ApiTags('Pipelines')
|
@ApiTags('Pipelines')
|
||||||
@Controller('pipelines')
|
@Controller('pipelines')
|
||||||
|
@Authenticated()
|
||||||
@AuthenticateCondition((req, user) => {
|
@AuthenticateCondition((req, user) => {
|
||||||
let action;
|
let action;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
|
||||||
|
export class INote {
|
||||||
|
@ApiProperty()
|
||||||
|
title: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
content: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
tags: string[];
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { ProductboardController } from './productboard.controller';
|
||||||
|
|
||||||
|
describe('ProductboardController', () => {
|
||||||
|
let controller: ProductboardController;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
controllers: [ProductboardController],
|
||||||
|
providers: [],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
controller = module.get<ProductboardController>(ProductboardController);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(controller).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import { Body, Controller, HttpException, Post } from '@nestjs/common';
|
||||||
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
|
import axios from 'axios';
|
||||||
|
import { User, RequestUser } from 'src/authentication/user.decorator';
|
||||||
|
import { getSecreteFromSecreteManager } from 'src/utils/SecretManager';
|
||||||
|
import { INote } from './dtos';
|
||||||
|
|
||||||
|
@ApiTags('Productboard')
|
||||||
|
@Controller('productboard')
|
||||||
|
export class ProductboardController {
|
||||||
|
@Post('notes')
|
||||||
|
async sendNote(@Body() note: INote, @User() user: RequestUser) {
|
||||||
|
const { title, content, tags } = note;
|
||||||
|
const { username, customer_name } = user;
|
||||||
|
|
||||||
|
const email = username.includes('@')
|
||||||
|
? username
|
||||||
|
: username + `@${customer_name}.default`;
|
||||||
|
|
||||||
|
const path = process.env.PB_TOKEN_PATH;
|
||||||
|
const token = await getSecreteFromSecreteManager(path);
|
||||||
|
|
||||||
|
const response = await axios
|
||||||
|
.post(
|
||||||
|
`https://api.productboard.com/notes`,
|
||||||
|
{
|
||||||
|
title,
|
||||||
|
content,
|
||||||
|
tags,
|
||||||
|
user: {
|
||||||
|
email,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: 'Bearer ' + token,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.catch(() => null);
|
||||||
|
|
||||||
|
if (!response) {
|
||||||
|
throw new HttpException(
|
||||||
|
'Your request could not be submitted, please try again in a few moments or contact support.',
|
||||||
|
502,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { ProductboardController } from './productboard.controller';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
controllers: [ProductboardController],
|
||||||
|
providers: [],
|
||||||
|
})
|
||||||
|
export class ProductboardModule {}
|
||||||
@@ -53,8 +53,8 @@ import { LanguageEnum } from 'src/utils/languages.enum';
|
|||||||
required: false,
|
required: false,
|
||||||
description: 'Defaults to pt-br',
|
description: 'Defaults to pt-br',
|
||||||
})
|
})
|
||||||
@UseFilters(new GrpcToHttpExceptionFilter())
|
|
||||||
@Authenticated()
|
@Authenticated()
|
||||||
|
@UseFilters(new GrpcToHttpExceptionFilter())
|
||||||
@Controller('roles')
|
@Controller('roles')
|
||||||
export class RolesController {
|
export class RolesController {
|
||||||
logger: DadosferaLogger;
|
logger: DadosferaLogger;
|
||||||
|
|||||||
@@ -21,7 +21,10 @@ import {
|
|||||||
ApiTags,
|
ApiTags,
|
||||||
} from '@nestjs/swagger';
|
} from '@nestjs/swagger';
|
||||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||||
import { RequireAllPermissions } from 'src/authentication/authentication.decorator';
|
import {
|
||||||
|
Authenticated,
|
||||||
|
RequireAllPermissions,
|
||||||
|
} from 'src/authentication/authentication.decorator';
|
||||||
import { PERMISSIONS_GROUPS } from 'src/authentication/permissions.enum';
|
import { PERMISSIONS_GROUPS } from 'src/authentication/permissions.enum';
|
||||||
import { RequestUser, User } from 'src/authentication/user.decorator';
|
import { RequestUser, User } from 'src/authentication/user.decorator';
|
||||||
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
|
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
|
||||||
@@ -56,6 +59,7 @@ import { Metadata } from '@grpc/grpc-js';
|
|||||||
required: false,
|
required: false,
|
||||||
description: 'Defaults to pt-br',
|
description: 'Defaults to pt-br',
|
||||||
})
|
})
|
||||||
|
@Authenticated()
|
||||||
@UseFilters(GrpcToHttpExceptionFilter)
|
@UseFilters(GrpcToHttpExceptionFilter)
|
||||||
export class UsersController {
|
export class UsersController {
|
||||||
logger: DadosferaLogger;
|
logger: DadosferaLogger;
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import {
|
||||||
|
SecretsManagerClient,
|
||||||
|
GetSecretValueCommand,
|
||||||
|
} from '@aws-sdk/client-secrets-manager';
|
||||||
|
|
||||||
|
export async function getSecreteFromSecreteManager(path: string) {
|
||||||
|
const secretsManagerClient = new SecretsManagerClient({});
|
||||||
|
|
||||||
|
const getSecretComand = new GetSecretValueCommand({
|
||||||
|
SecretId: `${path}`,
|
||||||
|
});
|
||||||
|
const res = await secretsManagerClient
|
||||||
|
.send(getSecretComand)
|
||||||
|
.catch(() => null);
|
||||||
|
|
||||||
|
return res?.SecretString;
|
||||||
|
}
|
||||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user