mirror of
https://github.com/dadosfera/maestro.git
synced 2026-09-08 05:14:48 +00:00
Compare commits
74
Commits
v1.1.0-alpha.2
...
v1.3.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b162bd0a7 | ||
|
|
829f7611e2 | ||
|
|
b986cf3281 | ||
|
|
75c7602e13 | ||
|
|
710105a4a8 | ||
|
|
30b048f776 | ||
|
|
845b95b112 | ||
|
|
6d6b024884 | ||
|
|
a4282a0dc5 | ||
|
|
4672ecb6b3 | ||
|
|
6160107d75 | ||
|
|
589a1f9d51 | ||
|
|
cb929d9b60 | ||
|
|
678bebef7e | ||
|
|
b6d7d54f9c | ||
|
|
5df8b2834c | ||
|
|
76d9571f02 | ||
|
|
0c51014ec9 | ||
|
|
7f1d8e4b2a | ||
|
|
92b78ff19d | ||
|
|
1b328b9915 | ||
|
|
e653aeea3c | ||
|
|
b49633cbc2 | ||
|
|
4d956e55c6 | ||
|
|
735703bf3b | ||
|
|
93cdc3f030 | ||
|
|
12b8b5926c | ||
|
|
1643096d47 | ||
|
|
8a519ac217 | ||
|
|
ffa69a0cf5 | ||
|
|
7722e380e3 | ||
|
|
ecdc7b4eb6 | ||
|
|
7d14080ac1 | ||
|
|
7e7deba2ab | ||
|
|
e425e90eeb | ||
|
|
45f35b4e39 | ||
|
|
d450acd007 | ||
|
|
e9c1dfc320 | ||
|
|
67484cbef8 | ||
|
|
740be1d98b | ||
|
|
b9989d86c1 | ||
|
|
9b3a127f6a | ||
|
|
55028c4b83 | ||
|
|
7d5dee4b0c | ||
|
|
708bf2f585 | ||
|
|
1d53226540 | ||
|
|
5f6ae5d512 | ||
|
|
c51092260a | ||
|
|
3add8b026e | ||
|
|
42726b805b | ||
|
|
8d8c5c000e | ||
|
|
b7f608f246 | ||
|
|
e513689f4a | ||
|
|
761a00c6a6 | ||
|
|
ef9cff601f | ||
|
|
a3ba9c743f | ||
|
|
9dd3ec4579 | ||
|
|
8b19da9217 | ||
|
|
238de920dc | ||
|
|
fe1a426e2b | ||
|
|
1f85d3f502 | ||
|
|
c68207728b | ||
|
|
c431867814 | ||
|
|
ca7f9855b1 | ||
|
|
7a95ec537f | ||
|
|
25d99089db | ||
|
|
e336f31fda | ||
|
|
2bdb06494a | ||
|
|
f94416200a | ||
|
|
3bbd48894b | ||
|
|
1f1660cdf2 | ||
|
|
3a7f392e8b | ||
|
|
04584df44d | ||
|
|
26ec0b3dfb |
@@ -0,0 +1,19 @@
|
||||
branch-defaults:
|
||||
alpha:
|
||||
environment: null
|
||||
global:
|
||||
application_name: maestro
|
||||
branch: null
|
||||
default_ec2_keyname: null
|
||||
default_platform: Docker running on 64bit Amazon Linux 2
|
||||
default_region: us-east-1
|
||||
include_git_submodules: true
|
||||
instance_profile: null
|
||||
platform_name: null
|
||||
platform_version: null
|
||||
profile: null
|
||||
repository: null
|
||||
sc: git
|
||||
workspace_type: Application
|
||||
deploy:
|
||||
artifact: deploy.zip
|
||||
@@ -7,9 +7,26 @@ on:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: self-hosted
|
||||
extract_environment:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
environment: ${{ steps.extract_environment.outputs.environment }}
|
||||
steps:
|
||||
- name: Extract Environment
|
||||
run: |
|
||||
if [ ${GITHUB_REF} == "refs/heads/main" ]; then
|
||||
echo "##[set-output name=environment;]$(echo "prd")"
|
||||
elif [ ${GITHUB_REF} == "refs/heads/alpha" ]; then
|
||||
echo "##[set-output name=environment;]$(echo "dev")"
|
||||
elif [ ${GITHUB_REF} == "refs/heads/beta" ]; then
|
||||
echo "##[set-output name=environment;]$(echo "stg")"
|
||||
fi
|
||||
id: extract_environment
|
||||
|
||||
deploy:
|
||||
needs: extract_environment
|
||||
runs-on:
|
||||
[self-hosted, '${{ needs.extract_environment.outputs.environment }}']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
@@ -18,6 +35,7 @@ jobs:
|
||||
- name: BKP .npmrc Step 1
|
||||
run: |
|
||||
cp .npmrc .npmrcbkp
|
||||
|
||||
- name: Semantic Release
|
||||
uses: cycjimmy/semantic-release-action@v2
|
||||
id: semantic
|
||||
@@ -46,29 +64,31 @@ jobs:
|
||||
- name: BKP .npmrc Step 2
|
||||
run: |
|
||||
cp .npmrcbkp .npmrc
|
||||
|
||||
- name: Update Pip
|
||||
if: steps.semantic.outputs.new_release_published == 'true'
|
||||
run: |
|
||||
python3 -m pip install --upgrade pip
|
||||
ls -a
|
||||
|
||||
- name: Install Docker Compose
|
||||
if: steps.semantic.outputs.new_release_published == 'true'
|
||||
run: |
|
||||
python3 -m pip install docker-compose --upgrade
|
||||
ls -a
|
||||
|
||||
- name: Install AWS CLI
|
||||
if: steps.semantic.outputs.new_release_published == 'true'
|
||||
run: |
|
||||
python3 -m pip install awscli --upgrade
|
||||
ls -a
|
||||
|
||||
- name: Install AWS Elastic Beanstalk CLI
|
||||
if: steps.semantic.outputs.new_release_published == 'true'
|
||||
run: |
|
||||
python3 -m pip install awsebcli --upgrade
|
||||
ls -a
|
||||
|
||||
- name: Configure AWS Region
|
||||
if: steps.semantic.outputs.new_release_published == 'true'
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
id: aws
|
||||
with:
|
||||
aws-region: us-east-1
|
||||
|
||||
@@ -76,11 +96,12 @@ jobs:
|
||||
if: steps.semantic.outputs.new_release_published == 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
ls -a
|
||||
if [ ${GITHUB_REF} == "refs/heads/main" ]; then
|
||||
echo "##[set-output name=result;]$(echo "production")"
|
||||
else
|
||||
echo "##[set-output name=result;]$(echo ${GITHUB_REF#refs/heads/})"
|
||||
echo "##[set-output name=result;]$(echo "prd")"
|
||||
elif [ ${GITHUB_REF} == "refs/heads/alpha" ]; then
|
||||
echo "##[set-output name=result;]$(echo "dev")"
|
||||
elif [ ${GITHUB_REF} == "refs/heads/beta" ]; then
|
||||
echo "##[set-output name=result;]$(echo "stg")"
|
||||
fi
|
||||
id: extract_environment
|
||||
|
||||
@@ -94,21 +115,24 @@ jobs:
|
||||
env:
|
||||
ENV: ${{ steps.extract_environment.outputs.result }}
|
||||
IMAGE_TAG: ${{ steps.semantic.outputs.new_release_version }}
|
||||
ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
docker-compose -f build.docker-compose.yml build --build-arg NPM_TOKEN=${NPM_TOKEN}
|
||||
docker-compose -f build.docker-compose.yml push
|
||||
ls -a
|
||||
|
||||
- name: Create ZIP file to Deploy AWS Beanstalk
|
||||
if: steps.semantic.outputs.new_release_published == 'true'
|
||||
env:
|
||||
ENV: ${{ steps.extract_environment.outputs.result }}
|
||||
IMAGE_TAG: ${{ steps.semantic.outputs.new_release_version }}
|
||||
ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }}
|
||||
run: |
|
||||
sed -i -e "s/\${ENV}/$ENV/g" docker-compose.yml
|
||||
sed -i -e "s/\${IMAGE_TAG}/$IMAGE_TAG/g" docker-compose.yml
|
||||
zip deploy.zip docker-compose.yml
|
||||
ls -a
|
||||
sed -i -e "s/\${ACCOUNT_ID}/$ACCOUNT_ID/g" docker-compose.yml
|
||||
zip deploy.zip docker-compose.yml -r .ebextensions
|
||||
|
||||
- name: Deploy AWS Beanstalk
|
||||
if: steps.semantic.outputs.new_release_published == 'true'
|
||||
env:
|
||||
@@ -116,8 +140,11 @@ jobs:
|
||||
AWS_REGION: us-east-1
|
||||
APP_NAME: maestro
|
||||
run: |
|
||||
[[ -d .elasticbeanstalk/ ]] && rm -R .elasticbeanstalk/
|
||||
printf "1\nn" | eb init $APP_NAME --region $AWS_REGION
|
||||
eb use $APP_NAME-$ENV
|
||||
echo -e "deploy:\n artifact: deploy.zip" >> .elasticbeanstalk/config.yml
|
||||
eb deploy
|
||||
eb deploy
|
||||
|
||||
- name: Remove Docker's Trash
|
||||
continue-on-error: true
|
||||
run: |
|
||||
docker system prune
|
||||
docker rmi -f $(docker images -aq)
|
||||
|
||||
@@ -16,6 +16,7 @@ jobs:
|
||||
- name: Install Docker Compose
|
||||
run: |
|
||||
python3 -m pip install docker-compose --upgrade
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
ENV: test
|
||||
@@ -24,13 +25,22 @@ jobs:
|
||||
run: |
|
||||
export ENV=test
|
||||
export IMAGE_TAG=test
|
||||
export ACCOUNT_ID=test
|
||||
docker-compose -f build.docker-compose.yml build --build-arg NPM_TOKEN=${NPM_TOKEN}
|
||||
|
||||
- name: Run Test
|
||||
env:
|
||||
ENV: test
|
||||
IMAGE_TAG: test
|
||||
ACCOUNT_ID: test
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
export ENV=test
|
||||
export IMAGE_TAG=test
|
||||
docker-compose -f build.docker-compose.yml run -e NPM_TOKEN=${NPM_TOKEN} --rm --entrypoint="npm run test" maestro
|
||||
docker-compose -f build.docker-compose.yml run -e NPM_TOKEN=${NPM_TOKEN} --rm --entrypoint="npm run test" maestro
|
||||
|
||||
- name: Remove Docker's Trash
|
||||
continue-on-error: true
|
||||
run: |
|
||||
docker system prune
|
||||
docker rmi -f $(docker images -aq)
|
||||
|
||||
@@ -37,10 +37,4 @@ lerna-debug.log*
|
||||
# Ignore .env files
|
||||
*.env
|
||||
|
||||
# Elastic Beanstalk Files
|
||||
.elasticbeanstalk/*
|
||||
!.elasticbeanstalk/*.cfg.yml
|
||||
!.elasticbeanstalk/*.global.yml
|
||||
|
||||
|
||||
.env
|
||||
+3
-1
@@ -33,7 +33,9 @@
|
||||
{ "from": "main", "to": "alpha" },
|
||||
{ "from": "main", "to": "beta" }
|
||||
],
|
||||
"backmergeStrategy": "merge"
|
||||
"backmergeStrategy": "merge",
|
||||
"clearWorkspace": true,
|
||||
"restoreWorkspace": true
|
||||
}
|
||||
],
|
||||
"@semantic-release/npm",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<p align="center">
|
||||
<image src="./assets/maestro.svg" style="width:10rem">
|
||||
<h1 align="center">Maestro</h1>
|
||||
</p>
|
||||
<h1 align="center">Maestro</h1>
|
||||
</p>
|
||||
@@ -2,4 +2,4 @@ version: "3.8"
|
||||
services:
|
||||
maestro:
|
||||
build: .
|
||||
image: 468720548566.dkr.ecr.us-east-1.amazonaws.com/microservices/maestro_${ENV}:${IMAGE_TAG}
|
||||
image: ${ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/microservices/maestro_${ENV}:${IMAGE_TAG}
|
||||
|
||||
+3
-1
@@ -1,11 +1,13 @@
|
||||
version: "3.8"
|
||||
services:
|
||||
maestro:
|
||||
image: 468720548566.dkr.ecr.us-east-1.amazonaws.com/microservices/maestro_${ENV}:${IMAGE_TAG}
|
||||
image: ${ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/microservices/maestro_${ENV}:${IMAGE_TAG}
|
||||
container_name: maestro
|
||||
restart: always
|
||||
ports:
|
||||
- 3333:3333
|
||||
env_file:
|
||||
- .env
|
||||
|
||||
node_exporter:
|
||||
image: prom/node-exporter:v1.3.1
|
||||
|
||||
Generated
+10508
-1677
File diff suppressed because it is too large
Load Diff
+18
-17
@@ -21,19 +21,20 @@
|
||||
"test:e2e": "jest --config ./test/jest-e2e.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@grpc/grpc-js": "^1.5.7",
|
||||
"@grpc/grpc-js": "^1.5.10",
|
||||
"@grpc/proto-loader": "^0.6.9",
|
||||
"@nestjs/common": "^8.4.0",
|
||||
"@nestjs/common": "^8.4.3",
|
||||
"@nestjs/config": "^1.2.1",
|
||||
"@nestjs/core": "^8.4.0",
|
||||
"@nestjs/core": "^8.4.3",
|
||||
"@nestjs/mapped-types": "*",
|
||||
"@nestjs/microservices": "^8.4.0",
|
||||
"@nestjs/platform-express": "^8.4.0",
|
||||
"@nestjs/swagger": "^5.1.5",
|
||||
"@victorradael/protospack": "^1.2.8",
|
||||
"@nestjs/microservices": "^8.4.3",
|
||||
"@nestjs/platform-express": "^8.4.3",
|
||||
"@nestjs/swagger": "^5.2.1",
|
||||
"@victorradael/protospack": "^1.5.5",
|
||||
"axios": "^0.25.0",
|
||||
"dotenv": "^14.2.0",
|
||||
"grpc": "^1.24.11",
|
||||
"helmet": "^5.0.2",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"jwk-to-pem": "^2.0.5",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
@@ -42,29 +43,29 @@
|
||||
"swagger-ui-express": "^4.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "^8.2.2",
|
||||
"@nestjs/cli": "^8.2.4",
|
||||
"@nestjs/schematics": "^8.0.8",
|
||||
"@nestjs/testing": "^8.4.0",
|
||||
"@nestjs/testing": "^8.4.3",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/jest": "27.0.2",
|
||||
"@types/jsonwebtoken": "^8.5.8",
|
||||
"@types/jwk-to-pem": "^2.0.1",
|
||||
"@types/node": "^16.11.26",
|
||||
"@types/supertest": "^2.0.11",
|
||||
"@typescript-eslint/eslint-plugin": "^5.14.0",
|
||||
"@typescript-eslint/parser": "^5.14.0",
|
||||
"eslint": "^8.10.0",
|
||||
"@types/supertest": "^2.0.12",
|
||||
"@typescript-eslint/eslint-plugin": "^5.17.0",
|
||||
"@typescript-eslint/parser": "^5.17.0",
|
||||
"eslint": "^8.12.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"jest": "^27.5.1",
|
||||
"prettier": "^2.3.2",
|
||||
"prettier": "^2.6.1",
|
||||
"source-map-support": "^0.5.20",
|
||||
"supertest": "^6.1.3",
|
||||
"ts-jest": "^27.0.3",
|
||||
"ts-jest": "^27.1.4",
|
||||
"ts-loader": "^9.2.7",
|
||||
"ts-node": "^10.7.0",
|
||||
"tsconfig-paths": "^3.13.0",
|
||||
"typescript": "^4.6.2"
|
||||
"tsconfig-paths": "^3.14.1",
|
||||
"typescript": "^4.6.3"
|
||||
},
|
||||
"jest": {
|
||||
"moduleFileExtensions": [
|
||||
|
||||
+11
-6
@@ -29,6 +29,8 @@ import { TransformationsClientConfiguration } from './clients/transformations/cl
|
||||
import { AuthClient } from './clients/auth/client.config';
|
||||
import { InputsClientConfiguration } from './clients/inputs/client.config';
|
||||
import { PipelinesClientConfiguration } from './clients/pipelines/client.config';
|
||||
import { CatalogController } from './modules/catalog/catalog.controller';
|
||||
import { CatalogService } from './modules/catalog/catalog.service';
|
||||
|
||||
const authClient = new AuthClient();
|
||||
const inputClient = new InputsClientConfiguration();
|
||||
@@ -44,6 +46,7 @@ const transformationClient = new TransformationsClientConfiguration();
|
||||
PipelinesController,
|
||||
AuthController,
|
||||
HealthController,
|
||||
CatalogController,
|
||||
],
|
||||
providers: [
|
||||
InputsService,
|
||||
@@ -57,6 +60,7 @@ const transformationClient = new TransformationsClientConfiguration();
|
||||
OutputsClientService,
|
||||
PipelinesClientService,
|
||||
AuthClientService,
|
||||
CatalogService,
|
||||
],
|
||||
imports: [
|
||||
ConfigModule.forRoot({
|
||||
@@ -92,11 +96,12 @@ export class AppModule implements NestModule {
|
||||
configure(consumer: MiddlewareConsumer) {
|
||||
consumer
|
||||
.apply(LoggerMiddleware)
|
||||
.forRoutes
|
||||
// InputsController,
|
||||
// TransformationsController,
|
||||
// OutputsController,
|
||||
// PipelinesController,
|
||||
();
|
||||
.forRoutes(
|
||||
InputsController,
|
||||
TransformationsController,
|
||||
OutputsController,
|
||||
PipelinesController,
|
||||
CatalogController,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { credentials } from '@grpc/grpc-js';
|
||||
import { ClientOptions, Transport } from '@nestjs/microservices';
|
||||
|
||||
import { DucProtofile } from '@victorradael/protospack';
|
||||
import { DucProtoFilePath, DucPackages } from '@victorradael/protospack';
|
||||
|
||||
export class AuthClient {
|
||||
config(): ClientOptions {
|
||||
@@ -9,9 +9,9 @@ export class AuthClient {
|
||||
transport: Transport.GRPC,
|
||||
options: {
|
||||
url: process.env.DUC_URL,
|
||||
package: 'duc',
|
||||
package: DucPackages,
|
||||
credentials: credentials.createSsl(),
|
||||
protoPath: DucProtofile,
|
||||
protoPath: DucProtoFilePath,
|
||||
loader: {
|
||||
enums: String,
|
||||
objects: true,
|
||||
|
||||
@@ -1,27 +1,30 @@
|
||||
import { OnModuleInit, Inject } from '@nestjs/common';
|
||||
import { ClientGrpc } from '@nestjs/microservices';
|
||||
|
||||
import { CognitoServiceInterface } from '@victorradael/protospack';
|
||||
import {
|
||||
AuthServiceInterface,
|
||||
DucServicesNames,
|
||||
} from '@victorradael/protospack';
|
||||
|
||||
import { ILogin } from './interfaces';
|
||||
|
||||
export class AuthClientService implements OnModuleInit {
|
||||
private cognitoService: CognitoServiceInterface;
|
||||
private authService: AuthServiceInterface;
|
||||
constructor(
|
||||
@Inject('AUTH_PACKAGE') private readonly grpcClient: ClientGrpc,
|
||||
) {}
|
||||
|
||||
onModuleInit() {
|
||||
this.cognitoService = this.grpcClient.getService<CognitoServiceInterface>(
|
||||
'CognitoProtoService',
|
||||
this.authService = this.grpcClient.getService<AuthServiceInterface>(
|
||||
DucServicesNames.AuthProtoService,
|
||||
);
|
||||
}
|
||||
|
||||
async signIn({ username, password }: ILogin): Promise<any> {
|
||||
console.log('CognitoClientService', 'SignIn');
|
||||
console.log('AuthClientService', 'SignIn');
|
||||
|
||||
const tokens = await new Promise((resolve, reject) => {
|
||||
this.cognitoService.signIn({ username, password }).subscribe({
|
||||
this.authService.signIn({ username, password }).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { credentials } from '@grpc/grpc-js';
|
||||
import { ClientOptions, Transport } from '@nestjs/microservices';
|
||||
|
||||
import { InputProtofile } from '@victorradael/protospack';
|
||||
import { InputPackages, InputProtoFilePath } from '@victorradael/protospack';
|
||||
|
||||
export class InputsClientConfiguration {
|
||||
config(): ClientOptions {
|
||||
@@ -9,9 +9,9 @@ export class InputsClientConfiguration {
|
||||
transport: Transport.GRPC,
|
||||
options: {
|
||||
url: process.env.INFACTORY_URL,
|
||||
package: 'input',
|
||||
// credentials: credentials.createSsl(),
|
||||
protoPath: InputProtofile,
|
||||
package: InputPackages,
|
||||
credentials: credentials.createSsl(),
|
||||
protoPath: InputProtoFilePath,
|
||||
loader: {
|
||||
enums: String,
|
||||
objects: true,
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
import {
|
||||
OnModuleInit,
|
||||
Inject,
|
||||
} from '@nestjs/common';
|
||||
import { OnModuleInit, Inject } from '@nestjs/common';
|
||||
import { ClientGrpc } from '@nestjs/microservices';
|
||||
import { InputService } from '@victorradael/protospack';
|
||||
import { ICreateInputRequest, IIdRequest, ITestConnectionRequest, UpdateInputRequest } from './interfaces';
|
||||
import {
|
||||
objectCamelToSnake,
|
||||
objectSnakeToCamel,
|
||||
} from 'src/utils/CaseConverter';
|
||||
import {
|
||||
ICreateInputRequest,
|
||||
IIdRequest,
|
||||
ITestConnectionRequest,
|
||||
UpdateInputRequest,
|
||||
} from './interfaces';
|
||||
|
||||
export class InputsClientService implements OnModuleInit {
|
||||
private inputService: InputService;
|
||||
@@ -12,21 +18,18 @@ export class InputsClientService implements OnModuleInit {
|
||||
@Inject('INPUTS_PACKAGE') private readonly grpcClient: ClientGrpc,
|
||||
) {}
|
||||
|
||||
|
||||
onModuleInit() {
|
||||
this.inputService =
|
||||
this.grpcClient.getService<InputService>(
|
||||
'InputService',
|
||||
);
|
||||
this.grpcClient.getService<InputService>('InputService');
|
||||
}
|
||||
|
||||
async create(createInputDto: ICreateInputRequest ) {
|
||||
async create(createInputDto: ICreateInputRequest) {
|
||||
console.log('InputClientService', 'Create');
|
||||
|
||||
const createInputResponse = await new Promise((resolve, reject) => {
|
||||
this.inputService.Create(createInputDto).subscribe({
|
||||
this.inputService.Create(objectSnakeToCamel(createInputDto)).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
resolve(objectCamelToSnake(x));
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
@@ -43,19 +46,15 @@ export class InputsClientService implements OnModuleInit {
|
||||
});
|
||||
|
||||
return createInputResponse;
|
||||
|
||||
}
|
||||
|
||||
|
||||
async findOne(data: IIdRequest ) {
|
||||
async findOne(data: IIdRequest) {
|
||||
console.log('InputClientService', 'FindOne');
|
||||
|
||||
const { id } = data
|
||||
|
||||
const findOneInputResponse = await new Promise((resolve, reject) => {
|
||||
this.inputService.FindOne({id}).subscribe({
|
||||
this.inputService.FindOne(objectSnakeToCamel(data)).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
resolve(objectCamelToSnake(x));
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
@@ -72,17 +71,15 @@ export class InputsClientService implements OnModuleInit {
|
||||
});
|
||||
|
||||
return findOneInputResponse;
|
||||
|
||||
}
|
||||
|
||||
|
||||
async findAll(data) {
|
||||
console.log('InputClientService', 'FindAll');
|
||||
|
||||
const findAllInputResponse = await new Promise((resolve, reject) => {
|
||||
this.inputService.FindAll({}).subscribe({
|
||||
this.inputService.FindAll(objectSnakeToCamel(data)).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
resolve(objectCamelToSnake(x));
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
@@ -99,18 +96,14 @@ export class InputsClientService implements OnModuleInit {
|
||||
});
|
||||
|
||||
return findAllInputResponse;
|
||||
|
||||
}
|
||||
|
||||
|
||||
async update(updateInputDTO:UpdateInputRequest) {
|
||||
async update(updateInputDTO: UpdateInputRequest) {
|
||||
console.log('InputClientService', 'Update');
|
||||
console.log(updateInputDTO)
|
||||
const updateInputResponse = await new Promise((resolve, reject) => {
|
||||
this.inputService.Update(updateInputDTO).subscribe({
|
||||
this.inputService.Update(objectSnakeToCamel(updateInputDTO)).subscribe({
|
||||
next(x) {
|
||||
console.log(x)
|
||||
resolve(x);
|
||||
resolve(objectCamelToSnake(x));
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
@@ -127,16 +120,15 @@ export class InputsClientService implements OnModuleInit {
|
||||
});
|
||||
|
||||
return updateInputResponse;
|
||||
|
||||
}
|
||||
|
||||
async remove(idRequest:IIdRequest) {
|
||||
async remove(idRequest: IIdRequest) {
|
||||
console.log('InputClientService', 'Remove');
|
||||
|
||||
const removeInputResponse = await new Promise((resolve, reject) => {
|
||||
this.inputService.Remove(idRequest).subscribe({
|
||||
this.inputService.Remove(objectSnakeToCamel(idRequest)).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
resolve(objectCamelToSnake(x));
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
@@ -153,16 +145,14 @@ export class InputsClientService implements OnModuleInit {
|
||||
});
|
||||
|
||||
return removeInputResponse;
|
||||
|
||||
}
|
||||
|
||||
async testConnection(data:ITestConnectionRequest) {
|
||||
console.log('InputClientService', 'TestCOnnection');
|
||||
|
||||
async testConnection(data: ITestConnectionRequest) {
|
||||
console.log('InputClientService', 'TestConnection');
|
||||
const testConnectionResponse = await new Promise((resolve, reject) => {
|
||||
this.inputService.TestConnection(data).subscribe({
|
||||
this.inputService.TestConnection(objectSnakeToCamel(data)).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
resolve(objectCamelToSnake(x));
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
@@ -179,7 +169,5 @@ export class InputsClientService implements OnModuleInit {
|
||||
});
|
||||
|
||||
return testConnectionResponse;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Vendored
+17
-11
@@ -8,7 +8,7 @@ interface Values {
|
||||
engine: string;
|
||||
schema: string;
|
||||
}
|
||||
|
||||
|
||||
interface Cron {
|
||||
hours: string[];
|
||||
hour_interval: boolean;
|
||||
@@ -28,29 +28,35 @@ interface Cron {
|
||||
week_days_resourse_value: number;
|
||||
}
|
||||
|
||||
export interface Info {
|
||||
costumer_id: string;
|
||||
user_id: string;
|
||||
}
|
||||
|
||||
export interface ICreateInputRequest {
|
||||
|
||||
cron: Cron;
|
||||
cron: string;
|
||||
name: string;
|
||||
plugin: string;
|
||||
values: Values;
|
||||
operation: string;
|
||||
|
||||
info: Info;
|
||||
}
|
||||
export interface IIdRequest{
|
||||
id:string;
|
||||
}
|
||||
|
||||
interface UpdateInputRequest {
|
||||
export interface IIdRequest {
|
||||
id: string;
|
||||
cron: Cron;
|
||||
info: Info;
|
||||
}
|
||||
|
||||
export interface UpdateInputRequest {
|
||||
id: string;
|
||||
cron: string;
|
||||
name: string;
|
||||
plugin: string;
|
||||
values: Values;
|
||||
operation: string;
|
||||
info: Info;
|
||||
}
|
||||
|
||||
export interface ITestConnectionRequest {
|
||||
plugin: string;
|
||||
values: Values;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { OutputProtofile } from '@victorradael/protospack';
|
||||
import { OutputPackages, OutputProtoFilePath } from '@victorradael/protospack';
|
||||
import { ClientOptions, Transport } from '@nestjs/microservices';
|
||||
import { credentials } from '@grpc/grpc-js';
|
||||
|
||||
@@ -7,10 +7,10 @@ export class OutputsClientConfiguration {
|
||||
return {
|
||||
transport: Transport.GRPC,
|
||||
options: {
|
||||
url: process.env.OUTFACTORY_URL,
|
||||
package: 'output',
|
||||
// credentials: credentials.createSsl(),
|
||||
protoPath: OutputProtofile,
|
||||
url: process.env.OTFACTORY_URL,
|
||||
package: OutputPackages,
|
||||
credentials: credentials.createSsl(),
|
||||
protoPath: OutputProtoFilePath,
|
||||
loader: {
|
||||
enums: String,
|
||||
objects: true,
|
||||
@@ -19,4 +19,4 @@ export class OutputsClientConfiguration {
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,39 +1,37 @@
|
||||
import { Controller, Inject, OnModuleInit } from '@nestjs/common';
|
||||
import { ClientGrpc, Payload } from '@nestjs/microservices';
|
||||
import {
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Inject,
|
||||
OnModuleInit,
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
} from '@nestjs/common';
|
||||
OutputServicesNames,
|
||||
OutputsServiceInterface,
|
||||
} from '@victorradael/protospack';
|
||||
import {
|
||||
ClientGrpc,
|
||||
Payload,
|
||||
} from '@nestjs/microservices';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { OutputsServiceInterface } from '@victorradael/protospack';
|
||||
import { objectCamelToSnake } from 'src/utils/CaseConverter';
|
||||
import { ICreateOutputRequest, IIdRequest, IOutputUpdateRequest } from './interfaces';
|
||||
objectCamelToSnake,
|
||||
objectSnakeToCamel,
|
||||
} from 'src/utils/CaseConverter';
|
||||
import {
|
||||
ICreateOutputRequest,
|
||||
IIdRequest,
|
||||
IOutputUpdateRequest,
|
||||
} from './interfaces';
|
||||
|
||||
@Controller('output')
|
||||
export class OutputsClientService implements OnModuleInit {
|
||||
private outputService: OutputsServiceInterface;
|
||||
constructor(
|
||||
@Inject('OUTPUTS_PACKAGE')private readonly grpcClient: ClientGrpc,
|
||||
){}
|
||||
@Inject('OUTPUTS_PACKAGE') private readonly grpcClient: ClientGrpc,
|
||||
) {}
|
||||
|
||||
onModuleInit() {
|
||||
this.outputService =
|
||||
this.grpcClient.getService<OutputsServiceInterface>('OutputService');
|
||||
this.outputService = this.grpcClient.getService<OutputsServiceInterface>(
|
||||
OutputServicesNames.OutputService,
|
||||
);
|
||||
}
|
||||
|
||||
async create(@Payload() createOutputDto:ICreateOutputRequest ) {
|
||||
async create(@Payload() createOutputDto: ICreateOutputRequest) {
|
||||
console.log('OutputClientService', 'Create');
|
||||
|
||||
const createOutputResponse = await new Promise((resolve, reject) => {
|
||||
this.outputService.create(createOutputDto).subscribe({
|
||||
this.outputService.Create(objectSnakeToCamel(createOutputDto)).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
@@ -50,18 +48,17 @@ export class OutputsClientService implements OnModuleInit {
|
||||
.catch((err) => {
|
||||
throw new Error(err);
|
||||
});
|
||||
|
||||
const convertedItem = objectCamelToSnake(createOutputResponse["item"])
|
||||
createOutputResponse["item"] = convertedItem
|
||||
|
||||
const convertedItem = objectCamelToSnake(createOutputResponse['output']);
|
||||
createOutputResponse['output'] = convertedItem;
|
||||
return createOutputResponse;
|
||||
}
|
||||
|
||||
async findAll() {
|
||||
async findAll(data) {
|
||||
console.log('OutputClientService', 'FindAll');
|
||||
|
||||
const findAllOutputResponse = await new Promise((resolve, reject) => {
|
||||
this.outputService.findAll({}).subscribe({
|
||||
this.outputService.FindAll(objectSnakeToCamel(data)).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
@@ -79,18 +76,18 @@ export class OutputsClientService implements OnModuleInit {
|
||||
throw new Error(err);
|
||||
});
|
||||
|
||||
const convertedOutputs = findAllOutputResponse['outputs'].map((ot)=>{
|
||||
return objectCamelToSnake(ot)
|
||||
})
|
||||
const convertedOutputs = findAllOutputResponse['outputs'].map((ot) => {
|
||||
return objectCamelToSnake(ot);
|
||||
});
|
||||
|
||||
return {outputs:convertedOutputs};
|
||||
return { outputs: convertedOutputs };
|
||||
}
|
||||
|
||||
async findOne({id}: IIdRequest) {
|
||||
async findOne(data: IIdRequest) {
|
||||
console.log('OutputClientService', 'FindOne');
|
||||
|
||||
const findOneOutputResponse = await new Promise((resolve, reject) => {
|
||||
this.outputService.findOne({id}).subscribe({
|
||||
this.outputService.FindOne(objectSnakeToCamel(data)).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
@@ -107,17 +104,15 @@ export class OutputsClientService implements OnModuleInit {
|
||||
.catch((err) => {
|
||||
throw new Error(err);
|
||||
});
|
||||
|
||||
|
||||
|
||||
return objectCamelToSnake(findOneOutputResponse);
|
||||
}
|
||||
|
||||
|
||||
async update(updateOutPutDTO: IOutputUpdateRequest) {
|
||||
console.log('OutputClientService', 'Update');
|
||||
|
||||
const updateOutputResponse = await new Promise((resolve, reject) => {
|
||||
this.outputService.update(updateOutPutDTO).subscribe({
|
||||
this.outputService.Update(objectSnakeToCamel(updateOutPutDTO)).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
@@ -134,17 +129,17 @@ export class OutputsClientService implements OnModuleInit {
|
||||
.catch((err) => {
|
||||
throw new Error(err);
|
||||
});
|
||||
|
||||
|
||||
return objectCamelToSnake(updateOutputResponse);
|
||||
}
|
||||
|
||||
async remove({id}:IIdRequest) {
|
||||
async remove(data: IIdRequest) {
|
||||
console.log('OutputClientService', 'Remove');
|
||||
|
||||
const removeOutputResponse = await new Promise((resolve, reject) => {
|
||||
this.outputService.remove({id}).subscribe({
|
||||
this.outputService.Remove(objectSnakeToCamel(data)).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
resolve(objectCamelToSnake(x));
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
@@ -160,6 +155,6 @@ export class OutputsClientService implements OnModuleInit {
|
||||
throw new Error(err);
|
||||
});
|
||||
|
||||
return removeOutputResponse;
|
||||
return removeOutputResponse;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+20
-13
@@ -1,22 +1,29 @@
|
||||
export interface ICreateOutputRequest {
|
||||
operation: string;
|
||||
name: string;
|
||||
plugin: string;
|
||||
values: Values;
|
||||
operation: string;
|
||||
name: string;
|
||||
plugin: string;
|
||||
values: Values;
|
||||
}
|
||||
|
||||
export interface Values {
|
||||
prefix: string;
|
||||
prefix: string;
|
||||
}
|
||||
|
||||
export interface IIdRequest{
|
||||
id:string;
|
||||
interface Info {
|
||||
user_id: string;
|
||||
customer_id: string;
|
||||
}
|
||||
|
||||
export interface IIdRequest {
|
||||
id: string;
|
||||
info: Info;
|
||||
}
|
||||
|
||||
export interface IOutputUpdateRequest {
|
||||
id: string;
|
||||
operation: string;
|
||||
values: Values;
|
||||
plugin: string;
|
||||
name: string;
|
||||
}
|
||||
id: string;
|
||||
operation: string;
|
||||
values: Values;
|
||||
plugin: string;
|
||||
name: string;
|
||||
info: Info;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { ClientOptions, Transport } from '@nestjs/microservices';
|
||||
import { PipelineProtofile } from '@victorradael/protospack';
|
||||
import {
|
||||
PipelinePackages,
|
||||
PipelineProtoFilePath,
|
||||
} from '@victorradael/protospack';
|
||||
import { credentials } from '@grpc/grpc-js';
|
||||
|
||||
export class PipelinesClientConfiguration {
|
||||
@@ -8,9 +11,9 @@ export class PipelinesClientConfiguration {
|
||||
transport: Transport.GRPC,
|
||||
options: {
|
||||
url: process.env.PIFACTORY_URL,
|
||||
package: 'pipeline',
|
||||
// credentials: credentials.createSsl(),
|
||||
protoPath: PipelineProtofile,
|
||||
package: PipelinePackages,
|
||||
credentials: credentials.createSsl(),
|
||||
protoPath: PipelineProtoFilePath,
|
||||
loader: {
|
||||
enums: String,
|
||||
objects: true,
|
||||
@@ -19,4 +22,4 @@ export class PipelinesClientConfiguration {
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,53 +1,51 @@
|
||||
import { Inject, OnModuleInit } from '@nestjs/common';
|
||||
import { ClientGrpc, Payload } from '@nestjs/microservices';
|
||||
import {
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Inject,
|
||||
OnModuleInit,
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
} from '@nestjs/common';
|
||||
PipelineServicesNames,
|
||||
PipelinesServiceInterface,
|
||||
} from '@victorradael/protospack';
|
||||
import {
|
||||
Client,
|
||||
ClientGrpc,
|
||||
MessagePattern,
|
||||
Payload,
|
||||
} from '@nestjs/microservices';
|
||||
import { PipelinesServiceInterface } from '@victorradael/protospack';
|
||||
import { ICreatePipelineDto, IdRequest, IGetPipelineLogsRequest, IUpdatePipelineRequest } from './interfaces';
|
||||
objectCamelToSnake,
|
||||
objectSnakeToCamel,
|
||||
} from 'src/utils/CaseConverter';
|
||||
import {
|
||||
ICreatePipelineDto,
|
||||
IGetPipelineLogsRequest,
|
||||
IIdRequest,
|
||||
IUpdatePipelineRequest,
|
||||
} from './interfaces';
|
||||
|
||||
export class PipelinesClientService implements OnModuleInit {
|
||||
private pipelineService: PipelinesServiceInterface;
|
||||
constructor(
|
||||
@Inject('PIPELINES_PACKAGE') private readonly grpcClient: ClientGrpc,
|
||||
){}
|
||||
@Inject('PIPELINES_PACKAGE') private readonly grpcClient: ClientGrpc,
|
||||
) {}
|
||||
|
||||
onModuleInit() {
|
||||
this.pipelineService =
|
||||
this.grpcClient.getService<PipelinesServiceInterface>(
|
||||
'PipelineService',
|
||||
PipelineServicesNames.PipelineService,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
async create(@Payload() createPipelineDto: ICreatePipelineDto ) {
|
||||
|
||||
async create(@Payload() createPipelineDto: ICreatePipelineDto) {
|
||||
console.log('PipelinesClientService', 'Create');
|
||||
|
||||
const createPipelineResponse = await new Promise((resolve, reject) => {
|
||||
this.pipelineService.create(createPipelineDto).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
this.pipelineService
|
||||
.Create(objectSnakeToCamel(createPipelineDto))
|
||||
.subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
})
|
||||
.then((res) => res)
|
||||
.catch((err) => {
|
||||
@@ -55,14 +53,13 @@ export class PipelinesClientService implements OnModuleInit {
|
||||
});
|
||||
|
||||
return createPipelineResponse;
|
||||
|
||||
}
|
||||
|
||||
async findAll() {
|
||||
async findAll(data: IIdRequest) {
|
||||
console.log('PipelinesClientService', 'FindAll');
|
||||
|
||||
const findAllPipelineResponse = await new Promise((resolve, reject) => {
|
||||
this.pipelineService.findAll({}).subscribe({
|
||||
this.pipelineService.FindAll(objectSnakeToCamel(data)).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
@@ -83,11 +80,11 @@ export class PipelinesClientService implements OnModuleInit {
|
||||
return findAllPipelineResponse;
|
||||
}
|
||||
|
||||
async findOne({id}: IdRequest) {
|
||||
async findOne(data: IIdRequest) {
|
||||
console.log('PipelinesClientService', 'FindOne');
|
||||
|
||||
const findOnePipelineResponse = await new Promise((resolve, reject) => {
|
||||
this.pipelineService.findOne({id}).subscribe({
|
||||
this.pipelineService.FindOne(objectSnakeToCamel(data)).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
@@ -108,39 +105,40 @@ export class PipelinesClientService implements OnModuleInit {
|
||||
return findOnePipelineResponse;
|
||||
}
|
||||
|
||||
async update(UpdatePipelineRequest:IUpdatePipelineRequest) {
|
||||
async update(UpdatePipelineRequest: IUpdatePipelineRequest) {
|
||||
console.log('PipelinesClientService', 'Update');
|
||||
|
||||
const updatePipelineResponse = await new Promise((resolve, reject) => {
|
||||
this.pipelineService.update(UpdatePipelineRequest).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
this.pipelineService
|
||||
.Update(objectSnakeToCamel(UpdatePipelineRequest))
|
||||
.subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
})
|
||||
.then((res) => res)
|
||||
.catch((err) => {
|
||||
throw new Error(err);
|
||||
});
|
||||
|
||||
return updatePipelineResponse;
|
||||
return updatePipelineResponse;
|
||||
}
|
||||
|
||||
|
||||
async remove({id}:IdRequest) {
|
||||
async remove(data: IIdRequest) {
|
||||
console.log('PipelinesClientService', 'Remove');
|
||||
|
||||
const removePipelineResponse = await new Promise((resolve, reject) => {
|
||||
this.pipelineService.remove({id}).subscribe({
|
||||
this.pipelineService.remove(objectSnakeToCamel(data)).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
resolve(objectCamelToSnake(x));
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
@@ -156,10 +154,10 @@ export class PipelinesClientService implements OnModuleInit {
|
||||
throw new Error(err);
|
||||
});
|
||||
|
||||
return removePipelineResponse;
|
||||
return removePipelineResponse;
|
||||
}
|
||||
|
||||
async getPipelineLogsMessages( data:IGetPipelineLogsRequest) {
|
||||
async getPipelineLogsMessages(data: IGetPipelineLogsRequest) {
|
||||
console.log('PipelinesClientService', 'GetPipelineLogsMessages');
|
||||
|
||||
const logsPipelineResponse = await new Promise((resolve, reject) => {
|
||||
@@ -181,14 +179,14 @@ export class PipelinesClientService implements OnModuleInit {
|
||||
throw new Error(err);
|
||||
});
|
||||
|
||||
return logsPipelineResponse;
|
||||
return logsPipelineResponse;
|
||||
}
|
||||
|
||||
async getPipelineStatus({id}:IdRequest) {
|
||||
async getPipelineStatus(data: IIdRequest) {
|
||||
console.log('PipelinesClientService', 'GetPipelineStatus');
|
||||
|
||||
const statusPipelineResponse = await new Promise((resolve, reject) => {
|
||||
this.pipelineService.getPipelineStatus({id}).subscribe({
|
||||
this.pipelineService.getPipelineStatus(data).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
@@ -206,6 +204,32 @@ export class PipelinesClientService implements OnModuleInit {
|
||||
throw new Error(err);
|
||||
});
|
||||
|
||||
return statusPipelineResponse;
|
||||
return statusPipelineResponse;
|
||||
}
|
||||
|
||||
async runPipeline({ id, info }: IIdRequest) {
|
||||
console.log('PipelinesClientService', 'RunPipeline');
|
||||
const statusPipelineResponse = await new Promise((resolve, reject) => {
|
||||
this.pipelineService
|
||||
.triggerPipeline(objectSnakeToCamel({ id, info }))
|
||||
.subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
})
|
||||
.then((res) => res)
|
||||
.catch((err) => {
|
||||
throw new Error(err);
|
||||
});
|
||||
|
||||
return statusPipelineResponse;
|
||||
}
|
||||
}
|
||||
|
||||
+29
-18
@@ -1,28 +1,39 @@
|
||||
|
||||
export interface ICreatePipelineDto {
|
||||
input: IdRequest;
|
||||
transformations: IdRequest[];
|
||||
output: IdRequest;
|
||||
tags: string[];
|
||||
name: string;
|
||||
description: string;
|
||||
input: IdRequest;
|
||||
transformations: IdRequest[];
|
||||
output: IdRequest;
|
||||
tags: string[];
|
||||
name: string;
|
||||
description: string;
|
||||
info: Info;
|
||||
}
|
||||
|
||||
export interface Info {
|
||||
customer_id: sting;
|
||||
user_id: string;
|
||||
}
|
||||
|
||||
export interface IdRequest {
|
||||
id: string;
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface IIdRequest {
|
||||
id: string;
|
||||
info: Info;
|
||||
}
|
||||
|
||||
export interface IUpdatePipelineRequest {
|
||||
input: IdRequest;
|
||||
transformations: IdRequest[];
|
||||
output: IdRequest;
|
||||
tags: string[];
|
||||
name: string;
|
||||
description: string;
|
||||
id: string;
|
||||
input: IdRequest;
|
||||
transformations: IdRequest[];
|
||||
output: IdRequest;
|
||||
tags: string[];
|
||||
name: string;
|
||||
description: string;
|
||||
id: string;
|
||||
info: Info;
|
||||
}
|
||||
|
||||
export interface IGetPipelineLogsRequest {
|
||||
id: string;
|
||||
details: string;
|
||||
}
|
||||
id: string;
|
||||
details: string;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { ClientOptions, Transport } from '@nestjs/microservices';
|
||||
import { TransformationProtofile } from '@victorradael/protospack';
|
||||
import {
|
||||
TransformationPackages,
|
||||
TransformationProtoFilePath,
|
||||
} from '@victorradael/protospack';
|
||||
import { credentials } from '@grpc/grpc-js';
|
||||
|
||||
export class TransformationsClientConfiguration {
|
||||
@@ -8,9 +11,9 @@ export class TransformationsClientConfiguration {
|
||||
transport: Transport.GRPC,
|
||||
options: {
|
||||
url: process.env.TRFACTORY_URL,
|
||||
package: 'transformation',
|
||||
// credentials: credentials.createSsl(),
|
||||
protoPath: TransformationProtofile,
|
||||
package: TransformationPackages,
|
||||
credentials: credentials.createSsl(),
|
||||
protoPath: TransformationProtoFilePath,
|
||||
loader: {
|
||||
enums: String,
|
||||
objects: true,
|
||||
@@ -19,4 +22,4 @@ export class TransformationsClientConfiguration {
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,22 +1,11 @@
|
||||
import {
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Inject,
|
||||
OnModuleInit,
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
Client,
|
||||
ClientGrpc,
|
||||
MessagePattern,
|
||||
Payload,
|
||||
} from '@nestjs/microservices';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { Controller, Inject, OnModuleInit, Post } from '@nestjs/common';
|
||||
import { ClientGrpc } from '@nestjs/microservices';
|
||||
import { TransformationsServiceInterface } from '@victorradael/protospack';
|
||||
import { ICreateTransformationElement, ICreateTransformationsRequest, IdRequest, IUpdateTransformationRequest } from './interfaces';
|
||||
import {
|
||||
objectCamelToSnake,
|
||||
objectSnakeToCamel,
|
||||
} from 'src/utils/CaseConverter';
|
||||
import { ICreateTransformationsRequest, IIdRequest } from './interfaces';
|
||||
|
||||
@Controller('transformation')
|
||||
export class TransformationsClientService implements OnModuleInit {
|
||||
@@ -36,124 +25,149 @@ export class TransformationsClientService implements OnModuleInit {
|
||||
async create(createTransformationsDto: ICreateTransformationsRequest) {
|
||||
console.log('TransformationClientService', 'Create');
|
||||
|
||||
const createTransformationResponse = await new Promise((resolve, reject) => {
|
||||
this.transformationService.create(createTransformationsDto).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
})
|
||||
const createTransformationResponse = await new Promise(
|
||||
(resolve, reject) => {
|
||||
this.transformationService
|
||||
.Create(objectSnakeToCamel(createTransformationsDto))
|
||||
.subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
},
|
||||
)
|
||||
.then((res) => res)
|
||||
.catch((err) => {
|
||||
throw new Error(err);
|
||||
});
|
||||
return createTransformationResponse;
|
||||
|
||||
const convertedTransforms = createTransformationResponse[
|
||||
'transformations'
|
||||
].map((tr) => {
|
||||
return objectCamelToSnake(tr);
|
||||
});
|
||||
|
||||
return { transformations: convertedTransforms };
|
||||
}
|
||||
|
||||
async findAll() {
|
||||
async findAll(data) {
|
||||
console.log('TransformationClientService', 'FindAll');
|
||||
|
||||
const findAllTransformationResponse = await new Promise((resolve, reject) => {
|
||||
this.transformationService.findAll({}).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
})
|
||||
const findAllTransformationResponse = await new Promise(
|
||||
(resolve, reject) => {
|
||||
this.transformationService.FindAll(objectSnakeToCamel(data)).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
},
|
||||
)
|
||||
.then((res) => res)
|
||||
.catch((err) => {
|
||||
throw new Error(err);
|
||||
});
|
||||
|
||||
return findAllTransformationResponse;
|
||||
const convertedTransforms = findAllTransformationResponse[
|
||||
'transformations'
|
||||
].map((tr) => {
|
||||
return objectCamelToSnake(tr);
|
||||
});
|
||||
return { transformations: convertedTransforms };
|
||||
}
|
||||
|
||||
async findOne({id}: IdRequest) {
|
||||
async findOne(data: IIdRequest) {
|
||||
console.log('TransformationClientService', 'FindOne');
|
||||
|
||||
const findOneTransformationResponse = await new Promise((resolve, reject) => {
|
||||
this.transformationService.findOne({id}).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
})
|
||||
const findOneTransformationResponse = await new Promise(
|
||||
(resolve, reject) => {
|
||||
this.transformationService.FindOne(objectSnakeToCamel(data)).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
},
|
||||
)
|
||||
.then((res) => res)
|
||||
.catch((err) => {
|
||||
throw new Error(err);
|
||||
});
|
||||
|
||||
return findOneTransformationResponse;
|
||||
return objectCamelToSnake(findOneTransformationResponse);
|
||||
}
|
||||
|
||||
async update(updateTransformationDTO: IUpdateTransformationRequest) {
|
||||
async update(updateTransformationDTO) {
|
||||
console.log('TransformationClientService', 'Update');
|
||||
|
||||
const updateTransformationResponse = await new Promise((resolve, reject) => {
|
||||
this.transformationService.update(updateTransformationDTO).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
})
|
||||
const updateTransformationResponse = await new Promise(
|
||||
(resolve, reject) => {
|
||||
this.transformationService
|
||||
.Update(objectSnakeToCamel(updateTransformationDTO))
|
||||
.subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
},
|
||||
)
|
||||
.then((res) => res)
|
||||
.catch((err) => {
|
||||
throw new Error(err);
|
||||
});
|
||||
|
||||
return updateTransformationResponse;
|
||||
return objectCamelToSnake(updateTransformationResponse);
|
||||
}
|
||||
|
||||
async remove({id}: IdRequest) {
|
||||
async remove(data: IIdRequest) {
|
||||
console.log('TransformationClientService', 'Remove');
|
||||
|
||||
const removeTransformationResponse = await new Promise((resolve, reject) => {
|
||||
this.transformationService.remove({id}).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
})
|
||||
const removeTransformationResponse = await new Promise(
|
||||
(resolve, reject) => {
|
||||
this.transformationService.Remove(objectSnakeToCamel(data)).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
error(err) {
|
||||
console.log('Observable Error');
|
||||
reject(err);
|
||||
},
|
||||
complete() {
|
||||
console.log('done');
|
||||
},
|
||||
});
|
||||
},
|
||||
)
|
||||
.then((res) => res)
|
||||
.catch((err) => {
|
||||
throw new Error(err);
|
||||
});
|
||||
|
||||
return removeTransformationResponse;
|
||||
return objectCamelToSnake(removeTransformationResponse);
|
||||
}
|
||||
}
|
||||
|
||||
+29
-23
@@ -1,31 +1,37 @@
|
||||
export interface ICreateTransformationsRequest {
|
||||
transformations: ICreateTransformationElement[];
|
||||
transformations: Transformation[];
|
||||
info: Info;
|
||||
}
|
||||
interface Param {
|
||||
base_column?: string;
|
||||
column_name?: string;
|
||||
n_digits?: number;
|
||||
start_index?: number;
|
||||
randbelow?: number;
|
||||
const?: string;
|
||||
}
|
||||
export interface ICreateTransformationElement {
|
||||
type: string;
|
||||
params: Param[];
|
||||
input_source: string;
|
||||
table: string;
|
||||
base_column: string;
|
||||
column_name: string;
|
||||
n_digits: number;
|
||||
start_index: number;
|
||||
randbelow: number;
|
||||
const: string;
|
||||
}
|
||||
|
||||
export interface IdRequest{
|
||||
id:string;
|
||||
export interface Info {
|
||||
customer_id: string;
|
||||
user_id: string;
|
||||
}
|
||||
|
||||
interface Transformation {
|
||||
created_at: string;
|
||||
id: string;
|
||||
client_id: string;
|
||||
type: string;
|
||||
params: Param[];
|
||||
input_source: string;
|
||||
table: string;
|
||||
}
|
||||
|
||||
export interface IIdRequest {
|
||||
id: string;
|
||||
info: Info;
|
||||
}
|
||||
|
||||
export interface IUpdateTransformationRequest {
|
||||
created_at?: string;
|
||||
id?: string;
|
||||
client_id?: string;
|
||||
params: Param[];
|
||||
type?: string;
|
||||
input_source?: string;
|
||||
table?: string;
|
||||
}
|
||||
transformation: Transformation;
|
||||
info: Info;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import { HttpExceptionFilter } from './http-exception.filter';
|
||||
|
||||
describe('HttpExceptionFilter', () => {
|
||||
it('should be defined', () => {
|
||||
expect(new HttpExceptionFilter()).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
import {
|
||||
ExceptionFilter,
|
||||
Catch,
|
||||
ArgumentsHost,
|
||||
HttpException,
|
||||
} from '@nestjs/common';
|
||||
import { Request, Response } from 'express';
|
||||
|
||||
@Catch(HttpException)
|
||||
export class HttpExceptionFilter implements ExceptionFilter {
|
||||
catch(exception: HttpException, host: ArgumentsHost) {
|
||||
const ctx = host.switchToHttp();
|
||||
const response = ctx.getResponse<Response>();
|
||||
const request = ctx.getRequest<Request>();
|
||||
const status = exception.getStatus();
|
||||
|
||||
response.status(status).json({
|
||||
status_code: status,
|
||||
timestamp: new Date().toISOString(),
|
||||
path: request.url,
|
||||
method: request.method,
|
||||
});
|
||||
}
|
||||
}
|
||||
+11
-1
@@ -1,11 +1,21 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||
import { writeFileSync } from 'fs';
|
||||
import helmet from 'helmet';
|
||||
|
||||
import { AppModule } from './app.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
const app = await NestFactory.create(AppModule, {
|
||||
cors: {
|
||||
origin: '*',
|
||||
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
|
||||
preflightContinue: false,
|
||||
optionsSuccessStatus: 204,
|
||||
},
|
||||
});
|
||||
|
||||
app.use(helmet());
|
||||
|
||||
const config = new DocumentBuilder()
|
||||
.setTitle('Maestro Grpc Documentation')
|
||||
|
||||
@@ -1,23 +1,127 @@
|
||||
import { Request, Response, NextFunction } from 'express';
|
||||
import axios from 'axios';
|
||||
import { NestMiddleware } from '@nestjs/common';
|
||||
import {
|
||||
ForbiddenException,
|
||||
InternalServerErrorException,
|
||||
NestMiddleware,
|
||||
UnauthorizedException,
|
||||
UseFilters,
|
||||
} from '@nestjs/common';
|
||||
import jwkToPem from 'jwk-to-pem';
|
||||
import { decode, verify } from 'jsonwebtoken';
|
||||
import { HttpExceptionFilter } from 'src/error/http-exception.filter';
|
||||
|
||||
@UseFilters(new HttpExceptionFilter())
|
||||
export class LoggerMiddleware implements NestMiddleware {
|
||||
use = async (request: Request, response: Response, next: NextFunction) => {
|
||||
try {
|
||||
const verify_response = await axios
|
||||
.post(`${process.env.DEV_URL}/user/verify`, {
|
||||
token: request.get('Authorization'),
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.data.message == 'Success') {
|
||||
next();
|
||||
}
|
||||
});
|
||||
const idToken = request.get('Dadosfera-User');
|
||||
const accessToken = request.get('Authorization');
|
||||
const privateKey = process.env.JWT_PRIVATE_KEY;
|
||||
|
||||
console.log(verify_response);
|
||||
} catch (error) {
|
||||
response.status(401).send({ message: 'Authentication Failed!' });
|
||||
const requiredMethod = request.method.trim();
|
||||
const requiredRoute = request.route.path.split('/')[1].trim();
|
||||
|
||||
verify(idToken, privateKey, (err) => {
|
||||
if (err) {
|
||||
throw new UnauthorizedException();
|
||||
}
|
||||
});
|
||||
const jwtDecoded: any = decode(idToken);
|
||||
|
||||
const permissions = jwtDecoded.user.permissions;
|
||||
const clienId = jwtDecoded.user.customerId;
|
||||
const customer = jwtDecoded.user.customer;
|
||||
const userId = jwtDecoded.user.id;
|
||||
|
||||
await verifyToken(accessToken);
|
||||
|
||||
let havePermission = false;
|
||||
permissions.forEach((permission) => {
|
||||
permission = permission.split('/');
|
||||
const method = permission[0].trim();
|
||||
const route = permission[1].trim();
|
||||
|
||||
if (method === requiredMethod && route === requiredRoute) {
|
||||
havePermission = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (havePermission) {
|
||||
request.body.info = {
|
||||
customer_id: clienId,
|
||||
user_id: userId,
|
||||
customer,
|
||||
};
|
||||
|
||||
next();
|
||||
} else {
|
||||
throw new ForbiddenException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let pems: { [key: string]: Record<string, unknown> }[];
|
||||
|
||||
const setUp = async (region: string, id: string) => {
|
||||
const URL = `https://cognito-idp.${region}.amazonaws.com/${id}/.well-known/jwks.json`;
|
||||
|
||||
try {
|
||||
const response = await axios.get(URL);
|
||||
|
||||
if (response.status !== 200) {
|
||||
throw new InternalServerErrorException();
|
||||
}
|
||||
const data = await response.data;
|
||||
const { keys } = data;
|
||||
|
||||
pems = keys.map((key: any) => {
|
||||
const modulus = key.n;
|
||||
const exponent = key.e;
|
||||
const keyType = key.kty;
|
||||
const jwk = { kty: keyType, n: modulus, e: exponent };
|
||||
const pem = jwkToPem(jwk);
|
||||
const keyId = key.kid;
|
||||
|
||||
return { [keyId]: pem };
|
||||
});
|
||||
} catch (error) {
|
||||
// console.log(error);
|
||||
// console.log('Error! Unable to download JWKs');
|
||||
}
|
||||
};
|
||||
|
||||
const verifyToken = async (accessToken: string) => {
|
||||
const awsRegion = process.env.AWS_REGION;
|
||||
const awsPoolId = process.env.AWS_IDENTITY_POOL_ID;
|
||||
|
||||
try {
|
||||
await setUp(awsRegion, awsPoolId);
|
||||
if (!accessToken) {
|
||||
throw new UnauthorizedException();
|
||||
}
|
||||
|
||||
const user: any = decode(accessToken, { complete: true });
|
||||
|
||||
if (user === null) {
|
||||
throw new UnauthorizedException();
|
||||
}
|
||||
|
||||
const { kid } = user.header;
|
||||
const pem = pems.filter((item: any) => item[kid]);
|
||||
const pemValue: any = pem[0][kid];
|
||||
|
||||
if (!pem) {
|
||||
throw new UnauthorizedException();
|
||||
}
|
||||
|
||||
verify(accessToken, pemValue, (err: any) => {
|
||||
if (err) {
|
||||
throw new UnauthorizedException();
|
||||
}
|
||||
|
||||
return;
|
||||
});
|
||||
} catch (error) {
|
||||
throw new UnauthorizedException();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Body, Controller, Post } from '@nestjs/common';
|
||||
import { Body, Controller, Post, UnauthorizedException } from '@nestjs/common';
|
||||
|
||||
import { AuthClientService } from 'src/clients/auth/client.service';
|
||||
|
||||
@@ -18,7 +18,9 @@ export class AuthController {
|
||||
const tokens = await this.authClient
|
||||
.signIn({ username, password })
|
||||
.then((result) => result)
|
||||
.catch((err) => console.log(err));
|
||||
.catch((err) => {
|
||||
throw new UnauthorizedException(err.message);
|
||||
});
|
||||
|
||||
return tokens;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,289 @@
|
||||
import { Body, Controller, Delete, Get, Param, Post } from '@nestjs/common';
|
||||
import { CatalogService } from './catalog.service';
|
||||
|
||||
@Controller('catalog')
|
||||
export class CatalogController {
|
||||
constructor(private catalogService: CatalogService) {}
|
||||
|
||||
@Get('all')
|
||||
async catalogAll(@Body() body) {
|
||||
console.log(`/catalog`, 'ON CATALOG ALL ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.catalogAll(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Get('data_apps')
|
||||
async dataAppsAll(@Body() body) {
|
||||
console.log(`/catalog`, 'ON FIND ALL DATA APPS ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.dataAppsAll(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Delete('data_apps/:id')
|
||||
async dataAppsOne(@Param() params, @Body() body) {
|
||||
console.log(`/catalog`, 'ON FIND ONE DATA APP ROUTE');
|
||||
const { id } = params;
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.dataAppsOne(body, id);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Get('dashboard-metabase')
|
||||
async getAllDashboardMetabase(@Body() body) {
|
||||
console.log(`/catalog`, 'ON GET ALL DASHBOARDS METABASE ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getAllDashboardMetabase(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Get('dashboard-metabase/:id')
|
||||
async getOneDashboardMetabase(@Body() body, @Param() params) {
|
||||
const { id } = params;
|
||||
console.log(`/catalog`, 'ON GET ONE DASHBOARD METABASE ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getOneDashboardMetabase(body, id);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Get('table-metadata')
|
||||
async getAllTableMetadata(@Body() body) {
|
||||
console.log(`/catalog`, 'ON GET ALL TABLES METADATA ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getAllTableMetadata(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Delete('table-metadata')
|
||||
async deleteOneTableMetadata(@Param() params, @Body() body) {
|
||||
const { id } = params;
|
||||
console.log(`/catalog`, 'ON DELETE ONE TABLE METADATA ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.deleteOneTableMetadata(body, id);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Get('column-metadata')
|
||||
async getOneColumnMetadata(@Body() body) {
|
||||
console.log(`/catalog`, 'ON GET ONE COLUMN METADATA ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getOneColumnMetadata(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Delete('column-metadata')
|
||||
async deleteOneColumnMetadata(@Param() params, @Body() body) {
|
||||
console.log(`/catalog`, 'ON DELETE ONE COLUMN METADATA ROUTE');
|
||||
const { id } = params;
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.deleteOneColumnMetadata(body, id);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Get('data-preview')
|
||||
async getOneDataPreview(@Body() body) {
|
||||
console.log(`/catalog`, 'ON GET ONE DATAPREVIEW ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getOneDataPreview(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Get('data-status')
|
||||
async getDataStatus(@Body() body) {
|
||||
console.log(`/catalog`, 'ON GET DATA STATUS ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getDataStatus(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Get('data-description')
|
||||
async getDataDescription(@Body() body) {
|
||||
console.log(`/catalog`, 'ON GET DATA DESCRIPTION ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getDataDescription(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Get('data-docs')
|
||||
async getDataDocs(@Body() body) {
|
||||
console.log(`/catalog`, 'ON GET DATA DOCS ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getDataDocs(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Get('data-rating')
|
||||
async getDataRating(@Body() body) {
|
||||
console.log(`/catalog`, 'ON GET DATA RATING ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getDataRating(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Get('summary-rating/:id')
|
||||
async getSummaryRating(@Param() params, @Body() body) {
|
||||
console.log(`/catalog`, 'ON GET SUMMARY RATING ROUTE');
|
||||
const { id } = params;
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getSummaryRating(id, body);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Get('data-comment')
|
||||
async getDataComment(@Body() body) {
|
||||
console.log(`/catalog`, 'ON GET DATA COMMENT ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getDataComment(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Get('data-review')
|
||||
async getDataReview(@Body() body) {
|
||||
console.log(`/catalog`, 'ON GET DATA REVIEW ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getDataReview(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Post('tags')
|
||||
async createTags(@Body() body) {
|
||||
console.log(`/catalog`, 'ON CREATE TAG ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.createTags(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Get('tags')
|
||||
async findAllTags(@Body() body) {
|
||||
console.log(`/catalog`, 'ON FIND ALL TAGS ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.findAllTags(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Delete('tags/:id')
|
||||
async deleteTags(@Param() params, @Body() body) {
|
||||
console.log(`/catalog`, 'ON DELETE TAG ROUTE');
|
||||
const { id } = params;
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.deleteTags(body, id);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Post('table-tags')
|
||||
async createTableTags(@Body() body) {
|
||||
console.log(`/catalog`, 'ON CREATE TABLE TAG ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.createTableTags(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Get('table-tags')
|
||||
async getAllTableTags(@Body() body) {
|
||||
console.log(`/catalog`, 'ON GET ALL TABLE TAGS ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.findAllTableTags(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Delete('table-tags')
|
||||
async deleteTableTags(@Param() params, @Body() body) {
|
||||
console.log(`/catalog`, 'ON CREATE TABLE TAGS ROUTE');
|
||||
const { id } = params;
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.deleteTableTags(body, id);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Get('table-rules')
|
||||
async getTableRules(@Body() body) {
|
||||
console.log(`/catalog`, 'ON GET TABLE RULES ROUTE');
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.getTableRules(body);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Delete('table-rules')
|
||||
async deleteTableRules(@Param() params, @Body() body) {
|
||||
console.log(`/catalog`, 'ON DELETE TABLE RULES ROUTE');
|
||||
const { id } = params;
|
||||
|
||||
const catalogService = new CatalogService();
|
||||
|
||||
const res = await catalogService.deleteTableRules(body, id);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
import axios from 'axios';
|
||||
|
||||
class CatalogService {
|
||||
async catalogAll(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
const { data } = await axios.get(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/all/`,
|
||||
);
|
||||
console.log(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/all/`,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async dataAppsAll(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.get(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/data_apps/`,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async dataAppsOne(id, body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.delete(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/data_apps/${id}/`,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async getAllDashboardMetabase(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.get(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/dashboard-metabase/`,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async getOneDashboardMetabase(body, id) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.get(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/dashboard-metabase/${id}`,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async getAllTableMetadata(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.get(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/table-metadata/`,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async deleteOneTableMetadata(id, body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.delete(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/table-metadata/${id}`,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async getOneColumnMetadata(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.get(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/column-metadata/`,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async deleteOneColumnMetadata(id, body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.delete(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/column-metadata/${id}/`,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async getOneDataPreview(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.get(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/data-preview/`,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async getDataStatus(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.get(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/data-status/`,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async getDataDescription(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.get(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/data-description/`,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async getDataDocs(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.get(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/data-docs/`,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async getDataRating(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.get(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/data-rating/`,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async getSummaryRating(id, body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
const { data } = await axios.get(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/summary-rating/${id}`,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async getDataComment(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.get(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/data-comment/`,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async getDataReview(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.get(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/data-review/`,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async createTags(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.post(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/tags/`,
|
||||
body,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async findAllTags(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.get(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/tags/`,
|
||||
body,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async findAllTableTags(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.get(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/table-tags/`,
|
||||
body,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async deleteTags(id, body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.delete(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/tags/${id}`,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async createTableTags(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.post(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/table-tags/`,
|
||||
body,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async deleteTableTags(id, body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.delete(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/table-tags/${id}`,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async getTableRules(body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.get(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/table-rules/`,
|
||||
body,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
|
||||
async deleteTableRules(id, body) {
|
||||
const customer =
|
||||
body.info.customer.toLowerCase() === 'dadosfera'
|
||||
? ``
|
||||
: `-${body.info.customer.toLowerCase()}`;
|
||||
|
||||
const { data } = await axios.delete(
|
||||
`${process.env.NIMBUS_BASE_URL}${customer}.${process.env.ENV}.dadosfera/api/catalog/table-rules/${id}`,
|
||||
);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
export { CatalogService };
|
||||
@@ -7,6 +7,7 @@ export class HealthController {
|
||||
|
||||
@Get()
|
||||
check() {
|
||||
console.log(`/health`, 'check');
|
||||
return this.healthService.check();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Injectable } from '@nestjs/common';
|
||||
@Injectable()
|
||||
export class HealthService {
|
||||
check() {
|
||||
console.log('HEALTH');
|
||||
return { message: 'Ok' };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,92 +7,83 @@ import {
|
||||
Post,
|
||||
Put,
|
||||
} from '@nestjs/common';
|
||||
import axios from 'axios';
|
||||
import { InputsService } from './inputs.service';
|
||||
import { InputsClientService } from 'src/clients/inputs/client.service';
|
||||
import { Payload } from '@nestjs/microservices';
|
||||
import {
|
||||
ICreateInputRequest,
|
||||
UpdateInputRequest,
|
||||
} from 'src/clients/inputs/interfaces';
|
||||
|
||||
@Controller('input')
|
||||
@Controller('inputs')
|
||||
export class InputsController {
|
||||
constructor(private inputsClientService: InputsClientService) {}
|
||||
|
||||
constructor( private inputsClientService:InputsClientService){}
|
||||
|
||||
@Get('/test-connection')
|
||||
@Post('/test-connection')
|
||||
async testConnection(@Body() data) {
|
||||
console.log(
|
||||
process.env.DEV_URL + `/test-connection`,
|
||||
'ON TEST CONNECTION ROUTE',
|
||||
);
|
||||
|
||||
console.log(data)
|
||||
console.log(`/test-connection`, 'ON TEST CONNECTION ROUTE');
|
||||
|
||||
const inputService = new InputsService(this.inputsClientService)
|
||||
const response = await inputService.testConnection(data)
|
||||
const inputService = new InputsService(this.inputsClientService);
|
||||
const response = await inputService.testConnection(data);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Post()
|
||||
async create(@Body() createInputDto) {
|
||||
console.log(process.env.DEV_URL + `/input`, 'ON CREATE ROUTE');
|
||||
async create(@Body() createInputDto: ICreateInputRequest) {
|
||||
console.log(`/input`, 'ON CREATE ROUTE');
|
||||
|
||||
const inputService = new InputsService(this.inputsClientService)
|
||||
const response = await inputService.create(createInputDto)
|
||||
const inputService = new InputsService(this.inputsClientService);
|
||||
const response = await inputService.create(createInputDto);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Get()
|
||||
async findAll() {
|
||||
console.log(process.env.DEV_URL + `/input`, 'ON FIND ALL ROUTE');
|
||||
async findAll(@Body() body) {
|
||||
console.log(`/input`, 'ON FIND ALL ROUTE');
|
||||
|
||||
const inputService = new InputsService(this.inputsClientService)
|
||||
const inputService = new InputsService(this.inputsClientService);
|
||||
|
||||
const response = await inputService.findAll()
|
||||
const response = await inputService.findAll(body);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Get('/:id')
|
||||
async findOne(@Param() params) {
|
||||
const { id } = params
|
||||
console.log(process.env.DEV_URL + `/input/${id}`, 'ON FIND ONE ROUTE');
|
||||
const inputService = new InputsService(this.inputsClientService)
|
||||
|
||||
const response = await inputService.findOne(id)
|
||||
async findOne(@Body() body, @Param() params) {
|
||||
const { id } = params;
|
||||
console.log(`/input/${id}`, 'ON FIND ONE ROUTE');
|
||||
const inputService = new InputsService(this.inputsClientService);
|
||||
|
||||
const response = await inputService.findOne({ id, ...body });
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@Put(':id')
|
||||
async update(
|
||||
@Payload() updateInputDto,
|
||||
@Param() params,
|
||||
) {
|
||||
|
||||
const {id} = params;
|
||||
async update(@Body() updateInputDto: UpdateInputRequest, @Param() params) {
|
||||
const { id } = params;
|
||||
const { info } = updateInputDto;
|
||||
delete updateInputDto.info;
|
||||
|
||||
console.log(process.env.DEV_URL + `/input/${id}`, 'ON UPDATE ROUTE');
|
||||
const inputService = new InputsService(this.inputsClientService)
|
||||
console.log(`/input/${id}`, 'ON UPDATE ROUTE');
|
||||
const inputService = new InputsService(this.inputsClientService);
|
||||
|
||||
const response = await inputService.update(id,updateInputDto)
|
||||
const response = await inputService.update(id, updateInputDto, info);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param() params) {
|
||||
async delete(@Body() data, @Param() params) {
|
||||
const { id } = params;
|
||||
|
||||
const {id} = params
|
||||
|
||||
console.log(process.env.DEV_URL + `/input/${id}`, 'ON DELETE ROUTE');
|
||||
console.log(`/input/${id}`, 'ON DELETE ROUTE');
|
||||
|
||||
const inputService = new InputsService(this.inputsClientService)
|
||||
const inputService = new InputsService(this.inputsClientService);
|
||||
|
||||
const response = await inputService.remove(id)
|
||||
const response = await inputService.remove({ id, ...data });
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,87 +1,77 @@
|
||||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||
import { Body, HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||
import { InputsClientService } from 'src/clients/inputs/client.service';
|
||||
import {
|
||||
ICreateInputRequest,
|
||||
IIdRequest,
|
||||
Info,
|
||||
} from 'src/clients/inputs/interfaces';
|
||||
|
||||
@Injectable()
|
||||
export class InputsService {
|
||||
constructor(private inputClient: InputsClientService) {}
|
||||
|
||||
constructor( private inputClient: InputsClientService){}
|
||||
async create(@Body() data: ICreateInputRequest) {
|
||||
try {
|
||||
const createInputResponse = await this.inputClient.create(data);
|
||||
|
||||
|
||||
async create(data){
|
||||
|
||||
try{
|
||||
|
||||
const createInputResponse = await this.inputClient.create(data)
|
||||
|
||||
return createInputResponse;
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findAll(){
|
||||
async findAll(body) {
|
||||
try {
|
||||
const findAllInputResponse = await this.inputClient.findAll(body);
|
||||
|
||||
try{
|
||||
|
||||
const findAllInputResponse = await this.inputClient.findAll({})
|
||||
|
||||
return findAllInputResponse;
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findOne(id:string){
|
||||
|
||||
try{
|
||||
|
||||
const findOneInputResponse = await this.inputClient.findOne({id})
|
||||
async findOne(idRequest: IIdRequest) {
|
||||
try {
|
||||
const findOneInputResponse = await this.inputClient.findOne(idRequest);
|
||||
return findOneInputResponse;
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async update(id:string,data){
|
||||
async update(id: string, data, info: Info) {
|
||||
try {
|
||||
const updateInputResponse = await this.inputClient.update({
|
||||
id,
|
||||
info,
|
||||
...data,
|
||||
});
|
||||
|
||||
try{
|
||||
|
||||
const updateInputResponse = await this.inputClient.update({id,...data})
|
||||
|
||||
return updateInputResponse;
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async remove(id:string){
|
||||
async remove(idRequest: IIdRequest) {
|
||||
try {
|
||||
const removeInputResponse = await this.inputClient.remove(idRequest);
|
||||
|
||||
try{
|
||||
const removeInputResponse = await this.inputClient.remove({id})
|
||||
|
||||
return removeInputResponse;
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async testConnection(data){
|
||||
async testConnection(data) {
|
||||
try {
|
||||
const testConnectionInputResponse = await this.inputClient.testConnection(
|
||||
data,
|
||||
);
|
||||
|
||||
try{
|
||||
|
||||
const testConnectionInputResponse = await this.inputClient.testConnection(data)
|
||||
|
||||
return testConnectionInputResponse;
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
Redirect,
|
||||
} from '@nestjs/common';
|
||||
import { Payload } from '@nestjs/microservices';
|
||||
import { OutputsClientService } from 'src/clients/outputs/client.service';
|
||||
@@ -14,63 +13,60 @@ import { OutputsService } from './outputs.service';
|
||||
|
||||
@Controller('outputs')
|
||||
export class OutputsController {
|
||||
|
||||
constructor( private outputsClientService:OutputsClientService){}
|
||||
constructor(private outputsClientService: OutputsClientService) {}
|
||||
|
||||
@Post()
|
||||
async create(@Body() createOutputDto) {
|
||||
console.log(process.env.DEV_URL + `/output`, 'ON CREATE ROUTE');
|
||||
|
||||
const outputService = new OutputsService(this.outputsClientService)
|
||||
const response = await outputService.create(createOutputDto)
|
||||
const outputService = new OutputsService(this.outputsClientService);
|
||||
const response = await outputService.create(createOutputDto);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Get()
|
||||
async findAll() {
|
||||
async findAll(@Body() data) {
|
||||
console.log(process.env.DEV_URL + `/output`, 'ON Find All ROUTE');
|
||||
|
||||
const outputService = new OutputsService(this.outputsClientService)
|
||||
const response = await outputService.findAll()
|
||||
const outputService = new OutputsService(this.outputsClientService);
|
||||
const response = await outputService.findAll(data);
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Get('/:id')
|
||||
async findOne(@Param() params) {
|
||||
const {id} = params;
|
||||
async findOne(@Body() data, @Param() params) {
|
||||
const { id } = params;
|
||||
console.log(process.env.DEV_URL + `/output/${id}`, 'ON Find One ROUTE');
|
||||
|
||||
const outputService = new OutputsService(this.outputsClientService)
|
||||
const response = await outputService.findOne(id)
|
||||
|
||||
const outputService = new OutputsService(this.outputsClientService);
|
||||
const response = await outputService.findOne({ id, ...data });
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
async update(
|
||||
@Payload() updateOutputDto,
|
||||
@Param() params,
|
||||
) {
|
||||
const {id} = params;
|
||||
async update(@Payload() updateOutputDto, @Param() params) {
|
||||
const { id } = params;
|
||||
const { info } = updateOutputDto;
|
||||
delete updateOutputDto.info;
|
||||
|
||||
console.log(process.env.DEV_URL + `/output/${id}`, 'ON UPDATE ROUTE');
|
||||
|
||||
const outputService = new OutputsService(this.outputsClientService)
|
||||
const response = await outputService.update(id,updateOutputDto)
|
||||
const outputService = new OutputsService(this.outputsClientService);
|
||||
const response = await outputService.update(id, updateOutputDto, info);
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param() params) {
|
||||
const {id} = params;
|
||||
async delete(@Body() data, @Param() params) {
|
||||
const { id } = params;
|
||||
console.log(process.env.DEV_URL + `/output/${id}`, 'ON DELETE ROUTE');
|
||||
|
||||
const outputService = new OutputsService(this.outputsClientService)
|
||||
const response = await outputService.remove(id)
|
||||
const outputService = new OutputsService(this.outputsClientService);
|
||||
const response = await outputService.remove({ id, ...data });
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -1,69 +1,63 @@
|
||||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||
import { IIdRequest, Info } from 'src/clients/outputs/interfaces';
|
||||
import { OutputsClientService } from 'src/clients/outputs/client.service';
|
||||
|
||||
@Injectable()
|
||||
export class OutputsService {
|
||||
constructor(private outputClient: OutputsClientService) {}
|
||||
|
||||
constructor( private outputClient: OutputsClientService){}
|
||||
async create(createOutputDto) {
|
||||
try {
|
||||
const createOutputResponse = await this.outputClient.create(
|
||||
createOutputDto,
|
||||
);
|
||||
|
||||
async create(createOutputDto){
|
||||
try{
|
||||
const createOutputResponse = await this.outputClient.create(createOutputDto);
|
||||
|
||||
return createOutputResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findOne(id:string){
|
||||
|
||||
try{
|
||||
const findOneOutputResponse = await this.outputClient.findOne({id});
|
||||
return findOneOutputResponse
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findAll(){
|
||||
|
||||
try{
|
||||
const findAllOutputResponse = await this.outputClient.findAll();
|
||||
|
||||
return findAllOutputResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return createOutputResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async update(id:string, data){
|
||||
|
||||
try{
|
||||
|
||||
const updateOutputResponse = await this.outputClient.update({id,...data});
|
||||
|
||||
return updateOutputResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
async findOne(data: IIdRequest) {
|
||||
try {
|
||||
const findOneOutputResponse = await this.outputClient.findOne(data);
|
||||
return findOneOutputResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async remove(id:string){
|
||||
async findAll(data) {
|
||||
try {
|
||||
const findAllOutputResponse = await this.outputClient.findAll(data);
|
||||
|
||||
try{
|
||||
return findAllOutputResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
const removeOutputResponse = await this.outputClient.remove({id});
|
||||
|
||||
return removeOutputResponse
|
||||
async update(id: string, data, info: Info) {
|
||||
try {
|
||||
const updateOutputResponse = await this.outputClient.update({
|
||||
id,
|
||||
info,
|
||||
...data,
|
||||
});
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return updateOutputResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async remove(data: IIdRequest) {
|
||||
try {
|
||||
const removeOutputResponse = await this.outputClient.remove(data);
|
||||
|
||||
return removeOutputResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,104 +6,113 @@ import {
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
Redirect,
|
||||
} from '@nestjs/common';
|
||||
import { Payload } from '@nestjs/microservices';
|
||||
import { PipelinesClientService } from 'src/clients/pipelines/client.service';
|
||||
import { objectCamelToSnake } from 'src/utils/CaseConverter';
|
||||
import { PipelinesService } from './pipelines.service';
|
||||
|
||||
@Controller('pipelines')
|
||||
export class PipelinesController {
|
||||
constructor(private pipelinesClientService: PipelinesClientService) {}
|
||||
|
||||
constructor( private pipelinesClientService:PipelinesClientService){}
|
||||
@Get('start/:id')
|
||||
async activate(@Param() params, @Body() body) {
|
||||
const { id } = params;
|
||||
const { info } = body;
|
||||
|
||||
@Get(':id/status')
|
||||
async getPipelineStatus(
|
||||
@Param() params,
|
||||
) {
|
||||
const { id , details } = params;
|
||||
console.log(process.env.DEV_URL + `/pipeline/${id}`, 'ON GET PIPELINE STATUS ROUTE');
|
||||
console.log(
|
||||
process.env.DEV_URL + `/transformation/start/${id}`,
|
||||
'ON START PIPELINE ROUTE',
|
||||
);
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.getPipelineStatus(id)
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService);
|
||||
const response = await pipelineService.runPipeline({ id, info });
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Get(':id/status')
|
||||
async getPipelineStatus(@Body() body, @Param() params) {
|
||||
const { id } = params;
|
||||
body.id = id;
|
||||
|
||||
@Get(':id/:details')
|
||||
async getPipelineLogs(
|
||||
@Param() params,
|
||||
) {
|
||||
const { id , details } = params;
|
||||
console.log(process.env.DEV_URL + `/pipeline/${id}`, 'ON GET PIPELINE LOGS ROUTE');
|
||||
console.log(
|
||||
process.env.DEV_URL + `/pipeline/${id}`,
|
||||
'ON GET PIPELINE STATUS ROUTE',
|
||||
);
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.getPipelineLogsMessages(id,details)
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService);
|
||||
const response = await pipelineService.getPipelineStatus(body);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Get(':id/:details')
|
||||
async getPipelineLogs(@Param() params) {
|
||||
const { id, details } = params;
|
||||
console.log(
|
||||
process.env.DEV_URL + `/pipeline/${id}`,
|
||||
'ON GET PIPELINE LOGS ROUTE',
|
||||
);
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService);
|
||||
const response = await pipelineService.getPipelineLogsMessages(id, details);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Post()
|
||||
async create(@Body() createPipelineDto) {
|
||||
console.log(process.env.DEV_URL + `/pipelines`, 'ON CREATE ROUTE');
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.create(createPipelineDto)
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService);
|
||||
const response = await pipelineService.create(createPipelineDto);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Get()
|
||||
async findAll() {
|
||||
async findAll(@Body() data) {
|
||||
console.log(process.env.DEV_URL + `/pipeline`, 'ON Find All ROUTE');
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.findAll()
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService);
|
||||
const response = await pipelineService.findAll(data);
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Get('/:id')
|
||||
async findOne(@Param() params) {
|
||||
const {id} = params;
|
||||
async findOne(@Body() data, @Param() params) {
|
||||
const { id } = params;
|
||||
console.log(process.env.DEV_URL + `/pipeline/${id}`, 'ON Find One ROUTE');
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.findOne(id)
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService);
|
||||
const response = await pipelineService.findOne({ id, ...data });
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
async update(
|
||||
@Payload() updatePipelineDto,
|
||||
@Param() params,
|
||||
) {
|
||||
const {id} = params;
|
||||
async update(@Body() updatePipelineDto, @Param() params) {
|
||||
const { id } = params;
|
||||
const { info } = updatePipelineDto;
|
||||
delete updatePipelineDto.info;
|
||||
|
||||
console.log(process.env.DEV_URL + `/pipeline/${id}`, 'ON UPDATE ROUTE');
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.update(id,updatePipelineDto)
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService);
|
||||
const response = await pipelineService.update(id, updatePipelineDto, info);
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param() params) {
|
||||
const {id} = params;
|
||||
async delete(@Body() data, @Param() params) {
|
||||
const { id } = params;
|
||||
console.log(process.env.DEV_URL + `/pipeline/${id}`, 'ON DELETE ROUTE');
|
||||
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService)
|
||||
const response = await pipelineService.remove(id)
|
||||
const pipelineService = new PipelinesService(this.pipelinesClientService);
|
||||
const response = await pipelineService.remove({ id, ...data });
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,99 +1,100 @@
|
||||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||
import { PipelinesClientService } from 'src/clients/pipelines/client.service';
|
||||
import { IIdRequest, Info } from 'src/clients/pipelines/interfaces';
|
||||
import { objectCamelToSnake } from 'src/utils/CaseConverter';
|
||||
|
||||
@Injectable()
|
||||
export class PipelinesService {
|
||||
constructor(private pipelineClient: PipelinesClientService) {}
|
||||
|
||||
constructor( private pipelineClient: PipelinesClientService){}
|
||||
async create(createPipelineDto) {
|
||||
try {
|
||||
const createPipelineResponse = await this.pipelineClient.create(
|
||||
createPipelineDto,
|
||||
);
|
||||
|
||||
async create(createPipelineDto){
|
||||
try{
|
||||
const createPipelineResponse = await this.pipelineClient.create(createPipelineDto);
|
||||
|
||||
return objectCamelToSnake(createPipelineResponse)
|
||||
|
||||
}catch(err){
|
||||
console.log(err)
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findOne(id:string){
|
||||
|
||||
try{
|
||||
const findOnePipelineResponse = await this.pipelineClient.findOne({id});
|
||||
return objectCamelToSnake(findOnePipelineResponse)
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findAll(){
|
||||
|
||||
try{
|
||||
const findAllPipelineResponse = await this.pipelineClient.findAll();
|
||||
|
||||
return objectCamelToSnake(findAllPipelineResponse)
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return objectCamelToSnake(createPipelineResponse);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async update(id:string, data){
|
||||
|
||||
try{
|
||||
|
||||
const updatePipelineResponse = await this.pipelineClient.update({id,...data});
|
||||
|
||||
return objectCamelToSnake(updatePipelineResponse)
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
async findOne(data: IIdRequest) {
|
||||
try {
|
||||
const findOnePipelineResponse = await this.pipelineClient.findOne(data);
|
||||
return objectCamelToSnake(findOnePipelineResponse);
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async remove(id:string){
|
||||
async findAll(data) {
|
||||
try {
|
||||
const findAllPipelineResponse = await this.pipelineClient.findAll(data);
|
||||
|
||||
try{
|
||||
|
||||
const removePipelineResponse = await this.pipelineClient.remove({id});
|
||||
|
||||
return removePipelineResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return objectCamelToSnake(findAllPipelineResponse);
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async update(id: string, data, info: Info) {
|
||||
try {
|
||||
const updatePipelineResponse = await this.pipelineClient.update({
|
||||
id,
|
||||
info,
|
||||
...data,
|
||||
});
|
||||
|
||||
async getPipelineLogsMessages(id:string,details:string){
|
||||
|
||||
try{
|
||||
|
||||
const pipelineLogsResponse = await this.pipelineClient.getPipelineLogsMessages({id,details});
|
||||
|
||||
return objectCamelToSnake(pipelineLogsResponse)
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return objectCamelToSnake(updatePipelineResponse);
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async getPipelineStatus(id:string){
|
||||
async remove(data: IIdRequest) {
|
||||
try {
|
||||
const removePipelineResponse = await this.pipelineClient.remove(data);
|
||||
|
||||
try{
|
||||
|
||||
const pipelineStatusResponse = await this.pipelineClient.getPipelineStatus({id});
|
||||
|
||||
return objectCamelToSnake(pipelineStatusResponse)
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return removePipelineResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async getPipelineLogsMessages(id: string, details: string) {
|
||||
try {
|
||||
const pipelineLogsResponse =
|
||||
await this.pipelineClient.getPipelineLogsMessages({ id, details });
|
||||
|
||||
return objectCamelToSnake(pipelineLogsResponse);
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async getPipelineStatus(data: IIdRequest) {
|
||||
try {
|
||||
const pipelineStatusResponse =
|
||||
await this.pipelineClient.getPipelineStatus(data);
|
||||
|
||||
return objectCamelToSnake(pipelineStatusResponse);
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async runPipeline({ id, info }: IIdRequest) {
|
||||
try {
|
||||
const triggerPipelineResponse = await this.pipelineClient.runPipeline({
|
||||
id,
|
||||
info,
|
||||
});
|
||||
|
||||
return objectCamelToSnake(triggerPipelineResponse);
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,74 +6,92 @@ import {
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
Redirect,
|
||||
} from '@nestjs/common';
|
||||
import { Payload } from '@nestjs/microservices';
|
||||
import { TransformationsClientService } from 'src/clients/transformations/client.service';
|
||||
import { IIdRequest } from 'src/clients/transformations/interfaces';
|
||||
import { TransformationsService } from './transformations.service';
|
||||
|
||||
@Controller('transformations')
|
||||
export class TransformationsController {
|
||||
constructor(
|
||||
private transformationsClientService: TransformationsClientService,
|
||||
) {}
|
||||
|
||||
constructor( private transformationsClientService:TransformationsClientService){}
|
||||
@Post()
|
||||
async create(@Body() createTransformationDto) {
|
||||
console.log(process.env.DEV_URL + `/transformation`, 'ON CREATE ROUTE');
|
||||
|
||||
const transformationService = new TransformationsService(
|
||||
this.transformationsClientService,
|
||||
);
|
||||
const response = await transformationService.create(
|
||||
createTransformationDto,
|
||||
);
|
||||
|
||||
@Post()
|
||||
async create(@Body() createTransformationDto) {
|
||||
console.log(process.env.DEV_URL + `/transformation`, 'ON CREATE ROUTE');
|
||||
|
||||
const transformationService = new TransformationsService(this.transformationsClientService)
|
||||
const response = await transformationService.create(createTransformationDto)
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Get()
|
||||
async findAll() {
|
||||
console.log(process.env.DEV_URL + `/transformation`, 'ON Find All ROUTE');
|
||||
|
||||
const transformationService = new TransformationsService(this.transformationsClientService)
|
||||
const response = await transformationService.findAll()
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Get('/:id')
|
||||
async findOne(@Param() params) {
|
||||
const {id} = params;
|
||||
console.log(process.env.DEV_URL + `/transformation/${id}`, 'ON Find One ROUTE');
|
||||
|
||||
const transformationService = new TransformationsService(this.transformationsClientService)
|
||||
const response = await transformationService.findOne(id)
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
async update(
|
||||
@Payload() updateTransformationDto,
|
||||
@Param() params,
|
||||
) {
|
||||
const {id} = params;
|
||||
console.log(process.env.DEV_URL + `/transformation/${id}`, 'ON UPDATE ROUTE');
|
||||
|
||||
const transformationService = new TransformationsService(this.transformationsClientService)
|
||||
const response = await transformationService.update(id,updateTransformationDto)
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param() params) {
|
||||
const {id} = params;
|
||||
console.log(process.env.DEV_URL + `/transformation/${id}`, 'ON DELETE ROUTE');
|
||||
|
||||
const transformationService = new TransformationsService(this.transformationsClientService)
|
||||
const response = await transformationService.remove(id)
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Get()
|
||||
async findAll(@Body() data: IIdRequest) {
|
||||
console.log(process.env.DEV_URL + `/transformation`, 'ON Find All ROUTE');
|
||||
|
||||
const transformationService = new TransformationsService(
|
||||
this.transformationsClientService,
|
||||
);
|
||||
const response = await transformationService.findAll(data);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Get('/:id')
|
||||
async findOne(@Body() data, @Param() params) {
|
||||
const { id } = params;
|
||||
console.log(
|
||||
process.env.DEV_URL + `/transformation/${id}`,
|
||||
'ON Find One ROUTE',
|
||||
);
|
||||
|
||||
const transformationService = new TransformationsService(
|
||||
this.transformationsClientService,
|
||||
);
|
||||
const response = await transformationService.findOne({ id, ...data });
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
async update(@Payload() updateTransformationDto, @Param() params) {
|
||||
const { id } = params;
|
||||
console.log(
|
||||
process.env.DEV_URL + `/transformation/${id}`,
|
||||
'ON UPDATE ROUTE',
|
||||
);
|
||||
|
||||
const transformationService = new TransformationsService(
|
||||
this.transformationsClientService,
|
||||
);
|
||||
const response = await transformationService.update(
|
||||
id,
|
||||
updateTransformationDto,
|
||||
);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Body() data, @Param() params) {
|
||||
const { id } = params;
|
||||
console.log(
|
||||
process.env.DEV_URL + `/transformation/${id}`,
|
||||
'ON DELETE ROUTE',
|
||||
);
|
||||
|
||||
const transformationService = new TransformationsService(
|
||||
this.transformationsClientService,
|
||||
);
|
||||
const response = await transformationService.remove({ id, ...data });
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,77 +1,79 @@
|
||||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||
import { TransformationsClientService } from 'src/clients/transformations/client.service';
|
||||
import { ICreateTransformationsRequest } from 'src/clients/transformations/interfaces';
|
||||
import {
|
||||
ICreateTransformationsRequest,
|
||||
IIdRequest,
|
||||
} from 'src/clients/transformations/interfaces';
|
||||
import { trSnakeToCamel } from 'src/utils/CaseConverter';
|
||||
|
||||
@Injectable()
|
||||
export class TransformationsService {
|
||||
constructor(private transformationClient: TransformationsClientService) {}
|
||||
|
||||
constructor( private transformationClient: TransformationsClientService){}
|
||||
async create(createTransformationDto: ICreateTransformationsRequest) {
|
||||
const { transformations, info } = createTransformationDto;
|
||||
|
||||
async create(createTransformationDto:ICreateTransformationsRequest){
|
||||
try{
|
||||
|
||||
let convertedDTO = createTransformationDto.transformations.map((tr)=>{
|
||||
|
||||
return trSnakeToCamel(tr)
|
||||
})
|
||||
|
||||
const createTransformationResponse = await this.transformationClient.create({transformations:convertedDTO});
|
||||
|
||||
return createTransformationResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
if (!transformations || transformations.length == 0) {
|
||||
throw new HttpException('Missing transformations field.', 400);
|
||||
}
|
||||
|
||||
}
|
||||
try {
|
||||
const convertedDTO = transformations.map((tr) => {
|
||||
return trSnakeToCamel(tr);
|
||||
});
|
||||
const createTransformationResponse =
|
||||
await this.transformationClient.create({
|
||||
transformations: convertedDTO,
|
||||
info: info,
|
||||
});
|
||||
|
||||
async findOne(id:string){
|
||||
|
||||
try{
|
||||
const findOneTransformationResponse = await this.transformationClient.findOne({id});
|
||||
return findOneTransformationResponse
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findAll(){
|
||||
|
||||
try{
|
||||
const findAllTransformationResponse = await this.transformationClient.findAll();
|
||||
|
||||
return findAllTransformationResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return createTransformationResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async update(id:string, data){
|
||||
|
||||
try{
|
||||
|
||||
const updateTransformationResponse = await this.transformationClient.update({id,...data});
|
||||
|
||||
return updateTransformationResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
async findOne(data: IIdRequest) {
|
||||
try {
|
||||
const findOneTransformationResponse =
|
||||
await this.transformationClient.findOne(data);
|
||||
return findOneTransformationResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async remove(id:string){
|
||||
async findAll(data) {
|
||||
try {
|
||||
const findAllTransformationResponse =
|
||||
await this.transformationClient.findAll(data);
|
||||
|
||||
try{
|
||||
return findAllTransformationResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
const removeTransformationResponse = await this.transformationClient.remove({id});
|
||||
|
||||
return removeTransformationResponse
|
||||
async update(id: string, data) {
|
||||
try {
|
||||
data.transformation['id'] = id;
|
||||
const updateTransformationResponse =
|
||||
await this.transformationClient.update({ ...data });
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return updateTransformationResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async remove(data: IIdRequest) {
|
||||
try {
|
||||
const removeTransformationResponse =
|
||||
await this.transformationClient.remove(data);
|
||||
|
||||
return removeTransformationResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import axios from 'axios';
|
||||
|
||||
export class AuthenticateController {
|
||||
private username: string;
|
||||
private password: string;
|
||||
|
||||
constructor() {
|
||||
this.username = process.env.AUTH_USERNAME;
|
||||
this.password = process.env.AUTH_PASSWORD;
|
||||
}
|
||||
|
||||
async authenticate(): Promise<string> {
|
||||
const response = await axios.post(process.env.AUTH_ROUTE, {
|
||||
username: this.username,
|
||||
password: this.password,
|
||||
});
|
||||
|
||||
return response.data.accessToken;
|
||||
}
|
||||
}
|
||||
+12
-14
@@ -5,7 +5,7 @@ export const objectCamelToSnake = (object) => {
|
||||
const newKeys = objectKeys.map((key) => {
|
||||
return key
|
||||
.split(/(?=[A-Z])/)
|
||||
.join("_")
|
||||
.join('_')
|
||||
.toLowerCase();
|
||||
});
|
||||
|
||||
@@ -17,7 +17,7 @@ export const objectCamelToSnake = (object) => {
|
||||
});
|
||||
|
||||
objectValues.forEach((value) => {
|
||||
if (typeof value === "object") {
|
||||
if (typeof value === 'object') {
|
||||
objectCamelToSnake(value);
|
||||
}
|
||||
});
|
||||
@@ -31,7 +31,7 @@ export const objectSnakeToCamel = (object) => {
|
||||
|
||||
const newKeys = objectKeys.map((key) => {
|
||||
return key.replace(/([-_][a-z])/gi, ($1) => {
|
||||
return $1.toUpperCase().replace("-", "").replace("_", "");
|
||||
return $1.toUpperCase().replace('-', '').replace('_', '');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -41,24 +41,22 @@ export const objectSnakeToCamel = (object) => {
|
||||
delete object[key];
|
||||
}
|
||||
});
|
||||
|
||||
objectValues.forEach((value) => {
|
||||
if (typeof value === "object") {
|
||||
if (value == null) return;
|
||||
if (typeof value === 'object') {
|
||||
objectSnakeToCamel(value);
|
||||
}
|
||||
});
|
||||
|
||||
return object;
|
||||
};
|
||||
|
||||
export const trSnakeToCamel = (object) =>{
|
||||
|
||||
const convertedParams = object.params.map((param)=>{
|
||||
return objectSnakeToCamel(param)
|
||||
})
|
||||
export const trSnakeToCamel = (object) => {
|
||||
const convertedParams = object.params.map((param) => {
|
||||
return objectSnakeToCamel(param);
|
||||
});
|
||||
|
||||
object.params = convertedParams
|
||||
object.params = convertedParams;
|
||||
|
||||
return objectSnakeToCamel(object)
|
||||
|
||||
}
|
||||
return objectSnakeToCamel(object);
|
||||
};
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user