Compare commits

...
14 Commits
Author SHA1 Message Date
Victor Radael 44d4b8e08c CI: Deploy 2022-03-21 10:39:41 -03:00
Victor Radael 63fa756c9b Merge pull request #41 from dadosfera/ft-int-duc
Ft int duc
2022-03-21 10:24:05 -03:00
Victor Radael 91236dde86 CI: Deploy 2022-03-21 10:03:54 -03:00
rodrigo.zamboni a39ea091ee prepared tests to deploy 2022-03-18 15:20:32 -03:00
Rodrigo Zamboni 8787aa05c2 Merge pull request #40 from dadosfera/ft-int-duc
Ft int duc
2022-03-18 10:17:27 -03:00
rodrigo.zamboni 1523c6b4d1 maestro connection with microservices - clients and modules 2022-03-18 10:16:27 -03:00
Victor Radael e15a680b9f FIX: Health Check 2022-03-14 10:39:51 -03:00
Victor Radael 363bc8b350 REFACTOR: Project Pattern and AuthClient (DUC) 2022-03-14 10:35:03 -03:00
Victor Radael 2f8d9b9550 Merge pull request #39 from dadosfera/att-ci
CI: Att CI
2022-02-10 14:49:40 -03:00
Victor Radael e729e1f0f4 CI: Att CI 2022-02-10 14:47:06 -03:00
Victor Radael a20ff87b27 Merge pull request #38 from dadosfera/ft-att-doc
docs: Att docs
2022-02-10 14:37:58 -03:00
Victor Radael abf5c71c08 docs: Att docs 2022-02-10 14:32:42 -03:00
Alexsander Pereira 6b991bce7d Merge pull request #37 from dadosfera/ci
CI: Adding @semantic-release/npm to modify package.json on deploy
2022-02-10 12:21:00 -03:00
alexsanderp e007c2c49c CI: Adding @semantic-release/npm to modify package.json on deploy 2022-02-10 12:14:46 -03:00
175 changed files with 3775 additions and 4322 deletions
+106 -94
View File
@@ -9,103 +9,115 @@ on:
jobs:
deploy:
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
id: semantic
with:
semantic_version: 16
extra_plugins: |
@saithodev/semantic-release-backmerge
conventional-changelog-eslint
branches: |
[
'main',
{
name: 'alpha',
prerelease: true
},
{
name: 'beta',
prerelease: true
}
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Because Semantic Realese deleted the .npmrc file, it was necessary to insert two steps to backup the file.
- name: BKP .npmrc Step 1
run: |
cp .npmrc .npmrcbkp
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
id: semantic
with:
semantic_version: 16
extra_plugins: |
@saithodev/semantic-release-backmerge
conventional-changelog-eslint
branches: |
[
'main',
{
name: 'alpha',
prerelease: true
},
{
name: 'beta',
prerelease: true
}
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Update Pip
if: steps.semantic.outputs.new_release_published == 'true'
run: |
python3 -m pip install --upgrade pip
# Because Semantic Realese deleted the .npmrc file, it was necessary to insert two steps to backup the file.
- 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
with:
aws-region: us-east-1
- name: Install Docker Compose
if: steps.semantic.outputs.new_release_published == 'true'
run: |
python3 -m pip install docker-compose --upgrade
- name: Extract Environment
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/})"
fi
id: extract_environment
- name: Install AWS CLI
if: steps.semantic.outputs.new_release_published == 'true'
run: |
python3 -m pip install awscli --upgrade
- name: Login to AWS ECR
if: steps.semantic.outputs.new_release_published == 'true'
id: login_ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Install AWS Elastic Beanstalk CLI
if: steps.semantic.outputs.new_release_published == 'true'
run: |
python3 -m pip install awsebcli --upgrade
- name: Configure AWS Region
if: steps.semantic.outputs.new_release_published == 'true'
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: us-east-1
- name: Extract Environment
if: steps.semantic.outputs.new_release_published == 'true'
shell: bash
run: |
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/})"
fi
id: extract_environment
- name: Login to AWS ECR
if: steps.semantic.outputs.new_release_published == 'true'
id: login_ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, Tag, and Push Image to AWS ECR
if: steps.semantic.outputs.new_release_published == 'true'
env:
ENV: ${{ steps.extract_environment.outputs.result }}
IMAGE_TAG: ${{ steps.semantic.outputs.new_release_version }}
run: |
docker-compose -f build.docker-compose.yml build
docker-compose -f build.docker-compose.yml push
- 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 }}
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
- name: Deploy AWS Beanstalk
if: steps.semantic.outputs.new_release_published == 'true'
env:
ENV: ${{ steps.extract_environment.outputs.result }}
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
- name: Build, Tag, and Push Image to AWS ECR
if: steps.semantic.outputs.new_release_published == 'true'
env:
ENV: ${{ steps.extract_environment.outputs.result }}
IMAGE_TAG: ${{ steps.semantic.outputs.new_release_version }}
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 }}
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
- name: Deploy AWS Beanstalk
if: steps.semantic.outputs.new_release_published == 'true'
env:
ENV: ${{ steps.extract_environment.outputs.result }}
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
+6 -4
View File
@@ -16,19 +16,21 @@ jobs:
- name: Install Docker Compose
run: |
python3 -m pip install docker-compose --upgrade
- name: Build
env:
ENV: test
IMAGE_TAG: test
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
export ENV=test
docker-compose -f build.docker-compose.yml build
export IMAGE_TAG=test
docker-compose -f build.docker-compose.yml build --build-arg NPM_TOKEN=${NPM_TOKEN}
- name: Run Test
env:
ENV: test
IMAGE_TAG: test
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
export ENV=test
docker-compose run --rm --entrypoint="npm run test" maestro
export IMAGE_TAG=test
docker-compose -f build.docker-compose.yml run -e NPM_TOKEN=${NPM_TOKEN} --rm --entrypoint="npm run test" maestro
+3
View File
@@ -41,3 +41,6 @@ lerna-debug.log*
.elasticbeanstalk/*
!.elasticbeanstalk/*.cfg.yml
!.elasticbeanstalk/*.global.yml
.env
+1
View File
@@ -0,0 +1 @@
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
+16 -12
View File
@@ -5,18 +5,18 @@
{
"preset": "eslint",
"releaseRules": [
{ "tag": "Fix", "release": "patch" },
{ "tag": "Feat", "release": "minor" },
{ "tag": "Update", "release": "minor" },
{ "tag": "Upgrade", "release": "minor" },
{ "tag": "Breaking", "release": "major" },
{ "tag": "Docs", "release": "patch" },
{ "tag": "Chore", "release": "minor" },
{ "tag": "Build", "release": "patch" },
{ "tag": "Refactor", "release": "minor" },
{ "tag": "Test", "release": "patch" },
{ "tag": "FIX", "release": "patch" },
{ "tag": "FEAT", "release": "minor" },
{ "tag": "UPDATE", "release": "minor" },
{ "tag": "UPGRADE", "release": "minor" },
{ "tag": "BREAKING", "release": "major" },
{ "tag": "DOCS", "release": "patch" },
{ "tag": "CHORE", "release": "minor" },
{ "tag": "BUILD", "release": "patch" },
{ "tag": "REFACTOR", "release": "minor" },
{ "tag": "TEST", "release": "patch" },
{ "tag": "CI", "release": "patch" },
{ "tag": "Perf", "release": "minor" }
{ "tag": "PERF", "release": "minor" }
]
}
],
@@ -29,10 +29,14 @@
[
"@saithodev/semantic-release-backmerge",
{
"branches": ["alpha", "beta"],
"branches": [
{ "from": "main", "to": "alpha" },
{ "from": "main", "to": "beta" }
],
"backmergeStrategy": "merge"
}
],
"@semantic-release/npm",
"@semantic-release/github"
]
}
+7 -3
View File
@@ -1,12 +1,16 @@
FROM node:14 as packages
FROM node:14.15.4-alpine3.12 as packages
WORKDIR /packages
ARG NPM_TOKEN
COPY package.json .
COPY .npmrc .
RUN npm install
RUN rm -f ./.npmrc
FROM node:alpine
FROM node:14.15.4-alpine3.12
WORKDIR /app
COPY . /app/
ARG NPM_TOKEN
COPY --from=packages /packages/node_modules /app/node_modules
RUN npm run build
EXPOSE 3333
ENTRYPOINT npm run start
ENTRYPOINT npm run start
+2 -71
View File
@@ -1,73 +1,4 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
<image src="./assets/maestro.svg" style="width:10rem">
<h1 align="center">Maestro</h1>
</p>
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
## Description
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
## Installation
```bash
$ npm install
```
## Running the app
```bash
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
```
## Test
```bash
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
```
## Support
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
## Stay in touch
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)
## License
Nest is [MIT licensed](LICENSE).
File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 13 KiB

+1612 -752
View File
File diff suppressed because it is too large Load Diff
+21 -19
View File
@@ -21,14 +21,16 @@
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@grpc/grpc-js": "^1.5.0",
"@grpc/grpc-js": "^1.5.7",
"@grpc/proto-loader": "^0.6.9",
"@nestjs/common": "^8.0.0",
"@nestjs/core": "^8.0.0",
"@nestjs/common": "^8.4.0",
"@nestjs/config": "^1.2.1",
"@nestjs/core": "^8.4.0",
"@nestjs/mapped-types": "*",
"@nestjs/microservices": "^8.2.4",
"@nestjs/platform-express": "^8.0.0",
"@nestjs/microservices": "^8.4.0",
"@nestjs/platform-express": "^8.4.0",
"@nestjs/swagger": "^5.1.5",
"@victorradael/protospack": "^1.2.8",
"axios": "^0.25.0",
"dotenv": "^14.2.0",
"grpc": "^1.24.11",
@@ -36,33 +38,33 @@
"jwk-to-pem": "^2.0.5",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.2.0",
"rxjs": "^7.5.5",
"swagger-ui-express": "^4.3.0"
},
"devDependencies": {
"@nestjs/cli": "^8.0.0",
"@nestjs/schematics": "^8.0.0",
"@nestjs/testing": "^8.0.0",
"@nestjs/cli": "^8.2.2",
"@nestjs/schematics": "^8.0.8",
"@nestjs/testing": "^8.4.0",
"@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.0.0",
"@types/node": "^16.11.26",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^8.0.1",
"eslint-config-prettier": "^8.3.0",
"@typescript-eslint/eslint-plugin": "^5.14.0",
"@typescript-eslint/parser": "^5.14.0",
"eslint": "^8.10.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.2.5",
"jest": "^27.5.1",
"prettier": "^2.3.2",
"source-map-support": "^0.5.20",
"supertest": "^6.1.3",
"ts-jest": "^27.0.3",
"ts-loader": "^9.2.3",
"ts-node": "^10.0.0",
"tsconfig-paths": "^3.10.1",
"typescript": "^4.3.5"
"ts-loader": "^9.2.7",
"ts-node": "^10.7.0",
"tsconfig-paths": "^3.13.0",
"typescript": "^4.6.2"
},
"jest": {
"moduleFileExtensions": [
+96 -38
View File
@@ -1,44 +1,102 @@
import { MiddlewareConsumer, Module, NestModule, RequestMethod } from '@nestjs/common';
import { InputGrpcClientModule } from './inputs/input-grpc-client.module';
import { UsersGrpcClientModule } from './users-grpc-client/users-grpc-client.module';
import { OutputsModule } from './outputs/outputs.module';
import { EnrichmentModule } from './enrichment/enrichment.module';
import { TransformationsModule } from './transformations/transformations.module';
import { PipelinesModule } from './pipelines/pipelines.module';
import { RestInputsModule } from './rest/rest-inputs/rest-inputs.module';
import { RestOutputsModule } from './rest/rest-outputs/rest-outputs.module';
import { RestEnrichmentsModule } from './rest/rest-enrichments/rest-enrichments.module';
import { RestTransformationsModule } from './rest/rest-transformations/rest-transformations.module';
import { RestPipelinesModule } from './rest/rest-pipelines/rest-pipelines.module';
import { RestUserModule } from './rest/rest-user/rest-user.module';
import { RestFactoryModule } from './rest/rest-factory/rest-factory.module';
import { LoggerMiddleware } from './middlewares/authentication';
import { RestInputsController } from './rest/rest-inputs/rest-inputs.controller';
import { RestOutputsController } from './rest/rest-outputs/rest-outputs.controller';
import { RestTransformationsController } from './rest/rest-transformations/rest-transformations.controller';
import { RestPipelinesController } from './rest/rest-pipelines/rest-pipelines.controller';
import { RestEnrichmentsController } from './rest/rest-enrichments/rest-enrichments.controller';
import { RestFactoryController } from './rest/rest-factory/rest-factory.controller';
import { HealthModule } from './health/health.module';
@Module({
imports: [
RestInputsModule, RestOutputsModule, RestEnrichmentsModule, RestTransformationsModule, RestPipelinesModule, RestUserModule, RestFactoryModule, HealthModule,
// InputGrpcClientModule,
//OutputsModule,
//EnrichmentModule,
//TransformationsModule,
//PipelinesModule
],
controllers: [],
providers: [],
})
export class AppModule implements NestModule{
import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
import { ClientsModule } from '@nestjs/microservices';
import { ConfigModule } from '@nestjs/config';
import { LoggerMiddleware } from './middlewares/authentication';
import { InputsController } from './modules/inputs/inputs.controller';
import { TransformationsController } from './modules/transformations/transformations.controller';
import { OutputsController } from './modules/outputs/outputs.controllers';
import { PipelinesController } from './modules/pipelines/pipelines.controller';
import { AuthController } from './modules/auth/auth.controller';
import { HealthController } from './modules/health/health.controller';
import { InputsService } from './modules/inputs/inputs.service';
import { TransformationsService } from './modules/transformations/transformations.service';
import { OutputsService } from './modules/outputs/outputs.service';
import { PipelinesService } from './modules/pipelines/pipelines.service';
// import { AuthService } from './modules/auth/auth.service';
import { HealthService } from './modules/health/health.service';
import { InputsClientService } from './clients/inputs/client.service';
import { TransformationsClientService } from './clients/transformations/client.service';
import { OutputsClientService } from './clients/outputs/client.service';
import { PipelinesClientService } from './clients/pipelines/client.service';
import { AuthClientService } from './clients/auth/client.service';
import { OutputsClientConfiguration } from './clients/outputs/client.config';
import { TransformationsClientConfiguration } from './clients/transformations/client.config';
import { AuthClient } from './clients/auth/client.config';
import { InputsClientConfiguration } from './clients/inputs/client.config';
import { PipelinesClientConfiguration } from './clients/pipelines/client.config';
const authClient = new AuthClient();
const inputClient = new InputsClientConfiguration();
const outputClient = new OutputsClientConfiguration();
const pipelineClient = new PipelinesClientConfiguration();
const transformationClient = new TransformationsClientConfiguration();
@Module({
controllers: [
InputsController,
TransformationsController,
OutputsController,
PipelinesController,
AuthController,
HealthController,
],
providers: [
InputsService,
TransformationsService,
OutputsService,
PipelinesService,
// AuthService,
HealthService,
InputsClientService,
TransformationsClientService,
OutputsClientService,
PipelinesClientService,
AuthClientService,
],
imports: [
ConfigModule.forRoot({
isGlobal: true,
}),
ClientsModule.register([
{
name: 'INPUTS_PACKAGE',
...inputClient.config(),
},
{
name: 'TRANSFORMATIONS_PACKAGE',
...transformationClient.config(),
},
{
name: 'OUTPUTS_PACKAGE',
...outputClient.config(),
},
{
name: 'AUTH_PACKAGE',
...authClient.config(),
},
{
name: 'PIPELINES_PACKAGE',
...pipelineClient.config(),
},
]),
],
})
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
consumer
.apply(LoggerMiddleware)
.forRoutes(RestInputsController,RestOutputsController,RestTransformationsController,RestPipelinesController,RestEnrichmentsController,RestFactoryController)
.forRoutes
// InputsController,
// TransformationsController,
// OutputsController,
// PipelinesController,
();
}
}
+23
View File
@@ -0,0 +1,23 @@
import { credentials } from '@grpc/grpc-js';
import { ClientOptions, Transport } from '@nestjs/microservices';
import { DucProtofile } from '@victorradael/protospack';
export class AuthClient {
config(): ClientOptions {
return {
transport: Transport.GRPC,
options: {
url: process.env.DUC_URL,
package: 'duc',
credentials: credentials.createSsl(),
protoPath: DucProtofile,
loader: {
enums: String,
objects: true,
arrays: true,
},
},
};
}
}
+43
View File
@@ -0,0 +1,43 @@
import { OnModuleInit, Inject } from '@nestjs/common';
import { ClientGrpc } from '@nestjs/microservices';
import { CognitoServiceInterface } from '@victorradael/protospack';
import { ILogin } from './interfaces';
export class AuthClientService implements OnModuleInit {
private cognitoService: CognitoServiceInterface;
constructor(
@Inject('AUTH_PACKAGE') private readonly grpcClient: ClientGrpc,
) {}
onModuleInit() {
this.cognitoService = this.grpcClient.getService<CognitoServiceInterface>(
'CognitoProtoService',
);
}
async signIn({ username, password }: ILogin): Promise<any> {
console.log('CognitoClientService', 'SignIn');
const tokens = await new Promise((resolve, reject) => {
this.cognitoService.signIn({ username, password }).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 tokens;
}
}
+4
View File
@@ -0,0 +1,4 @@
export interface ILogin {
username: string;
password: string;
}
+23
View File
@@ -0,0 +1,23 @@
import { credentials } from '@grpc/grpc-js';
import { ClientOptions, Transport } from '@nestjs/microservices';
import { InputProtofile } from '@victorradael/protospack';
export class InputsClientConfiguration {
config(): ClientOptions {
return {
transport: Transport.GRPC,
options: {
url: process.env.INFACTORY_URL,
package: 'input',
// credentials: credentials.createSsl(),
protoPath: InputProtofile,
loader: {
enums: String,
objects: true,
arrays: true,
},
},
};
}
}
+185
View File
@@ -0,0 +1,185 @@
import {
OnModuleInit,
Inject,
} from '@nestjs/common';
import { ClientGrpc } from '@nestjs/microservices';
import { InputService } from '@victorradael/protospack';
import { ICreateInputRequest, IIdRequest, ITestConnectionRequest, UpdateInputRequest } from './interfaces';
export class InputsClientService implements OnModuleInit {
private inputService: InputService;
constructor(
@Inject('INPUTS_PACKAGE') private readonly grpcClient: ClientGrpc,
) {}
onModuleInit() {
this.inputService =
this.grpcClient.getService<InputService>(
'InputService',
);
}
async create(createInputDto: ICreateInputRequest ) {
console.log('InputClientService', 'Create');
const createInputResponse = await new Promise((resolve, reject) => {
this.inputService.Create(createInputDto).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 createInputResponse;
}
async findOne(data: IIdRequest ) {
console.log('InputClientService', 'FindOne');
const { id } = data
const findOneInputResponse = await new Promise((resolve, reject) => {
this.inputService.FindOne({id}).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 findOneInputResponse;
}
async findAll(data) {
console.log('InputClientService', 'FindAll');
const findAllInputResponse = await new Promise((resolve, reject) => {
this.inputService.FindAll({}).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 findAllInputResponse;
}
async update(updateInputDTO:UpdateInputRequest) {
console.log('InputClientService', 'Update');
console.log(updateInputDTO)
const updateInputResponse = await new Promise((resolve, reject) => {
this.inputService.Update(updateInputDTO).subscribe({
next(x) {
console.log(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 updateInputResponse;
}
async remove(idRequest:IIdRequest) {
console.log('InputClientService', 'Remove');
const removeInputResponse = await new Promise((resolve, reject) => {
this.inputService.Remove(idRequest).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 removeInputResponse;
}
async testConnection(data:ITestConnectionRequest) {
console.log('InputClientService', 'TestCOnnection');
const testConnectionResponse = await new Promise((resolve, reject) => {
this.inputService.TestConnection(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 testConnectionResponse;
}
}
+56
View File
@@ -0,0 +1,56 @@
interface Values {
jdbc_user: string;
jdbc_password: string;
database: string;
endpoint: string;
tables: string[];
port: string;
engine: string;
schema: string;
}
interface Cron {
hours: string[];
hour_interval: boolean;
hour_resourse: boolean;
hour_resourse_value: number;
month_day: string[];
month_day_interval: boolean;
month_day_resourse: boolean;
month_day_resourse_value: number;
month: string[];
month_interval: boolean;
month_resourse: boolean;
month_resourse_value: number;
week_days: string[];
week_days_interval: boolean;
week_days_resourse: boolean;
week_days_resourse_value: number;
}
export interface ICreateInputRequest {
cron: Cron;
name: string;
plugin: string;
values: Values;
operation: string;
}
export interface IIdRequest{
id:string;
}
interface UpdateInputRequest {
id: string;
cron: Cron;
name: string;
plugin: string;
values: Values;
operation: string;
}
export interface ITestConnectionRequest {
plugin: string;
values: Values;
}
+22
View File
@@ -0,0 +1,22 @@
import { OutputProtofile } from '@victorradael/protospack';
import { ClientOptions, Transport } from '@nestjs/microservices';
import { credentials } from '@grpc/grpc-js';
export class OutputsClientConfiguration {
config(): ClientOptions {
return {
transport: Transport.GRPC,
options: {
url: process.env.OUTFACTORY_URL,
package: 'output',
// credentials: credentials.createSsl(),
protoPath: OutputProtofile,
loader: {
enums: String,
objects: true,
arrays: true,
},
},
};
}
};
+165
View File
@@ -0,0 +1,165 @@
import {
Controller,
Delete,
Get,
Inject,
OnModuleInit,
Param,
Post,
Put,
} from '@nestjs/common';
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';
@Controller('output')
export class OutputsClientService implements OnModuleInit {
private outputService: OutputsServiceInterface;
constructor(
@Inject('OUTPUTS_PACKAGE')private readonly grpcClient: ClientGrpc,
){}
onModuleInit() {
this.outputService =
this.grpcClient.getService<OutputsServiceInterface>('OutputService');
}
async create(@Payload() createOutputDto:ICreateOutputRequest ) {
console.log('OutputClientService', 'Create');
const createOutputResponse = await new Promise((resolve, reject) => {
this.outputService.create(createOutputDto).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);
});
const convertedItem = objectCamelToSnake(createOutputResponse["item"])
createOutputResponse["item"] = convertedItem
return createOutputResponse;
}
async findAll() {
console.log('OutputClientService', 'FindAll');
const findAllOutputResponse = await new Promise((resolve, reject) => {
this.outputService.findAll({}).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);
});
const convertedOutputs = findAllOutputResponse['outputs'].map((ot)=>{
return objectCamelToSnake(ot)
})
return {outputs:convertedOutputs};
}
async findOne({id}: IIdRequest) {
console.log('OutputClientService', 'FindOne');
const findOneOutputResponse = await new Promise((resolve, reject) => {
this.outputService.findOne({id}).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 objectCamelToSnake(findOneOutputResponse);
}
async update(updateOutPutDTO: IOutputUpdateRequest) {
console.log('OutputClientService', 'Update');
const updateOutputResponse = await new Promise((resolve, reject) => {
this.outputService.update(updateOutPutDTO).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 objectCamelToSnake(updateOutputResponse);
}
async remove({id}:IIdRequest) {
console.log('OutputClientService', 'Remove');
const removeOutputResponse = await new Promise((resolve, reject) => {
this.outputService.remove({id}).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 removeOutputResponse;
}
}
+22
View File
@@ -0,0 +1,22 @@
export interface ICreateOutputRequest {
operation: string;
name: string;
plugin: string;
values: Values;
}
export interface Values {
prefix: string;
}
export interface IIdRequest{
id:string;
}
export interface IOutputUpdateRequest {
id: string;
operation: string;
values: Values;
plugin: string;
name: string;
}
+22
View File
@@ -0,0 +1,22 @@
import { ClientOptions, Transport } from '@nestjs/microservices';
import { PipelineProtofile } from '@victorradael/protospack';
import { credentials } from '@grpc/grpc-js';
export class PipelinesClientConfiguration {
config(): ClientOptions {
return {
transport: Transport.GRPC,
options: {
url: process.env.PIFACTORY_URL,
package: 'pipeline',
// credentials: credentials.createSsl(),
protoPath: PipelineProtofile,
loader: {
enums: String,
objects: true,
arrays: true,
},
},
};
}
};
+211
View File
@@ -0,0 +1,211 @@
import {
Controller,
Delete,
Get,
Inject,
OnModuleInit,
Param,
Post,
Put,
} from '@nestjs/common';
import {
Client,
ClientGrpc,
MessagePattern,
Payload,
} from '@nestjs/microservices';
import { PipelinesServiceInterface } from '@victorradael/protospack';
import { ICreatePipelineDto, IdRequest, IGetPipelineLogsRequest, IUpdatePipelineRequest } from './interfaces';
export class PipelinesClientService implements OnModuleInit {
private pipelineService: PipelinesServiceInterface;
constructor(
@Inject('PIPELINES_PACKAGE') private readonly grpcClient: ClientGrpc,
){}
onModuleInit() {
this.pipelineService =
this.grpcClient.getService<PipelinesServiceInterface>(
'PipelineService',
);
}
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');
},
});
})
.then((res) => res)
.catch((err) => {
throw new Error(err);
});
return createPipelineResponse;
}
async findAll() {
console.log('PipelinesClientService', 'FindAll');
const findAllPipelineResponse = await new Promise((resolve, reject) => {
this.pipelineService.findAll({}).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 findAllPipelineResponse;
}
async findOne({id}: IdRequest) {
console.log('PipelinesClientService', 'FindOne');
const findOnePipelineResponse = await new Promise((resolve, reject) => {
this.pipelineService.findOne({id}).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 findOnePipelineResponse;
}
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');
},
});
})
.then((res) => res)
.catch((err) => {
throw new Error(err);
});
return updatePipelineResponse;
}
async remove({id}:IdRequest) {
console.log('PipelinesClientService', 'Remove');
const removePipelineResponse = await new Promise((resolve, reject) => {
this.pipelineService.remove({id}).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 removePipelineResponse;
}
async getPipelineLogsMessages( data:IGetPipelineLogsRequest) {
console.log('PipelinesClientService', 'GetPipelineLogsMessages');
const logsPipelineResponse = await new Promise((resolve, reject) => {
this.pipelineService.getPipelineLogs(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 logsPipelineResponse;
}
async getPipelineStatus({id}:IdRequest) {
console.log('PipelinesClientService', 'GetPipelineStatus');
const statusPipelineResponse = await new Promise((resolve, reject) => {
this.pipelineService.getPipelineStatus({id}).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;
}
}
+28
View File
@@ -0,0 +1,28 @@
export interface ICreatePipelineDto {
input: IdRequest;
transformations: IdRequest[];
output: IdRequest;
tags: string[];
name: string;
description: string;
}
export interface IdRequest {
id: string;
}
export interface IUpdatePipelineRequest {
input: IdRequest;
transformations: IdRequest[];
output: IdRequest;
tags: string[];
name: string;
description: string;
id: string;
}
export interface IGetPipelineLogsRequest {
id: string;
details: string;
}
@@ -0,0 +1,22 @@
import { ClientOptions, Transport } from '@nestjs/microservices';
import { TransformationProtofile } from '@victorradael/protospack';
import { credentials } from '@grpc/grpc-js';
export class TransformationsClientConfiguration {
config(): ClientOptions {
return {
transport: Transport.GRPC,
options: {
url: process.env.TRFACTORY_URL,
package: 'transformation',
// credentials: credentials.createSsl(),
protoPath: TransformationProtofile,
loader: {
enums: String,
objects: true,
arrays: true,
},
},
};
}
};
@@ -0,0 +1,159 @@
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 { TransformationsServiceInterface } from '@victorradael/protospack';
import { ICreateTransformationElement, ICreateTransformationsRequest, IdRequest, IUpdateTransformationRequest } from './interfaces';
@Controller('transformation')
export class TransformationsClientService implements OnModuleInit {
private transformationService: TransformationsServiceInterface;
constructor(
@Inject('TRANSFORMATIONS_PACKAGE') private readonly grpcClient: ClientGrpc,
) {}
onModuleInit() {
this.transformationService =
this.grpcClient.getService<TransformationsServiceInterface>(
'TransformationService',
);
}
@Post()
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');
},
});
})
.then((res) => res)
.catch((err) => {
throw new Error(err);
});
return createTransformationResponse;
}
async findAll() {
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');
},
});
})
.then((res) => res)
.catch((err) => {
throw new Error(err);
});
return findAllTransformationResponse;
}
async findOne({id}: IdRequest) {
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');
},
});
})
.then((res) => res)
.catch((err) => {
throw new Error(err);
});
return findOneTransformationResponse;
}
async update(updateTransformationDTO: IUpdateTransformationRequest) {
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');
},
});
})
.then((res) => res)
.catch((err) => {
throw new Error(err);
});
return updateTransformationResponse;
}
async remove({id}: IdRequest) {
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');
},
});
})
.then((res) => res)
.catch((err) => {
throw new Error(err);
});
return removeTransformationResponse;
}
}
+31
View File
@@ -0,0 +1,31 @@
export interface ICreateTransformationsRequest {
transformations: ICreateTransformationElement[];
}
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;
}
export interface IdRequest{
id:string;
}
export interface IUpdateTransformationRequest {
created_at?: string;
id?: string;
client_id?: string;
params: Param[];
type?: string;
input_source?: string;
table?: string;
}
-17
View File
@@ -1,17 +0,0 @@
import { join } from 'path';
import { ClientOptions, Transport } from '@nestjs/microservices';
export const GrpcClientConfiguration: ClientOptions = {
transport: Transport.GRPC,
options: {
//url: `${process.env.USERS_SVC_URL}:${process.env.USERS_SVC_PORT}`,
url: `127.0.0.1:50053`,
package: 'enrichment',
protoPath: join(__dirname, '..', 'proto', 'enrichment.proto'),
loader: {
enums: String,
objects: true,
arrays: true,
},
},
};
@@ -1,6 +0,0 @@
export class CreateEnrichmentDto {
type:string;
columns:string[]
}
@@ -1,6 +0,0 @@
import { PartialType } from '@nestjs/mapped-types';
import { CreateEnrichmentDto } from './create-enrichment.dto';
export class UpdateEnrichmentDto extends PartialType(CreateEnrichmentDto) {
}
@@ -1,20 +0,0 @@
import { Test, TestingModule } from '@nestjs/testing';
import { EnrichmentController } from './enrichment.controller';
import { EnrichmentsService } from './enrichment.service';
describe('EnrichmentController', () => {
let controller: EnrichmentController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [EnrichmentController],
providers: [EnrichmentsService],
}).compile();
controller = module.get<EnrichmentController>(EnrichmentController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});
-60
View File
@@ -1,60 +0,0 @@
import {
Controller,
Delete,
Get,
OnModuleInit,
Param,
Post,
Put,
} from '@nestjs/common';
import { Client, ClientGrpc, Payload } from '@nestjs/microservices';
import { EnrichmentsService } from './enrichment.service';
import { CreateEnrichmentDto } from './dto/create-enrichment.dto';
import { UpdateEnrichmentDto } from './dto/update-enrichment.dto';
import { ApiTags } from '@nestjs/swagger';
import { GrpcClientConfiguration } from './config/grpc-client';
@ApiTags('enrichments')
@Controller('enrichment')
export class EnrichmentController implements OnModuleInit {
@Client(GrpcClientConfiguration)
private enrichmentServiceClient: ClientGrpc;
private enrichmentService: EnrichmentsService;
onModuleInit() {
this.enrichmentService =
this.enrichmentServiceClient.getService<EnrichmentsService>(
'EnrichmentService',
);
}
@Post()
create(@Payload() createEnrichmentDto: CreateEnrichmentDto) {
return this.enrichmentService.create(createEnrichmentDto);
}
@Get()
list() {
return this.enrichmentService.list();
}
@Get(':id')
show(@Param() id: string) {
return this.enrichmentService.show(id);
}
@Put(':id')
update(
@Param() id: string,
@Payload() updateEnrichmentDto: UpdateEnrichmentDto,
) {
return this.enrichmentService.update(id, updateEnrichmentDto);
}
@Delete(':id')
remove(@Param() id: string) {
return this.enrichmentService.remove(id);
}
}
-9
View File
@@ -1,9 +0,0 @@
import { Module } from '@nestjs/common';
import { EnrichmentsService } from './enrichment.service';
import { EnrichmentController } from './enrichment.controller';
@Module({
controllers: [EnrichmentController],
providers: [EnrichmentsService],
})
export class EnrichmentModule {}
-18
View File
@@ -1,18 +0,0 @@
import { Test, TestingModule } from '@nestjs/testing';
import { EnrichmentsService } from './enrichment.service';
describe('EnrichmentService', () => {
let service: EnrichmentsService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [EnrichmentsService],
}).compile();
service = module.get<EnrichmentsService>(EnrichmentsService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});
-26
View File
@@ -1,26 +0,0 @@
import { Injectable } from '@nestjs/common';
import { CreateEnrichmentDto } from './dto/create-enrichment.dto';
import { UpdateEnrichmentDto } from './dto/update-enrichment.dto';
@Injectable()
export class EnrichmentsService {
create(createEnrichmentDto: CreateEnrichmentDto) {
return 'This action adds a new enrichment';
}
list() {
return `This action returns all enrichment`;
}
show(id: string) {
return `This action returns a #${id} enrichment`;
}
update(id: string, updateEnrichmentDto: UpdateEnrichmentDto) {
return `This action updates a #${id} enrichment`;
}
remove(id: string) {
return `This action removes a #${id} enrichment`;
}
}
@@ -1,8 +0,0 @@
export class Enrichment {
id:string;
type:string;
columns:string[]
}
-43
View File
@@ -1,43 +0,0 @@
syntax = "proto3";
package enrichment;
import "google/protobuf/timestamp.proto";
service EnrichmentService {
rpc Create(CreateEnrichmentRequest) returns (Enrichment) {}
rpc Show(IdRequest) returns (Enrichment) {}
rpc List(Empty) returns (ListResponse){}
rpc Update(UpdateEnrichmentRequest) returns (Enrichment){}
rpc Remove(IdRequest) returns (Empty){}
}
message Empty {}
message IdRequest{
string id = 1;
}
message UpdateEnrichmentRequest{
string id = 1;
string type = 2;
repeated string columns = 3;
}
message Enrichment {
string id = 1;
string type = 2;
repeated string columns = 3;
}
message CreateEnrichmentRequest {
string type = 1;
repeated string columns = 2;
}
message ListResponse {
repeated Enrichment enrichments = 2;
}
-1
View File
@@ -1 +0,0 @@
export class Health {}
-9
View File
@@ -1,9 +0,0 @@
import { Module } from '@nestjs/common';
import { HealthService } from './health.service';
import { HealthController } from './health.controller';
@Module({
controllers: [HealthController],
providers: [HealthService],
})
export class HealthModule {}
-17
View File
@@ -1,17 +0,0 @@
import { join } from 'path';
import { ClientOptions, Transport } from '@nestjs/microservices';
export const GrpcClientConfiguration: ClientOptions = {
transport: Transport.GRPC,
options: {
//url: `${process.env.USERS_SVC_URL}:${process.env.USERS_SVC_PORT}`,
url: `127.0.0.1:50052`,
package: 'input',
protoPath: join(__dirname, '..', 'proto', 'input.proto'),
loader: {
enums: String,
objects: true,
arrays: true,
},
},
};
@@ -1,13 +0,0 @@
export class CreateInputGrpcClientDto {
cron:string;
name:string;
plugin:string;
values:string;
operation:string;
}
@@ -1,5 +0,0 @@
export class TestConnectionDTO{
values:string;
plugin:string;
}
@@ -1,6 +0,0 @@
import { PartialType } from '@nestjs/mapped-types';
import { CreateInputGrpcClientDto } from './create-input-grpc-client.dto';
export class UpdateInputGrpcClientDto extends PartialType(
CreateInputGrpcClientDto,
) {}
@@ -1,14 +0,0 @@
export class InputGrpcClient {
id:string;
cron:string;
name:string;
plugin:string;
values:string;
operation:string;
}
@@ -1,63 +0,0 @@
import {
Get,
Post,
Controller,
Delete,
OnModuleInit,
Put,
Param
} from '@nestjs/common';
import { Client, ClientGrpc, Payload } from '@nestjs/microservices';
import { CreateInputGrpcClientDto } from './dto/create-input-grpc-client.dto';
import { UpdateInputGrpcClientDto } from './dto/update-input-grpc-client.dto';
import { InputGrpcClientService } from './input-grpc-client.service';
import { GrpcClientConfiguration } from './config/grpc-client';
import { TestConnectionDTO } from './dto/test-connection-grpc-client.dto';
import { ApiTags } from '@nestjs/swagger';
@Controller('grpc/input')
export class InputGrpcClientController implements OnModuleInit {
@Client(GrpcClientConfiguration)
private inputServiceClient: ClientGrpc;
private inputService: InputGrpcClientService;
onModuleInit() {
this.inputService =
this.inputServiceClient.getService<InputGrpcClientService>('InputService');
}
@Post()
async create(@Payload() createInputDto: CreateInputGrpcClientDto) {
return this.inputService.create(createInputDto);
}
@Get()
list() {
return this.inputService.list();
}
@Get(':id')
show(@Param() id: string) {
return this.inputService.show(id);
}
@Put(':id')
update(
@Payload() updateInputDto: UpdateInputGrpcClientDto,
@Param() id: string,
) {
return this.inputService.update(id, updateInputDto);
}
@Delete(':id')
remove(@Param() id: string) {
return this.inputService.remove(id);
}
@Get('/test-connection')
testConnection(@Payload() testConnectionDTO:TestConnectionDTO){
return this.inputService.testConnection(testConnectionDTO)
}
}
-13
View File
@@ -1,13 +0,0 @@
import { Module } from '@nestjs/common';
import { InputGrpcClientService } from './input-grpc-client.service';
import { InputGrpcClientController } from './input-grpc-client.controller';
// import { InputRestClientController } from './input-rest-client.controller';
@Module({
controllers: [
InputGrpcClientController,
// InputRestClientController
],
providers: [InputGrpcClientService],
})
export class InputGrpcClientModule {}
@@ -1,18 +0,0 @@
import { Test, TestingModule } from '@nestjs/testing';
import { InputGrpcClientService } from './input-grpc-client.service';
describe('InputGrcpClientService', () => {
let service: InputGrpcClientService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [InputGrpcClientService],
}).compile();
service = module.get<InputGrpcClientService>(InputGrpcClientService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});
-31
View File
@@ -1,31 +0,0 @@
import { Injectable } from '@nestjs/common';
import { CreateInputGrpcClientDto } from './dto/create-input-grpc-client.dto';
import { TestConnectionDTO } from './dto/test-connection-grpc-client.dto';
import { UpdateInputGrpcClientDto } from './dto/update-input-grpc-client.dto';
@Injectable()
export class InputGrpcClientService {
create(createInputGrcpClientDto: CreateInputGrpcClientDto) {
return 'This action adds a new InputGrcpClient';
}
list() {
return `This action returns all InputGrcpClient`;
}
show(id: string) {
return `This action returns a #${id} InputGrcpClient`;
}
update(id: string, updateInputGrcpClientDto: UpdateInputGrpcClientDto) {
return `This action updates a #${id} InputGrcpClient`;
}
remove(id: string) {
return `This action removes a #${id} InputGrcpClient`;
}
testConnection(testConnectionDTO:TestConnectionDTO){
return `This action tests a given connection`;
}
}
@@ -1,71 +0,0 @@
import { Body, Controller, Delete, Get, Param, Post, Put, Redirect } from '@nestjs/common';
import { Payload } from '@nestjs/microservices';
import axios from 'axios';
import { Console } from 'console';
import { CreateInputGrpcClientDto } from './dto/create-input-grpc-client.dto';
import { UpdateInputGrpcClientDto } from './dto/update-input-grpc-client.dto';
@Controller('input')
export class InputRestClientController {
@Get('/test-connection/')
async testConnection(){
console.log(process.env.DEV_URL+`/test-connection`, "ON TEST CONNECTION ROUTE")
await axios.get(process.env.DEV_URL+`/test-connection`).then( (response) => {
return response
})
}
@Post()
async create(@Body() createInputDto: CreateInputGrpcClientDto){
console.log(createInputDto)
console.log(process.env.DEV_URL+`/input`, "ON CREATE ROUTE")
await axios.post(process.env.DEV_URL+'/input',createInputDto).then( (response) => {
return response
})
}
@Get()
async list(){
console.log(process.env.DEV_URL+`/input`, "ON GET ROUTE")
await axios.get(process.env.DEV_URL+`/input`).then( (response) => {
return response
})
}
@Get('/:id')
async show(@Param() id: string){
console.log(process.env.DEV_URL+`/input/${id}`, "ON SHOW ROUTE")
await axios.get(process.env.DEV_URL+`/input/${id}`).then( (response) => {
return response
})
}
@Put(':id')
async update(
@Payload() updateInputDto: UpdateInputGrpcClientDto,
@Param() id: string,
){
console.log(process.env.DEV_URL+`/input/${id}`, "ON UPDATE ROUTE")
await axios.put(process.env.DEV_URL+`input/${id}`,updateInputDto).then( (response) => {
return response
})
}
@Delete(':id')
async delete(@Param() id: string){
console.log(process.env.DEV_URL+`/input/${id}`, "ON DELETE ROUTE")
await axios.delete(process.env.DEV_URL+`/input/${id}`).then( (response) => {
return response
})
}
}
-65
View File
@@ -1,65 +0,0 @@
syntax = "proto3";
package input;
import "google/protobuf/timestamp.proto";
service InputService {
rpc Create(CreateInputRequest) returns (Input) {}
rpc Show(IdRequest) returns (Input) {}
rpc List(Empty) returns (ListResponse){}
rpc Update(UpdateInputRequest) returns (Input){}
rpc Remove(IdRequest) returns (Empty){}
rpc TestConnection(TestConnectionRequest) returns (TestConnectionResponse){}
}
message Empty {}
message IdRequest{
string id = 1;
}
message UpdateInputRequest{
string id = 1;
string cron = 2;
string name = 3;
string plugin = 4;
string values = 5;
string operation = 6;
}
message Input {
string id = 1;
string cronFormated = 2;
string name = 3;
string plugin = 4;
string values = 5;
string operation = 6;
}
message CreateInputRequest {
string cron = 1;
string name = 2;
string plugin = 3;
string values = 4;
string operation = 5;
}
message ListResponse {
repeated Input inputs = 1;
}
message TestConnectionRequest{
string values = 1;
string plugin = 2;
}
message TestConnectionResponse{
// nao sei como vai ser a resposta
bool respose = 1;
}
+1 -2
View File
@@ -3,8 +3,7 @@ import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { writeFileSync } from 'fs';
import { AppModule } from './app.module';
import { config } from 'dotenv';
config();
async function bootstrap() {
const app = await NestFactory.create(AppModule);
+17 -24
View File
@@ -2,29 +2,22 @@ import { Request, Response, NextFunction } from 'express';
import axios from 'axios';
import { NestMiddleware } from '@nestjs/common';
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()
}
})
} catch (error) {
response.status(401).send({ message: 'Authentication Failed!' });
}
};
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();
}
});
console.log(verify_response);
} catch (error) {
response.status(401).send({ message: 'Authentication Failed!' });
}
};
}
+25
View File
@@ -0,0 +1,25 @@
import { Body, Controller, Post } from '@nestjs/common';
import { AuthClientService } from 'src/clients/auth/client.service';
interface ISignIn {
username: string;
password: string;
}
@Controller('auth')
export class AuthController {
constructor(private authClient: AuthClientService) {}
@Post()
async signIn(@Body() { username, password }: ISignIn) {
console.log(`/auth`, 'SignIn');
const tokens = await this.authClient
.signIn({ username, password })
.then((result) => result)
.catch((err) => console.log(err));
return tokens;
}
}
+5
View File
@@ -0,0 +1,5 @@
describe('PipelinesGrpcServerService', () => {
it('should be defined', () => {
expect(2 + 2).toBe(4);
});
});
@@ -0,0 +1,5 @@
describe('PipelinesGrpcServerService', () => {
it('should be defined', () => {
expect(2 + 2).toBe(4);
});
});
+98
View File
@@ -0,0 +1,98 @@
import {
Body,
Controller,
Delete,
Get,
Param,
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';
@Controller('input')
export class InputsController {
constructor( private inputsClientService:InputsClientService){}
@Get('/test-connection')
async testConnection(@Body() data) {
console.log(
process.env.DEV_URL + `/test-connection`,
'ON TEST CONNECTION ROUTE',
);
console.log(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');
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');
const inputService = new InputsService(this.inputsClientService)
const response = await inputService.findAll()
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)
return response;
}
@Put(':id')
async update(
@Payload() updateInputDto,
@Param() params,
) {
const {id} = params;
console.log(process.env.DEV_URL + `/input/${id}`, 'ON UPDATE ROUTE');
const inputService = new InputsService(this.inputsClientService)
const response = await inputService.update(id,updateInputDto)
return response;
}
@Delete(':id')
async delete(@Param() params) {
const {id} = params
console.log(process.env.DEV_URL + `/input/${id}`, 'ON DELETE ROUTE');
const inputService = new InputsService(this.inputsClientService)
const response = await inputService.remove(id)
return response;
}
}
@@ -0,0 +1,5 @@
describe('PipelinesGrpcServerService', () => {
it('should be defined', () => {
expect(2 + 2).toBe(4);
});
});
+87
View File
@@ -0,0 +1,87 @@
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { InputsClientService } from 'src/clients/inputs/client.service';
@Injectable()
export class InputsService {
constructor( private inputClient: InputsClientService){}
async create(data){
try{
const createInputResponse = await this.inputClient.create(data)
return createInputResponse;
}catch(err){
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
}
}
async findAll(){
try{
const findAllInputResponse = await this.inputClient.findAll({})
return findAllInputResponse;
}catch(err){
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
}
}
async findOne(id:string){
try{
const findOneInputResponse = await this.inputClient.findOne({id})
return findOneInputResponse;
}catch(err){
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
}
}
async update(id:string,data){
try{
const updateInputResponse = await this.inputClient.update({id,...data})
return updateInputResponse;
}catch(err){
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
}
}
async remove(id:string){
try{
const removeInputResponse = await this.inputClient.remove({id})
return removeInputResponse;
}catch(err){
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
}
}
async testConnection(data){
try{
const testConnectionInputResponse = await this.inputClient.testConnection(data)
return testConnectionInputResponse;
}catch(err){
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
}
}
}
@@ -0,0 +1,77 @@
import {
Body,
Controller,
Delete,
Get,
Param,
Post,
Put,
Redirect,
} from '@nestjs/common';
import { Payload } from '@nestjs/microservices';
import { OutputsClientService } from 'src/clients/outputs/client.service';
import { OutputsService } from './outputs.service';
@Controller('outputs')
export class OutputsController {
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)
return response;
}
@Get()
async findAll() {
console.log(process.env.DEV_URL + `/output`, 'ON Find All ROUTE');
const outputService = new OutputsService(this.outputsClientService)
const response = await outputService.findAll()
return response;
}
@Get('/:id')
async findOne(@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)
return response;
}
@Put(':id')
async update(
@Payload() updateOutputDto,
@Param() params,
) {
const {id} = params;
console.log(process.env.DEV_URL + `/output/${id}`, 'ON UPDATE ROUTE');
const outputService = new OutputsService(this.outputsClientService)
const response = await outputService.update(id,updateOutputDto)
return response;
}
@Delete(':id')
async delete(@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)
return response;
}
}
@@ -0,0 +1,5 @@
describe('PipelinesGrpcServerService', () => {
it('should be defined', () => {
expect(2 + 2).toBe(4);
});
});
+69
View File
@@ -0,0 +1,69 @@
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { OutputsClientService } from 'src/clients/outputs/client.service';
@Injectable()
export class OutputsService {
constructor( private outputClient: OutputsClientService){}
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)
}
}
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 remove(id:string){
try{
const removeOutputResponse = await this.outputClient.remove({id});
return removeOutputResponse
}catch(err){
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
}
}
}
@@ -0,0 +1,109 @@
import {
Body,
Controller,
Delete,
Get,
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){}
@Get(':id/status')
async getPipelineStatus(
@Param() params,
) {
const { id , details } = params;
console.log(process.env.DEV_URL + `/pipeline/${id}`, 'ON GET PIPELINE STATUS ROUTE');
const pipelineService = new PipelinesService(this.pipelinesClientService)
const response = await pipelineService.getPipelineStatus(id)
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)
return response;
}
@Get()
async findAll() {
console.log(process.env.DEV_URL + `/pipeline`, 'ON Find All ROUTE');
const pipelineService = new PipelinesService(this.pipelinesClientService)
const response = await pipelineService.findAll()
return response;
}
@Get('/:id')
async findOne(@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)
return response;
}
@Put(':id')
async update(
@Payload() updatePipelineDto,
@Param() params,
) {
const {id} = params;
console.log(process.env.DEV_URL + `/pipeline/${id}`, 'ON UPDATE ROUTE');
const pipelineService = new PipelinesService(this.pipelinesClientService)
const response = await pipelineService.update(id,updatePipelineDto)
return response;
}
@Delete(':id')
async delete(@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)
return response;
}
}
@@ -0,0 +1,5 @@
describe('PipelinesGrpcServerService', () => {
it('should be defined', () => {
expect(2 + 2).toBe(4);
});
});
@@ -0,0 +1,99 @@
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { PipelinesClientService } from 'src/clients/pipelines/client.service';
import { objectCamelToSnake } from 'src/utils/CaseConverter';
@Injectable()
export class PipelinesService {
constructor( private pipelineClient: PipelinesClientService){}
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)
}
}
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 remove(id:string){
try{
const removePipelineResponse = await this.pipelineClient.remove({id});
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(id:string){
try{
const pipelineStatusResponse = await this.pipelineClient.getPipelineStatus({id});
return objectCamelToSnake(pipelineStatusResponse)
}catch(err){
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
}
}
}
@@ -0,0 +1,79 @@
import {
Body,
Controller,
Delete,
Get,
Param,
Post,
Put,
Redirect,
} from '@nestjs/common';
import { Payload } from '@nestjs/microservices';
import { TransformationsClientService } from 'src/clients/transformations/client.service';
import { TransformationsService } from './transformations.service';
@Controller('transformations')
export class TransformationsController {
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)
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;
}
}
@@ -0,0 +1,5 @@
describe('PipelinesGrpcServerService', () => {
it('should be defined', () => {
expect(2 + 2).toBe(4);
});
});
@@ -0,0 +1,77 @@
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { TransformationsClientService } from 'src/clients/transformations/client.service';
import { ICreateTransformationsRequest } from 'src/clients/transformations/interfaces';
import { trSnakeToCamel } from 'src/utils/CaseConverter';
@Injectable()
export class TransformationsService {
constructor( private transformationClient: TransformationsClientService){}
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)
}
}
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)
}
}
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 remove(id:string){
try{
const removeTransformationResponse = await this.transformationClient.remove({id});
return removeTransformationResponse
}catch(err){
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
}
}
}
-17
View File
@@ -1,17 +0,0 @@
import { join } from 'path';
import { ClientOptions, Transport } from '@nestjs/microservices';
export const GrpcClientConfiguration: ClientOptions = {
transport: Transport.GRPC,
options: {
//url: `${process.env.USERS_SVC_URL}:${process.env.USERS_SVC_PORT}`,
url: `127.0.0.1:50053`,
package: 'output',
protoPath: join(__dirname, '..', 'proto', 'output.proto'),
loader: {
enums: String,
objects: true,
arrays: true,
},
},
};
-7
View File
@@ -1,7 +0,0 @@
export class CreateOutputDto {
name:string;
plugin:string;
values:string;
operation:string;
}
-6
View File
@@ -1,6 +0,0 @@
import { PartialType } from '@nestjs/mapped-types';
import { CreateOutputDto } from './create-output.dto';
export class UpdateOutputDto extends PartialType(CreateOutputDto) {
}
-9
View File
@@ -1,9 +0,0 @@
export class Output {
id:string;
name:string;
plugin:string;
values:string;
operation:string;
}
-20
View File
@@ -1,20 +0,0 @@
import { Test, TestingModule } from '@nestjs/testing';
import { OutputsController } from './outputs.controller';
import { OutputsService } from './outputs.service';
describe('OutputsController', () => {
let controller: OutputsController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [OutputsController],
providers: [OutputsService],
}).compile();
controller = module.get<OutputsController>(OutputsController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});
-57
View File
@@ -1,57 +0,0 @@
import {
Controller,
Delete,
Get,
OnModuleInit,
Param,
Post,
Put,
} from '@nestjs/common';
import {
Client,
ClientGrpc,
MessagePattern,
Payload,
} from '@nestjs/microservices';
import { OutputsService } from './outputs.service';
import { CreateOutputDto } from './dto/create-output.dto';
import { UpdateOutputDto } from './dto/update-output.dto';
import { ApiTags } from '@nestjs/swagger';
import { GrpcClientConfiguration } from './config/grpc-client';
@Controller('output')
export class OutputsController implements OnModuleInit {
@Client(GrpcClientConfiguration)
private outputServiceClient: ClientGrpc;
private outputService: OutputsService;
onModuleInit() {
this.outputService =
this.outputServiceClient.getService<OutputsService>('OutputService');
}
@Post()
create(@Payload() createOutputDto: CreateOutputDto) {
return this.outputService.create(createOutputDto);
}
@Get()
list() {
return this.outputService.list();
}
@Get(':id')
show(@Param() id: string) {
return this.outputService.show(id);
}
@Put(':id')
update(@Param() id: string, @Payload() updateOutputDto: UpdateOutputDto) {
return this.outputService.update(id, updateOutputDto);
}
@Delete(':id')
remove(@Param() id: string) {
return this.outputService.remove(id);
}
}
-9
View File
@@ -1,9 +0,0 @@
import { Module } from '@nestjs/common';
import { OutputsService } from './outputs.service';
import { OutputsController } from './outputs.controller';
@Module({
controllers: [OutputsController],
providers: [OutputsService],
})
export class OutputsModule {}
-18
View File
@@ -1,18 +0,0 @@
import { Test, TestingModule } from '@nestjs/testing';
import { OutputsService } from './outputs.service';
describe('OutputsService', () => {
let service: OutputsService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [OutputsService],
}).compile();
service = module.get<OutputsService>(OutputsService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});
-26
View File
@@ -1,26 +0,0 @@
import { Injectable } from '@nestjs/common';
import { CreateOutputDto } from './dto/create-output.dto';
import { UpdateOutputDto } from './dto/update-output.dto';
@Injectable()
export class OutputsService {
create(createOutputDto: CreateOutputDto) {
return 'This action adds a new output';
}
list() {
return `This action returns all outputs`;
}
show(id: string) {
return `This action returns a #${id} output`;
}
update(id: string, updateOutputDto: UpdateOutputDto) {
return `This action updates a #${id} output`;
}
remove(id: string) {
return `This action removes a #${id} output`;
}
}
-48
View File
@@ -1,48 +0,0 @@
syntax = "proto3";
package output;
import "google/protobuf/timestamp.proto";
service OutputService{
rpc Create(CreateOutputRequest) returns (Output) {}
rpc Show(IdRequest) returns (Output) {}
rpc List(Empty) returns (ListResponse){}
rpc Update(UpdateOutputRequest) returns (Output){}
rpc Remove(IdRequest) returns (Empty){}
}
message Empty {}
message IdRequest{
string id = 1;
}
message Output {
string id = 1;
string name = 2;
string plugin = 3;
string values = 4;
string operation = 5;
}
message CreateOutputRequest {
string name = 1;
string plugin = 2;
string values = 3;
string operation = 4;
}
message UpdateOutputRequest{
string id = 1;
string name = 3;
string plugin = 4;
string values = 5;
string operation = 6;
}
message ListResponse {
repeated Output outputs = 1;
}
-17
View File
@@ -1,17 +0,0 @@
import { join } from 'path';
import { ClientOptions, Transport } from '@nestjs/microservices';
export const GrpcClientConfiguration: ClientOptions = {
transport: Transport.GRPC,
options: {
//url: `${process.env.USERS_SVC_URL}:${process.env.USERS_SVC_PORT}`,
url: `127.0.0.1:50054`,
package: 'pipeline',
protoPath: join(__dirname, '..', 'proto', 'pipeline.proto'),
loader: {
enums: String,
objects: true,
arrays: true,
},
},
};
-12
View File
@@ -1,12 +0,0 @@
import { InputGrpcClient } from "src/inputs/entities/input-grcp-client.entity";
import { Output } from "src/outputs/entities/output.entity";
import { Transformation } from "src/transformations/entities/transformation.entity";
export class CreatePipelineDto {
input:InputGrpcClient;
output:Output;
transformations:Transformation;
tags:string[];
name:string;
description:string;
}
-6
View File
@@ -1,6 +0,0 @@
import { PartialType } from '@nestjs/mapped-types';
import { CreatePipelineDto } from './create-pipeline.dto';
export class UpdatePipelineDto extends PartialType(CreatePipelineDto) {
}
-14
View File
@@ -1,14 +0,0 @@
import { InputGrpcClient } from "src/inputs/entities/input-grcp-client.entity";
import { Output } from "src/outputs/entities/output.entity";
import { Transformation } from "src/transformations/entities/transformation.entity";
export class Pipeline {
id:string;
input:InputGrpcClient;
output:Output;
transformations:Transformation;
tags:string[];
name:string;
description:string;
status:string;
}
@@ -1,20 +0,0 @@
import { Test, TestingModule } from '@nestjs/testing';
import { PipelinesController } from './pipelines.controller';
import { PipelinesService } from './pipelines.service';
describe('PipelinesController', () => {
let controller: PipelinesController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [PipelinesController],
providers: [PipelinesService],
}).compile();
controller = module.get<PipelinesController>(PipelinesController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});
-70
View File
@@ -1,70 +0,0 @@
import {
Controller,
Delete,
Get,
OnModuleInit,
Param,
Post,
Put,
} from '@nestjs/common';
import {
Client,
ClientGrpc,
MessagePattern,
Payload,
} from '@nestjs/microservices';
import { PipelinesService } from './pipelines.service';
import { CreatePipelineDto } from './dto/create-pipeline.dto';
import { UpdatePipelineDto } from './dto/update-pipeline.dto';
import { GrpcClientConfiguration } from './config/grpc-client';
@Controller('pipeline')
export class PipelinesController implements OnModuleInit {
@Client(GrpcClientConfiguration)
private pipelineServiceClient: ClientGrpc;
private pipelineService: PipelinesService;
onModuleInit() {
this.pipelineService =
this.pipelineServiceClient.getService<PipelinesService>(
'PipelineService',
);
}
@Post()
create(@Payload() createPipelineDto: CreatePipelineDto) {
return this.pipelineService.create(createPipelineDto);
}
@Get()
list() {
return this.pipelineService.list();
}
@Get(':id')
show(@Param() id: string) {
return this.pipelineService.show(id);
}
@Put(':id')
update(@Param() id: string, @Payload() updatePipelineDto: UpdatePipelineDto) {
return this.pipelineService.update(id, updatePipelineDto);
}
@Delete()
remove(@Param() id: string) {
return this.pipelineService.remove(id);
}
@Post()
getPipelineLogsMessages(@Param() id: string, @Payload() details: string) {
return this.pipelineService.getPipelineLogsMessages(id, details);
}
getPipelineStatus(id: string) {
return this.pipelineService.getPipelineStatus(id);
}
}
-9
View File
@@ -1,9 +0,0 @@
import { Module } from '@nestjs/common';
import { PipelinesService } from './pipelines.service';
import { PipelinesController } from './pipelines.controller';
@Module({
controllers: [PipelinesController],
providers: [PipelinesService],
})
export class PipelinesModule {}
-18
View File
@@ -1,18 +0,0 @@
import { Test, TestingModule } from '@nestjs/testing';
import { PipelinesService } from './pipelines.service';
describe('PipelinesService', () => {
let service: PipelinesService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [PipelinesService],
}).compile();
service = module.get<PipelinesService>(PipelinesService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});
-34
View File
@@ -1,34 +0,0 @@
import { Injectable } from '@nestjs/common';
import { CreatePipelineDto } from './dto/create-pipeline.dto';
import { UpdatePipelineDto } from './dto/update-pipeline.dto';
@Injectable()
export class PipelinesService {
create(createPipelineDto: CreatePipelineDto) {
return 'This action adds a new pipeline';
}
list() {
return `This action returns all pipelines`;
}
show(id: string) {
return `This action returns a #${id} pipeline`;
}
update(id: string, updatePipelineDto: UpdatePipelineDto) {
return `This action updates a #${id} pipeline`;
}
remove(id: string) {
return `This action removes a #${id} pipeline`;
}
getPipelineLogsMessages(id: string, details: string) {
return `This action perfoms a getLogMessages on #${id} pipeline`;
}
getPipelineStatus(id: string) {
return `This action performs a getStatus on #${id} pipeline`;
}
}
-97
View File
@@ -1,97 +0,0 @@
syntax = "proto3";
package pipeline;
import "google/protobuf/timestamp.proto";
service PipelineService{
rpc Create(CreatePipelineRequest) returns (Pipeline) {}
rpc Show(IdRequest) returns (Pipeline) {}
rpc List(Empty) returns (ListResponse){}
rpc Update(UpdatePipelineRequest) returns (Pipeline){}
rpc Remove(IdRequest) returns (Empty){}
rpc getPipelineLogsMessages(getPipelineLogsMessagesRequest) returns (getPipelineLogsMessagesResponse){}
rpc getPipelineStatus(IdRequest) returns (getPipelineStatusResponse){}
}
message Empty {}
message IdRequest{
string id = 1;
}
message Transformation {
string id = 1;
string inputSource = 2;
string table = 3;
string type = 4;
string params = 5;
}
message Input {
string id = 1;
string cronFormated = 2;
string name = 3;
string plugin = 4;
string values = 5;
string operation = 6;
}
message Output {
string id = 1;
string name = 2;
string plugin = 3;
string values = 4;
string operation = 5;
}
message Pipeline {
string id = 1;
Input input = 2;
Output output = 3;
Transformation transformations = 4;
repeated string tags = 5;
string name = 6;
string description = 7;
string status = 8;
}
message CreatePipelineRequest {
Input input = 1;
Output output = 2;
Transformation transformations = 3;
repeated string tags = 4;
string name = 5;
string description = 6;
}
message UpdatePipelineRequest{
string id = 1;
repeated string tags = 2;
string name = 3;
string description = 4;
string status = 5;
}
message ListResponse {
repeated Pipeline pipelines = 1;
}
message getPipelineLogsMessagesRequest{
string id = 1;
string details = 2;
}
message getPipelineLogsMessagesResponseItem{
string date = 1;
string log = 2;
}
message getPipelineLogsMessagesResponse{
repeated getPipelineLogsMessagesResponseItem pipelineLogs = 1;
}
message getPipelineStatusResponse{
string status = 1;
}
@@ -1,6 +0,0 @@
export class CreateRestEnrichmentDto {
type:string;
columns
}
@@ -1,4 +0,0 @@
import { PartialType } from '@nestjs/swagger';
import { CreateRestEnrichmentDto } from './create-rest-enrichment.dto';
export class UpdateRestEnrichmentDto extends PartialType(CreateRestEnrichmentDto) {}
@@ -1,7 +0,0 @@
export class RestEnrichment {
id:string;
type:string;
columns:string[]
}
@@ -1,20 +0,0 @@
import { Test, TestingModule } from '@nestjs/testing';
import { RestEnrichmentsController } from './rest-enrichments.controller';
import { RestEnrichmentsService } from './rest-enrichments.service';
describe('RestEnrichmentsController', () => {
let controller: RestEnrichmentsController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [RestEnrichmentsController],
providers: [RestEnrichmentsService],
}).compile();
controller = module.get<RestEnrichmentsController>(RestEnrichmentsController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});
@@ -1,92 +0,0 @@
import { Controller, Get, Post, Body, Patch, Param, Delete, Put, Headers} from '@nestjs/common';
import { RestEnrichmentsService } from './rest-enrichments.service';
import { CreateRestEnrichmentDto } from './dto/create-rest-enrichment.dto';
import { UpdateRestEnrichmentDto } from './dto/update-rest-enrichment.dto';
import axios from 'axios';
import { ApiTags } from '@nestjs/swagger';
@ApiTags('Enrichments')
@Controller('enrichment')
export class RestEnrichmentsController {
constructor(private readonly restEnrichmentsService: RestEnrichmentsService) {}
@Post()
async create(@Body() body: CreateRestEnrichmentDto,@Headers() headers) {
const connectionResponse = await axios.post(
`${process.env.DEV_URL}/enrichment`,
body,
{
headers:{
"Authorization":headers.authorization,
"Content-Type":"application/json"
}
}
)
return connectionResponse.data
}
@Get()
async list(@Headers() headers) {
const connectionResponse = await axios.get(
`${process.env.DEV_URL}/enrichment`,
{
headers:{
"Authorization":headers.authorization
}
}
)
return connectionResponse.data
}
@Get(':id')
async show(@Param('id') id: string,@Headers() headers) {
const connectionResponse = await axios.get(
`${process.env.DEV_URL}/enrichment/${id}`,
{
headers:{
"Authorization":headers.authorization
}
}
)
return connectionResponse.data
}
@Put(':id')
async update(@Param('id') id: string,@Headers() headers, @Body() body: UpdateRestEnrichmentDto) {
const connectionResponse = await axios.put(
`${process.env.DEV_URL}/enrichment/${id}`,
body,
{
headers:{
"Authorization":headers.authorization,
"Content-Type":"application/json"
}
}
)
return connectionResponse.data
}
@Delete(':id')
async remove(@Param('id') id: string,@Headers() headers) {
const connectionResponse = await axios.delete(
`${process.env.DEV_URL}/enrichment/${id}`,
{
headers:{
"Authorization":headers.authorization,
"Content-Type":"application/json"
}
}
)
return connectionResponse.data
}
}
@@ -1,9 +0,0 @@
import { Module } from '@nestjs/common';
import { RestEnrichmentsService } from './rest-enrichments.service';
import { RestEnrichmentsController } from './rest-enrichments.controller';
@Module({
controllers: [RestEnrichmentsController],
providers: [RestEnrichmentsService]
})
export class RestEnrichmentsModule {}
@@ -1,18 +0,0 @@
import { Test, TestingModule } from '@nestjs/testing';
import { RestEnrichmentsService } from './rest-enrichments.service';
describe('RestEnrichmentsService', () => {
let service: RestEnrichmentsService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [RestEnrichmentsService],
}).compile();
service = module.get<RestEnrichmentsService>(RestEnrichmentsService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});
@@ -1,26 +0,0 @@
import { Injectable } from '@nestjs/common';
import { CreateRestEnrichmentDto } from './dto/create-rest-enrichment.dto';
import { UpdateRestEnrichmentDto } from './dto/update-rest-enrichment.dto';
@Injectable()
export class RestEnrichmentsService {
create(createRestEnrichmentDto: CreateRestEnrichmentDto) {
return 'This action adds a new restEnrichment';
}
findAll() {
return `This action returns all restEnrichments`;
}
findOne(id: number) {
return `This action returns a #${id} restEnrichment`;
}
update(id: number, updateRestEnrichmentDto: UpdateRestEnrichmentDto) {
return `This action updates a #${id} restEnrichment`;
}
remove(id: number) {
return `This action removes a #${id} restEnrichment`;
}
}
@@ -1 +0,0 @@
export class CreateRestFactoryDto {}
@@ -1,4 +0,0 @@
import { PartialType } from '@nestjs/swagger';
import { CreateRestFactoryDto } from './create-rest-factory.dto';
export class UpdateRestFactoryDto extends PartialType(CreateRestFactoryDto) {}
@@ -1 +0,0 @@
export class RestFactory {}
@@ -1,20 +0,0 @@
import { Test, TestingModule } from '@nestjs/testing';
import { RestFactoryController } from './rest-factory.controller';
import { RestFactoryService } from './rest-factory.service';
describe('RestFactoryController', () => {
let controller: RestFactoryController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [RestFactoryController],
providers: [RestFactoryService],
}).compile();
controller = module.get<RestFactoryController>(RestFactoryController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

Some files were not shown because too many files have changed in this diff Show More