mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-27 18:50:06 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7062efc60 | ||
|
|
4a3dd98977 | ||
|
|
06f4260b61 | ||
|
|
64717c8d92 | ||
|
|
131e82b4c5 | ||
|
|
32d37ecadf | ||
|
|
4d667acb86 | ||
|
|
9d417ff61b | ||
|
|
703b5f36b3 | ||
|
|
54d10cb873 | ||
|
|
3c877b8b8d | ||
|
|
e6b0034805 | ||
|
|
b9c1f784d3 | ||
|
|
3edf5c2416 | ||
|
|
f3e00a15c8 | ||
|
|
0422c7a369 | ||
|
|
f22d9370db | ||
|
|
a9ee74724f |
@@ -10,7 +10,6 @@ on:
|
|||||||
required: true
|
required: true
|
||||||
type: choice
|
type: choice
|
||||||
options:
|
options:
|
||||||
- dev
|
|
||||||
- stg
|
- stg
|
||||||
- stg2
|
- stg2
|
||||||
- prd
|
- prd
|
||||||
|
|||||||
+11
-24
@@ -505,18 +505,16 @@
|
|||||||
"schema": {
|
"schema": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
],
|
{
|
||||||
"requestBody": {
|
"name": "version",
|
||||||
"required": true,
|
"required": true,
|
||||||
"content": {
|
"in": "query",
|
||||||
"application/json": {
|
"schema": {
|
||||||
"schema": {
|
"type": "string"
|
||||||
"$ref": "#/components/schemas/DeleteConnectorDto"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": ""
|
"description": ""
|
||||||
@@ -948,7 +946,7 @@
|
|||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "List of users of a customer",
|
"description": "",
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
@@ -3235,9 +3233,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"info": {
|
"info": {
|
||||||
"title": "Maestro - feature/update-pipeline-cron",
|
"title": "Maestro - stg2",
|
||||||
"description": "Documentation for Maestro gateway",
|
"description": "Documentation for Maestro gateway",
|
||||||
"version": "25.11.2022 - 12:58",
|
"version": "0.0.0",
|
||||||
"contact": {}
|
"contact": {}
|
||||||
},
|
},
|
||||||
"tags": [],
|
"tags": [],
|
||||||
@@ -3505,17 +3503,6 @@
|
|||||||
"tags"
|
"tags"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"DeleteConnectorDto": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"version": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"version"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"PermissionGroupPermission": {
|
"PermissionGroupPermission": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
+1
-7
@@ -30,12 +30,8 @@ async function bootstrap() {
|
|||||||
|
|
||||||
await app.listen(3333);
|
await app.listen(3333);
|
||||||
}
|
}
|
||||||
function configureSwagger(app: INestApplication) {
|
|
||||||
const date = new Date();
|
|
||||||
const swaggerVersion = `${date.getDate()}.${
|
|
||||||
date.getMonth() + 1
|
|
||||||
}.${date.getFullYear()} - ${date.getHours()}:${date.getMinutes()}`;
|
|
||||||
|
|
||||||
|
function configureSwagger(app: INestApplication) {
|
||||||
let branchName = '';
|
let branchName = '';
|
||||||
try {
|
try {
|
||||||
branchName = execSync('git rev-parse --abbrev-ref HEAD')
|
branchName = execSync('git rev-parse --abbrev-ref HEAD')
|
||||||
@@ -50,7 +46,6 @@ function configureSwagger(app: INestApplication) {
|
|||||||
const config = new DocumentBuilder()
|
const config = new DocumentBuilder()
|
||||||
.setTitle(swaggerTitle)
|
.setTitle(swaggerTitle)
|
||||||
.setDescription('Documentation for Maestro gateway')
|
.setDescription('Documentation for Maestro gateway')
|
||||||
.setVersion(swaggerVersion)
|
|
||||||
.addBearerAuth(
|
.addBearerAuth(
|
||||||
{ type: 'http', scheme: 'bearer', bearerFormat: 'JWT' },
|
{ type: 'http', scheme: 'bearer', bearerFormat: 'JWT' },
|
||||||
'Authorization',
|
'Authorization',
|
||||||
@@ -60,7 +55,6 @@ function configureSwagger(app: INestApplication) {
|
|||||||
const document = SwaggerModule.createDocument(app, config);
|
const document = SwaggerModule.createDocument(app, config);
|
||||||
|
|
||||||
if (process.env.ENV === 'local') SwaggerModule.setup('api', app, document);
|
if (process.env.ENV === 'local') SwaggerModule.setup('api', app, document);
|
||||||
|
|
||||||
writeFileSync(
|
writeFileSync(
|
||||||
'docsfera.json',
|
'docsfera.json',
|
||||||
JSON.stringify(
|
JSON.stringify(
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
import {
|
import { OnModuleInit, Inject } from '@nestjs/common';
|
||||||
OnModuleInit,
|
|
||||||
Inject,
|
|
||||||
HttpException,
|
|
||||||
HttpStatus,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { ClientGrpc } from '@nestjs/microservices';
|
import { ClientGrpc } from '@nestjs/microservices';
|
||||||
import { ConnectionManager } from '@dadosfera/protospack-v2';
|
import { ConnectionManager } from '@dadosfera/protospack-v2';
|
||||||
import { lastValueFrom } from 'rxjs';
|
import { lastValueFrom } from 'rxjs';
|
||||||
@@ -86,12 +81,7 @@ export class ConnectionClientService implements OnModuleInit {
|
|||||||
},
|
},
|
||||||
metadata,
|
metadata,
|
||||||
),
|
),
|
||||||
).catch((err) => {
|
);
|
||||||
throw new HttpException(
|
|
||||||
err.details,
|
|
||||||
err.code === 6 ? HttpStatus.CONFLICT : 400,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateConnection(
|
async updateConnection(
|
||||||
@@ -112,12 +102,7 @@ export class ConnectionClientService implements OnModuleInit {
|
|||||||
},
|
},
|
||||||
metadata,
|
metadata,
|
||||||
),
|
),
|
||||||
).catch((err) => {
|
);
|
||||||
throw new HttpException(
|
|
||||||
err.details,
|
|
||||||
err.code === 6 ? HttpStatus.CONFLICT : 400,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteConnection({ body, metadata }): Promise<ConnectionRes> {
|
async deleteConnection({ body, metadata }): Promise<ConnectionRes> {
|
||||||
@@ -130,12 +115,7 @@ export class ConnectionClientService implements OnModuleInit {
|
|||||||
},
|
},
|
||||||
metadata,
|
metadata,
|
||||||
),
|
),
|
||||||
).catch((err) => {
|
);
|
||||||
throw new HttpException(
|
|
||||||
err.details,
|
|
||||||
err.code === 6 ? HttpStatus.CONFLICT : 400,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAllConnections({ body, metadata }): Promise<ConnectionsRes> {
|
async getAllConnections({ body, metadata }): Promise<ConnectionsRes> {
|
||||||
@@ -146,12 +126,7 @@ export class ConnectionClientService implements OnModuleInit {
|
|||||||
{ search, filters: JSON.stringify(filters), size, page },
|
{ search, filters: JSON.stringify(filters), size, page },
|
||||||
metadata,
|
metadata,
|
||||||
),
|
),
|
||||||
).catch((err) => {
|
);
|
||||||
throw new HttpException(
|
|
||||||
err.details,
|
|
||||||
err.code === 6 ? HttpStatus.CONFLICT : 400,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getConnectionDetails({
|
async getConnectionDetails({
|
||||||
@@ -162,12 +137,7 @@ export class ConnectionClientService implements OnModuleInit {
|
|||||||
|
|
||||||
return lastValueFrom(
|
return lastValueFrom(
|
||||||
this.connectionServiceRead.GetConnectionDetails({ id }, metadata),
|
this.connectionServiceRead.GetConnectionDetails({ id }, metadata),
|
||||||
).catch((err) => {
|
);
|
||||||
throw new HttpException(
|
|
||||||
err.details,
|
|
||||||
err.code === 6 ? HttpStatus.CONFLICT : 400,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async INTERNAL_getAllConnections({
|
async INTERNAL_getAllConnections({
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
Get,
|
Get,
|
||||||
Headers,
|
Headers,
|
||||||
Query,
|
Query,
|
||||||
|
UseFilters,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
import { ConnectionClientService } from './client.service';
|
import { ConnectionClientService } from './client.service';
|
||||||
@@ -28,8 +29,10 @@ import {
|
|||||||
} from './dtos/connection';
|
} from './dtos/connection';
|
||||||
import { CreateConnectionDto } from './dtos/connection';
|
import { CreateConnectionDto } from './dtos/connection';
|
||||||
import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
|
import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
|
||||||
|
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
|
||||||
|
|
||||||
const connectionPermissions = PERMISSIONS_GROUPS.CONNECTION.permissions;
|
const connectionPermissions = PERMISSIONS_GROUPS.CONNECTION.permissions;
|
||||||
|
@UseFilters(new GrpcToHttpExceptionFilter())
|
||||||
@ApiTags('connections')
|
@ApiTags('connections')
|
||||||
@ApiBearerAuth()
|
@ApiBearerAuth()
|
||||||
@Authenticated()
|
@Authenticated()
|
||||||
|
|||||||
@@ -83,163 +83,30 @@ export class ConnectorClientService implements OnModuleInit {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
const responseParsed = JSON.parse(res.message);
|
const responseParsed = JSON.parse(res.message);
|
||||||
const connectorErrors = responseParsed.items
|
const connectorsResponse = responseParsed.items.filter(
|
||||||
.filter((i) => i.update._index === 'connectors' && i.update.error)
|
(i) => i.update._index === process.env.CONNECTORS_INDEX,
|
||||||
|
);
|
||||||
|
const connectorErrors = connectorsResponse
|
||||||
|
.filter((i) => i.update.error)
|
||||||
.map((i) => ({
|
.map((i) => ({
|
||||||
id: i.update._id,
|
id: i.update?._id,
|
||||||
reason: i.update.error,
|
reason: i.update?.error,
|
||||||
status: i.error.status,
|
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 === 'connectors' && 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 === 'connectors' && 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 === 'connectors' && 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,
|
|
||||||
}));
|
}));
|
||||||
|
const connectorCreated = connectorsResponse
|
||||||
|
.filter((i) => i.update.result === 'created')
|
||||||
|
.map((i) => i.update._id);
|
||||||
|
const connectorUpdated = connectorsResponse
|
||||||
|
.filter((i) => i.update.result === 'updated')
|
||||||
|
.map((i) => i.update._id);
|
||||||
|
const connectorNoop = connectorsResponse
|
||||||
|
.filter((i) => i.update.result === 'noop')
|
||||||
|
.map((i) => i.update._id);
|
||||||
return {
|
return {
|
||||||
errors: {
|
errors: connectorErrors,
|
||||||
connectors: connectorErrors,
|
created: connectorCreated,
|
||||||
connection_controls: connectionControlsErrors,
|
updated: connectorUpdated,
|
||||||
connection_steps: connectionStepsErrors,
|
noop: connectorNoop,
|
||||||
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,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,12 +185,7 @@ export class ConnectorClientService implements OnModuleInit {
|
|||||||
version,
|
version,
|
||||||
plugin,
|
plugin,
|
||||||
}),
|
}),
|
||||||
).catch((err) => {
|
);
|
||||||
throw new HttpException(
|
|
||||||
err.details,
|
|
||||||
err.code === 6 ? HttpStatus.CONFLICT : 400,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateConnector({ plugin, changes }) {
|
async updateConnector({ plugin, changes }) {
|
||||||
|
|||||||
@@ -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 { 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';
|
||||||
import { UpdateDto } from './dtos/update';
|
import { UpdateDto } from './dtos/update';
|
||||||
@@ -274,7 +273,7 @@ export class ConnectorController {
|
|||||||
@RequireAllPermissions(PERMISSIONS_GROUPS.CONNECTORS.permissions.DELETE)
|
@RequireAllPermissions(PERMISSIONS_GROUPS.CONNECTORS.permissions.DELETE)
|
||||||
async deleteConnector(
|
async deleteConnector(
|
||||||
@Param('plugin') plugin: string,
|
@Param('plugin') plugin: string,
|
||||||
@Body() { version }: DeleteConnectorDto,
|
@Query('version') version: string,
|
||||||
) {
|
) {
|
||||||
this.logger.info('/upload - Upload Connector Route');
|
this.logger.info('/upload - Upload Connector Route');
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
import {
|
import { BadRequestException, Inject, OnModuleInit } from '@nestjs/common';
|
||||||
BadRequestException,
|
|
||||||
Inject,
|
|
||||||
InternalServerErrorException,
|
|
||||||
OnModuleInit,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { ClientGrpc } from '@nestjs/microservices';
|
import { ClientGrpc } from '@nestjs/microservices';
|
||||||
import {
|
import {
|
||||||
Messages,
|
Messages,
|
||||||
@@ -23,6 +18,8 @@ import { InputsService } from '../inputs/inputs.service';
|
|||||||
import { RequestUser } from 'src/authentication/user.decorator';
|
import { RequestUser } from 'src/authentication/user.decorator';
|
||||||
import { TransformationsService } from '../transformations/transformations.service';
|
import { TransformationsService } from '../transformations/transformations.service';
|
||||||
import { getObjValueFromPath } from 'src/utils/ObjValueFromPath';
|
import { getObjValueFromPath } from 'src/utils/ObjValueFromPath';
|
||||||
|
import ErrorCodes from 'src/utils/errorCodes';
|
||||||
|
import ErrorBuilder from 'src/utils/ErrorBuilder';
|
||||||
|
|
||||||
export class PipelinesService implements OnModuleInit {
|
export class PipelinesService implements OnModuleInit {
|
||||||
logger: DadosferaLogger;
|
logger: DadosferaLogger;
|
||||||
@@ -99,7 +96,7 @@ export class PipelinesService implements OnModuleInit {
|
|||||||
const [errorType, message] = error.details.split('|');
|
const [errorType, message] = error.details.split('|');
|
||||||
throw new BadRequestException(message);
|
throw new BadRequestException(message);
|
||||||
}
|
}
|
||||||
throw new InternalServerErrorException(error.details);
|
throw new ErrorBuilder(error.details);
|
||||||
});
|
});
|
||||||
this.logger.info('Done');
|
this.logger.info('Done');
|
||||||
|
|
||||||
@@ -164,45 +161,53 @@ export class PipelinesService implements OnModuleInit {
|
|||||||
customer_id: user.customer_id,
|
customer_id: user.customer_id,
|
||||||
customer: user.customer_name,
|
customer: user.customer_name,
|
||||||
};
|
};
|
||||||
|
let existsInProduct = true;
|
||||||
const { pipeline } = await lastValueFrom(
|
const { pipeline } = await lastValueFrom(
|
||||||
this.pipelineReadService.PipelineV2FindOne({ id }, metadata),
|
this.pipelineReadService.PipelineV2FindOne({ id }, metadata),
|
||||||
);
|
).catch((e) => {
|
||||||
|
if (e.details === ErrorCodes.PIPELINE.NOT_FOUND) existsInProduct = false;
|
||||||
|
else throw new ErrorBuilder(e.details);
|
||||||
|
|
||||||
|
return { pipeline: undefined };
|
||||||
|
});
|
||||||
await lastValueFrom(
|
await lastValueFrom(
|
||||||
this.pipelineWriteService.PipelineV2Remove({ id }, metadata),
|
this.pipelineWriteService.PipelineV2Remove({ id }, metadata),
|
||||||
);
|
);
|
||||||
|
|
||||||
//{pipeline:{tables: {tables: [], input_id: ''}}}
|
if (existsInProduct) {
|
||||||
const input = pipeline.config.tables
|
//{pipeline:{tables: {tables: [], input_id: ''}}}
|
||||||
? JSON.parse(pipeline.config.tables)
|
const input = pipeline.config.tables
|
||||||
: null;
|
? JSON.parse(pipeline.config.tables)
|
||||||
if (input)
|
: null;
|
||||||
await this.inputsService
|
if (input)
|
||||||
.remove({
|
await this.inputsService
|
||||||
id: input.input_id,
|
|
||||||
info,
|
|
||||||
})
|
|
||||||
.catch((error) =>
|
|
||||||
this.logger.error('Could not delete input', {
|
|
||||||
data: { input, error },
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
const transformations: { id: string }[] = pipeline.transformations
|
|
||||||
? JSON.parse(pipeline.transformations)
|
|
||||||
: null;
|
|
||||||
if (transformations && transformations.length)
|
|
||||||
for (const transformation of transformations) {
|
|
||||||
await this.transformationsService
|
|
||||||
.remove({
|
.remove({
|
||||||
id: transformation.id,
|
id: input.input_id,
|
||||||
info,
|
info,
|
||||||
})
|
})
|
||||||
.catch((error) =>
|
.catch((error) =>
|
||||||
this.logger.error('Could not delete transformation', {
|
this.logger.error('Could not delete input', {
|
||||||
data: { transformation, error },
|
data: { input, error },
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
const transformations: { id: string }[] = pipeline.transformations
|
||||||
|
? JSON.parse(pipeline.transformations)
|
||||||
|
: null;
|
||||||
|
if (transformations && transformations.length)
|
||||||
|
for (const transformation of transformations) {
|
||||||
|
await this.transformationsService
|
||||||
|
.remove({
|
||||||
|
id: transformation.id,
|
||||||
|
info,
|
||||||
|
})
|
||||||
|
.catch((error) =>
|
||||||
|
this.logger.error('Could not delete transformation', {
|
||||||
|
data: { transformation, error },
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async findOneProperties(id: string, metadata: Metadata) {
|
async findOneProperties(id: string, metadata: Metadata) {
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ import { Metadata } from '@grpc/grpc-js';
|
|||||||
import ErrorBuilder from 'src/utils/ErrorBuilder';
|
import ErrorBuilder from 'src/utils/ErrorBuilder';
|
||||||
import ErrorCodes from 'src/utils/errorCodes';
|
import ErrorCodes from 'src/utils/errorCodes';
|
||||||
|
|
||||||
// TODO GET de hierarquias e do PATCH em usuário
|
|
||||||
@ApiTags('Users')
|
@ApiTags('Users')
|
||||||
@Controller('users')
|
@Controller('users')
|
||||||
@ApiHeader({
|
@ApiHeader({
|
||||||
@@ -75,10 +74,6 @@ export class UsersController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@ApiOkResponse({
|
|
||||||
type: GetAllUsersByCustomerIdRes,
|
|
||||||
description: 'List of users of a customer',
|
|
||||||
})
|
|
||||||
async getAllUsersByCustomerId(
|
async getAllUsersByCustomerId(
|
||||||
@User() user: RequestUser,
|
@User() user: RequestUser,
|
||||||
@Headers('dadosfera-lang') language,
|
@Headers('dadosfera-lang') language,
|
||||||
|
|||||||
@@ -214,6 +214,16 @@ export function EnrichErrorCode(code: string) {
|
|||||||
message: 'Id encontra-se num formato inválido',
|
message: 'Id encontra-se num formato inválido',
|
||||||
code,
|
code,
|
||||||
};
|
};
|
||||||
|
case ErrorCodes.CONNECTION.NOT_FOUND:
|
||||||
|
case ErrorCodes.CONNECTION.PLATFORM_NOT_FOUND:
|
||||||
|
return {
|
||||||
|
statusCode: HttpStatus.NOT_FOUND,
|
||||||
|
error: 'Conexão não encontrada',
|
||||||
|
message:
|
||||||
|
'Não encontramos a conexão solicitada. Caso o erro persista, entre em contato com o suporte',
|
||||||
|
code,
|
||||||
|
};
|
||||||
|
|
||||||
case ErrorCodes.CONNECTION_TEST.ERROR:
|
case ErrorCodes.CONNECTION_TEST.ERROR:
|
||||||
return {
|
return {
|
||||||
statusCode: HttpStatus.BAD_REQUEST,
|
statusCode: HttpStatus.BAD_REQUEST,
|
||||||
|
|||||||
@@ -60,6 +60,10 @@ const PIPELINE = {
|
|||||||
const INPUT = {
|
const INPUT = {
|
||||||
NOT_FOUND: 'INPUT.NOT_FOUND',
|
NOT_FOUND: 'INPUT.NOT_FOUND',
|
||||||
};
|
};
|
||||||
|
const CONNECTION = {
|
||||||
|
NOT_FOUND: 'CONNECTION.NOT_FOUND',
|
||||||
|
PLATFORM_NOT_FOUND: 'CONNECTION.PLATFORM_NOT_FOUND',
|
||||||
|
};
|
||||||
const TRANSFORMATION = {
|
const TRANSFORMATION = {
|
||||||
NOT_FOUND: 'TRANSFORMATION.NOT_FOUND',
|
NOT_FOUND: 'TRANSFORMATION.NOT_FOUND',
|
||||||
};
|
};
|
||||||
@@ -77,6 +81,7 @@ const ErrorCodes = {
|
|||||||
PIPELINE,
|
PIPELINE,
|
||||||
INPUT,
|
INPUT,
|
||||||
TRANSFORMATION,
|
TRANSFORMATION,
|
||||||
|
CONNECTION,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ErrorCodes;
|
export default ErrorCodes;
|
||||||
|
|||||||
Reference in New Issue
Block a user