mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-24 05:09:08 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe44664970 | ||
|
|
0503732c1e | ||
|
|
fa0855d631 | ||
|
|
38aee30f2a | ||
|
|
19f5c947bd | ||
|
|
44aa0e6010 | ||
|
|
cf4e7da1d8 | ||
|
|
8bd7d54aa7 | ||
|
|
a00a66e0d0 | ||
|
|
f4c5d03269 | ||
|
|
060ba7da8a | ||
|
|
5ec2c01b20 | ||
|
|
4a7e660a49 | ||
|
|
abc6258492 | ||
|
|
7ee1215da2 | ||
|
|
cd5886337b | ||
|
|
5fb8dae312 | ||
|
|
5072a54ef6 | ||
|
|
718f5cb12a | ||
|
|
4c41dd8029 | ||
|
|
fe8a0b88b0 | ||
|
|
cd67ca61cd | ||
|
|
b9439685f3 | ||
|
|
04edce0c56 | ||
|
|
ef098dd74d | ||
|
|
2541960b44 | ||
|
|
2dc965ed90 | ||
|
|
b2f1ce669d | ||
|
|
602d81e51f | ||
|
|
bbdb023dde | ||
|
|
9cb4cd7093 | ||
|
|
efc5870d87 | ||
|
|
c3d33f8230 | ||
|
|
0654e8fa04 | ||
|
|
28ab892208 | ||
|
|
d1522eb0ea | ||
|
|
6be9e06b22 | ||
|
|
7af261d56c | ||
|
|
8fa924fdfb | ||
|
|
4b4bdfea61 | ||
|
|
d1064c852b | ||
|
|
63338f5250 | ||
|
|
5e1fb41930 | ||
|
|
a807da2414 | ||
|
|
85f14fcf4b | ||
|
|
d95898ce55 | ||
|
|
33075b0f85 | ||
|
|
ca75f8f6e7 | ||
|
|
af12a39959 | ||
|
|
f77476b9ae | ||
|
|
fb0c659cd1 | ||
|
|
aea6815de7 | ||
|
|
0103f100f5 | ||
|
|
66b6be43b7 | ||
|
|
c029e286b5 | ||
|
|
a8f94a2d53 | ||
|
|
aadb3fcdee | ||
|
|
a26e88d2b6 | ||
|
|
fc7a9c7909 | ||
|
|
932616a578 | ||
|
|
4ffd0916c3 |
@@ -6,7 +6,7 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
environment:
|
environment:
|
||||||
description: 'Deployment environment'
|
description: "Deployment environment"
|
||||||
required: true
|
required: true
|
||||||
type: choice
|
type: choice
|
||||||
options:
|
options:
|
||||||
@@ -26,9 +26,9 @@ jobs:
|
|||||||
- name: Extract Environment
|
- name: Extract Environment
|
||||||
run: |
|
run: |
|
||||||
if [ ${EVENT} == "workflow_dispatch" ]; then
|
if [ ${EVENT} == "workflow_dispatch" ]; then
|
||||||
echo "##[set-output name=environment;]$(echo ${DEPLOY_ENV})"
|
echo "environment=${DEPLOY_ENV}" >> $GITHUB_OUTPUT
|
||||||
elif [ ${GITHUB_REF} == "refs/heads/main" ]; then
|
elif [ ${GITHUB_REF} == "refs/heads/main" ]; then
|
||||||
echo "##[set-output name=environment;]$(echo "prd")"
|
echo "environment=prd" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
id: extract_environment
|
id: extract_environment
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ jobs:
|
|||||||
new_release_version: ${{ (steps.semantic.outputs.new_release_published == 'true' && steps.semantic.outputs.new_release_version) || (github.event_name == 'workflow_dispatch' && '0.0.0') }}
|
new_release_version: ${{ (steps.semantic.outputs.new_release_published == 'true' && steps.semantic.outputs.new_release_version) || (github.event_name == 'workflow_dispatch' && '0.0.0') }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- if: github.event_name != 'workflow_dispatch'
|
- if: github.event_name != 'workflow_dispatch'
|
||||||
name: Semantic Release
|
name: Semantic Release
|
||||||
@@ -56,20 +56,26 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
deploy:
|
deploy-info:
|
||||||
if: ${{ github.event_name == 'workflow_dispatch' || needs.semantic_release.outputs.new_release_published == 'true' }}
|
if: ${{ github.event_name == 'workflow_dispatch'}}
|
||||||
needs: [extract_environment, semantic_release]
|
needs: [extract_environment, semantic_release]
|
||||||
runs-on:
|
runs-on: ubuntu-latest
|
||||||
[self-hosted, '${{ needs.extract_environment.outputs.environment }}']
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Printing stats
|
- name: Create summary
|
||||||
env:
|
env:
|
||||||
EVENT: ${{ github.event_name }}
|
EVENT: ${{ github.event_name }}
|
||||||
IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
|
IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
|
||||||
ENV: ${{ needs.extract_environment.outputs.environment }}
|
ENV: ${{ needs.extract_environment.outputs.environment }}
|
||||||
run: echo ${GITHUB_REF#refs/heads/}
|
run: echo "### Deploy da branch \`$GITHUB_REF_NAME\` no ambiente **$ENV** :rocket:" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
if: ${{ github.event_name == 'workflow_dispatch' || needs.semantic_release.outputs.new_release_published == 'true' }}
|
||||||
|
needs: [extract_environment, semantic_release]
|
||||||
|
runs-on:
|
||||||
|
[self-hosted, "${{ needs.extract_environment.outputs.environment }}"]
|
||||||
|
|
||||||
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
@@ -90,7 +96,7 @@ jobs:
|
|||||||
python3 -m pip install awsebcli --upgrade
|
python3 -m pip install awsebcli --upgrade
|
||||||
|
|
||||||
- name: Configure AWS Region
|
- name: Configure AWS Region
|
||||||
uses: aws-actions/configure-aws-credentials@v1
|
uses: aws-actions/configure-aws-credentials@v1-node16
|
||||||
id: aws
|
id: aws
|
||||||
with:
|
with:
|
||||||
aws-region: us-east-1
|
aws-region: us-east-1
|
||||||
@@ -113,10 +119,12 @@ jobs:
|
|||||||
ENV: ${{ needs.extract_environment.outputs.environment }}
|
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 }}
|
||||||
|
NODE_EXPORTER_URL: ${{needs.extract_environment.outputs.environment == 'prd' && '611330257153.dkr.ecr.us-east-1.amazonaws.com\/monitoring\/node_exporter:latest' || '468720548566.dkr.ecr.us-east-1.amazonaws.com\/monitoring\/node_exporter:latest'}}
|
||||||
run: |
|
run: |
|
||||||
sed -i -e "s/\${ENV}/$ENV/g" docker-compose.yml
|
sed -i -e "s/\${ENV}/$ENV/g" docker-compose.yml
|
||||||
sed -i -e "s/\${IMAGE_TAG}/$IMAGE_TAG/g" docker-compose.yml
|
sed -i -e "s/\${IMAGE_TAG}/$IMAGE_TAG/g" docker-compose.yml
|
||||||
sed -i -e "s/\${ACCOUNT_ID}/$ACCOUNT_ID/g" docker-compose.yml
|
sed -i -e "s/\${ACCOUNT_ID}/$ACCOUNT_ID/g" docker-compose.yml
|
||||||
|
sed -i -e "s/\${NODE_EXPORTER_URL}/$NODE_EXPORTER_URL/g" docker-compose.yml
|
||||||
zip deploy.zip docker-compose.yml -r .ebextensions
|
zip deploy.zip docker-compose.yml -r .ebextensions
|
||||||
|
|
||||||
- name: Deploy AWS Beanstalk
|
- name: Deploy AWS Beanstalk
|
||||||
@@ -136,71 +144,47 @@ jobs:
|
|||||||
docker system df
|
docker system df
|
||||||
api_docs:
|
api_docs:
|
||||||
needs: [extract_environment, semantic_release, deploy]
|
needs: [extract_environment, semantic_release, deploy]
|
||||||
runs-on:
|
runs-on: ubuntu-latest
|
||||||
[self-hosted, '${{ needs.extract_environment.outputs.environment }}']
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Extract Docs PageId
|
- name: Extract Docs BlockId and PageId
|
||||||
env:
|
env:
|
||||||
ENV: ${{ needs.extract_environment.outputs.environment }}
|
ENV: ${{ needs.extract_environment.outputs.environment }}
|
||||||
|
DEV_DOCS_BLOCK_ID: ${{ secrets.DEV_DOCS_BLOCK_ID }}
|
||||||
DEV_DOCS_PAGE_ID: ${{ secrets.DEV_DOCS_PAGE_ID }}
|
DEV_DOCS_PAGE_ID: ${{ secrets.DEV_DOCS_PAGE_ID }}
|
||||||
|
STG_DOCS_BLOCK_ID: ${{ secrets.STG_DOCS_BLOCK_ID }}
|
||||||
STG_DOCS_PAGE_ID: ${{ secrets.STG_DOCS_PAGE_ID }}
|
STG_DOCS_PAGE_ID: ${{ secrets.STG_DOCS_PAGE_ID }}
|
||||||
|
PRD_DOCS_BLOCK_ID: ${{ secrets.PRD_DOCS_BLOCK_ID }}
|
||||||
PRD_DOCS_PAGE_ID: ${{ secrets.PRD_DOCS_PAGE_ID }}
|
PRD_DOCS_PAGE_ID: ${{ secrets.PRD_DOCS_PAGE_ID }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
if [ $ENV == "dev" ]; then
|
if [ $ENV == "dev" ]; then
|
||||||
echo "##[set-output name=result;]$(echo $DEV_DOCS_PAGE_ID)"
|
echo "block_id=$DEV_DOCS_BLOCK_ID" >> $GITHUB_OUTPUT
|
||||||
|
echo "page_id=$DEV_DOCS_PAGE_ID" >> $GITHUB_OUTPUT
|
||||||
elif [ $ENV == "stg" ]; then
|
elif [ $ENV == "stg" ]; then
|
||||||
echo "##[set-output name=result;]$(echo $STG_DOCS_PAGE_ID)"
|
echo "block_id=$STG_DOCS_BLOCK_ID" >> $GITHUB_OUTPUT
|
||||||
|
echo "page_id=$STG_DOCS_PAGE_ID" >> $GITHUB_OUTPUT
|
||||||
elif [ $ENV == "prd" ]; then
|
elif [ $ENV == "prd" ]; then
|
||||||
echo "##[set-output name=result;]$(echo $PRD_DOCS_PAGE_ID)"
|
echo "block_id=$PRD_DOCS_BLOCK_ID" >> $GITHUB_OUTPUT
|
||||||
|
echo "page_id=$PRD_DOCS_PAGE_ID" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
id: extract_docs_page_id
|
id: extract_docs_info
|
||||||
|
|
||||||
- name: Extract Docs BlockId
|
|
||||||
env:
|
|
||||||
ENV: ${{ needs.extract_environment.outputs.environment }}
|
|
||||||
DEV_DOCS_BLOCK_ID: ${{ secrets.DEV_DOCS_BLOCK_ID }}
|
|
||||||
STG_DOCS_BLOCK_ID: ${{ secrets.STG_DOCS_BLOCK_ID }}
|
|
||||||
PRD_DOCS_BLOCK_ID: ${{ secrets.PRD_DOCS_BLOCK_ID }}
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
if [ $ENV == "dev" ]; then
|
|
||||||
echo "##[set-output name=result;]$(echo $DEV_DOCS_BLOCK_ID)"
|
|
||||||
elif [ $ENV == "stg" ]; then
|
|
||||||
echo "##[set-output name=result;]$(echo $STG_DOCS_BLOCK_ID)"
|
|
||||||
elif [ $ENV == "prd" ]; then
|
|
||||||
echo "##[set-output name=result;]$(echo $PRD_DOCS_BLOCK_ID)"
|
|
||||||
fi
|
|
||||||
id: extract_docs_block_id
|
|
||||||
|
|
||||||
- name: Generate API docs
|
- name: Generate API docs
|
||||||
env:
|
env:
|
||||||
ENV: ${{ needs.extract_environment.outputs.environment }}
|
|
||||||
DOCS_URL: ${{ secrets.DOCS_URL }}
|
DOCS_URL: ${{ secrets.DOCS_URL }}
|
||||||
DOCS_API_TOKEN: ${{ secrets.DOCS_API_TOKEN }}
|
DOCS_API_TOKEN: ${{ secrets.DOCS_API_TOKEN }}
|
||||||
DOCS_PAGE_ID: ${{ steps.extract_docs_page_id.outputs.result }}
|
DOCS_PAGE_ID: ${{ steps.extract_docs_info.outputs.page_id }}
|
||||||
DOCS_BLOCK_ID: ${{ steps.extract_docs_block_id.outputs.result }}
|
DOCS_BLOCK_ID: ${{ steps.extract_docs_info.outputs.block_id }}
|
||||||
continue-on-error: true
|
EVENT: ${{ github.event_name }}
|
||||||
|
RELEASE_VERSION: ${{ needs.semantic_release.outputs.new_release_version }}
|
||||||
run: |
|
run: |
|
||||||
SWAGGER=`cat swagger.txt`
|
if [ ${EVENT} != "workflow_dispatch" ]; then
|
||||||
curl --request POST \
|
sed -i -E "s/(\"title\": )\"Maestro.+\"/\1\"Maestro - $RELEASE_VERSION\"/g" docsfera.json
|
||||||
--url $DOCS_URL \
|
fi
|
||||||
--header 'Content-Type: application/json' \
|
sed -i -e "s/\${DOCS_API_TOKEN}/$DOCS_API_TOKEN/g" docsfera.json
|
||||||
--data @<(cat <<EOF
|
sed -i -e "s/\${DOCS_PAGE_ID}/$DOCS_PAGE_ID/g" docsfera.json
|
||||||
{
|
sed -i -e "s/\${DOCS_BLOCK_ID}/$DOCS_BLOCK_ID/g" docsfera.json
|
||||||
"service": "$DOCS_API_TOKEN",
|
curl -X POST -H 'Content-Type: application/json' -d @docsfera.json $DOCS_URL
|
||||||
"pageId": "$DOCS_PAGE_ID",
|
|
||||||
"blockId": "$DOCS_BLOCK_ID",
|
|
||||||
"schema": $SWAGGER
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
)
|
|
||||||
- name: Cleanup Docker's Leftovers
|
|
||||||
if: always()
|
|
||||||
continue-on-error: true
|
|
||||||
run: |
|
|
||||||
docker system prune
|
|
||||||
docker rmi -f $(docker images -aq)
|
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ services:
|
|||||||
- .env
|
- .env
|
||||||
|
|
||||||
node_exporter:
|
node_exporter:
|
||||||
image: prom/node-exporter:v1.3.1
|
image: ${NODE_EXPORTER_URL}
|
||||||
container_name: node_exporter
|
container_name: node_exporter
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
+6159
File diff suppressed because it is too large
Load Diff
Generated
+62
-18
@@ -12,7 +12,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-secrets-manager": "^3.112.0",
|
"@aws-sdk/client-secrets-manager": "^3.112.0",
|
||||||
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
||||||
"@dadosfera/protospack-v2": "3.18.18",
|
"@dadosfera/protospack-v2": "3.19.4",
|
||||||
"@grpc/grpc-js": "^1.6.7",
|
"@grpc/grpc-js": "^1.6.7",
|
||||||
"@grpc/proto-loader": "^0.6.13",
|
"@grpc/proto-loader": "^0.6.13",
|
||||||
"@nestjs/common": "^8.4.7",
|
"@nestjs/common": "^8.4.7",
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
"helmet": "^5.1.0",
|
"helmet": "^5.1.0",
|
||||||
"jsonwebtoken": "^8.5.1",
|
"jsonwebtoken": "^8.5.1",
|
||||||
"jwk-to-pem": "^2.0.5",
|
"jwk-to-pem": "^2.0.5",
|
||||||
|
"mixpanel": "^0.17.0",
|
||||||
"passport": "^0.6.0",
|
"passport": "^0.6.0",
|
||||||
"passport-facebook": "^3.0.0",
|
"passport-facebook": "^3.0.0",
|
||||||
"passport-forcedotcom": "^0.1.5",
|
"passport-forcedotcom": "^0.1.5",
|
||||||
@@ -1726,9 +1727,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@dadosfera/protospack-v2": {
|
"node_modules/@dadosfera/protospack-v2": {
|
||||||
"version": "3.18.18",
|
"version": "3.19.4",
|
||||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.18.18.tgz",
|
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.19.4.tgz",
|
||||||
"integrity": "sha512-4KiuMUDMZu8ouic0RBBuM7Ky9wfczeS4GKLRyD29GV371m/NOo+1ujrcLysc8OuevPdXmaqzCgE6WWi6SIt9sQ==",
|
"integrity": "sha512-Vb6bdFgQKYHf0kDK9kuMtN+nt3nkaMhJZ3wNVaUmQNxsnpGyARWBL29R2n+YnxS8g23tRwuj331sjg+DY0Fnhg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@grpc/grpc-js": "^1.6.7",
|
"@grpc/grpc-js": "^1.6.7",
|
||||||
"rxjs": "^7.5.5",
|
"rxjs": "^7.5.5",
|
||||||
@@ -3543,7 +3544,6 @@
|
|||||||
},
|
},
|
||||||
"node_modules/agent-base": {
|
"node_modules/agent-base": {
|
||||||
"version": "6.0.2",
|
"version": "6.0.2",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"debug": "4"
|
"debug": "4"
|
||||||
@@ -8205,6 +8205,29 @@
|
|||||||
"version": "1.2.6",
|
"version": "1.2.6",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/mixpanel": {
|
||||||
|
"version": "0.17.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mixpanel/-/mixpanel-0.17.0.tgz",
|
||||||
|
"integrity": "sha512-DY5WeOy/hmkPrNiiZugJpWR0iMuOwuj1a3u0bgwB2eUFRV6oIew/pIahhpawdbNjb+Bye4a8ID3gefeNPvL81g==",
|
||||||
|
"dependencies": {
|
||||||
|
"https-proxy-agent": "5.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/mixpanel/node_modules/https-proxy-agent": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==",
|
||||||
|
"dependencies": {
|
||||||
|
"agent-base": "6",
|
||||||
|
"debug": "4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/mkdirp": {
|
"node_modules/mkdirp": {
|
||||||
"version": "0.5.6",
|
"version": "0.5.6",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -8229,8 +8252,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/moment-timezone": {
|
"node_modules/moment-timezone": {
|
||||||
"version": "0.5.34",
|
"version": "0.5.38",
|
||||||
"license": "MIT",
|
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.38.tgz",
|
||||||
|
"integrity": "sha512-nMIrzGah4+oYZPflDvLZUgoVUO4fvAqHstvG3xAUnMolWncuAiLDWNnJZj6EwJGMGfb1ZcuTFE6GI3hNOVWI/Q==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"moment": ">= 2.9.0"
|
"moment": ">= 2.9.0"
|
||||||
},
|
},
|
||||||
@@ -10337,9 +10361,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ts-proto": {
|
"node_modules/ts-proto": {
|
||||||
"version": "1.126.1",
|
"version": "1.131.0",
|
||||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/ts-proto/-/ts-proto-1.126.1.tgz",
|
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/ts-proto/-/ts-proto-1.131.0.tgz",
|
||||||
"integrity": "sha512-PKrcgd0mCQJDY7tp+th349uYhnjs2Tz7wSqm9+DBcodl3YCKPt1pFtFmApOZdQ8WlghhgKAuJDIRQJBd6jD5YA==",
|
"integrity": "sha512-oj/kWrDz3JkkPQwumQDKfwHroH9iNz2alvrbCYzNYJlb/2MAUzFNfh9T+SZUPDfoXXK6oJoW1hGCHznj67yHNg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/object-hash": "^1.3.0",
|
"@types/object-hash": "^1.3.0",
|
||||||
"dataloader": "^1.4.0",
|
"dataloader": "^1.4.0",
|
||||||
@@ -12306,9 +12330,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@dadosfera/protospack-v2": {
|
"@dadosfera/protospack-v2": {
|
||||||
"version": "3.18.18",
|
"version": "3.19.4",
|
||||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.18.18.tgz",
|
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.19.4.tgz",
|
||||||
"integrity": "sha512-4KiuMUDMZu8ouic0RBBuM7Ky9wfczeS4GKLRyD29GV371m/NOo+1ujrcLysc8OuevPdXmaqzCgE6WWi6SIt9sQ==",
|
"integrity": "sha512-Vb6bdFgQKYHf0kDK9kuMtN+nt3nkaMhJZ3wNVaUmQNxsnpGyARWBL29R2n+YnxS8g23tRwuj331sjg+DY0Fnhg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@grpc/grpc-js": "^1.6.7",
|
"@grpc/grpc-js": "^1.6.7",
|
||||||
"rxjs": "^7.5.5",
|
"rxjs": "^7.5.5",
|
||||||
@@ -13555,7 +13579,6 @@
|
|||||||
},
|
},
|
||||||
"agent-base": {
|
"agent-base": {
|
||||||
"version": "6.0.2",
|
"version": "6.0.2",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"debug": "4"
|
"debug": "4"
|
||||||
}
|
}
|
||||||
@@ -16719,6 +16742,25 @@
|
|||||||
"minimist": {
|
"minimist": {
|
||||||
"version": "1.2.6"
|
"version": "1.2.6"
|
||||||
},
|
},
|
||||||
|
"mixpanel": {
|
||||||
|
"version": "0.17.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mixpanel/-/mixpanel-0.17.0.tgz",
|
||||||
|
"integrity": "sha512-DY5WeOy/hmkPrNiiZugJpWR0iMuOwuj1a3u0bgwB2eUFRV6oIew/pIahhpawdbNjb+Bye4a8ID3gefeNPvL81g==",
|
||||||
|
"requires": {
|
||||||
|
"https-proxy-agent": "5.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"https-proxy-agent": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==",
|
||||||
|
"requires": {
|
||||||
|
"agent-base": "6",
|
||||||
|
"debug": "4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"mkdirp": {
|
"mkdirp": {
|
||||||
"version": "0.5.6",
|
"version": "0.5.6",
|
||||||
"requires": {
|
"requires": {
|
||||||
@@ -16736,7 +16778,9 @@
|
|||||||
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w=="
|
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w=="
|
||||||
},
|
},
|
||||||
"moment-timezone": {
|
"moment-timezone": {
|
||||||
"version": "0.5.34",
|
"version": "0.5.38",
|
||||||
|
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.38.tgz",
|
||||||
|
"integrity": "sha512-nMIrzGah4+oYZPflDvLZUgoVUO4fvAqHstvG3xAUnMolWncuAiLDWNnJZj6EwJGMGfb1ZcuTFE6GI3hNOVWI/Q==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"moment": ">= 2.9.0"
|
"moment": ">= 2.9.0"
|
||||||
}
|
}
|
||||||
@@ -18131,9 +18175,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ts-proto": {
|
"ts-proto": {
|
||||||
"version": "1.126.1",
|
"version": "1.131.0",
|
||||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/ts-proto/-/ts-proto-1.126.1.tgz",
|
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/ts-proto/-/ts-proto-1.131.0.tgz",
|
||||||
"integrity": "sha512-PKrcgd0mCQJDY7tp+th349uYhnjs2Tz7wSqm9+DBcodl3YCKPt1pFtFmApOZdQ8WlghhgKAuJDIRQJBd6jD5YA==",
|
"integrity": "sha512-oj/kWrDz3JkkPQwumQDKfwHroH9iNz2alvrbCYzNYJlb/2MAUzFNfh9T+SZUPDfoXXK6oJoW1hGCHznj67yHNg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/object-hash": "^1.3.0",
|
"@types/object-hash": "^1.3.0",
|
||||||
"dataloader": "^1.4.0",
|
"dataloader": "^1.4.0",
|
||||||
|
|||||||
+3
-2
@@ -17,7 +17,7 @@
|
|||||||
"start": "nest start",
|
"start": "nest start",
|
||||||
"start:dev": "nest start --watch",
|
"start:dev": "nest start --watch",
|
||||||
"start:debug": "nest start --debug --watch",
|
"start:debug": "nest start --debug --watch",
|
||||||
"start:prod": "node dist/main",
|
"start:prod": "npm run build && node dist/main",
|
||||||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"test:watch": "jest --watch",
|
"test:watch": "jest --watch",
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-secrets-manager": "^3.112.0",
|
"@aws-sdk/client-secrets-manager": "^3.112.0",
|
||||||
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
|
||||||
"@dadosfera/protospack-v2": "3.18.18",
|
"@dadosfera/protospack-v2": "3.19.4",
|
||||||
"@grpc/grpc-js": "^1.6.7",
|
"@grpc/grpc-js": "^1.6.7",
|
||||||
"@grpc/proto-loader": "^0.6.13",
|
"@grpc/proto-loader": "^0.6.13",
|
||||||
"@nestjs/common": "^8.4.7",
|
"@nestjs/common": "^8.4.7",
|
||||||
@@ -49,6 +49,7 @@
|
|||||||
"helmet": "^5.1.0",
|
"helmet": "^5.1.0",
|
||||||
"jsonwebtoken": "^8.5.1",
|
"jsonwebtoken": "^8.5.1",
|
||||||
"jwk-to-pem": "^2.0.5",
|
"jwk-to-pem": "^2.0.5",
|
||||||
|
"mixpanel": "^0.17.0",
|
||||||
"passport": "^0.6.0",
|
"passport": "^0.6.0",
|
||||||
"passport-facebook": "^3.0.0",
|
"passport-facebook": "^3.0.0",
|
||||||
"passport-forcedotcom": "^0.1.5",
|
"passport-forcedotcom": "^0.1.5",
|
||||||
|
|||||||
+4
-2
@@ -24,6 +24,7 @@ import { CatalogModule } from './modules/catalog/catalog.module';
|
|||||||
import { ConfigModule } from '@nestjs/config';
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { PipelinesV2Module } from './modules/pipelinesV2/pipelines.module';
|
import { PipelinesV2Module } from './modules/pipelinesV2/pipelines.module';
|
||||||
import { ProductboardModule } from './modules/productboard/productboard.module';
|
import { ProductboardModule } from './modules/productboard/productboard.module';
|
||||||
|
import { MixpanelModule } from './modules/mixpanel/mixpanel.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
controllers: [],
|
controllers: [],
|
||||||
@@ -38,14 +39,15 @@ import { ProductboardModule } from './modules/productboard/productboard.module';
|
|||||||
ConfigModule.forRoot({
|
ConfigModule.forRoot({
|
||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
}),
|
}),
|
||||||
ConnectorModule,
|
|
||||||
AuthModule,
|
AuthModule,
|
||||||
|
ConnectorModule,
|
||||||
PermissionsModule,
|
PermissionsModule,
|
||||||
TermsOfUseModule,
|
TermsOfUseModule,
|
||||||
ConnectionModule,
|
ConnectionModule,
|
||||||
NetworkConfigModule,
|
NetworkConfigModule,
|
||||||
ConnectionTestModule,
|
ConnectionTestModule,
|
||||||
PipelinesModule,
|
PipelinesModule,
|
||||||
|
PipelinesV2Module,
|
||||||
TransformationsModule,
|
TransformationsModule,
|
||||||
HealthModule,
|
HealthModule,
|
||||||
CatalogModule,
|
CatalogModule,
|
||||||
@@ -53,9 +55,9 @@ import { ProductboardModule } from './modules/productboard/productboard.module';
|
|||||||
RolesModule,
|
RolesModule,
|
||||||
InputsModule,
|
InputsModule,
|
||||||
OauthModule,
|
OauthModule,
|
||||||
PipelinesV2Module,
|
|
||||||
CatalogModule,
|
CatalogModule,
|
||||||
ProductboardModule,
|
ProductboardModule,
|
||||||
|
MixpanelModule,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class AppModule {}
|
export class AppModule {}
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ export const PERMISSIONS_GROUPS = {
|
|||||||
DELETE: {
|
DELETE: {
|
||||||
seqid: 38,
|
seqid: 38,
|
||||||
claim: 'connection:delete',
|
claim: 'connection:delete',
|
||||||
usage: PermissionUsages.INTERNAL,
|
usage: PermissionUsages.PUBLIC,
|
||||||
name: {
|
name: {
|
||||||
'pt-br': 'Excluir Fonte',
|
'pt-br': 'Excluir Fonte',
|
||||||
'en-us': 'Remove Source',
|
'en-us': 'Remove Source',
|
||||||
@@ -290,15 +290,15 @@ export const PERMISSIONS_GROUPS = {
|
|||||||
claim: 'GET /catalog',
|
claim: 'GET /catalog',
|
||||||
usage: PermissionUsages.PUBLIC,
|
usage: PermissionUsages.PUBLIC,
|
||||||
name: {
|
name: {
|
||||||
'pt-br': 'Buscar data assets',
|
'pt-br': 'Acessar lista de Ativos e visualizar atributos',
|
||||||
'en-us': 'Search for data assets',
|
'en-us': 'Access Assets list and its attributes',
|
||||||
'es-es': 'Buscar data assets',
|
'es-es': 'Acceda a la lista de Activos y vea los atributos',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
CREATE: {
|
CREATE: {
|
||||||
seqid: 19,
|
seqid: 19,
|
||||||
claim: 'POST /catalog',
|
claim: 'POST /catalog',
|
||||||
usage: PermissionUsages.PUBLIC,
|
usage: PermissionUsages.INTERNAL,
|
||||||
name: {
|
name: {
|
||||||
'pt-br': 'Criar atributos no catálogo',
|
'pt-br': 'Criar atributos no catálogo',
|
||||||
'en-us': 'Create attributes',
|
'en-us': 'Create attributes',
|
||||||
@@ -307,32 +307,33 @@ export const PERMISSIONS_GROUPS = {
|
|||||||
},
|
},
|
||||||
UPDATE: {
|
UPDATE: {
|
||||||
seqid: 25,
|
seqid: 25,
|
||||||
claim: 'PUT /catalog',
|
claim: 'catalog:edit',
|
||||||
usage: PermissionUsages.INTERNAL,
|
usage: PermissionUsages.PUBLIC,
|
||||||
name: {
|
name: {
|
||||||
'pt-br': 'Editar atributos no catálogo',
|
'pt-br': 'Criar e editar atributos no catálogo',
|
||||||
'en-us': 'Edit attributes',
|
'en-us': 'Create and edit attributes on the catalog',
|
||||||
'es-es': 'Editar atributos',
|
'es-es': 'Crear y editar atributos en el catálogo',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
DELETE: {
|
DELETE: {
|
||||||
seqid: 1,
|
seqid: 1,
|
||||||
claim: 'DELETE /catalog',
|
claim: 'catalog:delete',
|
||||||
usage: PermissionUsages.INTERNAL,
|
usage: PermissionUsages.PUBLIC,
|
||||||
name: {
|
name: {
|
||||||
'pt-br': 'Excluir atributos no catálogo',
|
'pt-br': 'Excluir Ativos do catálogo',
|
||||||
'en-us': 'Remove attributes',
|
'en-us': 'Remove Assets from the catalog',
|
||||||
'es-es': 'Eliminar atributos',
|
'es-es': 'Eliminar Activos del catálogo',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
DATA_MANAGER: {
|
DATA_MANAGER: {
|
||||||
seqid: 42,
|
seqid: 42,
|
||||||
claim: 'catalog:data_manager',
|
claim: 'catalog:data_manager',
|
||||||
usage: PermissionUsages.PUBLIC,
|
usage: PermissionUsages.INTERNAL,
|
||||||
name: {
|
name: {
|
||||||
'pt-br': 'Vizualizar todos os recursos do catálogo.',
|
'pt-br':
|
||||||
'en-us': 'View all data assets.',
|
'Gerente do catálogo. Consegue vizualizar e editar todos os ativos.',
|
||||||
'es-es': 'Ver todos los activos de datos',
|
'en-us': 'Catalog manager. Able to view and edit all assets.',
|
||||||
|
'es-es': 'Gestor de catálogos. Puede ver y editar todos los activos.',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -448,11 +449,11 @@ export const PERMISSIONS_GROUPS = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
ORCHEST: {
|
MODULES: {
|
||||||
title: {
|
title: {
|
||||||
'pt-br': 'Analisar | Inteligência',
|
'pt-br': 'Módulos da Dadosfera',
|
||||||
'en-us': 'Analyze | Intelligence',
|
'en-us': 'Dadosfera Modules',
|
||||||
'es-es': 'Analizar | Inteligencia',
|
'es-es': 'Módulos de la Dadosfera',
|
||||||
},
|
},
|
||||||
permissions: {
|
permissions: {
|
||||||
INTELLIGENCE: {
|
INTELLIGENCE: {
|
||||||
@@ -460,9 +461,9 @@ export const PERMISSIONS_GROUPS = {
|
|||||||
claim: 'intelligence:open',
|
claim: 'intelligence:open',
|
||||||
usage: PermissionUsages.INTERNAL,
|
usage: PermissionUsages.INTERNAL,
|
||||||
name: {
|
name: {
|
||||||
'pt-br': 'Acessar Orchest',
|
'pt-br': 'Acessar Módulo de Inteligência',
|
||||||
'en-us': 'Access Orchest',
|
'en-us': 'Access Intelligence Module',
|
||||||
'es-s': 'Acceso Orchest',
|
'es-s': 'Acceder Módulo de Inteligencia',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
APP_BUILDER: {
|
APP_BUILDER: {
|
||||||
@@ -472,7 +473,7 @@ export const PERMISSIONS_GROUPS = {
|
|||||||
name: {
|
name: {
|
||||||
'pt-br': 'Acessar App Builder',
|
'pt-br': 'Acessar App Builder',
|
||||||
'en-us': 'Access App Builder',
|
'en-us': 'Access App Builder',
|
||||||
'es-es': 'Acceso App Builder',
|
'es-es': 'Acceder App Builder',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
MACHINE_LEARNING: {
|
MACHINE_LEARNING: {
|
||||||
@@ -482,7 +483,17 @@ export const PERMISSIONS_GROUPS = {
|
|||||||
name: {
|
name: {
|
||||||
'pt-br': 'Acessar Machine Learning',
|
'pt-br': 'Acessar Machine Learning',
|
||||||
'en-us': 'Access Machine Learning',
|
'en-us': 'Access Machine Learning',
|
||||||
'es-es': 'Acceso Machine Learning',
|
'es-es': 'Acceder Machine Learning',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
PROCESS: {
|
||||||
|
seqid: 43,
|
||||||
|
claim: 'process:open',
|
||||||
|
usage: PermissionUsages.INTERNAL,
|
||||||
|
name: {
|
||||||
|
'pt-br': 'Acessar Módulo de Processamento',
|
||||||
|
'en-us': 'Access Processing Module',
|
||||||
|
'es-es': 'Acceder Módulo de Tramitación',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import {
|
|||||||
Catch,
|
Catch,
|
||||||
ArgumentsHost,
|
ArgumentsHost,
|
||||||
HttpException,
|
HttpException,
|
||||||
HttpStatus,
|
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { Response } from 'express';
|
import { Response } from 'express';
|
||||||
|
|
||||||
|
|||||||
+38
-9
@@ -6,6 +6,8 @@ import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
|||||||
|
|
||||||
import { AppModule } from './app.module';
|
import { AppModule } from './app.module';
|
||||||
import { writeFileSync } from 'fs';
|
import { writeFileSync } from 'fs';
|
||||||
|
import { execSync } from 'child_process';
|
||||||
|
import { INestApplication } from '@nestjs/common';
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
DadosferaLogger.setupLogger({
|
DadosferaLogger.setupLogger({
|
||||||
serviceName: 'maestro',
|
serviceName: 'maestro',
|
||||||
@@ -24,26 +26,53 @@ async function bootstrap() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.use(helmet());
|
app.use(helmet());
|
||||||
|
configureSwagger(app);
|
||||||
|
|
||||||
|
await app.listen(3333);
|
||||||
|
}
|
||||||
|
function configureSwagger(app: INestApplication) {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
|
const swaggerVersion = `${date.getDate()}.${
|
||||||
|
date.getMonth() + 1
|
||||||
|
}.${date.getFullYear()} - ${date.getHours()}:${date.getMinutes()}`;
|
||||||
|
|
||||||
|
let branchName = '';
|
||||||
|
try {
|
||||||
|
branchName = execSync('git rev-parse --abbrev-ref HEAD')
|
||||||
|
.toString()
|
||||||
|
.replace('\n', '')
|
||||||
|
.trim();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Can't get branch name", error);
|
||||||
|
}
|
||||||
|
const swaggerTitle = branchName ? `Maestro - ${branchName}` : 'Maestro';
|
||||||
|
|
||||||
const config = new DocumentBuilder()
|
const config = new DocumentBuilder()
|
||||||
.setTitle('Maestro')
|
.setTitle(swaggerTitle)
|
||||||
.setDescription('Documentation for Maestro gateway')
|
.setDescription('Documentation for Maestro gateway')
|
||||||
.setVersion(
|
.setVersion(swaggerVersion)
|
||||||
`${date.getDate()}.${
|
.addBearerAuth(
|
||||||
date.getMonth() + 1
|
{ type: 'http', scheme: 'bearer', bearerFormat: 'JWT' },
|
||||||
}.${date.getFullYear()} - ${date.getHours()}:${date.getMinutes()}`,
|
'Authorization',
|
||||||
)
|
)
|
||||||
.addBearerAuth()
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
const document = SwaggerModule.createDocument(app, config);
|
const document = SwaggerModule.createDocument(app, config);
|
||||||
|
|
||||||
if (process.env.ENV === 'local') SwaggerModule.setup('api', app, document);
|
if (process.env.ENV === 'local') SwaggerModule.setup('api', app, document);
|
||||||
|
|
||||||
await writeFileSync('swagger.txt', JSON.stringify(JSON.stringify(document)));
|
writeFileSync(
|
||||||
|
'docsfera.json',
|
||||||
await app.listen(3333);
|
JSON.stringify(
|
||||||
|
{
|
||||||
|
service: '${DOCS_API_TOKEN}',
|
||||||
|
pageId: '${DOCS_PAGE_ID}',
|
||||||
|
blockId: '${DOCS_BLOCK_ID}',
|
||||||
|
schema: document,
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
2,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
bootstrap();
|
bootstrap();
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import {
|
|||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
import {
|
import {
|
||||||
AuthSignInRequest,
|
|
||||||
AuthRefreshAccessTokenRequest,
|
AuthRefreshAccessTokenRequest,
|
||||||
AuthChangePasswordRequest,
|
AuthChangePasswordRequest,
|
||||||
AuthResetPasswordRequest,
|
AuthResetPasswordRequest,
|
||||||
@@ -28,6 +27,7 @@ import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
|||||||
import { GrpcToHttpExceptionFilter } from '../../error/grpc-to-http-exception.filter';
|
import { GrpcToHttpExceptionFilter } from '../../error/grpc-to-http-exception.filter';
|
||||||
import { RequestUser, User } from 'src/authentication/user.decorator';
|
import { RequestUser, User } from 'src/authentication/user.decorator';
|
||||||
import { Metadata } from '@grpc/grpc-js';
|
import { Metadata } from '@grpc/grpc-js';
|
||||||
|
import { AuthSignInReq, AuthSignInRes } from './dtos/login';
|
||||||
|
|
||||||
@ApiTags('Auth')
|
@ApiTags('Auth')
|
||||||
@UseFilters(new GrpcToHttpExceptionFilter())
|
@UseFilters(new GrpcToHttpExceptionFilter())
|
||||||
@@ -43,6 +43,18 @@ export class AuthController {
|
|||||||
this.logger = dadosferaLogger.logger;
|
this.logger = dadosferaLogger.logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post('sign-in')
|
||||||
|
@HttpCode(HttpStatus.OK)
|
||||||
|
async signIn(
|
||||||
|
@Body() { username, password, totp }: AuthSignInReq,
|
||||||
|
@Headers('Dadosfera-Lang') language: string,
|
||||||
|
): Promise<AuthSignInRes> {
|
||||||
|
this.logger.info('/auth - SignIn');
|
||||||
|
const metadata = new Metadata();
|
||||||
|
metadata.add('language', language || 'pt-br');
|
||||||
|
return this.authClient.signIn({ username, password, totp }, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
@Post('/sso/snowflake')
|
@Post('/sso/snowflake')
|
||||||
@RequireAllPermissions(PERMISSIONS_GROUPS.SNOWFLAKE.permissions.OPEN)
|
@RequireAllPermissions(PERMISSIONS_GROUPS.SNOWFLAKE.permissions.OPEN)
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
@@ -58,18 +70,6 @@ export class AuthController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('sign-in')
|
|
||||||
@HttpCode(HttpStatus.OK)
|
|
||||||
async signIn(
|
|
||||||
@Body() { username, password, totp }: AuthSignInRequest,
|
|
||||||
@Headers('Dadosfera-Lang') language: string,
|
|
||||||
) {
|
|
||||||
this.logger.info('/auth - SignIn');
|
|
||||||
const metadata = new Metadata();
|
|
||||||
metadata.add('language', language || 'pt-br');
|
|
||||||
return this.authClient.signIn({ username, password, totp }, metadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Post('refresh-access-token')
|
@Post('refresh-access-token')
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
async refreshAccessToken(
|
async refreshAccessToken(
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
import { ApiProperty } from '@nestjs/swagger';
|
import {
|
||||||
|
AuthSignInRequest,
|
||||||
|
AuthSignInResponse,
|
||||||
|
} from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages';
|
||||||
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||||
|
|
||||||
export class LoginDto {
|
export class LoginDto {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
@@ -10,3 +14,86 @@ export class LoginDto {
|
|||||||
@ApiProperty({ required: false })
|
@ApiProperty({ required: false })
|
||||||
totp: string;
|
totp: string;
|
||||||
}
|
}
|
||||||
|
export class AuthTokens {
|
||||||
|
@ApiProperty()
|
||||||
|
accessToken: string;
|
||||||
|
@ApiProperty()
|
||||||
|
refreshToken: string;
|
||||||
|
@ApiPropertyOptional()
|
||||||
|
termsOfUseToken: string;
|
||||||
|
@ApiProperty({ deprecated: true })
|
||||||
|
idToken: string;
|
||||||
|
}
|
||||||
|
export enum MfaStatuses {
|
||||||
|
PENDING = 'pending',
|
||||||
|
NONE = 'none',
|
||||||
|
TOTP = 'totp',
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum TouStatuses {
|
||||||
|
PENDING = 'pending',
|
||||||
|
REQUIRED = 'required',
|
||||||
|
OK = 'ok',
|
||||||
|
}
|
||||||
|
export class TermsOfUse {
|
||||||
|
@ApiProperty()
|
||||||
|
version: number;
|
||||||
|
@ApiProperty()
|
||||||
|
publicUrl: string;
|
||||||
|
@ApiProperty()
|
||||||
|
enforceDate: string;
|
||||||
|
@ApiProperty()
|
||||||
|
createdAt: string;
|
||||||
|
}
|
||||||
|
export class TermsOfUseStatus {
|
||||||
|
@ApiProperty({ enum: TouStatuses })
|
||||||
|
status: string;
|
||||||
|
@ApiPropertyOptional()
|
||||||
|
lastSigned?: TermsOfUse;
|
||||||
|
@ApiPropertyOptional()
|
||||||
|
next?: TermsOfUse;
|
||||||
|
}
|
||||||
|
export class AuthUser {
|
||||||
|
@ApiProperty()
|
||||||
|
id: string;
|
||||||
|
@ApiProperty()
|
||||||
|
name: string;
|
||||||
|
@ApiProperty()
|
||||||
|
username: string;
|
||||||
|
@ApiProperty()
|
||||||
|
createdAt: string;
|
||||||
|
}
|
||||||
|
export class AuthCustomer {
|
||||||
|
@ApiProperty()
|
||||||
|
modules: string[];
|
||||||
|
@ApiProperty()
|
||||||
|
id: string;
|
||||||
|
@ApiProperty()
|
||||||
|
name: string;
|
||||||
|
@ApiProperty()
|
||||||
|
tier: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class AuthSignInReq implements AuthSignInRequest {
|
||||||
|
@ApiProperty()
|
||||||
|
username: string;
|
||||||
|
@ApiProperty()
|
||||||
|
password: string;
|
||||||
|
@ApiPropertyOptional()
|
||||||
|
totp: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class AuthSignInRes implements AuthSignInResponse {
|
||||||
|
@ApiProperty()
|
||||||
|
permissions: string[];
|
||||||
|
@ApiProperty({ enum: MfaStatuses })
|
||||||
|
mfaStatus: string;
|
||||||
|
@ApiPropertyOptional()
|
||||||
|
customer?: AuthCustomer;
|
||||||
|
@ApiPropertyOptional()
|
||||||
|
user?: AuthUser;
|
||||||
|
@ApiPropertyOptional()
|
||||||
|
tokens?: AuthTokens;
|
||||||
|
@ApiPropertyOptional()
|
||||||
|
termsOfUse?: TermsOfUseStatus;
|
||||||
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import { RequestUser, User } from 'src/authentication/user.decorator';
|
|||||||
import {
|
import {
|
||||||
ICatalogAllResponse,
|
ICatalogAllResponse,
|
||||||
IColumnsMetadataResponse,
|
IColumnsMetadataResponse,
|
||||||
|
ICreateDataAsset,
|
||||||
IDeleteComment,
|
IDeleteComment,
|
||||||
IDocsResponse,
|
IDocsResponse,
|
||||||
IMakeAComment,
|
IMakeAComment,
|
||||||
@@ -33,24 +34,30 @@ import {
|
|||||||
IUpdateDataRequest,
|
IUpdateDataRequest,
|
||||||
} from './dtos';
|
} from './dtos';
|
||||||
|
|
||||||
|
const catalogPermissions = PERMISSIONS_GROUPS.CATALOG.permissions;
|
||||||
@ApiTags('Catalog')
|
@ApiTags('Catalog')
|
||||||
@Controller('catalog')
|
@Controller('catalog')
|
||||||
@Authenticated()
|
@Authenticated()
|
||||||
@AuthenticateCondition((req, user) => {
|
@AuthenticateCondition((req, user: RequestUser) => {
|
||||||
if (req.path.includes('/manage_permissions/')) return true;
|
if (user.permissions.includes(catalogPermissions.DATA_MANAGER.seqid))
|
||||||
let action;
|
return true;
|
||||||
|
|
||||||
|
if (req.path.includes('/manage-permissions')) return true;
|
||||||
|
let action: keyof typeof catalogPermissions;
|
||||||
|
|
||||||
switch (req.method) {
|
switch (req.method) {
|
||||||
case 'POST':
|
case 'POST':
|
||||||
action = 'CREATE';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'PUT':
|
case 'PUT':
|
||||||
action = 'UPDATE';
|
action = 'UPDATE';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'DELETE':
|
||||||
|
if (req.path.includes('/comment')) action = 'UPDATE';
|
||||||
|
else action = req.method;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
action = req.method;
|
action = req.method as 'GET';
|
||||||
}
|
}
|
||||||
|
|
||||||
return user.permissions.includes(
|
return user.permissions.includes(
|
||||||
@@ -372,7 +379,7 @@ export class CatalogController {
|
|||||||
@Body('docs') docs: string,
|
@Body('docs') docs: string,
|
||||||
) {
|
) {
|
||||||
const { user_id, customer_name } = user;
|
const { user_id, customer_name } = user;
|
||||||
const [data_asset_type, id] = data_asset_id.split('-');
|
const [, id] = data_asset_id.split('-');
|
||||||
|
|
||||||
this.logger.info(`/catalog - ON GET DATA DOCS ROUTE`, {
|
this.logger.info(`/catalog - ON GET DATA DOCS ROUTE`, {
|
||||||
user_id,
|
user_id,
|
||||||
@@ -432,6 +439,26 @@ export class CatalogController {
|
|||||||
return { message: response.message };
|
return { message: response.message };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async createDataAsset(
|
||||||
|
@User() user: RequestUser,
|
||||||
|
@Body() body: ICreateDataAsset,
|
||||||
|
) {
|
||||||
|
const { customer_id, customer_name, user_id, username } = user;
|
||||||
|
const metadata = PackTheMetadata({
|
||||||
|
customer_id,
|
||||||
|
customer_name,
|
||||||
|
user_id,
|
||||||
|
username,
|
||||||
|
});
|
||||||
|
const { data_asset } = await this.catalogService.createDataAsset(
|
||||||
|
body,
|
||||||
|
metadata,
|
||||||
|
);
|
||||||
|
|
||||||
|
return { data_asset: JSON.parse(data_asset) };
|
||||||
|
}
|
||||||
|
|
||||||
@Post('data-asset/:id/comment')
|
@Post('data-asset/:id/comment')
|
||||||
async commentOnDataAsset(
|
async commentOnDataAsset(
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
|
|||||||
@@ -58,6 +58,19 @@ class CatalogService implements OnModuleInit {
|
|||||||
)}.dadosfera.ai`;
|
)}.dadosfera.ai`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async createDataAsset(data: Messages.CreateDataAssetRequest, metadata) {
|
||||||
|
this.logger.info('CatalogService - Manage Data assets permissions');
|
||||||
|
|
||||||
|
return lastValueFrom(
|
||||||
|
this.catalogWriteService.CreateDataAsset(data, metadata),
|
||||||
|
).catch((err) => {
|
||||||
|
throw new HttpException(
|
||||||
|
err.details,
|
||||||
|
err.code === 6 ? HttpStatus.CONFLICT : 404,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async managePermissions(data: Messages.ManagePermissionRequest, metadata) {
|
async managePermissions(data: Messages.ManagePermissionRequest, metadata) {
|
||||||
this.logger.info('CatalogService - Manage Data assets permissions');
|
this.logger.info('CatalogService - Manage Data assets permissions');
|
||||||
|
|
||||||
@@ -275,7 +288,7 @@ class CatalogService implements OnModuleInit {
|
|||||||
async updateOneDataAsset({ data_asset_id, customer_id, body, metadata }) {
|
async updateOneDataAsset({ data_asset_id, customer_id, body, metadata }) {
|
||||||
const { data_asset } = await lastValueFrom(
|
const { data_asset } = await lastValueFrom(
|
||||||
this.catalogWriteService.UpdateDataAsset(
|
this.catalogWriteService.UpdateDataAsset(
|
||||||
{ id: data_asset_id, ...body },
|
{ id: data_asset_id, changes: JSON.stringify(body) },
|
||||||
metadata,
|
metadata,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||||
|
import { CreateDataAssetRequest } from '@dadosfera/protospack-v2/dist/lib/Catalog/interfaces/messages';
|
||||||
|
|
||||||
export class IRole {
|
export class IRole {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
@@ -128,6 +129,19 @@ export class IUpdateDataRequest {
|
|||||||
tags: string[];
|
tags: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class ICreateDataAsset implements CreateDataAssetRequest {
|
||||||
|
@ApiProperty()
|
||||||
|
display_name: string;
|
||||||
|
@ApiProperty()
|
||||||
|
description: string;
|
||||||
|
@ApiProperty()
|
||||||
|
data_asset_type: string;
|
||||||
|
@ApiProperty()
|
||||||
|
external_url: string;
|
||||||
|
@ApiProperty()
|
||||||
|
location: string;
|
||||||
|
}
|
||||||
|
|
||||||
export class IPreview {
|
export class IPreview {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
id: string;
|
id: string;
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ export class ConnectorClientService implements OnModuleInit {
|
|||||||
});
|
});
|
||||||
const responseParsed = JSON.parse(res.message);
|
const responseParsed = JSON.parse(res.message);
|
||||||
const connectorErrors = responseParsed.items
|
const connectorErrors = responseParsed.items
|
||||||
.filter((i) => i.update._index === 'connector' && i.update.error)
|
.filter((i) => i.update._index === 'connectors' && i.update.error)
|
||||||
.map((i) => ({
|
.map((i) => ({
|
||||||
id: i.update._id,
|
id: i.update._id,
|
||||||
reason: i.update.error,
|
reason: i.update.error,
|
||||||
@@ -115,7 +115,8 @@ export class ConnectorClientService implements OnModuleInit {
|
|||||||
}));
|
}));
|
||||||
const connectorCreated = responseParsed.items
|
const connectorCreated = responseParsed.items
|
||||||
.filter(
|
.filter(
|
||||||
(i) => i.update._index === 'connector' && i.update.result === 'created',
|
(i) =>
|
||||||
|
i.update._index === 'connectors' && i.update.result === 'created',
|
||||||
)
|
)
|
||||||
.map((i) => ({
|
.map((i) => ({
|
||||||
id: i.update._id,
|
id: i.update._id,
|
||||||
@@ -149,7 +150,8 @@ export class ConnectorClientService implements OnModuleInit {
|
|||||||
}));
|
}));
|
||||||
const connectorUpdated = responseParsed.items
|
const connectorUpdated = responseParsed.items
|
||||||
.filter(
|
.filter(
|
||||||
(i) => i.update._index === 'connector' && i.update.result === 'updated',
|
(i) =>
|
||||||
|
i.update._index === 'connectors' && i.update.result === 'updated',
|
||||||
)
|
)
|
||||||
.map((i) => ({
|
.map((i) => ({
|
||||||
id: i.update._id,
|
id: i.update._id,
|
||||||
@@ -183,7 +185,7 @@ export class ConnectorClientService implements OnModuleInit {
|
|||||||
}));
|
}));
|
||||||
const connectorNoop = responseParsed.items
|
const connectorNoop = responseParsed.items
|
||||||
.filter(
|
.filter(
|
||||||
(i) => i.update._index === 'connector' && i.update.result === 'noop',
|
(i) => i.update._index === 'connectors' && i.update.result === 'noop',
|
||||||
)
|
)
|
||||||
.map((i) => ({
|
.map((i) => ({
|
||||||
id: i.update._id,
|
id: i.update._id,
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ export class DucClient {
|
|||||||
transport: Transport.GRPC,
|
transport: Transport.GRPC,
|
||||||
options: {
|
options: {
|
||||||
url: process.env.DUC_URL,
|
url: process.env.DUC_URL,
|
||||||
package: ProtoPackages.WritePackage,
|
package: [ProtoPackages.WritePackage, ProtoPackages.ReadPackage],
|
||||||
credentials:
|
credentials:
|
||||||
process.env.LOCAL_ENV || process.env.ENV === 'local'
|
process.env.LOCAL_ENV || process.env.ENV === 'local'
|
||||||
? undefined
|
? undefined
|
||||||
: credentials.createSsl(),
|
: credentials.createSsl(),
|
||||||
protoPath: ProtoPaths.WriteFilePath,
|
protoPath: [ProtoPaths.WriteFilePath, ProtoPaths.ReadFilePath],
|
||||||
loader: {
|
loader: {
|
||||||
keepCase: true,
|
keepCase: true,
|
||||||
enums: String,
|
enums: String,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
Param,
|
Param,
|
||||||
Patch,
|
Patch,
|
||||||
Post,
|
Post,
|
||||||
|
UseFilters,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { InputsService } from './inputs.service';
|
import { InputsService } from './inputs.service';
|
||||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||||
@@ -26,8 +27,11 @@ import {
|
|||||||
import { UpdateInputRequest } from './dtos/old_interfaces';
|
import { UpdateInputRequest } from './dtos/old_interfaces';
|
||||||
import { RequestUser, User } from 'src/authentication/user.decorator';
|
import { RequestUser, User } from 'src/authentication/user.decorator';
|
||||||
import { Info } from '@dadosfera/protospack-v2/dist/lib/Input/interfaces/entities';
|
import { Info } from '@dadosfera/protospack-v2/dist/lib/Input/interfaces/entities';
|
||||||
|
import ErrorBuilder from 'src/utils/ErrorBuilder';
|
||||||
|
import ErrorCodes from 'src/utils/errorCodes';
|
||||||
|
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
|
||||||
|
|
||||||
@ApiTags('inputs')
|
@ApiTags('Inputs')
|
||||||
@Controller('inputs')
|
@Controller('inputs')
|
||||||
@AuthenticateCondition((req, user) => {
|
@AuthenticateCondition((req, user) => {
|
||||||
switch (req.method) {
|
switch (req.method) {
|
||||||
@@ -38,7 +42,9 @@ import { Info } from '@dadosfera/protospack-v2/dist/lib/Input/interfaces/entitie
|
|||||||
user.permissions.includes(
|
user.permissions.includes(
|
||||||
PERMISSIONS_GROUPS.PIPELINE.permissions.CREATE.seqid,
|
PERMISSIONS_GROUPS.PIPELINE.permissions.CREATE.seqid,
|
||||||
) ||
|
) ||
|
||||||
user.permissions.includes(PERMISSIONS_GROUPS.PIPELINE.permissions.UPDATE.seqid)
|
user.permissions.includes(
|
||||||
|
PERMISSIONS_GROUPS.PIPELINE.permissions.UPDATE.seqid,
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -49,10 +55,13 @@ import { Info } from '@dadosfera/protospack-v2/dist/lib/Input/interfaces/entitie
|
|||||||
user.permissions.includes(
|
user.permissions.includes(
|
||||||
PERMISSIONS_GROUPS.PIPELINE.permissions.UPDATE.seqid,
|
PERMISSIONS_GROUPS.PIPELINE.permissions.UPDATE.seqid,
|
||||||
) ||
|
) ||
|
||||||
user.permissions.includes(PERMISSIONS_GROUPS.PIPELINE.permissions.GET.seqid)
|
user.permissions.includes(
|
||||||
|
PERMISSIONS_GROUPS.PIPELINE.permissions.GET.seqid,
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@UseFilters(new GrpcToHttpExceptionFilter())
|
||||||
export class InputsController {
|
export class InputsController {
|
||||||
logger: DadosferaLogger;
|
logger: DadosferaLogger;
|
||||||
constructor(
|
constructor(
|
||||||
@@ -90,6 +99,7 @@ export class InputsController {
|
|||||||
@Post('/test-connection/get-columns')
|
@Post('/test-connection/get-columns')
|
||||||
@ApiOkResponse({ type: TestConnectionGetColumnsRes })
|
@ApiOkResponse({ type: TestConnectionGetColumnsRes })
|
||||||
async getColumns(@Body() data: TestConnectionGetColumnsReq) {
|
async getColumns(@Body() data: TestConnectionGetColumnsReq) {
|
||||||
|
throw new ErrorBuilder(ErrorCodes.NOT_IMPLEMENTED);
|
||||||
this.logger.info(
|
this.logger.info(
|
||||||
`/test-connection/get-columns - ON TEST CONNECTION GET COLUMNS ROUTE`,
|
`/test-connection/get-columns - ON TEST CONNECTION GET COLUMNS ROUTE`,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -72,17 +72,6 @@ export class InputsService {
|
|||||||
objectCamelToSnake(createInputResponse);
|
objectCamelToSnake(createInputResponse);
|
||||||
return createInputResponse;
|
return createInputResponse;
|
||||||
},
|
},
|
||||||
findOne: async (data: IIdRequest) => {
|
|
||||||
this.logger.info('InputClientService - FindOne');
|
|
||||||
const findOneInputResponse = await lastValueFrom(
|
|
||||||
this.inputReadService.InputFindOne(data),
|
|
||||||
).catch((e) => {
|
|
||||||
this.logger.error(e.details);
|
|
||||||
throw new HttpException(e.details, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
||||||
});
|
|
||||||
objectCamelToSnake(findOneInputResponse);
|
|
||||||
return findOneInputResponse;
|
|
||||||
},
|
|
||||||
update: async (updateInputDTO: UpdateInputRequest) => {
|
update: async (updateInputDTO: UpdateInputRequest) => {
|
||||||
this.logger.info('InputClientService - Update');
|
this.logger.info('InputClientService - Update');
|
||||||
const updateInputResponse = await lastValueFrom(
|
const updateInputResponse = await lastValueFrom(
|
||||||
@@ -91,14 +80,6 @@ export class InputsService {
|
|||||||
|
|
||||||
return updateInputResponse;
|
return updateInputResponse;
|
||||||
},
|
},
|
||||||
remove: async (idRequest: IIdRequest) => {
|
|
||||||
this.logger.info('InputClientService - Remove');
|
|
||||||
const removeInputResponse = await lastValueFrom(
|
|
||||||
this.inputWriteService.InputRemove(idRequest),
|
|
||||||
);
|
|
||||||
|
|
||||||
return removeInputResponse;
|
|
||||||
},
|
|
||||||
testConnection: async (data: TestConnectionRequest) => {
|
testConnection: async (data: TestConnectionRequest) => {
|
||||||
this.logger.info('InputClientService - TestConnection');
|
this.logger.info('InputClientService - TestConnection');
|
||||||
const testConnectionResponse = await lastValueFrom(
|
const testConnectionResponse = await lastValueFrom(
|
||||||
@@ -239,17 +220,13 @@ export class InputsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async findOne(idRequest: IIdRequest) {
|
async findOne(idRequest: IIdRequest) {
|
||||||
try {
|
const findOneInputResponse: any = await lastValueFrom(
|
||||||
const findOneInputResponse: any = await this.OLD_inputClient.findOne(
|
this.inputReadService.InputFindOne(idRequest),
|
||||||
idRequest,
|
);
|
||||||
);
|
findOneInputResponse.input = this.adjustInputPayload(
|
||||||
findOneInputResponse.input = this.adjustInputPayload(
|
findOneInputResponse.input,
|
||||||
findOneInputResponse.input,
|
);
|
||||||
);
|
return findOneInputResponse;
|
||||||
return findOneInputResponse;
|
|
||||||
} catch (err) {
|
|
||||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async update(id: string, data, info: Info) {
|
async update(id: string, data, info: Info) {
|
||||||
@@ -271,13 +248,7 @@ export class InputsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async remove(idRequest: IIdRequest) {
|
async remove(idRequest: IIdRequest) {
|
||||||
try {
|
return lastValueFrom(this.inputWriteService.InputRemove(idRequest));
|
||||||
const removeInputResponse = await this.OLD_inputClient.remove(idRequest);
|
|
||||||
|
|
||||||
return removeInputResponse;
|
|
||||||
} catch (err) {
|
|
||||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Timeout(60000 * 10) // Timeout set for 10 minutes
|
@Timeout(60000 * 10) // Timeout set for 10 minutes
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import { Body, Controller, Inject, Param, Post } from '@nestjs/common';
|
||||||
|
import { init } from 'mixpanel';
|
||||||
|
import { RequestUser, User } from 'src/authentication/user.decorator';
|
||||||
|
|
||||||
|
@Controller('trackEvent')
|
||||||
|
export class MixpanelController {
|
||||||
|
constructor(
|
||||||
|
@Inject('MIXPANEL_TOKEN')
|
||||||
|
private readonly mixpanelToken: string,
|
||||||
|
) {}
|
||||||
|
@Post(':id')
|
||||||
|
async trackEvent(@Param('id') id, @Body() body, @User() user: RequestUser) {
|
||||||
|
delete body.info;
|
||||||
|
const mixpanel = init(this.mixpanelToken);
|
||||||
|
|
||||||
|
await mixpanel.people.set(user.username, {
|
||||||
|
$name: user.username,
|
||||||
|
$email: user.username,
|
||||||
|
customer_name: user.customer_name,
|
||||||
|
});
|
||||||
|
|
||||||
|
await mixpanel.track(id, {
|
||||||
|
distinct_id: user.username,
|
||||||
|
customer: user.customer_name,
|
||||||
|
env: process.env.ENV,
|
||||||
|
...body,
|
||||||
|
});
|
||||||
|
|
||||||
|
return { id, body, user: user.username };
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { getSecreteFromSecreteManager } from 'src/utils/SecretManager';
|
||||||
|
import { MixpanelController } from './mixpanel.controller';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
controllers: [MixpanelController],
|
||||||
|
providers: [
|
||||||
|
{
|
||||||
|
provide: 'MIXPANEL_TOKEN',
|
||||||
|
useValue: getSecreteFromSecreteManager(
|
||||||
|
`${process.env.ENV}/root/mixpanel_token`,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class MixpanelModule {}
|
||||||
@@ -1,14 +1,8 @@
|
|||||||
import { Controller, Get, Headers, Inject } from '@nestjs/common';
|
import { Controller, Get, Headers, Inject } from '@nestjs/common';
|
||||||
import { ApiHeader, ApiOkResponse, ApiTags } from '@nestjs/swagger';
|
import { ApiHeader, ApiOkResponse, ApiTags } from '@nestjs/swagger';
|
||||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||||
import {
|
import { Authenticated } from 'src/authentication/authentication.decorator';
|
||||||
Authenticated,
|
import { PermissionUsages } from 'src/authentication/permissions.enum';
|
||||||
RequireAllPermissions,
|
|
||||||
} from 'src/authentication/authentication.decorator';
|
|
||||||
import {
|
|
||||||
PERMISSIONS_GROUPS,
|
|
||||||
PermissionUsages,
|
|
||||||
} from 'src/authentication/permissions.enum';
|
|
||||||
import { RequestUser, User } from 'src/authentication/user.decorator';
|
import { RequestUser, User } from 'src/authentication/user.decorator';
|
||||||
import { LanguageEnum } from 'src/utils/languages.enum';
|
import { LanguageEnum } from 'src/utils/languages.enum';
|
||||||
import { GetPublicPermissionsRes } from './dto/entities';
|
import { GetPublicPermissionsRes } from './dto/entities';
|
||||||
|
|||||||
@@ -9,8 +9,15 @@ import {
|
|||||||
Put,
|
Put,
|
||||||
Headers,
|
Headers,
|
||||||
Query,
|
Query,
|
||||||
|
UseFilters,
|
||||||
|
HttpCode,
|
||||||
|
HttpStatus,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ApiCreatedResponse, ApiTags } from '@nestjs/swagger';
|
import {
|
||||||
|
ApiCreatedResponse,
|
||||||
|
ApiNoContentResponse,
|
||||||
|
ApiTags,
|
||||||
|
} from '@nestjs/swagger';
|
||||||
import { AuthenticateCondition } from 'src/authentication/authentication.decorator';
|
import { AuthenticateCondition } from 'src/authentication/authentication.decorator';
|
||||||
import { PERMISSIONS_GROUPS } from '../../authentication/permissions.enum';
|
import { PERMISSIONS_GROUPS } from '../../authentication/permissions.enum';
|
||||||
import { PipelinesService } from './pipelines.service';
|
import { PipelinesService } from './pipelines.service';
|
||||||
@@ -21,7 +28,10 @@ import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
|
|||||||
|
|
||||||
import { PipelinesService as OldPipelineService } from 'src/modules/pipelines/pipelines.service';
|
import { PipelinesService as OldPipelineService } from 'src/modules/pipelines/pipelines.service';
|
||||||
import { ICreatePipelineV2Req, IPipelineV2 } from './interfaces';
|
import { ICreatePipelineV2Req, IPipelineV2 } from './interfaces';
|
||||||
@ApiTags('Pipelines')
|
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
|
||||||
|
|
||||||
|
@UseFilters(new GrpcToHttpExceptionFilter())
|
||||||
|
@ApiTags('PipelinesV2')
|
||||||
@Controller('pipelinesV2')
|
@Controller('pipelinesV2')
|
||||||
@AuthenticateCondition((req, user) => {
|
@AuthenticateCondition((req, user) => {
|
||||||
let action;
|
let action;
|
||||||
@@ -143,13 +153,16 @@ export class PipelinesController {
|
|||||||
const result = await this.pipelinesClientService
|
const result = await this.pipelinesClientService
|
||||||
.findOne({ id }, metadata)
|
.findOne({ id }, metadata)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
//{pipeline:{tables: {tables: [], input_id: ''}}}
|
||||||
|
let tables = JSON.parse(res.pipeline.config.tables);
|
||||||
|
if (tables?.tables) tables = tables.tables;
|
||||||
Object.assign(res.pipeline, {
|
Object.assign(res.pipeline, {
|
||||||
transformations: res.pipeline.transformations
|
transformations: res.pipeline.transformations
|
||||||
? JSON.parse(res.pipeline.transformations)
|
? JSON.parse(res.pipeline.transformations)
|
||||||
: [],
|
: [],
|
||||||
config: {
|
config: {
|
||||||
cron: res.pipeline.config.cron,
|
cron: res.pipeline.config.cron,
|
||||||
tables: JSON.parse(res.pipeline.config.tables),
|
tables,
|
||||||
},
|
},
|
||||||
properties: res.pipeline.properties
|
properties: res.pipeline.properties
|
||||||
? JSON.parse(res.pipeline.properties)
|
? JSON.parse(res.pipeline.properties)
|
||||||
@@ -180,17 +193,17 @@ export class PipelinesController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
async delete(@Body() data, @Param() params, @User() user: RequestUser) {
|
@ApiNoContentResponse()
|
||||||
|
@HttpCode(HttpStatus.NO_CONTENT)
|
||||||
|
async delete(@Param() params, @User() user: RequestUser) {
|
||||||
|
this.logger.info('PipelinesController - delete', { user });
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
this.logger.info('PipelinesController - findOne', { user });
|
const metadata = PackTheMetadata({
|
||||||
|
customer_id: user.customer_id,
|
||||||
const metadata = PackTheMetadata({ ...user });
|
customer_name: user.customer_name,
|
||||||
|
user_id: user.user_id,
|
||||||
const response = await this.pipelinesClientService.remove(
|
});
|
||||||
{ id, ...data },
|
await this.pipelinesClientService.remove({ id, metadata, user });
|
||||||
metadata,
|
this.logger.info('PipelinesController - delete: OK');
|
||||||
);
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import { PipelinesClientConfiguration } from './pipelines-client';
|
|||||||
|
|
||||||
import { PipelinesModule as OldPipelineModule } from 'src/modules/pipelines/pipelines.module';
|
import { PipelinesModule as OldPipelineModule } from 'src/modules/pipelines/pipelines.module';
|
||||||
import { ConnectorModule } from '../connector/connector.module';
|
import { ConnectorModule } from '../connector/connector.module';
|
||||||
|
import { InputsModule } from '../inputs/inputs.module';
|
||||||
|
import { TransformationsModule } from '../transformations/transformations.module';
|
||||||
|
|
||||||
const client = new PipelinesClientConfiguration();
|
const client = new PipelinesClientConfiguration();
|
||||||
|
|
||||||
@@ -17,6 +19,8 @@ const client = new PipelinesClientConfiguration();
|
|||||||
ClientsModule.register([client.providerOptions]),
|
ClientsModule.register([client.providerOptions]),
|
||||||
OldPipelineModule,
|
OldPipelineModule,
|
||||||
ConnectorModule,
|
ConnectorModule,
|
||||||
|
InputsModule,
|
||||||
|
TransformationsModule,
|
||||||
],
|
],
|
||||||
controllers: [PipelinesController],
|
controllers: [PipelinesController],
|
||||||
providers: [PipelinesService, DadosferaLogger],
|
providers: [PipelinesService, DadosferaLogger],
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
BadRequestException,
|
BadRequestException,
|
||||||
HttpException,
|
|
||||||
Inject,
|
Inject,
|
||||||
InternalServerErrorException,
|
InternalServerErrorException,
|
||||||
OnModuleInit,
|
OnModuleInit,
|
||||||
@@ -20,6 +19,10 @@ import { ICreatePipelineV2Req } from './interfaces';
|
|||||||
import { PipelineV2CreateRequest } from '@dadosfera/protospack-v2/dist/lib/PipelineV2/interfaces/messages';
|
import { PipelineV2CreateRequest } from '@dadosfera/protospack-v2/dist/lib/PipelineV2/interfaces/messages';
|
||||||
import { Metadata } from '@grpc/grpc-js';
|
import { Metadata } from '@grpc/grpc-js';
|
||||||
import { ConnectorClientService } from '../connector/client.service';
|
import { ConnectorClientService } from '../connector/client.service';
|
||||||
|
import { InputsService } from '../inputs/inputs.service';
|
||||||
|
import { RequestUser } from 'src/authentication/user.decorator';
|
||||||
|
import { TransformationsService } from '../transformations/transformations.service';
|
||||||
|
import { getObjValueFromPath } from 'src/utils/ObjValueFromPath';
|
||||||
|
|
||||||
export class PipelinesService implements OnModuleInit {
|
export class PipelinesService implements OnModuleInit {
|
||||||
logger: DadosferaLogger;
|
logger: DadosferaLogger;
|
||||||
@@ -31,6 +34,8 @@ export class PipelinesService implements OnModuleInit {
|
|||||||
@Inject(PipelinesClientConfiguration.name)
|
@Inject(PipelinesClientConfiguration.name)
|
||||||
private readonly grpcClient: ClientGrpc,
|
private readonly grpcClient: ClientGrpc,
|
||||||
private readonly connectorService: ConnectorClientService,
|
private readonly connectorService: ConnectorClientService,
|
||||||
|
private readonly inputsService: InputsService,
|
||||||
|
private readonly transformationsService: TransformationsService,
|
||||||
) {
|
) {
|
||||||
this.logger = dadosferaLogger.logger;
|
this.logger = dadosferaLogger.logger;
|
||||||
}
|
}
|
||||||
@@ -129,10 +134,7 @@ export class PipelinesService implements OnModuleInit {
|
|||||||
|
|
||||||
const findOnePipelineResponse = await lastValueFrom(
|
const findOnePipelineResponse = await lastValueFrom(
|
||||||
this.pipelineReadService.PipelineV2FindOne(data, metadata),
|
this.pipelineReadService.PipelineV2FindOne(data, metadata),
|
||||||
).catch((err) => {
|
);
|
||||||
this.logger.error(err.message);
|
|
||||||
throw new Error(err);
|
|
||||||
});
|
|
||||||
this.logger.info('Done');
|
this.logger.info('Done');
|
||||||
|
|
||||||
return findOnePipelineResponse;
|
return findOnePipelineResponse;
|
||||||
@@ -143,39 +145,58 @@ export class PipelinesService implements OnModuleInit {
|
|||||||
|
|
||||||
const updatePipelineResponse = await lastValueFrom(
|
const updatePipelineResponse = await lastValueFrom(
|
||||||
this.pipelineWriteService.PipelineV2Update(UpdatePipelineRequest),
|
this.pipelineWriteService.PipelineV2Update(UpdatePipelineRequest),
|
||||||
)
|
);
|
||||||
.then((res) => {
|
this.logger.info('Done');
|
||||||
this.logger.info('Done');
|
|
||||||
return res;
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
this.logger.error(err.message);
|
|
||||||
throw new Error(err);
|
|
||||||
});
|
|
||||||
|
|
||||||
return updatePipelineResponse;
|
return updatePipelineResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
async remove(data: Messages.PipelineV2RemoveRequest, metadata: Metadata) {
|
async remove(data: { id: string; metadata: Metadata; user: RequestUser }) {
|
||||||
this.logger.info('PipelinesClientService - Remove');
|
const { id, metadata, user } = data;
|
||||||
|
const info = {
|
||||||
|
user_id: user.user_id,
|
||||||
|
customer_id: user.customer_id,
|
||||||
|
customer: user.customer_name,
|
||||||
|
};
|
||||||
|
const { pipeline } = await lastValueFrom(
|
||||||
|
this.pipelineReadService.PipelineV2FindOne({ id }, metadata),
|
||||||
|
);
|
||||||
|
await lastValueFrom(
|
||||||
|
this.pipelineWriteService.PipelineV2Remove({ id }, metadata),
|
||||||
|
);
|
||||||
|
|
||||||
const removePipelineResponse = await lastValueFrom(
|
//{pipeline:{tables: {tables: [], input_id: ''}}}
|
||||||
this.pipelineWriteService.PipelineV2Remove(data, metadata),
|
const input = pipeline.config.tables
|
||||||
)
|
? JSON.parse(pipeline.config.tables)
|
||||||
.then((res) => {
|
: null;
|
||||||
this.logger.info('Done');
|
if (input)
|
||||||
return res;
|
await this.inputsService
|
||||||
})
|
.remove({
|
||||||
.catch((err) => {
|
id: input.input_id,
|
||||||
this.logger.error(err.message);
|
info,
|
||||||
console.log(err);
|
})
|
||||||
throw new HttpException(
|
.catch((error) =>
|
||||||
err.details,
|
this.logger.error('Could not delete input', {
|
||||||
err.details === 'Erro ao pausar pipeline na plataforma.' ? 409 : 500,
|
data: { input, error },
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
return removePipelineResponse;
|
const transformations: { id: string }[] = pipeline.transformations
|
||||||
|
? JSON.parse(pipeline.transformations)
|
||||||
|
: null;
|
||||||
|
if (transformations && transformations.length)
|
||||||
|
for (const transformation of transformations) {
|
||||||
|
await this.transformationsService
|
||||||
|
.remove({
|
||||||
|
id: transformation.id,
|
||||||
|
info,
|
||||||
|
})
|
||||||
|
.catch((error) =>
|
||||||
|
this.logger.error('Could not delete transformation', {
|
||||||
|
data: { transformation, error },
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async findOneProperties(id: string, metadata: Metadata) {
|
async findOneProperties(id: string, metadata: Metadata) {
|
||||||
@@ -193,16 +214,14 @@ export class PipelinesService implements OnModuleInit {
|
|||||||
const connector = JSON.parse(res.connector);
|
const connector = JSON.parse(res.connector);
|
||||||
const config_controls = connector.config_controls || [];
|
const config_controls = connector.config_controls || [];
|
||||||
|
|
||||||
for (const key in pipelineProperties) {
|
for (const config_control of config_controls) {
|
||||||
const i = config_controls
|
const path: string = config_control.name;
|
||||||
.map((cc) => cc.name)
|
const default_value = getObjValueFromPath({
|
||||||
.indexOf(`properties.${key}`);
|
object: { properties: pipelineProperties },
|
||||||
if (i > -1) {
|
path,
|
||||||
config_controls[i] = {
|
});
|
||||||
...config_controls[i],
|
if (default_value != undefined)
|
||||||
default_value: pipelineProperties[key],
|
config_control.default_value = default_value;
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -11,34 +11,19 @@ import {
|
|||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
import { TransformationsClientService } from './client.service';
|
import { TransformationsClientService } from './client.service';
|
||||||
import { IIdRequest } from './interfaces';
|
import { IIdRequest } from './interfaces';
|
||||||
import { AuthenticateCondition } from 'src/authentication/authentication.decorator';
|
import {
|
||||||
|
AuthenticateCondition,
|
||||||
|
Authenticated,
|
||||||
|
RequireSomePermission,
|
||||||
|
} from 'src/authentication/authentication.decorator';
|
||||||
import { PERMISSIONS_GROUPS } from '../../authentication/permissions.enum';
|
import { PERMISSIONS_GROUPS } from '../../authentication/permissions.enum';
|
||||||
import { TransformationsService } from './transformations.service';
|
import { TransformationsService } from './transformations.service';
|
||||||
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
|
||||||
import { RequestUser, User } from 'src/authentication/user.decorator';
|
import { RequestUser, User } from 'src/authentication/user.decorator';
|
||||||
|
const pipelinePermissions = PERMISSIONS_GROUPS.PIPELINE.permissions;
|
||||||
@ApiTags('Transformations')
|
@ApiTags('Transformations')
|
||||||
@Controller('transformations')
|
@Controller('transformations')
|
||||||
@AuthenticateCondition((req, user) => {
|
@Authenticated()
|
||||||
let action;
|
|
||||||
|
|
||||||
switch (req.method) {
|
|
||||||
case 'POST':
|
|
||||||
action = 'CREATE';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'PUT':
|
|
||||||
action = 'UPDATE';
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
action = req.method;
|
|
||||||
}
|
|
||||||
|
|
||||||
return user.permissions.includes(
|
|
||||||
PERMISSIONS_GROUPS.TRANSFORMATIONS.permissions[action].seqid,
|
|
||||||
);
|
|
||||||
})
|
|
||||||
export class TransformationsController {
|
export class TransformationsController {
|
||||||
logger: DadosferaLogger;
|
logger: DadosferaLogger;
|
||||||
constructor(
|
constructor(
|
||||||
@@ -50,6 +35,7 @@ export class TransformationsController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
|
@RequireSomePermission(pipelinePermissions.CREATE, pipelinePermissions.UPDATE)
|
||||||
async create(@Body() createTransformationDto) {
|
async create(@Body() createTransformationDto) {
|
||||||
this.logger.info(`/transformation - ON CREATE ROUTE`, {
|
this.logger.info(`/transformation - ON CREATE ROUTE`, {
|
||||||
user: createTransformationDto.info.user_id,
|
user: createTransformationDto.info.user_id,
|
||||||
@@ -67,6 +53,7 @@ export class TransformationsController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
|
@RequireSomePermission(pipelinePermissions.GET)
|
||||||
async findAll(@Body() data: IIdRequest) {
|
async findAll(@Body() data: IIdRequest) {
|
||||||
this.logger.info(`/transformation - ON Find All ROUTE`, {
|
this.logger.info(`/transformation - ON Find All ROUTE`, {
|
||||||
user: data.info.user_id,
|
user: data.info.user_id,
|
||||||
@@ -82,6 +69,7 @@ export class TransformationsController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get('/:id')
|
@Get('/:id')
|
||||||
|
@RequireSomePermission(pipelinePermissions.GET)
|
||||||
async findOne(@Body() data, @Param() params) {
|
async findOne(@Body() data, @Param() params) {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
this.logger.info(`/transformation/${id} - ON Find One ROUTE`, {
|
this.logger.info(`/transformation/${id} - ON Find One ROUTE`, {
|
||||||
@@ -98,6 +86,7 @@ export class TransformationsController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Put(':id')
|
@Put(':id')
|
||||||
|
@RequireSomePermission(pipelinePermissions.CREATE, pipelinePermissions.UPDATE)
|
||||||
async update(
|
async update(
|
||||||
@User() user: RequestUser,
|
@User() user: RequestUser,
|
||||||
@Body() updateTransformationDto,
|
@Body() updateTransformationDto,
|
||||||
@@ -120,6 +109,7 @@ export class TransformationsController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
|
@RequireSomePermission(pipelinePermissions.CREATE, pipelinePermissions.UPDATE)
|
||||||
async delete(@Body() data, @Param() params) {
|
async delete(@Body() data, @Param() params) {
|
||||||
const { id } = params;
|
const { id } = params;
|
||||||
this.logger.info(`/transformation/${id} - ON DELETE ROUTE`, {
|
this.logger.info(`/transformation/${id} - ON DELETE ROUTE`, {
|
||||||
|
|||||||
@@ -248,14 +248,48 @@ export function EnrichErrorCode(code: string) {
|
|||||||
code,
|
code,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
case ErrorCodes.PIPELINE.NOT_FOUND:
|
||||||
|
return {
|
||||||
|
statusCode: HttpStatus.NOT_FOUND,
|
||||||
|
error: 'Não encontramos a pipeline solicitada',
|
||||||
|
message:
|
||||||
|
'Tente realizar a ação novamente. Caso o erro persista, entre em contato com o suporte',
|
||||||
|
code,
|
||||||
|
};
|
||||||
|
|
||||||
|
case ErrorCodes.PIPELINE.PLATFORM_NOT_FOUND:
|
||||||
|
case ErrorCodes.PIPELINE.PLATFORM_BAD_REQUEST:
|
||||||
|
case ErrorCodes.PIPELINE.PLATFORM_UNKNOWN:
|
||||||
|
return {
|
||||||
|
statusCode: HttpStatus.BAD_GATEWAY,
|
||||||
|
error: 'Oops... Não foi possível realizar sua ação',
|
||||||
|
message:
|
||||||
|
'Houve um erro interno ao buscar por sua pipeline. Caso o erro persista, entre em contato com o suporte',
|
||||||
|
code,
|
||||||
|
};
|
||||||
|
case ErrorCodes.INPUT.NOT_FOUND:
|
||||||
|
return {
|
||||||
|
statusCode: HttpStatus.NOT_FOUND,
|
||||||
|
error: 'Oops... O recurso que você buscou não está disponível',
|
||||||
|
message:
|
||||||
|
'Não encontramos o recurso buscado. Caso o erro persista, entre em contato com o suporte',
|
||||||
|
code,
|
||||||
|
};
|
||||||
|
case ErrorCodes.NOT_IMPLEMENTED:
|
||||||
|
return {
|
||||||
|
statusCode: HttpStatus.NOT_FOUND,
|
||||||
|
error: 'Oops... O serviço que você está tentando acessar não existe!',
|
||||||
|
message: 'Caso o erro persista, entre em contato com o suporte',
|
||||||
|
code,
|
||||||
|
};
|
||||||
case ErrorCodes.INTERNAL:
|
case ErrorCodes.INTERNAL:
|
||||||
case ErrorCodes.UNKNOWN:
|
case ErrorCodes.UNKNOWN:
|
||||||
default:
|
default:
|
||||||
return {
|
return {
|
||||||
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
|
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
error: 'Desconhecido',
|
error: 'Oops... Não foi possível realizar sua ação',
|
||||||
message:
|
message:
|
||||||
'Erro desconhecido. Tente novamente ou entre em contato com o suporte',
|
'Ocorreu um erro desconhecido. Caso o erro persista, entre em contato com o suporte',
|
||||||
code: ErrorCodes.UNKNOWN,
|
code: ErrorCodes.UNKNOWN,
|
||||||
details: code,
|
details: code,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
export function getObjValueFromPath<T>(data: { object: T; path: string }): T {
|
||||||
|
const { object, path } = data;
|
||||||
|
const keys = path.split('.');
|
||||||
|
|
||||||
|
let value = JSON.parse(JSON.stringify(object));
|
||||||
|
for (const key of keys) {
|
||||||
|
if (value != undefined) value = value[key];
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
+16
-1
@@ -51,17 +51,32 @@ const CONNECTION_TEST = {
|
|||||||
BAD_REQUEST: 'CONNECTION_TEST.BAD_REQUEST',
|
BAD_REQUEST: 'CONNECTION_TEST.BAD_REQUEST',
|
||||||
UNKNOWN: 'CONNECTION_TEST.UNKNOWN',
|
UNKNOWN: 'CONNECTION_TEST.UNKNOWN',
|
||||||
};
|
};
|
||||||
|
const PIPELINE = {
|
||||||
|
NOT_FOUND: 'PIPELINE.NOT_FOUND',
|
||||||
|
PLATFORM_NOT_FOUND: 'PIPELINE.PLATFORM_NOT_FOUND',
|
||||||
|
PLATFORM_BAD_REQUEST: 'PIPELINE.PLATFORM_BAD_REQUEST',
|
||||||
|
PLATFORM_UNKNOWN: 'PIPELINE.PLATFORM_UNKNOWN',
|
||||||
|
};
|
||||||
|
const INPUT = {
|
||||||
|
NOT_FOUND: 'INPUT.NOT_FOUND',
|
||||||
|
};
|
||||||
|
const TRANSFORMATION = {
|
||||||
|
NOT_FOUND: 'TRANSFORMATION.NOT_FOUND',
|
||||||
|
};
|
||||||
const ErrorCodes = {
|
const ErrorCodes = {
|
||||||
UNKNOWN: 'UNKNOWN',
|
UNKNOWN: 'UNKNOWN',
|
||||||
RATE_LIMIT: 'RATE_LIMIT',
|
RATE_LIMIT: 'RATE_LIMIT',
|
||||||
INTERNAL: 'INTERNAL',
|
INTERNAL: 'INTERNAL',
|
||||||
|
NOT_IMPLEMENTED: 'NOT_IMPLEMENTED',
|
||||||
AUTH,
|
AUTH,
|
||||||
ROLE,
|
ROLE,
|
||||||
TERMS_OF_USE,
|
TERMS_OF_USE,
|
||||||
USER,
|
USER,
|
||||||
CUSTOMER,
|
CUSTOMER,
|
||||||
CONNECTION_TEST,
|
CONNECTION_TEST,
|
||||||
|
PIPELINE,
|
||||||
|
INPUT,
|
||||||
|
TRANSFORMATION,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ErrorCodes;
|
export default ErrorCodes;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"extends": "./tsconfig.json",
|
"extends": "./tsconfig.json",
|
||||||
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
|
"exclude": ["node_modules", "test", "dist", "**/*spec.ts", "jest.config.ts"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user