Compare commits

...
31 Commits
Author SHA1 Message Date
Arthur Simas 5d1a54a720 CI: . 2022-05-25 11:45:37 -03:00
Arthur Simas 8399a0e4c1 CI: . 2022-05-25 11:40:38 -03:00
Arthur Simas cf54cb0bc2 CI: not considering semver during manual deploy 2022-05-25 11:37:14 -03:00
Arthur Simas 2344e4dba3 CI: using github-flow deployment workflow 2022-05-24 18:57:41 -03:00
Rodrigo Zamboni c1498f8f1b Merge pull request #98 from dadosfera/beta
Beta -> main
2022-05-20 17:27:29 -03:00
Gabriel Rosa 0b3cb581c4 merge alpha -> beta 2022-05-20 15:19:43 -03:00
Gabriel Rosa 97a6e05812 FIX: returning input when creating jdbc 2022-05-20 15:19:00 -03:00
Gabriel Rosa 356d438404 merge alpha 2022-05-20 14:07:02 -03:00
Gabriel Rosa cf870cff14 FIX: formating payload 2022-05-20 14:06:13 -03:00
Gabriel Rosa 26c6a289eb merge from beta 2022-05-20 11:51:48 -03:00
Gabriel Rosa 8d27e42fcd FIX: protospack version 2022-05-20 11:51:08 -03:00
Gabriel Rosa c44e557b11 merge beta 2022-05-20 10:08:20 -03:00
Gabriel Rosa 25d06ab4c5 FIX: send input to createS3 2022-05-20 10:07:38 -03:00
Gabriel Amorim 31bb795d23 Merge pull request #97 from dadosfera/alpha
Alpha -> Beta
2022-05-20 09:12:34 -03:00
Gabriel Rosa a2e25eb737 FIX: added ssl back 2022-05-20 08:51:25 -03:00
Gabriel Rosa 6be53bebaf FIX: adjusting pipeline payload fixed 2022-05-20 08:50:08 -03:00
Rodrigo Zamboni 741f009723 Merge pull request #96 from dadosfera/alpha
Alpha
2022-05-19 15:20:06 -03:00
Rodrigo Zamboni 45477b5750 Merge branch 'beta' into alpha 2022-05-19 15:09:15 -03:00
rodrigo.zamboni 36de53dfd3 FIX: lib version 2022-05-19 14:48:22 -03:00
rodrigo.zamboni cd8fe2fbf6 CI: Deploy 2022-05-19 14:46:17 -03:00
rodrigo.zamboni c4a2bee69c CI: DEploy 2022-05-19 14:18:08 -03:00
rodrigo.zamboni e48d11153d FIX: Added S3 or JDBC input selection for pipelines 2022-05-19 14:13:06 -03:00
Gabriel Amorim c7e4de7d65 Merge pull request #95 from dadosfera/feat/mfa
FEAT: MFA finished + better error handling
2022-05-19 13:59:46 -03:00
Arthur Simas b2e7870cc5 CHORE: protospack version bump 2022-05-19 12:56:32 -03:00
Arthur Simas 1e239026a3 FEAT: MFA finished + better error handling 2022-05-19 12:02:08 -03:00
Rodrigo Zamboni bc108d43e3 Merge pull request #94 from dadosfera/beta
Beta
2022-05-18 16:54:04 -03:00
Arthur Simas 1c5b929c1b REFACTOR: nimbus URL 2022-05-18 13:57:19 -03:00
Gabriel Rosa f4a5f91cbb FIX: remove backmerge 2022-05-16 17:03:12 -03:00
Arthur Simas 65f6f03e55 CHORE: pinning protospack version to 1.7.4 2022-05-13 11:15:05 -03:00
Arthur Simas a54300f600 CHORE: pinning protospack version to 1.7.2 2022-05-13 11:00:25 -03:00
Arthur Simas 5ef85f79d3 Merge branch 'alpha' into beta 2022-05-13 10:49:27 -03:00
20 changed files with 411 additions and 397 deletions
@@ -2,37 +2,50 @@ name: Deploy
on: on:
push: push:
branches: branches:
- alpha
- beta
- main - main
workflow_dispatch:
inputs:
environment:
description: 'Deployment environment'
required: true
type: choice
options:
- dev
- stg
- prd
jobs: jobs:
extract_environment: extract_environment:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
environment: ${{ steps.extract_environment.outputs.environment }} environment: ${{ steps.extract_environment.outputs.environment }}
env:
EVENT: ${{ github.event_name }}
DEPLOY_ENV: ${{ github.event.inputs.environment }}
steps: steps:
- name: Extract Environment - name: Extract Environment
run: | run: |
if [ ${GITHUB_REF} == "refs/heads/main" ]; then if [ ${EVENT} == "workflow_dispatch" ]; then
echo "##[set-output name=environment;]$(echo ${DEPLOY_ENV})"
elif [ ${GITHUB_REF} == "refs/heads/main" ]; then
echo "##[set-output name=environment;]$(echo "prd")" 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 fi
id: extract_environment id: extract_environment
semantic_release: semantic_release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
#new_release_published: ${{ steps.semantic.outputs.last_release_version != steps.semantic.outputs.new_release_version }}
new_release_published: ${{ steps.semantic.outputs.new_release_published }} new_release_published: ${{ steps.semantic.outputs.new_release_published }}
new_release_version: ${{ steps.semantic.outputs.new_release_version }} new_release_version: ${{ steps.semantic.outputs.new_release_version }}
test: ${{ (steps.semantic.outputs.new_release_published == 'true' && steps.semantic.outputs.new_release_version) || (github.event_name == 'workflow_dispatch' && '0.0.0') }}
testt: ${{ (needs.semantic_release.outputs.new_release_published == 'true' && needs.semantic_release.outputs.new_release_version) || '1.0.0' }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Semantic Release - if: github.event_name != 'workflow_dispatch'
name: Semantic Release
uses: cycjimmy/semantic-release-action@v2 uses: cycjimmy/semantic-release-action@v2
id: semantic id: semantic
with: with:
@@ -41,77 +54,58 @@ jobs:
conventional-changelog-eslint conventional-changelog-eslint
branches: | branches: |
[ [
'main', 'main'
{
name: 'alpha',
prerelease: true
},
{
name: 'beta',
prerelease: true
}
] ]
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
deploy: deploy:
if: ${{ (github.event_name != 'workflow_dispatch' && needs.semantic_release.outputs.new_release_published == 'true') || 'true' }}
needs: [extract_environment, semantic_release] needs: [extract_environment, semantic_release]
runs-on: [self-hosted, "${{ needs.extract_environment.outputs.environment }}"] runs-on:
[self-hosted, '${{ needs.extract_environment.outputs.environment }}']
steps: steps:
- name: print
env:
EVENT: ${{ github.event_name }}
IMAGE_TAG: ${{ needs.semantic_release.outputs.test }}
IMAGE_TAGG: ${{ needs.semantic_release.outputs.testT }}
run: echo ${IMAGE_TAG} ${IMAGE_TAGG} ${EVENT}
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Update Pip - name: Update Pip
if: needs.semantic_release.outputs.new_release_published == 'true'
run: | run: |
python3 -m pip install --upgrade pip python3 -m pip install --upgrade pip
- name: Install Docker Compose - name: Install Docker Compose
if: needs.semantic_release.outputs.new_release_published == 'true'
run: | run: |
python3 -m pip install docker-compose --upgrade python3 -m pip install docker-compose --upgrade
- name: Install AWS CLI - name: Install AWS CLI
if: needs.semantic_release.outputs.new_release_published == 'true'
run: | run: |
python3 -m pip install awscli --upgrade python3 -m pip install awscli --upgrade
- name: Install AWS Elastic Beanstalk CLI - name: Install AWS Elastic Beanstalk CLI
if: needs.semantic_release.outputs.new_release_published == 'true'
run: | run: |
python3 -m pip install awsebcli --upgrade python3 -m pip install awsebcli --upgrade
- name: Configure AWS Region - name: Configure AWS Region
if: needs.semantic_release.outputs.new_release_published == 'true'
uses: aws-actions/configure-aws-credentials@v1 uses: aws-actions/configure-aws-credentials@v1
id: aws id: aws
with: with:
aws-region: us-east-1 aws-region: us-east-1
- name: Extract Environment
if: needs.semantic_release.outputs.new_release_published == 'true'
shell: bash
run: |
if [ ${GITHUB_REF} == "refs/heads/main" ]; then
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
- name: Login to AWS ECR - name: Login to AWS ECR
if: needs.semantic_release.outputs.new_release_published == 'true'
id: login_ecr id: login_ecr
uses: aws-actions/amazon-ecr-login@v1 uses: aws-actions/amazon-ecr-login@v1
- name: Build, Tag, and Push Image to AWS ECR - name: Build, Tag, and Push Image to AWS ECR
if: needs.semantic_release.outputs.new_release_published == 'true'
env: env:
ENV: ${{ steps.extract_environment.outputs.result }} ENV: ${{ needs.extract_environment.outputs.environment }}
IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }} IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }} ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -120,9 +114,8 @@ jobs:
docker-compose -f build.docker-compose.yml push docker-compose -f build.docker-compose.yml push
- name: Create ZIP file to Deploy AWS Beanstalk - name: Create ZIP file to Deploy AWS Beanstalk
if: needs.semantic_release.outputs.new_release_published == 'true'
env: env:
ENV: ${{ steps.extract_environment.outputs.result }} ENV: ${{ needs.extract_environment.outputs.environment }}
IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }} IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }} ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }}
run: | run: |
@@ -132,11 +125,10 @@ jobs:
zip deploy.zip docker-compose.yml -r .ebextensions zip deploy.zip docker-compose.yml -r .ebextensions
- name: Deploy AWS Beanstalk - name: Deploy AWS Beanstalk
if: needs.semantic_release.outputs.new_release_published == 'true'
env: env:
ENV: ${{ steps.extract_environment.outputs.result }} ENV: ${{ needs.extract_environment.outputs.environment }}
AWS_REGION: us-east-1 AWS_REGION: us-east-1
APP_NAME: maestro APP_NAME: ${{ github.event.repository.name }}
run: | run: |
eb use $APP_NAME-$ENV eb use $APP_NAME-$ENV
echo -e "deploy:\n artifact: deploy.zip" >> .elasticbeanstalk/config.yml echo -e "deploy:\n artifact: deploy.zip" >> .elasticbeanstalk/config.yml
+1 -1
View File
@@ -29,7 +29,7 @@ lerna-debug.log*
# IDE - VSCode # IDE - VSCode
.vscode/* .vscode/*
!.vscode/settings.json #!.vscode/settings.json
!.vscode/tasks.json !.vscode/tasks.json
!.vscode/launch.json !.vscode/launch.json
!.vscode/extensions.json !.vscode/extensions.json
+7 -28
View File
@@ -19,7 +19,7 @@
"@nestjs/platform-express": "^8.4.3", "@nestjs/platform-express": "^8.4.3",
"@nestjs/schedule": "^1.1.0", "@nestjs/schedule": "^1.1.0",
"@nestjs/swagger": "^5.2.1", "@nestjs/swagger": "^5.2.1",
"@victorradael/protospack": "^1.8.0", "@victorradael/protospack": "2.3.0",
"axios": "^0.25.0", "axios": "^0.25.0",
"dotenv": "^14.2.0", "dotenv": "^14.2.0",
"helmet": "^5.0.2", "helmet": "^5.0.2",
@@ -2359,9 +2359,9 @@
} }
}, },
"node_modules/@victorradael/protospack": { "node_modules/@victorradael/protospack": {
"version": "1.8.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/@victorradael/protospack/-/protospack-1.8.0.tgz", "resolved": "https://registry.npmjs.org/@victorradael/protospack/-/protospack-2.3.0.tgz",
"integrity": "sha512-vixXFliu7hPtJshGyxyekXBMsY1VCDo6WKu+aDKGHxAvd1cSG46UjAOYvYX5yPL4/J6fD//C4mdEYNW9l5TLvQ==", "integrity": "sha512-D2iy5Ff8G2FhH6Grs4MHM0qyqc6EU7iGuD3Bit6Tm6GbHmhDbLER9uBowClPjbPSAQ6jP7WTYxwn/TgDK4lNaA==",
"dependencies": { "dependencies": {
"rxjs": "^7.5.5" "rxjs": "^7.5.5"
} }
@@ -4738,20 +4738,6 @@
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
}, },
"node_modules/fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"hasInstallScript": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/function-bind": { "node_modules/function-bind": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
@@ -10955,9 +10941,9 @@
} }
}, },
"@victorradael/protospack": { "@victorradael/protospack": {
"version": "1.8.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/@victorradael/protospack/-/protospack-1.8.0.tgz", "resolved": "https://registry.npmjs.org/@victorradael/protospack/-/protospack-2.3.0.tgz",
"integrity": "sha512-vixXFliu7hPtJshGyxyekXBMsY1VCDo6WKu+aDKGHxAvd1cSG46UjAOYvYX5yPL4/J6fD//C4mdEYNW9l5TLvQ==", "integrity": "sha512-D2iy5Ff8G2FhH6Grs4MHM0qyqc6EU7iGuD3Bit6Tm6GbHmhDbLER9uBowClPjbPSAQ6jP7WTYxwn/TgDK4lNaA==",
"requires": { "requires": {
"rxjs": "^7.5.5" "rxjs": "^7.5.5"
} }
@@ -12828,13 +12814,6 @@
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
}, },
"fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"optional": true
},
"function-bind": { "function-bind": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
+1 -1
View File
@@ -31,7 +31,7 @@
"@nestjs/platform-express": "^8.4.3", "@nestjs/platform-express": "^8.4.3",
"@nestjs/schedule": "^1.1.0", "@nestjs/schedule": "^1.1.0",
"@nestjs/swagger": "^5.2.1", "@nestjs/swagger": "^5.2.1",
"@victorradael/protospack": "^1.8.0", "@victorradael/protospack": "2.3.0",
"axios": "^0.25.0", "axios": "^0.25.0",
"dotenv": "^14.2.0", "dotenv": "^14.2.0",
"helmet": "^5.0.2", "helmet": "^5.0.2",
+3 -1
View File
@@ -10,7 +10,9 @@ export class AuthClient {
options: { options: {
url: process.env.DUC_URL, url: process.env.DUC_URL,
package: DucPackages, package: DucPackages,
credentials: credentials.createSsl(), credentials: process.env.LOCAL_ENV
? undefined
: credentials.createSsl(),
protoPath: DucProtoFilePath, protoPath: DucProtoFilePath,
loader: { loader: {
enums: String, enums: String,
+54 -85
View File
@@ -2,17 +2,18 @@ import { OnModuleInit, Inject } from '@nestjs/common';
import { ClientGrpc } from '@nestjs/microservices'; import { ClientGrpc } from '@nestjs/microservices';
import { import {
AuthConfirmationRequest,
AuthDisableTotpMfaRequest,
AuthEnableTotpMfaRequest,
AuthResendConfirmationCodeRequest,
AuthServiceInterface,
AuthVerifyTotpMfaRequest,
DucServicesNames, DucServicesNames,
AuthServiceInterface,
AuthSignInRequest,
AuthRefreshAccessTokenRequest,
AuthConfirmationRequest,
AuthResendConfirmationCodeRequest,
AuthEnableTotpMfaRequest,
AuthDisableTotpMfaRequest,
AuthDismissTotpMfaRequest,
AuthVerifyTotpMfaRequest,
} from '@victorradael/protospack'; } from '@victorradael/protospack';
import { ISignIn, IRefreshAccessToken } from './interfaces';
export class AuthClientService implements OnModuleInit { export class AuthClientService implements OnModuleInit {
private authService: AuthServiceInterface; private authService: AuthServiceInterface;
constructor( constructor(
@@ -25,111 +26,89 @@ export class AuthClientService implements OnModuleInit {
); );
} }
async signIn({ username, password, totp }: ISignIn): Promise<any> { async signIn({ username, password, totp }: AuthSignInRequest): Promise<any> {
console.log('AuthClientService', 'SignIn'); console.log('AuthClientService', 'SignIn');
const tokens = await new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.authService.signIn({ username, password, totp }).subscribe({ this.authService.signIn({ username, password, totp }).subscribe({
next(x) { next: resolve,
resolve(x); //error: (err) => reject(err.details),
}, error: (err) => {
error(err) { console.log(err);
console.log('Observable Error'); reject(err.details);
reject(err);
}, },
complete() { complete() {
console.log('done'); console.log('done');
}, },
}); });
}) });
.then((res) => res)
.catch((err) => {
throw new Error(err);
});
return tokens;
} }
async enableTotpMFA({ async enableTotpMFA({
username, accessToken,
password, password,
}: AuthEnableTotpMfaRequest): Promise<any> { }: AuthEnableTotpMfaRequest): Promise<any> {
console.log('AuthClientService', 'enableTotpMFA'); console.log('AuthClientService', 'enableTotpMFA');
const tokens = await new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.authService.enableTotpMfa({ username, password }).subscribe({ this.authService.enableTotpMfa({ accessToken, password }).subscribe({
next(x) { next: resolve,
resolve(x); error: (err) => reject(err.details),
},
error(err) {
console.log('Observable Error');
reject(err);
},
complete() { complete() {
console.log('done'); console.log('done');
}, },
}); });
}) });
.then((res) => res)
.catch((err) => {
throw new Error(err);
});
return tokens;
} }
async disableTotpMFA({ async disableTotpMFA({
username, accessToken,
password, password,
totp,
}: AuthDisableTotpMfaRequest): Promise<any> { }: AuthDisableTotpMfaRequest): Promise<any> {
console.log('AuthClientService', 'disableTotpMFA'); console.log('AuthClientService', 'disableTotpMFA');
const tokens = await new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.authService.disableTotpMfa({ username, password, totp }).subscribe({ this.authService.disableTotpMfa({ accessToken, password }).subscribe({
next(x) { next: resolve,
resolve(x); error: (err) => reject(err.details),
},
error(err) {
console.log('Observable Error');
reject(err);
},
complete() { complete() {
console.log('done'); console.log('done');
}, },
}); });
}) });
.then((res) => res) }
.catch((err) => {
throw new Error(err); async dismissTotpMFA({
accessToken,
}: AuthDismissTotpMfaRequest): Promise<any> {
console.log('AuthClientService', 'dismissTotpMFA');
return new Promise((resolve, reject) => {
this.authService.dismissTotpMfa({ accessToken }).subscribe({
next: resolve,
error: (err) => reject(err.details),
complete() {
console.log('done');
},
}); });
return tokens; });
} }
async verifyTotp({ async verifyTotp({
username,
accessToken, accessToken,
totp, totp,
}: AuthVerifyTotpMfaRequest): Promise<any> { }: AuthVerifyTotpMfaRequest): Promise<any> {
console.log('AuthClientService', 'disableTotpMFA'); console.log('AuthClientService', 'disableTotpMFA');
const tokens = await new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.authService.verifyTotp({ username, accessToken, totp }).subscribe({ this.authService.verifyTotp({ accessToken, totp }).subscribe({
next(x) { next: resolve,
resolve(x); error: (err) => reject(err.details),
},
error(err) {
console.log('Observable Error');
reject(err);
},
complete() { complete() {
console.log('done'); console.log('done');
}, },
}); });
}) });
.then((res) => res)
.catch((err) => {
throw new Error(err);
});
return tokens;
} }
async confirmRegister({ async confirmRegister({
@@ -190,29 +169,19 @@ export class AuthClientService implements OnModuleInit {
async refreshAccessToken({ async refreshAccessToken({
username, username,
refreshToken, refreshToken,
}: IRefreshAccessToken): Promise<any> { }: AuthRefreshAccessTokenRequest): Promise<any> {
console.log('AuthClientService', 'RefreshAccessToken'); console.log('AuthClientService', 'RefreshAccessToken');
const tokens = await new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.authService this.authService
.refreshAccessToken({ username, refreshToken }) .refreshAccessToken({ username, refreshToken })
.subscribe({ .subscribe({
next(x) { next: resolve,
resolve(x); error: (err) => reject(err.details),
},
error(err) {
console.log('Observable Error');
reject(err);
},
complete() { complete() {
console.log('done'); console.log('done');
}, },
}); });
}) });
.then((res) => res)
.catch((err) => {
throw new Error(err);
});
return tokens;
} }
} }
-10
View File
@@ -1,10 +0,0 @@
export interface ISignIn {
username: string;
password: string;
totp: string;
}
export interface IRefreshAccessToken {
username: string;
refreshToken: string;
}
+3 -1
View File
@@ -10,7 +10,9 @@ export class InputsClientConfiguration {
options: { options: {
url: process.env.INFACTORY_URL, url: process.env.INFACTORY_URL,
package: InputPackages, package: InputPackages,
credentials: credentials.createSsl(), credentials: process.env.LOCAL_ENV
? undefined
: credentials.createSsl(),
protoPath: InputProtoFilePath, protoPath: InputProtoFilePath,
loader: { loader: {
enums: String, enums: String,
+4 -5
View File
@@ -1,6 +1,7 @@
import { OnModuleInit, Inject } from '@nestjs/common'; import { OnModuleInit, Inject } from '@nestjs/common';
import { ClientGrpc } from '@nestjs/microservices'; import { ClientGrpc } from '@nestjs/microservices';
import { import {
InputCreateResponse,
InputCreateS3Request, InputCreateS3Request,
InputNewCreateRequest, InputNewCreateRequest,
InputService, InputService,
@@ -42,11 +43,9 @@ export class InputsClientService implements OnModuleInit {
console.log('done'); console.log('done');
}, },
}); });
}) }).catch((err) => {
.then((res) => res) throw new Error(err);
.catch((err) => { });
throw new Error(err);
});
return createInputResponse; return createInputResponse;
} }
+3 -1
View File
@@ -9,7 +9,9 @@ export class OutputsClientConfiguration {
options: { options: {
url: process.env.OTFACTORY_URL, url: process.env.OTFACTORY_URL,
package: OutputPackages, package: OutputPackages,
credentials: credentials.createSsl(), credentials: process.env.LOCAL_ENV
? undefined
: credentials.createSsl(),
protoPath: OutputProtoFilePath, protoPath: OutputProtoFilePath,
loader: { loader: {
enums: String, enums: String,
+3 -1
View File
@@ -12,7 +12,9 @@ export class PipelinesClientConfiguration {
options: { options: {
url: process.env.PIFACTORY_URL, url: process.env.PIFACTORY_URL,
package: PipelinePackages, package: PipelinePackages,
credentials: credentials.createSsl(), credentials: process.env.LOCAL_ENV
? undefined
: credentials.createSsl(),
protoPath: PipelineProtoFilePath, protoPath: PipelineProtoFilePath,
loader: { loader: {
enums: String, enums: String,
+1 -1
View File
@@ -61,7 +61,7 @@ export class PipelinesClientService implements OnModuleInit {
const findAllPipelineResponse = await new Promise((resolve, reject) => { const findAllPipelineResponse = await new Promise((resolve, reject) => {
this.pipelineService.FindAll(objectSnakeToCamel(data)).subscribe({ this.pipelineService.FindAll(objectSnakeToCamel(data)).subscribe({
next(x) { next(x) {
resolve(x); resolve(x.pipelines);
}, },
error(err) { error(err) {
console.log('Observable Error'); console.log('Observable Error');
+70 -22
View File
@@ -3,15 +3,21 @@ import {
Controller, Controller,
Headers, Headers,
Post, Post,
HttpCode,
HttpStatus,
UnauthorizedException, UnauthorizedException,
} from '@nestjs/common'; } from '@nestjs/common';
import { import {
AuthSignInRequest,
AuthRefreshAccessTokenRequest,
AuthEnableTotpMfaRequest, AuthEnableTotpMfaRequest,
AuthDisableTotpMfaRequest,
AuthVerifyTotpMfaRequest, AuthVerifyTotpMfaRequest,
} from '@victorradael/protospack'; } from '@victorradael/protospack';
import { AuthClientService } from 'src/clients/auth/client.service'; import { AuthClientService } from 'src/clients/auth/client.service';
import { ISignIn, IRefreshAccessToken } from 'src/clients/auth/interfaces';
import ErrorBuilder from '../../utils/ErrorBuilder';
@Controller('auth') @Controller('auth')
export class AuthController { export class AuthController {
@@ -19,82 +25,124 @@ export class AuthController {
// DEPRECADO! // DEPRECADO!
@Post() @Post()
async signIn_old(@Body() body: ISignIn) { @HttpCode(HttpStatus.OK)
async signIn_old(@Body() body: AuthSignInRequest) {
console.log(`/auth`, 'SignIn_old'); console.log(`/auth`, 'SignIn_old');
return this.signIn(body); return this.signIn(body);
} }
@Post('login') @Post('login')
async signIn_login(@Body() body: ISignIn) { @HttpCode(HttpStatus.OK)
async signIn_login(@Body() body: AuthSignInRequest) {
console.log(`/auth`, 'SignIn_login'); console.log(`/auth`, 'SignIn_login');
return this.signIn(body); return this.signIn(body);
} }
@Post('sign-in') @Post('sign-in')
async signIn(@Body() { username, password, totp }: ISignIn) { @HttpCode(HttpStatus.OK)
async signIn(@Body() { username, password, totp }: AuthSignInRequest) {
console.log(`/auth`, 'SignIn'); console.log(`/auth`, 'SignIn');
const tokens = await this.authClient const tokens = await this.authClient
.signIn({ username, password, totp }) .signIn({ username, password, totp })
.then((result) => result)
.catch((err) => { .catch((err) => {
throw new UnauthorizedException(err.message); throw ErrorBuilder(err);
}); });
return tokens; return tokens;
} }
@Post('refresh-access-token') @Post('refresh-access-token')
@HttpCode(HttpStatus.OK)
async refreshAccessToken( async refreshAccessToken(
@Body() { username, refreshToken }: IRefreshAccessToken, @Body() { username, refreshToken }: AuthRefreshAccessTokenRequest,
) { ) {
console.log(`/auth`, 'RefreshAccessToken'); console.log(`/auth`, 'RefreshAccessToken');
const accessToken = await this.authClient const accessToken = await this.authClient
.refreshAccessToken({ username, refreshToken }) .refreshAccessToken({ username, refreshToken })
.then((result) => result)
.catch((err) => { .catch((err) => {
throw new UnauthorizedException(err.message); throw ErrorBuilder(err);
}); });
return accessToken; return accessToken;
} }
@Post('enable-totp') @Post('enable-totp')
@HttpCode(HttpStatus.OK)
async enableTotpMFA( async enableTotpMFA(
@Body() { username, password }: AuthEnableTotpMfaRequest, @Body() body: AuthEnableTotpMfaRequest,
@Headers() headers,
) { ) {
console.log(`/auth`, 'enable-totp'); console.log(`/auth`, 'enable-totp');
const enableTotpResponse = await this.authClient const { password } = body;
.enableTotpMFA({ username, password }) const { authorization: accessToken } = headers;
.then((result) => result)
const response = await this.authClient
.enableTotpMFA({ accessToken, password })
.catch((err) => { .catch((err) => {
throw new UnauthorizedException(err.message); throw ErrorBuilder(err);
}); });
return enableTotpResponse; return response;
}
@Post('disable-totp')
@HttpCode(HttpStatus.OK)
async disableTotpMFA(
@Body() body: AuthDisableTotpMfaRequest,
@Headers() headers,
) {
console.log(`/auth`, 'disable-totp');
const { password } = body;
const { authorization: accessToken } = headers;
const response = await this.authClient
.disableTotpMFA({ accessToken, password })
.catch((err) => {
throw ErrorBuilder(err);
});
return response;
}
@Post('dismiss-totp')
@HttpCode(HttpStatus.OK)
async dismissTotpMFA(@Headers() headers) {
console.log(`/auth`, 'disable-totp');
const { authorization: accessToken } = headers;
const response = await this.authClient
.dismissTotpMFA({ accessToken })
.catch((err) => {
throw ErrorBuilder(err);
});
return response;
} }
@Post('verify-totp') @Post('verify-totp')
@HttpCode(HttpStatus.OK)
async verifyTotp( async verifyTotp(
@Body() body: AuthVerifyTotpMfaRequest, @Body() body: AuthVerifyTotpMfaRequest,
@Headers() headers, @Headers() headers,
): Promise<any> { ): Promise<any> {
console.log(`/auth`, 'enable-totp'); console.log(`/auth`, 'enable-totp');
const { username, totp } = body; const { totp } = body;
const { Authorization } = headers; const { authorization: accessToken } = headers;
const enableTotpResponse = await this.authClient const response = await this.authClient
.verifyTotp({ username, totp, accessToken: Authorization }) .verifyTotp({ accessToken, totp })
.then((result) => result)
.catch((err) => { .catch((err) => {
throw new UnauthorizedException(err.message); throw ErrorBuilder(err);
}); });
return enableTotpResponse; return response;
} }
} }
+40 -188
View File
@@ -1,39 +1,31 @@
import axios from 'axios'; import axios from 'axios';
class CatalogService { class CatalogService {
async catalogAll(body) { _getNimbusUrl(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const customer = body.info.customer.toLowerCase();
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${ if (process.env.ENV === 'prd') {
process.env.ENV return `https://nimbus-${customer}.dadosfera.ai`;
}.dadosfera.ai`;
} }
return `https://nimbus-${customer}.${process.env.ENV}.dadosfera.ai`;
}
async catalogAll(body) {
const nimbusUrl = this._getNimbusUrl(body);
const { data } = await axios.get(`${nimbusUrl}/api/catalog/all/`); const { data } = await axios.get(`${nimbusUrl}/api/catalog/all/`);
return data; return data;
} }
async dataAppsAll(body) { async dataAppsAll(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.get(`${nimbusUrl}/api/catalog/data_apps/`); const { data } = await axios.get(`${nimbusUrl}/api/catalog/data_apps/`);
return data; return data;
} }
async dataAppsOne(id, body) { async dataAppsOne(id, body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.get( const { data } = await axios.get(
`${nimbusUrl}/api/catalog/data_apps/${id}/`, `${nimbusUrl}/api/catalog/data_apps/${id}/`,
); );
@@ -42,12 +34,7 @@ class CatalogService {
} }
async getAllDashboardMetabase(body) { async getAllDashboardMetabase(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.get( const { data } = await axios.get(
`${nimbusUrl}/api/catalog/dashboard-metabase/`, `${nimbusUrl}/api/catalog/dashboard-metabase/`,
); );
@@ -55,12 +42,7 @@ class CatalogService {
} }
async getOneDashboardMetabase(id, body) { async getOneDashboardMetabase(id, body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.get( const { data } = await axios.get(
`${nimbusUrl}/api/catalog/dashboard-metabase/${id}`, `${nimbusUrl}/api/catalog/dashboard-metabase/${id}`,
); );
@@ -74,12 +56,7 @@ class CatalogService {
} }
async getAllTableMetadata(body) { async getAllTableMetadata(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.get( const { data } = await axios.get(
`${nimbusUrl}/api/catalog/table-metadata/`, `${nimbusUrl}/api/catalog/table-metadata/`,
); );
@@ -87,12 +64,7 @@ class CatalogService {
} }
async getOneTableMetadata(body, params) { async getOneTableMetadata(body, params) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.get( const { data } = await axios.get(
`${nimbusUrl}/api/catalog/table-metadata/`, `${nimbusUrl}/api/catalog/table-metadata/`,
{ params: params }, { params: params },
@@ -101,12 +73,7 @@ class CatalogService {
} }
async deleteOneTableMetadata(id, body) { async deleteOneTableMetadata(id, body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.delete( const { data } = await axios.delete(
`${nimbusUrl}/api/catalog/table-metadata/${id}`, `${nimbusUrl}/api/catalog/table-metadata/${id}`,
); );
@@ -114,12 +81,7 @@ class CatalogService {
} }
async getOneColumnMetadata(body, params) { async getOneColumnMetadata(body, params) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.get( const { data } = await axios.get(
`${nimbusUrl}/api/catalog/column-metadata/`, `${nimbusUrl}/api/catalog/column-metadata/`,
{ params: params }, { params: params },
@@ -128,12 +90,7 @@ class CatalogService {
} }
async deleteOneColumnMetadata(id, body) { async deleteOneColumnMetadata(id, body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.delete( const { data } = await axios.delete(
`${nimbusUrl}/api/catalog/column-metadata/${id}/`, `${nimbusUrl}/api/catalog/column-metadata/${id}/`,
); );
@@ -141,12 +98,7 @@ class CatalogService {
} }
async getOneDataPreview(body, params) { async getOneDataPreview(body, params) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-preview/`, { const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-preview/`, {
params: params, params: params,
}); });
@@ -154,23 +106,13 @@ class CatalogService {
} }
async getDataStatus(body) { async getDataStatus(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-status/`); const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-status/`);
return data; return data;
} }
async createDataStatus(body) { async createDataStatus(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.post( const { data } = await axios.post(
`${nimbusUrl}/api/catalog/data-status/`, `${nimbusUrl}/api/catalog/data-status/`,
body, body,
@@ -179,12 +121,7 @@ class CatalogService {
} }
async getDataDescription(body) { async getDataDescription(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.get( const { data } = await axios.get(
`${nimbusUrl}/api/catalog/data-description/`, `${nimbusUrl}/api/catalog/data-description/`,
); );
@@ -192,12 +129,7 @@ class CatalogService {
} }
async createDataDescription(body) { async createDataDescription(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.post( const { data } = await axios.post(
`${nimbusUrl}/api/catalog/data-description/`, `${nimbusUrl}/api/catalog/data-description/`,
body, body,
@@ -206,23 +138,13 @@ class CatalogService {
} }
async getDataDocs(body) { async getDataDocs(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-docs/`); const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-docs/`);
return data; return data;
} }
async createDataDocs(body) { async createDataDocs(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.post( const { data } = await axios.post(
`${nimbusUrl}/api/catalog/data-docs/`, `${nimbusUrl}/api/catalog/data-docs/`,
body, body,
@@ -231,23 +153,13 @@ class CatalogService {
} }
async getDataRating(body) { async getDataRating(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-rating/`); const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-rating/`);
return data; return data;
} }
async createDataRating(body) { async createDataRating(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.post( const { data } = await axios.post(
`${nimbusUrl}/api/catalog/data-rating/`, `${nimbusUrl}/api/catalog/data-rating/`,
body, body,
@@ -256,12 +168,7 @@ class CatalogService {
} }
async getSummaryRating(id, body) { async getSummaryRating(id, body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.get( const { data } = await axios.get(
`${nimbusUrl}/api/catalog/summary-rating/${id}`, `${nimbusUrl}/api/catalog/summary-rating/${id}`,
); );
@@ -269,23 +176,13 @@ class CatalogService {
} }
async getDataComment(body) { async getDataComment(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-comment/`); const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-comment/`);
return data; return data;
} }
async createDataComment(body) { async createDataComment(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.post( const { data } = await axios.post(
`${nimbusUrl}/api/catalog/data-comment/`, `${nimbusUrl}/api/catalog/data-comment/`,
body, body,
@@ -294,12 +191,7 @@ class CatalogService {
} }
async getDataReview(body, params) { async getDataReview(body, params) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-review/`, { const { data } = await axios.get(`${nimbusUrl}/api/catalog/data-review/`, {
params: params, params: params,
}); });
@@ -307,34 +199,19 @@ class CatalogService {
} }
async createTags(body) { async createTags(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.post(`${nimbusUrl}/api/catalog/tags/`, body); const { data } = await axios.post(`${nimbusUrl}/api/catalog/tags/`, body);
return data; return data;
} }
async findAllTags(body) { async findAllTags(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.get(`${nimbusUrl}/api/catalog/tags/`, body); const { data } = await axios.get(`${nimbusUrl}/api/catalog/tags/`, body);
return data; return data;
} }
async findAllTableTags(body) { async findAllTableTags(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.get( const { data } = await axios.get(
`${nimbusUrl}/api/catalog/table-tags/`, `${nimbusUrl}/api/catalog/table-tags/`,
body, body,
@@ -343,23 +220,13 @@ class CatalogService {
} }
async deleteTags(id, body) { async deleteTags(id, body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.delete(`${nimbusUrl}/api/catalog/tags/${id}`); const { data } = await axios.delete(`${nimbusUrl}/api/catalog/tags/${id}`);
return data; return data;
} }
async createTableTags(body) { async createTableTags(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.post( const { data } = await axios.post(
`${nimbusUrl}/api/catalog/table-tags/`, `${nimbusUrl}/api/catalog/table-tags/`,
body, body,
@@ -368,12 +235,7 @@ class CatalogService {
} }
async deleteTableTags(id, body) { async deleteTableTags(id, body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.delete( const { data } = await axios.delete(
`${nimbusUrl}/api/catalog/table-tags/${id}`, `${nimbusUrl}/api/catalog/table-tags/${id}`,
); );
@@ -381,12 +243,7 @@ class CatalogService {
} }
async getTableRules(body) { async getTableRules(body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.get( const { data } = await axios.get(
`${nimbusUrl}/api/catalog/table-rules/`, `${nimbusUrl}/api/catalog/table-rules/`,
body, body,
@@ -395,12 +252,7 @@ class CatalogService {
} }
async deleteTableRules(id, body) { async deleteTableRules(id, body) {
let nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.dadosfera.ai`; const nimbusUrl = this._getNimbusUrl(body);
if (process.env.ENV !== 'prd') {
nimbusUrl = `https://nimbus-${body.info.customer.toLowerCase()}.${
process.env.ENV
}.dadosfera.ai`;
}
const { data } = await axios.delete( const { data } = await axios.delete(
`${nimbusUrl}/api/catalog/table-rules/${id}`, `${nimbusUrl}/api/catalog/table-rules/${id}`,
); );
+35 -2
View File
@@ -14,10 +14,18 @@ export class InputsService {
data.plugin == 'json' || data.plugin == 'json' ||
data.plugin == 'parquet' data.plugin == 'parquet'
) { ) {
const createInputResponse = await this.inputClient.createS3Inputs(data); const { info, ...input } = data;
const inputPayload = this.generateInputS3Payload(input);
const createInputResponse = await this.inputClient.createS3Inputs({
input: inputPayload,
info,
});
return createInputResponse; return createInputResponse;
} else { } else {
const createInputResponse = await this.inputClient.create(data); const createInputResponse: any = await this.inputClient.create(data);
if (createInputResponse?.input?.input_jdbc) {
return { input: createInputResponse?.input?.input_jdbc };
}
return createInputResponse; return createInputResponse;
} }
} catch (err) { } catch (err) {
@@ -91,4 +99,29 @@ export class InputsService {
throw new HttpException(err.message, HttpStatus.NOT_FOUND); throw new HttpException(err.message, HttpStatus.NOT_FOUND);
} }
} }
generateInputS3Payload(payload) {
const { credentials, plugin } = payload;
if (!credentials) return payload;
const {
client_aws_access_key_id,
client_aws_secret_access_key,
file_format_params,
format_file_params,
client_bucket,
file_to_extract,
} = credentials;
const formatedPayload = {
plugin,
source_bucket: client_bucket,
source_prefix: file_to_extract,
auth_parameters: {
aws_access_key_id: client_aws_access_key_id,
aws_secret_access_key: client_aws_secret_access_key,
},
file_format_params: file_format_params || format_file_params,
};
return formatedPayload;
}
} }
+22 -4
View File
@@ -7,13 +7,20 @@ import { objectCamelToSnake } from 'src/utils/CaseConverter';
export class PipelinesService { export class PipelinesService {
constructor(private pipelineClient: PipelinesClientService) {} constructor(private pipelineClient: PipelinesClientService) {}
adjustPayload(payload) {
payload.input = payload.input?.input_s3 || payload.input?.input_jdbc;
}
async create(createPipelineDto) { async create(createPipelineDto) {
try { try {
const createPipelineResponse = await this.pipelineClient.create( const createPipelineResponse = await this.pipelineClient.create(
createPipelineDto, createPipelineDto,
); );
return objectCamelToSnake(createPipelineResponse); const pipeline = objectCamelToSnake(createPipelineResponse);
this.adjustPayload(pipeline.pipeline);
return pipeline;
} catch (err) { } catch (err) {
console.log(err); console.log(err);
throw new HttpException(err.message, HttpStatus.NOT_FOUND); throw new HttpException(err.message, HttpStatus.NOT_FOUND);
@@ -23,7 +30,11 @@ export class PipelinesService {
async findOne(data: IIdRequest) { async findOne(data: IIdRequest) {
try { try {
const findOnePipelineResponse = await this.pipelineClient.findOne(data); const findOnePipelineResponse = await this.pipelineClient.findOne(data);
return objectCamelToSnake(findOnePipelineResponse);
const pipeline = objectCamelToSnake(findOnePipelineResponse);
this.adjustPayload(pipeline.pipeline);
return pipeline;
} catch (err) { } catch (err) {
throw new HttpException(err.message, HttpStatus.NOT_FOUND); throw new HttpException(err.message, HttpStatus.NOT_FOUND);
} }
@@ -33,7 +44,11 @@ export class PipelinesService {
try { try {
const findAllPipelineResponse = await this.pipelineClient.findAll(data); const findAllPipelineResponse = await this.pipelineClient.findAll(data);
return objectCamelToSnake(findAllPipelineResponse); const pipelines = objectCamelToSnake(findAllPipelineResponse);
pipelines.forEach((pipeline) => {
this.adjustPayload(pipeline);
});
return { pipelines };
} catch (err) { } catch (err) {
throw new HttpException(err.message, HttpStatus.NOT_FOUND); throw new HttpException(err.message, HttpStatus.NOT_FOUND);
} }
@@ -47,7 +62,10 @@ export class PipelinesService {
...data, ...data,
}); });
return objectCamelToSnake(updatePipelineResponse); const pipeline = objectCamelToSnake(updatePipelineResponse);
this.adjustPayload(pipeline);
return pipeline;
} catch (err) { } catch (err) {
throw new HttpException(err.message, HttpStatus.NOT_FOUND); throw new HttpException(err.message, HttpStatus.NOT_FOUND);
} }
+106
View File
@@ -0,0 +1,106 @@
import { HttpStatus, HttpException } from '@nestjs/common';
import ErrorCodes from './errorCodes';
function Builder({ statusCode, message, error, code }) {
return new HttpException({ statusCode, message, error, code }, statusCode);
}
export default function ErrorBuilder(code: string) {
console.log(code);
switch (code) {
case ErrorCodes.AUTH.WRONG_CREDENTIALS:
return Builder({
statusCode: HttpStatus.UNAUTHORIZED,
error: 'Não autenticado',
message: 'Usuário ou senha incorretos',
code,
});
case ErrorCodes.AUTH.WRONG_PASSWORD_CONFIRMATION:
return Builder({
statusCode: HttpStatus.UNAUTHORIZED,
error: 'Senha incorreta',
message: 'Confirmação de senha incorreta',
code,
});
case ErrorCodes.AUTH.TOTP_NOT_ENABLED:
return Builder({
statusCode: HttpStatus.PRECONDITION_FAILED,
error: 'Não permitido',
message: 'A autenticação multifator não está habilitada',
code,
});
case ErrorCodes.AUTH.TOTP_ALREADY_ENABLED:
return Builder({
statusCode: HttpStatus.PRECONDITION_FAILED,
error: 'Não permitido',
message: 'A autenticação multifator já está habilitada',
code,
});
case ErrorCodes.AUTH.TOTP_ALREADY_DISABLED:
return Builder({
statusCode: HttpStatus.PRECONDITION_FAILED,
error: 'Não permitido',
message: 'A autenticação multifator já está desabilitada',
code,
});
case ErrorCodes.AUTH.TOTP_REQUIRED:
return Builder({
statusCode: HttpStatus.UNAUTHORIZED,
error: 'Não autenticado',
message: 'Informe o token de autenticação multifator',
code,
});
case ErrorCodes.AUTH.CODE_MISMATCH:
case ErrorCodes.AUTH.CODE_ALREADY_USED:
return Builder({
statusCode: HttpStatus.UNAUTHORIZED,
error: 'Não autenticado',
message: 'Token de autenticação multifator inválido',
code,
});
case ErrorCodes.RATE_LIMIT:
return Builder({
statusCode: HttpStatus.TOO_MANY_REQUESTS,
error: 'Limite excedido',
message:
'Você tentou realizar essa operação muitas vezes. Tente novamente mais tarde',
code,
});
case ErrorCodes.AUTH.UNAUTHORIZED:
return Builder({
statusCode: HttpStatus.UNAUTHORIZED,
error: 'Não autenticado',
message: 'É necessário estar logado para realizar essa operação',
code,
});
case ErrorCodes.AUTH.FORBIDDEN:
return Builder({
statusCode: HttpStatus.FORBIDDEN,
error: 'Não autorizado',
message:
'Você não tem permissões suficientes para realizar essa operação',
code,
});
case ErrorCodes.UNKNOWN:
default:
return Builder({
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
error: 'Desconhecido',
message:
'Erro desconhecido. Tente novamente ou entre em contato com o suporte',
code: ErrorCodes.UNKNOWN,
});
}
}
+20
View File
@@ -0,0 +1,20 @@
export const Auth = {
UNAUTHORIZED: 'AUTH.UNAUTHORIZED',
FORBIDDEN: 'AUTH.FORBIDDEN',
WRONG_CREDENTIALS: 'AUTH.WRONG_CREDENTIALS',
WRONG_PASSWORD_CONFIRMATION: 'AUTH.WRONG_PASSWORD_CONFIRMATION',
TOTP_NOT_ENABLED: 'AUTH.TOTP_NOT_ENABLED',
TOTP_ALREADY_ENABLED: 'AUTH.TOTP_ALREADY_ENABLED',
TOTP_ALREADY_DISABLED: 'AUTH.TOTP_ALREADY_DISABLED',
TOTP_REQUIRED: 'AUTH.TOTP_REQUIRED',
CODE_MISMATCH: 'AUTH.CODE_MISMATCH',
CODE_ALREADY_USED: 'AUTH.CODE_ALREADY_USED',
};
const ErrorCodes = {
UNKNOWN: 'UNKNOWN',
RATE_LIMIT: 'RATE_LIMIT',
AUTH: Auth,
};
export default ErrorCodes;
+1 -1
View File
File diff suppressed because one or more lines are too long