mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-24 20:29:12 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7062efc60 | ||
|
|
4a3dd98977 | ||
|
|
06f4260b61 | ||
|
|
64717c8d92 | ||
|
|
e6e66c77e1 | ||
|
|
131e82b4c5 | ||
|
|
32d37ecadf | ||
|
|
4d667acb86 | ||
|
|
9d417ff61b | ||
|
|
b01c4c6c25 | ||
|
|
449a1abb63 | ||
|
|
04ca17a69d | ||
|
|
34a0eb40a7 | ||
|
|
2df69fba84 | ||
|
|
dcbcc5ff36 | ||
|
|
703b5f36b3 | ||
|
|
54d10cb873 | ||
|
|
569c3cf573 | ||
|
|
c420ef62ed | ||
|
|
966ba00fec | ||
|
|
0aadf7fc40 | ||
|
|
3e3268cb26 | ||
|
|
09bd623b62 | ||
|
|
4bf9a5831a | ||
|
|
264077289b | ||
|
|
14c686cff4 | ||
|
|
0e57667419 | ||
|
|
ac7dc4905e | ||
|
|
94282718ad | ||
|
|
7c228c5c53 | ||
|
|
14e0f3d2d3 | ||
|
|
85ef0d7c74 | ||
|
|
e00b6481d0 | ||
|
|
8906c73d84 | ||
|
|
3bc37db891 | ||
|
|
3c877b8b8d | ||
|
|
fe44664970 | ||
|
|
0503732c1e | ||
|
|
fa0855d631 | ||
|
|
38aee30f2a | ||
|
|
19f5c947bd | ||
|
|
44aa0e6010 | ||
|
|
cf4e7da1d8 | ||
|
|
8bd7d54aa7 | ||
|
|
a00a66e0d0 | ||
|
|
f4c5d03269 | ||
|
|
060ba7da8a | ||
|
|
5ec2c01b20 | ||
|
|
4a7e660a49 | ||
|
|
abc6258492 | ||
|
|
7ee1215da2 | ||
|
|
cd5886337b | ||
|
|
e6b0034805 | ||
|
|
b9c1f784d3 | ||
|
|
5fb8dae312 | ||
|
|
5072a54ef6 | ||
|
|
718f5cb12a | ||
|
|
4c41dd8029 | ||
|
|
fe8a0b88b0 | ||
|
|
3edf5c2416 | ||
|
|
cd67ca61cd | ||
|
|
b9439685f3 | ||
|
|
04edce0c56 | ||
|
|
f3e00a15c8 | ||
|
|
0422c7a369 | ||
|
|
f22d9370db | ||
|
|
ef098dd74d | ||
|
|
2541960b44 | ||
|
|
2dc965ed90 | ||
|
|
a9ee74724f | ||
|
|
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,12 +6,12 @@ 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:
|
||||||
- dev
|
|
||||||
- stg
|
- stg
|
||||||
|
- stg2
|
||||||
- prd
|
- prd
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -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_PAGE_ID: ${{ secrets.DEV_DOCS_PAGE_ID }}
|
STG2_DOCS_BLOCK_ID: ${{ secrets.DEV_DOCS_BLOCK_ID }}
|
||||||
|
STG2_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 == "stg2" ]; then
|
||||||
echo "##[set-output name=result;]$(echo $DEV_DOCS_PAGE_ID)"
|
echo "block_id=$STG2_DOCS_BLOCK_ID" >> $GITHUB_OUTPUT
|
||||||
|
echo "page_id=$STG2_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:
|
||||||
|
|||||||
+5717
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.21.0",
|
||||||
"@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.21.0",
|
||||||
"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.21.0.tgz",
|
||||||
"integrity": "sha512-4KiuMUDMZu8ouic0RBBuM7Ky9wfczeS4GKLRyD29GV371m/NOo+1ujrcLysc8OuevPdXmaqzCgE6WWi6SIt9sQ==",
|
"integrity": "sha512-gHIRLSto813lagxqcphO4/xc82g/QkCZRslRhj5tJK4V69f/ScviBHB4CCRBRW5Md2Lql6zWuTV5R0uADFIiZA==",
|
||||||
"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.21.0",
|
||||||
"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.21.0.tgz",
|
||||||
"integrity": "sha512-4KiuMUDMZu8ouic0RBBuM7Ky9wfczeS4GKLRyD29GV371m/NOo+1ujrcLysc8OuevPdXmaqzCgE6WWi6SIt9sQ==",
|
"integrity": "sha512-gHIRLSto813lagxqcphO4/xc82g/QkCZRslRhj5tJK4V69f/ScviBHB4CCRBRW5Md2Lql6zWuTV5R0uADFIiZA==",
|
||||||
"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.21.0",
|
||||||
"@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 {}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class NoClassAuthController {
|
|||||||
@Get('has-all-permissions')
|
@Get('has-all-permissions')
|
||||||
@RequireAllPermissions(
|
@RequireAllPermissions(
|
||||||
PERMISSIONS_GROUPS.ZENDESK.permissions.OPEN,
|
PERMISSIONS_GROUPS.ZENDESK.permissions.OPEN,
|
||||||
PERMISSIONS_GROUPS.METABASE.permissions.OPEN,
|
PERMISSIONS_GROUPS.ANALYZE.permissions.METABASE,
|
||||||
)
|
)
|
||||||
async hasAllPermissions(@Body() body) {
|
async hasAllPermissions(@Body() body) {
|
||||||
return { body };
|
return { body };
|
||||||
@@ -53,7 +53,7 @@ class NoClassAuthController {
|
|||||||
@Get('has-some-permission')
|
@Get('has-some-permission')
|
||||||
@RequireSomePermission(
|
@RequireSomePermission(
|
||||||
PERMISSIONS_GROUPS.ZENDESK.permissions.OPEN,
|
PERMISSIONS_GROUPS.ZENDESK.permissions.OPEN,
|
||||||
PERMISSIONS_GROUPS.METABASE.permissions.OPEN,
|
PERMISSIONS_GROUPS.ANALYZE.permissions.METABASE,
|
||||||
)
|
)
|
||||||
async hasSomePermission(@Body() body) {
|
async hasSomePermission(@Body() body) {
|
||||||
return { body };
|
return { body };
|
||||||
@@ -62,7 +62,7 @@ class NoClassAuthController {
|
|||||||
|
|
||||||
@Controller('class-auth-condition')
|
@Controller('class-auth-condition')
|
||||||
@AuthenticateCondition((req) => req.get('x-on-class') === 'ok')
|
@AuthenticateCondition((req) => req.get('x-on-class') === 'ok')
|
||||||
@RequireSomePermission(PERMISSIONS_GROUPS.METABASE.permissions.OPEN)
|
@RequireSomePermission(PERMISSIONS_GROUPS.ANALYZE.permissions.METABASE)
|
||||||
class ClassAuthConditionController {
|
class ClassAuthConditionController {
|
||||||
@Get('body')
|
@Get('body')
|
||||||
async getBody(@Body() body) {
|
async getBody(@Body() body) {
|
||||||
@@ -444,13 +444,13 @@ describe('authentication.guard', () => {
|
|||||||
NoClassAuthTest(tokenZ, ['zendesk']);
|
NoClassAuthTest(tokenZ, ['zendesk']);
|
||||||
ClassAuthConditionTest(tokenZ, ['zendesk']);
|
ClassAuthConditionTest(tokenZ, ['zendesk']);
|
||||||
|
|
||||||
const tokenM = CreateToken([PERMISSIONS_GROUPS.METABASE.permissions.OPEN]);
|
const tokenM = CreateToken([PERMISSIONS_GROUPS.ANALYZE.permissions.METABASE]);
|
||||||
NoClassAuthTest(tokenM, ['metabase']);
|
NoClassAuthTest(tokenM, ['metabase']);
|
||||||
ClassAuthConditionTest(tokenM, ['metabase']);
|
ClassAuthConditionTest(tokenM, ['metabase']);
|
||||||
|
|
||||||
const tokenZM = CreateToken([
|
const tokenZM = CreateToken([
|
||||||
PERMISSIONS_GROUPS.ZENDESK.permissions.OPEN,
|
PERMISSIONS_GROUPS.ZENDESK.permissions.OPEN,
|
||||||
PERMISSIONS_GROUPS.METABASE.permissions.OPEN,
|
PERMISSIONS_GROUPS.ANALYZE.permissions.METABASE,
|
||||||
]);
|
]);
|
||||||
NoClassAuthTest(tokenZM, ['zendesk', 'metabase']);
|
NoClassAuthTest(tokenZM, ['zendesk', 'metabase']);
|
||||||
ClassAuthConditionTest(tokenZM, ['zendesk', 'metabase']);
|
ClassAuthConditionTest(tokenZM, ['zendesk', 'metabase']);
|
||||||
|
|||||||
@@ -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,49 +290,50 @@ 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: 'catalog:create',
|
||||||
usage: PermissionUsages.PUBLIC,
|
usage: PermissionUsages.PUBLIC,
|
||||||
name: {
|
name: {
|
||||||
'pt-br': 'Criar atributos no catálogo',
|
'pt-br': 'Criar Ativos',
|
||||||
'en-us': 'Create attributes',
|
'en-us': 'Create Assets',
|
||||||
'es-es': 'Crear atributos',
|
'es-es': 'Crear Activos',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
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.',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -428,14 +429,14 @@ export const PERMISSIONS_GROUPS = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
METABASE: {
|
ANALYZE: {
|
||||||
title: {
|
title: {
|
||||||
'pt-br': 'Analisar | Visualização',
|
'pt-br': 'Analisar | Visualização',
|
||||||
'en-us': 'Analyze | Visualization',
|
'en-us': 'Analyze | Visualization',
|
||||||
'es-es': 'Analizar | Visualización',
|
'es-es': 'Analizar | Visualización',
|
||||||
},
|
},
|
||||||
permissions: {
|
permissions: {
|
||||||
OPEN: {
|
METABASE: {
|
||||||
seqid: 11,
|
seqid: 11,
|
||||||
claim: 'GET /metabase',
|
claim: 'GET /metabase',
|
||||||
usage: PermissionUsages.PUBLIC,
|
usage: PermissionUsages.PUBLIC,
|
||||||
@@ -445,26 +446,26 @@ export const PERMISSIONS_GROUPS = {
|
|||||||
'es-es': 'Acceso Metabase',
|
'es-es': 'Acceso Metabase',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
ORCHEST: {
|
|
||||||
title: {
|
|
||||||
'pt-br': 'Analisar | Inteligência',
|
|
||||||
'en-us': 'Analyze | Intelligence',
|
|
||||||
'es-es': 'Analizar | Inteligencia',
|
|
||||||
},
|
|
||||||
permissions: {
|
|
||||||
INTELLIGENCE: {
|
INTELLIGENCE: {
|
||||||
seqid: 31,
|
seqid: 31,
|
||||||
claim: 'intelligence:open',
|
claim: 'intelligence:open',
|
||||||
usage: PermissionUsages.INTERNAL,
|
usage: PermissionUsages.PUBLIC,
|
||||||
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',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
MODULES: {
|
||||||
|
title: {
|
||||||
|
'pt-br': 'Módulos da Dadosfera',
|
||||||
|
'en-us': 'Dadosfera Modules',
|
||||||
|
'es-es': 'Módulos de la Dadosfera',
|
||||||
|
},
|
||||||
|
permissions: {
|
||||||
APP_BUILDER: {
|
APP_BUILDER: {
|
||||||
seqid: 32,
|
seqid: 32,
|
||||||
claim: 'app-builder:open',
|
claim: 'app-builder:open',
|
||||||
@@ -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,7 @@ 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',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -506,6 +507,25 @@ export const PERMISSIONS_GROUPS = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
PROCESS: {
|
||||||
|
title: {
|
||||||
|
'pt-br': 'Processar',
|
||||||
|
'en-us': 'Process',
|
||||||
|
'es-es': 'Procesar',
|
||||||
|
},
|
||||||
|
permissions: {
|
||||||
|
TRANSFORMATION: {
|
||||||
|
seqid: 43,
|
||||||
|
claim: 'process:open',
|
||||||
|
usage: PermissionUsages.PUBLIC,
|
||||||
|
name: {
|
||||||
|
'pt-br': 'Acessar Módulo de Transformação',
|
||||||
|
'en-us': 'Access Transformation Module',
|
||||||
|
'es-es': 'Acceder Módulo de transformación',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
DADOSFERA: {
|
DADOSFERA: {
|
||||||
title: {
|
title: {
|
||||||
'pt-br': 'Usuários',
|
'pt-br': 'Usuários',
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ describe('user.decorator', () => {
|
|||||||
const fakeUserPayload = {
|
const fakeUserPayload = {
|
||||||
user_id: 'd50d33c7-6c2b-463c-861f-e21667e7c125',
|
user_id: 'd50d33c7-6c2b-463c-861f-e21667e7c125',
|
||||||
username: 'super.admin',
|
username: 'super.admin',
|
||||||
permissions: [PERMISSIONS_GROUPS.METABASE.permissions.OPEN].map(
|
permissions: [PERMISSIONS_GROUPS.ANALYZE.permissions.METABASE].map(
|
||||||
({ seqid }) => seqid,
|
({ seqid }) => seqid,
|
||||||
),
|
),
|
||||||
customer_id: '9d18e8ae-24b9-41a3-9e8f-a25ce57555b11',
|
customer_id: '9d18e8ae-24b9-41a3-9e8f-a25ce57555b11',
|
||||||
|
|||||||
@@ -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';
|
||||||
|
|
||||||
|
|||||||
+34
-11
@@ -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,47 @@ async function bootstrap() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.use(helmet());
|
app.use(helmet());
|
||||||
|
configureSwagger(app);
|
||||||
|
|
||||||
const date = new Date();
|
await app.listen(3333);
|
||||||
|
}
|
||||||
|
|
||||||
|
function configureSwagger(app: INestApplication) {
|
||||||
|
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(
|
.addBearerAuth(
|
||||||
`${date.getDate()}.${
|
{ type: 'http', scheme: 'bearer', bearerFormat: 'JWT' },
|
||||||
date.getMonth() + 1
|
'Authorization',
|
||||||
}.${date.getFullYear()} - ${date.getHours()}:${date.getMinutes()}`,
|
|
||||||
)
|
)
|
||||||
.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);
|
||||||
|
writeFileSync(
|
||||||
await writeFileSync('swagger.txt', JSON.stringify(JSON.stringify(document)));
|
'docsfera.json',
|
||||||
|
JSON.stringify(
|
||||||
await app.listen(3333);
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ import {
|
|||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
import {
|
import {
|
||||||
AuthenticateCondition,
|
|
||||||
Authenticated,
|
Authenticated,
|
||||||
|
RequireSomePermission,
|
||||||
} from '../../authentication/authentication.decorator';
|
} from '../../authentication/authentication.decorator';
|
||||||
import { PERMISSIONS_GROUPS } from '../../authentication/permissions.enum';
|
import { PERMISSIONS_GROUPS } from '../../authentication/permissions.enum';
|
||||||
import { CatalogService } from './catalog.service';
|
import { CatalogService } from './catalog.service';
|
||||||
@@ -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,
|
||||||
@@ -36,27 +37,6 @@ import {
|
|||||||
@ApiTags('Catalog')
|
@ApiTags('Catalog')
|
||||||
@Controller('catalog')
|
@Controller('catalog')
|
||||||
@Authenticated()
|
@Authenticated()
|
||||||
@AuthenticateCondition((req, user) => {
|
|
||||||
if (req.path.includes('/manage_permissions/')) return true;
|
|
||||||
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.CATALOG.permissions[action].seqid,
|
|
||||||
);
|
|
||||||
})
|
|
||||||
export class CatalogController {
|
export class CatalogController {
|
||||||
logger: DadosferaLogger;
|
logger: DadosferaLogger;
|
||||||
constructor(
|
constructor(
|
||||||
@@ -68,6 +48,10 @@ export class CatalogController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
|
@RequireSomePermission(
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.GET,
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.DATA_MANAGER,
|
||||||
|
)
|
||||||
async catalogAll(
|
async catalogAll(
|
||||||
@User() user: RequestUser,
|
@User() user: RequestUser,
|
||||||
@Query() query,
|
@Query() query,
|
||||||
@@ -103,6 +87,10 @@ export class CatalogController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get('tags')
|
@Get('tags')
|
||||||
|
@RequireSomePermission(
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.GET,
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.DATA_MANAGER,
|
||||||
|
)
|
||||||
async findAllTags(@Body() body) {
|
async findAllTags(@Body() body) {
|
||||||
this.logger.info(`/catalog - ON FIND ALL TAGS ROUTE`, {
|
this.logger.info(`/catalog - ON FIND ALL TAGS ROUTE`, {
|
||||||
user: body.info.user_id,
|
user: body.info.user_id,
|
||||||
@@ -122,6 +110,10 @@ export class CatalogController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get('data-asset/:id')
|
@Get('data-asset/:id')
|
||||||
|
@RequireSomePermission(
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.GET,
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.DATA_MANAGER,
|
||||||
|
)
|
||||||
async getDataAsset(
|
async getDataAsset(
|
||||||
@User() user: RequestUser,
|
@User() user: RequestUser,
|
||||||
@Headers() headers,
|
@Headers() headers,
|
||||||
@@ -176,6 +168,10 @@ export class CatalogController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get('data-asset/rls/:id')
|
@Get('data-asset/rls/:id')
|
||||||
|
@RequireSomePermission(
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.GET,
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.DATA_MANAGER,
|
||||||
|
)
|
||||||
async getDataAssetRls(
|
async getDataAssetRls(
|
||||||
@User() user: RequestUser,
|
@User() user: RequestUser,
|
||||||
@Headers() headers,
|
@Headers() headers,
|
||||||
@@ -230,6 +226,10 @@ export class CatalogController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get('data-asset/:id/columns-metadata')
|
@Get('data-asset/:id/columns-metadata')
|
||||||
|
@RequireSomePermission(
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.GET,
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.DATA_MANAGER,
|
||||||
|
)
|
||||||
async getDataAssetColumnsMetadata(
|
async getDataAssetColumnsMetadata(
|
||||||
@User() user: RequestUser,
|
@User() user: RequestUser,
|
||||||
@Headers('Dadosfera-Lang') language,
|
@Headers('Dadosfera-Lang') language,
|
||||||
@@ -266,6 +266,10 @@ export class CatalogController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get('data-asset/:id/preview')
|
@Get('data-asset/:id/preview')
|
||||||
|
@RequireSomePermission(
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.GET,
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.DATA_MANAGER,
|
||||||
|
)
|
||||||
async getDataAssetPreview(
|
async getDataAssetPreview(
|
||||||
@User() user: RequestUser,
|
@User() user: RequestUser,
|
||||||
@Headers('Dadosfera-lang') language,
|
@Headers('Dadosfera-lang') language,
|
||||||
@@ -301,6 +305,10 @@ export class CatalogController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get('data-asset/:id/docs')
|
@Get('data-asset/:id/docs')
|
||||||
|
@RequireSomePermission(
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.GET,
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.DATA_MANAGER,
|
||||||
|
)
|
||||||
async getDataAssetDocs(
|
async getDataAssetDocs(
|
||||||
@User() user: RequestUser,
|
@User() user: RequestUser,
|
||||||
@Headers('Dadosfera-Lang') language,
|
@Headers('Dadosfera-Lang') language,
|
||||||
@@ -336,6 +344,10 @@ export class CatalogController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Put('data-asset/:id')
|
@Put('data-asset/:id')
|
||||||
|
@RequireSomePermission(
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.UPDATE,
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.DATA_MANAGER,
|
||||||
|
)
|
||||||
async updateDataAsset(
|
async updateDataAsset(
|
||||||
@User() user: RequestUser,
|
@User() user: RequestUser,
|
||||||
@Headers('Dadosfera-Lang') language,
|
@Headers('Dadosfera-Lang') language,
|
||||||
@@ -365,6 +377,10 @@ export class CatalogController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Post('data-asset/:id/docs')
|
@Post('data-asset/:id/docs')
|
||||||
|
@RequireSomePermission(
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.UPDATE,
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.DATA_MANAGER,
|
||||||
|
)
|
||||||
async manageDataAssetDocs(
|
async manageDataAssetDocs(
|
||||||
@User() user: RequestUser,
|
@User() user: RequestUser,
|
||||||
@Headers() headers,
|
@Headers() headers,
|
||||||
@@ -372,7 +388,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,7 +448,35 @@ export class CatalogController {
|
|||||||
return { message: response.message };
|
return { message: response.message };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
@RequireSomePermission(
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.CREATE,
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.DATA_MANAGER,
|
||||||
|
)
|
||||||
|
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')
|
||||||
|
@RequireSomePermission(
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.UPDATE,
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.DATA_MANAGER,
|
||||||
|
)
|
||||||
async commentOnDataAsset(
|
async commentOnDataAsset(
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
@User() user: RequestUser,
|
@User() user: RequestUser,
|
||||||
@@ -455,6 +499,10 @@ export class CatalogController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Delete('data-asset/:id')
|
@Delete('data-asset/:id')
|
||||||
|
@RequireSomePermission(
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.DELETE,
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.DATA_MANAGER,
|
||||||
|
)
|
||||||
async deleteDataAsset(
|
async deleteDataAsset(
|
||||||
@Param('id') data_asset_id: string,
|
@Param('id') data_asset_id: string,
|
||||||
@User() user: RequestUser,
|
@User() user: RequestUser,
|
||||||
@@ -477,6 +525,10 @@ export class CatalogController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Delete('data-asset/:id/comment')
|
@Delete('data-asset/:id/comment')
|
||||||
|
@RequireSomePermission(
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.UPDATE,
|
||||||
|
PERMISSIONS_GROUPS.CATALOG.permissions.DATA_MANAGER,
|
||||||
|
)
|
||||||
async deleteComment(
|
async deleteComment(
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
@User() user: RequestUser,
|
@User() user: RequestUser,
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
import {
|
import { OnModuleInit, Inject } from '@nestjs/common';
|
||||||
OnModuleInit,
|
|
||||||
Inject,
|
|
||||||
HttpException,
|
|
||||||
HttpStatus,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { ClientGrpc } from '@nestjs/microservices';
|
import { ClientGrpc } from '@nestjs/microservices';
|
||||||
import { ConnectionManager } from '@dadosfera/protospack-v2';
|
import { ConnectionManager } from '@dadosfera/protospack-v2';
|
||||||
import { lastValueFrom } from 'rxjs';
|
import { lastValueFrom } from 'rxjs';
|
||||||
@@ -86,12 +81,7 @@ export class ConnectionClientService implements OnModuleInit {
|
|||||||
},
|
},
|
||||||
metadata,
|
metadata,
|
||||||
),
|
),
|
||||||
).catch((err) => {
|
);
|
||||||
throw new HttpException(
|
|
||||||
err.details,
|
|
||||||
err.code === 6 ? HttpStatus.CONFLICT : 400,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateConnection(
|
async updateConnection(
|
||||||
@@ -112,12 +102,7 @@ export class ConnectionClientService implements OnModuleInit {
|
|||||||
},
|
},
|
||||||
metadata,
|
metadata,
|
||||||
),
|
),
|
||||||
).catch((err) => {
|
);
|
||||||
throw new HttpException(
|
|
||||||
err.details,
|
|
||||||
err.code === 6 ? HttpStatus.CONFLICT : 400,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteConnection({ body, metadata }): Promise<ConnectionRes> {
|
async deleteConnection({ body, metadata }): Promise<ConnectionRes> {
|
||||||
@@ -130,12 +115,7 @@ export class ConnectionClientService implements OnModuleInit {
|
|||||||
},
|
},
|
||||||
metadata,
|
metadata,
|
||||||
),
|
),
|
||||||
).catch((err) => {
|
);
|
||||||
throw new HttpException(
|
|
||||||
err.details,
|
|
||||||
err.code === 6 ? HttpStatus.CONFLICT : 400,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAllConnections({ body, metadata }): Promise<ConnectionsRes> {
|
async getAllConnections({ body, metadata }): Promise<ConnectionsRes> {
|
||||||
@@ -146,12 +126,7 @@ export class ConnectionClientService implements OnModuleInit {
|
|||||||
{ search, filters: JSON.stringify(filters), size, page },
|
{ search, filters: JSON.stringify(filters), size, page },
|
||||||
metadata,
|
metadata,
|
||||||
),
|
),
|
||||||
).catch((err) => {
|
);
|
||||||
throw new HttpException(
|
|
||||||
err.details,
|
|
||||||
err.code === 6 ? HttpStatus.CONFLICT : 400,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getConnectionDetails({
|
async getConnectionDetails({
|
||||||
@@ -162,12 +137,7 @@ export class ConnectionClientService implements OnModuleInit {
|
|||||||
|
|
||||||
return lastValueFrom(
|
return lastValueFrom(
|
||||||
this.connectionServiceRead.GetConnectionDetails({ id }, metadata),
|
this.connectionServiceRead.GetConnectionDetails({ id }, metadata),
|
||||||
).catch((err) => {
|
);
|
||||||
throw new HttpException(
|
|
||||||
err.details,
|
|
||||||
err.code === 6 ? HttpStatus.CONFLICT : 400,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async INTERNAL_getAllConnections({
|
async INTERNAL_getAllConnections({
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
Get,
|
Get,
|
||||||
Headers,
|
Headers,
|
||||||
Query,
|
Query,
|
||||||
|
UseFilters,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
import { ConnectionClientService } from './client.service';
|
import { ConnectionClientService } from './client.service';
|
||||||
@@ -28,8 +29,10 @@ import {
|
|||||||
} from './dtos/connection';
|
} from './dtos/connection';
|
||||||
import { CreateConnectionDto } from './dtos/connection';
|
import { CreateConnectionDto } from './dtos/connection';
|
||||||
import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
|
import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
|
||||||
|
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
|
||||||
|
|
||||||
const connectionPermissions = PERMISSIONS_GROUPS.CONNECTION.permissions;
|
const connectionPermissions = PERMISSIONS_GROUPS.CONNECTION.permissions;
|
||||||
|
@UseFilters(new GrpcToHttpExceptionFilter())
|
||||||
@ApiTags('connections')
|
@ApiTags('connections')
|
||||||
@ApiBearerAuth()
|
@ApiBearerAuth()
|
||||||
@Authenticated()
|
@Authenticated()
|
||||||
|
|||||||
@@ -83,161 +83,30 @@ export class ConnectorClientService implements OnModuleInit {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
const responseParsed = JSON.parse(res.message);
|
const responseParsed = JSON.parse(res.message);
|
||||||
const connectorErrors = responseParsed.items
|
const connectorsResponse = responseParsed.items.filter(
|
||||||
.filter((i) => i.update._index === 'connector' && i.update.error)
|
(i) => i.update._index === process.env.CONNECTORS_INDEX,
|
||||||
|
);
|
||||||
|
const connectorErrors = connectorsResponse
|
||||||
|
.filter((i) => i.update.error)
|
||||||
.map((i) => ({
|
.map((i) => ({
|
||||||
id: i.update._id,
|
id: i.update?._id,
|
||||||
reason: i.update.error,
|
reason: i.update?.error,
|
||||||
status: i.error.status,
|
status: i.error?.status,
|
||||||
}));
|
|
||||||
const connectionControlsErrors = responseParsed.items
|
|
||||||
.filter(
|
|
||||||
(i) => i.update._index === 'connection_controls' && i.update.error,
|
|
||||||
)
|
|
||||||
.map((i) => ({
|
|
||||||
id: i.update._id,
|
|
||||||
reason: i.update.error,
|
|
||||||
status: i.error.status,
|
|
||||||
}));
|
|
||||||
const connectionStepsErrors = responseParsed.items
|
|
||||||
.filter((i) => i.update._index === 'connection_steps' && i.update.error)
|
|
||||||
.map((i) => ({
|
|
||||||
id: i.update._id,
|
|
||||||
reason: i.update.error,
|
|
||||||
status: i.error.status,
|
|
||||||
}));
|
|
||||||
const configControlsErrors = responseParsed.items
|
|
||||||
.filter((i) => i.update._index === 'config_controls' && i.update.error)
|
|
||||||
.map((i) => ({
|
|
||||||
id: i.update._id,
|
|
||||||
reason: i.update.error,
|
|
||||||
status: i.error.status,
|
|
||||||
}));
|
|
||||||
const connectorCreated = responseParsed.items
|
|
||||||
.filter(
|
|
||||||
(i) => i.update._index === 'connector' && i.update.result === 'created',
|
|
||||||
)
|
|
||||||
.map((i) => ({
|
|
||||||
id: i.update._id,
|
|
||||||
}));
|
|
||||||
const connectionControlsCreated = responseParsed.items
|
|
||||||
.filter(
|
|
||||||
(i) =>
|
|
||||||
i.update._index === 'connection_controls' &&
|
|
||||||
i.update.result === 'created',
|
|
||||||
)
|
|
||||||
.map((i) => ({
|
|
||||||
id: i.update._id,
|
|
||||||
}));
|
|
||||||
const connectionStepsCreated = responseParsed.items
|
|
||||||
.filter(
|
|
||||||
(i) =>
|
|
||||||
i.update._index === 'connection_steps' &&
|
|
||||||
i.update.result === 'created',
|
|
||||||
)
|
|
||||||
.map((i) => ({
|
|
||||||
id: i.update._id,
|
|
||||||
}));
|
|
||||||
const configControlsCreated = responseParsed.items
|
|
||||||
.filter(
|
|
||||||
(i) =>
|
|
||||||
i.update._index === 'config_controls' &&
|
|
||||||
i.update.result === 'created',
|
|
||||||
)
|
|
||||||
.map((i) => ({
|
|
||||||
id: i.update._id,
|
|
||||||
}));
|
|
||||||
const connectorUpdated = responseParsed.items
|
|
||||||
.filter(
|
|
||||||
(i) => i.update._index === 'connector' && i.update.result === 'updated',
|
|
||||||
)
|
|
||||||
.map((i) => ({
|
|
||||||
id: i.update._id,
|
|
||||||
}));
|
|
||||||
const connectionControlsUpdated = responseParsed.items
|
|
||||||
.filter(
|
|
||||||
(i) =>
|
|
||||||
i.update._index === 'connection_controls' &&
|
|
||||||
i.update.result === 'updated',
|
|
||||||
)
|
|
||||||
.map((i) => ({
|
|
||||||
id: i.update._id,
|
|
||||||
}));
|
|
||||||
const connectionStepsUpdated = responseParsed.items
|
|
||||||
.filter(
|
|
||||||
(i) =>
|
|
||||||
i.update._index === 'connection_steps' &&
|
|
||||||
i.update.result === 'updated',
|
|
||||||
)
|
|
||||||
.map((i) => ({
|
|
||||||
id: i.update._id,
|
|
||||||
}));
|
|
||||||
const configControlsUpdated = responseParsed.items
|
|
||||||
.filter(
|
|
||||||
(i) =>
|
|
||||||
i.update._index === 'config_controls' &&
|
|
||||||
i.update.result === 'updated',
|
|
||||||
)
|
|
||||||
.map((i) => ({
|
|
||||||
id: i.update._id,
|
|
||||||
}));
|
|
||||||
const connectorNoop = responseParsed.items
|
|
||||||
.filter(
|
|
||||||
(i) => i.update._index === 'connector' && i.update.result === 'noop',
|
|
||||||
)
|
|
||||||
.map((i) => ({
|
|
||||||
id: i.update._id,
|
|
||||||
}));
|
|
||||||
const connectionControlsNoop = responseParsed.items
|
|
||||||
.filter(
|
|
||||||
(i) =>
|
|
||||||
i.update._index === 'connection_controls' &&
|
|
||||||
i.update.result === 'noop',
|
|
||||||
)
|
|
||||||
.map((i) => ({
|
|
||||||
id: i.update._id,
|
|
||||||
}));
|
|
||||||
const connectionStepsNoop = responseParsed.items
|
|
||||||
.filter(
|
|
||||||
(i) =>
|
|
||||||
i.update._index === 'connection_steps' && i.update.result === 'noop',
|
|
||||||
)
|
|
||||||
.map((i) => ({
|
|
||||||
id: i.update._id,
|
|
||||||
}));
|
|
||||||
const configControlsNoop = responseParsed.items
|
|
||||||
.filter(
|
|
||||||
(i) =>
|
|
||||||
i.update._index === 'config_controls' && i.update.result === 'noop',
|
|
||||||
)
|
|
||||||
.map((i) => ({
|
|
||||||
id: i.update._id,
|
|
||||||
}));
|
}));
|
||||||
|
const connectorCreated = connectorsResponse
|
||||||
|
.filter((i) => i.update.result === 'created')
|
||||||
|
.map((i) => i.update._id);
|
||||||
|
const connectorUpdated = connectorsResponse
|
||||||
|
.filter((i) => i.update.result === 'updated')
|
||||||
|
.map((i) => i.update._id);
|
||||||
|
const connectorNoop = connectorsResponse
|
||||||
|
.filter((i) => i.update.result === 'noop')
|
||||||
|
.map((i) => i.update._id);
|
||||||
return {
|
return {
|
||||||
errors: {
|
errors: connectorErrors,
|
||||||
connectors: connectorErrors,
|
created: connectorCreated,
|
||||||
connection_controls: connectionControlsErrors,
|
updated: connectorUpdated,
|
||||||
connection_steps: connectionStepsErrors,
|
noop: connectorNoop,
|
||||||
config_controls: configControlsErrors,
|
|
||||||
},
|
|
||||||
created: {
|
|
||||||
connectors: connectorCreated,
|
|
||||||
connection_controls: connectionControlsCreated,
|
|
||||||
connection_steps: connectionStepsCreated,
|
|
||||||
config_controls: configControlsCreated,
|
|
||||||
},
|
|
||||||
updated: {
|
|
||||||
connectors: connectorUpdated,
|
|
||||||
connection_controls: connectionControlsUpdated,
|
|
||||||
connection_steps: connectionStepsUpdated,
|
|
||||||
config_controls: configControlsUpdated,
|
|
||||||
},
|
|
||||||
noop: {
|
|
||||||
connectors: connectorNoop,
|
|
||||||
connection_controls: connectionControlsNoop,
|
|
||||||
connection_steps: connectionStepsNoop,
|
|
||||||
config_controls: configControlsNoop,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,12 +185,7 @@ export class ConnectorClientService implements OnModuleInit {
|
|||||||
version,
|
version,
|
||||||
plugin,
|
plugin,
|
||||||
}),
|
}),
|
||||||
).catch((err) => {
|
);
|
||||||
throw new HttpException(
|
|
||||||
err.details,
|
|
||||||
err.code === 6 ? HttpStatus.CONFLICT : 400,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateConnector({ plugin, changes }) {
|
async updateConnector({ plugin, changes }) {
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import { ApiBearerAuth, ApiConsumes, ApiTags } from '@nestjs/swagger';
|
|||||||
import { ConnectorClientService } from './client.service';
|
import { ConnectorClientService } from './client.service';
|
||||||
import { AddTagDto } from './dtos/add-tag';
|
import { AddTagDto } from './dtos/add-tag';
|
||||||
import { CreateConnectorDto } from './dtos/create-connector';
|
import { CreateConnectorDto } from './dtos/create-connector';
|
||||||
import { DeleteConnectorDto } from './dtos/delete-connector';
|
|
||||||
import { GetAllDto } from './dtos/get-all';
|
import { GetAllDto } from './dtos/get-all';
|
||||||
import { RemoveTagDto } from './dtos/remove-tag';
|
import { RemoveTagDto } from './dtos/remove-tag';
|
||||||
import { UpdateDto } from './dtos/update';
|
import { UpdateDto } from './dtos/update';
|
||||||
@@ -274,7 +273,7 @@ export class ConnectorController {
|
|||||||
@RequireAllPermissions(PERMISSIONS_GROUPS.CONNECTORS.permissions.DELETE)
|
@RequireAllPermissions(PERMISSIONS_GROUPS.CONNECTORS.permissions.DELETE)
|
||||||
async deleteConnector(
|
async deleteConnector(
|
||||||
@Param('plugin') plugin: string,
|
@Param('plugin') plugin: string,
|
||||||
@Body() { version }: DeleteConnectorDto,
|
@Query('version') version: string,
|
||||||
) {
|
) {
|
||||||
this.logger.info('/upload - Upload Connector Route');
|
this.logger.info('/upload - Upload Connector Route');
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -1,106 +1,5 @@
|
|||||||
import { ApiProperty, ApiPropertyOptional, OmitType } from '@nestjs/swagger';
|
import { ApiProperty, ApiPropertyOptional, OmitType } from '@nestjs/swagger';
|
||||||
import { Info } from 'protospack/dist/lib/interfaces';
|
|
||||||
|
|
||||||
export class GoogleAnalyticsClientSecrets {
|
|
||||||
@ApiProperty()
|
|
||||||
type: string;
|
|
||||||
@ApiProperty()
|
|
||||||
project_id: string;
|
|
||||||
@ApiProperty()
|
|
||||||
private_key_id: string;
|
|
||||||
@ApiProperty()
|
|
||||||
private_key: string;
|
|
||||||
@ApiProperty()
|
|
||||||
client_email: string;
|
|
||||||
@ApiProperty()
|
|
||||||
client_id: string;
|
|
||||||
@ApiProperty()
|
|
||||||
auth_uri: string;
|
|
||||||
@ApiProperty()
|
|
||||||
token_uri: string;
|
|
||||||
@ApiProperty()
|
|
||||||
auth_provider_x509_cert_url: string;
|
|
||||||
@ApiProperty()
|
|
||||||
client_x509_cert_url: string;
|
|
||||||
}
|
|
||||||
export class OauthObject {
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
get_tokens_url: string;
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
get_tokens_url_params: string;
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
get_tokens_set_response: Record<string, any>;
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
content_type: string;
|
|
||||||
}
|
|
||||||
export class InputOptions {
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
oauth: OauthObject;
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
skip_select_columns: true;
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
skip_select_entities: false;
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
skip_transformation: true;
|
|
||||||
}
|
|
||||||
export class FileFormatParams {
|
|
||||||
@ApiProperty()
|
|
||||||
sep: string;
|
|
||||||
@ApiProperty()
|
|
||||||
header: boolean;
|
|
||||||
@ApiProperty()
|
|
||||||
encoding: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class AuthParameters {
|
|
||||||
@ApiProperty()
|
|
||||||
aws_access_key_id: string;
|
|
||||||
@ApiProperty()
|
|
||||||
aws_secret_access_key: string;
|
|
||||||
}
|
|
||||||
export class CredentialsJdbc {
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
jdbc_user: string;
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
jdbc_password: string;
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
database: string;
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
endpoint: string;
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
port: string;
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
engine: string;
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
schema: string;
|
|
||||||
}
|
|
||||||
export class Credentials extends CredentialsJdbc {
|
|
||||||
@ApiProperty()
|
|
||||||
connection_type: string;
|
|
||||||
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
client_aws_access_key_id: string;
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
client_aws_secret_access_key: string;
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
client_bucket: string;
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
file_to_extract: string;
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
file_format_params: FileFormatParams;
|
|
||||||
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
view_id: string;
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
client_secrets: GoogleAnalyticsClientSecrets;
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
start_date: string;
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
end_date: string;
|
|
||||||
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
oauth_code: string;
|
|
||||||
}
|
|
||||||
export class Column {
|
export class Column {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
name: string;
|
name: string;
|
||||||
@@ -114,6 +13,14 @@ export class TableColumns {
|
|||||||
columns: string[];
|
columns: string[];
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
references: Column[];
|
references: Column[];
|
||||||
|
@ApiProperty()
|
||||||
|
type: string;
|
||||||
|
}
|
||||||
|
export class AvailableEntity {
|
||||||
|
@ApiProperty()
|
||||||
|
name: string;
|
||||||
|
@ApiProperty()
|
||||||
|
replication_methods: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Input {
|
export class Input {
|
||||||
@@ -133,26 +40,6 @@ export class Input {
|
|||||||
created_at: string;
|
created_at: string;
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
updated_at: string;
|
updated_at: string;
|
||||||
|
|
||||||
//deprecated attributes (for retro compatibility)
|
|
||||||
@ApiPropertyOptional({ deprecated: true })
|
|
||||||
category: string;
|
|
||||||
@ApiPropertyOptional({ deprecated: true })
|
|
||||||
credentials: Credentials;
|
|
||||||
@ApiPropertyOptional({ deprecated: true })
|
|
||||||
options: InputOptions;
|
|
||||||
@ApiPropertyOptional({ deprecated: true })
|
|
||||||
info: Info;
|
|
||||||
@ApiPropertyOptional({ deprecated: true })
|
|
||||||
cron: string;
|
|
||||||
@ApiPropertyOptional({ deprecated: true })
|
|
||||||
source_bucket: string;
|
|
||||||
@ApiPropertyOptional({ deprecated: true })
|
|
||||||
source_prefix: string;
|
|
||||||
@ApiPropertyOptional({ deprecated: true })
|
|
||||||
auth_parameters: AuthParameters;
|
|
||||||
@ApiPropertyOptional({ deprecated: true })
|
|
||||||
file_format_params: FileFormatParams;
|
|
||||||
}
|
}
|
||||||
export class GetAvailableEntitiesReq {
|
export class GetAvailableEntitiesReq {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
@@ -160,43 +47,10 @@ export class GetAvailableEntitiesReq {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class GetAvailableEntitiesRes {
|
export class GetAvailableEntitiesRes {
|
||||||
@ApiProperty()
|
@ApiProperty({ type: [AvailableEntity] })
|
||||||
entities: string[];
|
entities: AvailableEntity[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TestConnectionGetColumnsReq {
|
|
||||||
@ApiProperty()
|
|
||||||
plugin: string;
|
|
||||||
@ApiProperty()
|
|
||||||
tables: string[];
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
credentials: CredentialsJdbc;
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
id: string;
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
info: Info;
|
|
||||||
}
|
|
||||||
export class TestConnectionGetColumnsRes {
|
|
||||||
@ApiProperty({ type: [TableColumns] })
|
|
||||||
tables: TableColumns[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export class TestConnectionReq {
|
|
||||||
@ApiProperty()
|
|
||||||
plugin: string;
|
|
||||||
@ApiProperty()
|
|
||||||
credentials: CredentialsJdbc;
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
info: Info;
|
|
||||||
}
|
|
||||||
export class TestConnectionRes {
|
|
||||||
@ApiProperty()
|
|
||||||
connection_state: boolean;
|
|
||||||
@ApiProperty()
|
|
||||||
total_entities: number;
|
|
||||||
@ApiProperty()
|
|
||||||
database_tables: string[];
|
|
||||||
}
|
|
||||||
export class CreateInputReq extends OmitType(Input, [
|
export class CreateInputReq extends OmitType(Input, [
|
||||||
'id',
|
'id',
|
||||||
'created_at',
|
'created_at',
|
||||||
|
|||||||
@@ -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';
|
||||||
@@ -18,16 +19,13 @@ import {
|
|||||||
GetAvailableEntitiesReq,
|
GetAvailableEntitiesReq,
|
||||||
GetAvailableEntitiesRes,
|
GetAvailableEntitiesRes,
|
||||||
Input,
|
Input,
|
||||||
TestConnectionGetColumnsReq,
|
|
||||||
TestConnectionGetColumnsRes,
|
|
||||||
TestConnectionReq,
|
|
||||||
TestConnectionRes,
|
|
||||||
} from './dtos/input.model';
|
} from './dtos/input.model';
|
||||||
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 { 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 +36,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 +49,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(
|
||||||
@@ -66,41 +69,19 @@ export class InputsController {
|
|||||||
@Get('available-entities/:plugin')
|
@Get('available-entities/:plugin')
|
||||||
@ApiOkResponse({ type: GetAvailableEntitiesRes })
|
@ApiOkResponse({ type: GetAvailableEntitiesRes })
|
||||||
async getAvailableEntities(
|
async getAvailableEntities(
|
||||||
@Body() body,
|
|
||||||
@Param() params: GetAvailableEntitiesReq,
|
@Param() params: GetAvailableEntitiesReq,
|
||||||
|
@User() user: RequestUser,
|
||||||
) {
|
) {
|
||||||
const { info } = body;
|
|
||||||
const { plugin } = params;
|
const { plugin } = params;
|
||||||
return await this.inputService.getAvailableEntities({ info, plugin });
|
const availableEntities = await this.inputService.getAvailableEntities({
|
||||||
}
|
info: {
|
||||||
|
customer: user.customer_name,
|
||||||
@Post('/test-connection')
|
customer_id: user.customer_id,
|
||||||
@ApiOkResponse({ type: TestConnectionRes })
|
user_id: user.user_id,
|
||||||
async testConnection(@Body() data: TestConnectionReq) {
|
|
||||||
this.logger.info(`/test-connection - ON TEST CONNECTION ROUTE`, {
|
|
||||||
user: data.info.user_id,
|
|
||||||
customer: data.info.customer,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await this.inputService.testConnection(data);
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Post('/test-connection/get-columns')
|
|
||||||
@ApiOkResponse({ type: TestConnectionGetColumnsRes })
|
|
||||||
async getColumns(@Body() data: TestConnectionGetColumnsReq) {
|
|
||||||
this.logger.info(
|
|
||||||
`/test-connection/get-columns - ON TEST CONNECTION GET COLUMNS ROUTE`,
|
|
||||||
{
|
|
||||||
user: data.info.user_id,
|
|
||||||
customer: data.info.customer,
|
|
||||||
},
|
},
|
||||||
);
|
plugin,
|
||||||
|
});
|
||||||
const response = await this.inputService.getColumns(data);
|
return availableEntities;
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ import { objectCamelToSnake } from 'src/utils/CaseConverter';
|
|||||||
import { IIdRequest, UpdateInputRequest } from './dtos/old_interfaces';
|
import { IIdRequest, UpdateInputRequest } from './dtos/old_interfaces';
|
||||||
import { Input } from '@dadosfera/protospack-v2';
|
import { Input } from '@dadosfera/protospack-v2';
|
||||||
import {
|
import {
|
||||||
|
GetAvailableEntitiesRequest,
|
||||||
InputCreateGenericRequest,
|
InputCreateGenericRequest,
|
||||||
InputCreateS3Request,
|
InputCreateS3Request,
|
||||||
InputNewCreateRequest,
|
InputNewCreateRequest,
|
||||||
TestConnectionGetColumnsRequest,
|
|
||||||
TestConnectionRequest,
|
TestConnectionRequest,
|
||||||
} from '@dadosfera/protospack-v2/dist/lib/Input/interfaces/messages';
|
} from '@dadosfera/protospack-v2/dist/lib/Input/interfaces/messages';
|
||||||
import { Info } from '@dadosfera/protospack-v2/dist/lib/Input/interfaces/entities';
|
import { Info } from '@dadosfera/protospack-v2/dist/lib/Input/interfaces/entities';
|
||||||
@@ -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(
|
||||||
@@ -107,32 +88,6 @@ export class InputsService {
|
|||||||
|
|
||||||
return testConnectionResponse;
|
return testConnectionResponse;
|
||||||
},
|
},
|
||||||
getColumns: async (data: TestConnectionGetColumnsRequest) => {
|
|
||||||
this.logger.info('InputClientService - TestConnection/Get-Columns');
|
|
||||||
const getColumnsResponse = await new Promise((resolve, reject) => {
|
|
||||||
this.inputReadService.GetColumns(data).subscribe({
|
|
||||||
next(x) {
|
|
||||||
resolve(objectCamelToSnake(x));
|
|
||||||
},
|
|
||||||
error(err) {
|
|
||||||
reject(err);
|
|
||||||
},
|
|
||||||
complete() {
|
|
||||||
// console.log('done');
|
|
||||||
},
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.then((res) => {
|
|
||||||
this.logger.info('Done');
|
|
||||||
return res;
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
this.logger.error(err.message);
|
|
||||||
throw new Error(err);
|
|
||||||
});
|
|
||||||
|
|
||||||
return getColumnsResponse;
|
|
||||||
},
|
|
||||||
getAvailableEntities: async (data) => {
|
getAvailableEntities: async (data) => {
|
||||||
this.logger.info('InputClientService - GetAvailableEntities');
|
this.logger.info('InputClientService - GetAvailableEntities');
|
||||||
data;
|
data;
|
||||||
@@ -207,12 +162,9 @@ export class InputsService {
|
|||||||
// this.validateCron(data);
|
// this.validateCron(data);
|
||||||
const { body, info } = data;
|
const { body, info } = data;
|
||||||
|
|
||||||
if (body.info) delete body.info;
|
const inputCreateGenericRequest: InputCreateGenericRequest = {
|
||||||
|
|
||||||
const inputCreateGenericRequest: any | InputCreateGenericRequest = {
|
|
||||||
input: {
|
input: {
|
||||||
...body,
|
...body,
|
||||||
credentials: body.credentials && JSON.stringify(body.credentials),
|
|
||||||
},
|
},
|
||||||
info,
|
info,
|
||||||
};
|
};
|
||||||
@@ -224,8 +176,8 @@ export class InputsService {
|
|||||||
return { input: adjustedInput };
|
return { input: adjustedInput };
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAvailableEntities(data): Promise<{ entities: string[] }> {
|
async getAvailableEntities(data: GetAvailableEntitiesRequest) {
|
||||||
return await this.OLD_inputClient.getAvailableEntities(data);
|
return lastValueFrom(this.inputReadService.GetAvailableEntities(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
async findAll(info: Info) {
|
async findAll(info: Info) {
|
||||||
@@ -239,17 +191,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 +219,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
|
||||||
@@ -292,17 +234,6 @@ export class InputsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getColumns(data) {
|
|
||||||
try {
|
|
||||||
const testConnectionGetColumnsResponse =
|
|
||||||
await this.OLD_inputClient.getColumns(data);
|
|
||||||
|
|
||||||
return testConnectionGetColumnsResponse;
|
|
||||||
} catch (err) {
|
|
||||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
generateInputS3Payload(payload) {
|
generateInputS3Payload(payload) {
|
||||||
const { credentials, plugin, cron } = payload;
|
const { credentials, plugin, cron } = payload;
|
||||||
if (!credentials) return payload;
|
if (!credentials) return payload;
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { Body, Controller, Inject, Param, Post } from '@nestjs/common';
|
||||||
|
import { init } from 'mixpanel';
|
||||||
|
import { Authenticated } from 'src/authentication/authentication.decorator';
|
||||||
|
import { RequestUser, User } from 'src/authentication/user.decorator';
|
||||||
|
|
||||||
|
@Authenticated()
|
||||||
|
@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,16 @@ import {
|
|||||||
Put,
|
Put,
|
||||||
Headers,
|
Headers,
|
||||||
Query,
|
Query,
|
||||||
|
UseFilters,
|
||||||
|
HttpCode,
|
||||||
|
HttpStatus,
|
||||||
|
Patch,
|
||||||
} 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 +29,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;
|
||||||
@@ -35,6 +46,10 @@ import { ICreatePipelineV2Req, IPipelineV2 } from './interfaces';
|
|||||||
action = 'UPDATE';
|
action = 'UPDATE';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'PATCH':
|
||||||
|
action = 'UPDATE';
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
action = req.method;
|
action = req.method;
|
||||||
}
|
}
|
||||||
@@ -143,13 +158,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)
|
||||||
@@ -162,35 +180,64 @@ export class PipelinesController {
|
|||||||
|
|
||||||
@Put('/:id')
|
@Put('/:id')
|
||||||
async update(
|
async update(
|
||||||
|
@Headers('Dadosfera-Lang') language,
|
||||||
@Body() updatePipelineDto,
|
@Body() updatePipelineDto,
|
||||||
@Param('id') id,
|
@Param('id') id,
|
||||||
@User() user: RequestUser,
|
@User() user: RequestUser,
|
||||||
) {
|
) {
|
||||||
this.logger.info('PipelinesController - findOne', { user });
|
this.logger.info('PipelinesController - update', { user });
|
||||||
const { info } = updatePipelineDto;
|
const { info } = updatePipelineDto;
|
||||||
delete updatePipelineDto.info;
|
delete updatePipelineDto.info;
|
||||||
|
|
||||||
const response = await this.pipelinesClientService.update({
|
const { customer_id, customer_name, user_id, username } = user;
|
||||||
...updatePipelineDto,
|
if (!language) language = 'en-us';
|
||||||
info,
|
|
||||||
id,
|
const metadata = PackTheMetadata({
|
||||||
|
customer_id,
|
||||||
|
customer_name,
|
||||||
|
user_id,
|
||||||
|
username,
|
||||||
|
language,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const response = await this.pipelinesClientService.update(
|
||||||
|
{
|
||||||
|
...updatePipelineDto,
|
||||||
|
info,
|
||||||
|
id,
|
||||||
|
},
|
||||||
|
metadata,
|
||||||
|
);
|
||||||
|
|
||||||
|
this.logger.info('PipelinesController - update: OK', { user });
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch('/:id')
|
||||||
|
async updateByPatch(
|
||||||
|
@Headers('Dadosfera-Lang') language,
|
||||||
|
@Body() updatePipelineDto,
|
||||||
|
@Param('id') id,
|
||||||
|
@User() user: RequestUser,
|
||||||
|
) {
|
||||||
|
this.logger.info('PipelinesController - patch', { user });
|
||||||
|
const response = await this.update(language, updatePipelineDto, id, user);
|
||||||
|
this.logger.info('PipelinesController - patch: OK', { user });
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@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,10 +1,4 @@
|
|||||||
import {
|
import { BadRequestException, Inject, OnModuleInit } from '@nestjs/common';
|
||||||
BadRequestException,
|
|
||||||
HttpException,
|
|
||||||
Inject,
|
|
||||||
InternalServerErrorException,
|
|
||||||
OnModuleInit,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { ClientGrpc } from '@nestjs/microservices';
|
import { ClientGrpc } from '@nestjs/microservices';
|
||||||
import {
|
import {
|
||||||
Messages,
|
Messages,
|
||||||
@@ -20,6 +14,12 @@ 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';
|
||||||
|
import ErrorCodes from 'src/utils/errorCodes';
|
||||||
|
import ErrorBuilder from 'src/utils/ErrorBuilder';
|
||||||
|
|
||||||
export class PipelinesService implements OnModuleInit {
|
export class PipelinesService implements OnModuleInit {
|
||||||
logger: DadosferaLogger;
|
logger: DadosferaLogger;
|
||||||
@@ -31,6 +31,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;
|
||||||
}
|
}
|
||||||
@@ -94,7 +96,7 @@ export class PipelinesService implements OnModuleInit {
|
|||||||
const [errorType, message] = error.details.split('|');
|
const [errorType, message] = error.details.split('|');
|
||||||
throw new BadRequestException(message);
|
throw new BadRequestException(message);
|
||||||
}
|
}
|
||||||
throw new InternalServerErrorException(error.details);
|
throw new ErrorBuilder(error.details);
|
||||||
});
|
});
|
||||||
this.logger.info('Done');
|
this.logger.info('Done');
|
||||||
|
|
||||||
@@ -129,53 +131,83 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
async update(UpdatePipelineRequest: Messages.PipelineV2UpdateRequest) {
|
async update(
|
||||||
|
UpdatePipelineRequest: Messages.PipelineV2UpdateRequest,
|
||||||
|
metadata,
|
||||||
|
) {
|
||||||
this.logger.info('PipelinesClientService - Update');
|
this.logger.info('PipelinesClientService - Update');
|
||||||
|
|
||||||
const updatePipelineResponse = await lastValueFrom(
|
const updatePipelineResponse = await lastValueFrom(
|
||||||
this.pipelineWriteService.PipelineV2Update(UpdatePipelineRequest),
|
this.pipelineWriteService.PipelineV2Update(
|
||||||
)
|
UpdatePipelineRequest,
|
||||||
.then((res) => {
|
metadata,
|
||||||
this.logger.info('Done');
|
),
|
||||||
return res;
|
);
|
||||||
})
|
this.logger.info('Done');
|
||||||
.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,
|
||||||
|
};
|
||||||
|
let existsInProduct = true;
|
||||||
|
const { pipeline } = await lastValueFrom(
|
||||||
|
this.pipelineReadService.PipelineV2FindOne({ id }, metadata),
|
||||||
|
).catch((e) => {
|
||||||
|
if (e.details === ErrorCodes.PIPELINE.NOT_FOUND) existsInProduct = false;
|
||||||
|
else throw new ErrorBuilder(e.details);
|
||||||
|
|
||||||
const removePipelineResponse = await lastValueFrom(
|
return { pipeline: undefined };
|
||||||
this.pipelineWriteService.PipelineV2Remove(data, metadata),
|
});
|
||||||
)
|
await lastValueFrom(
|
||||||
.then((res) => {
|
this.pipelineWriteService.PipelineV2Remove({ id }, metadata),
|
||||||
this.logger.info('Done');
|
);
|
||||||
return res;
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
this.logger.error(err.message);
|
|
||||||
console.log(err);
|
|
||||||
throw new HttpException(
|
|
||||||
err.details,
|
|
||||||
err.details === 'Erro ao pausar pipeline na plataforma.' ? 409 : 500,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
return removePipelineResponse;
|
if (existsInProduct) {
|
||||||
|
//{pipeline:{tables: {tables: [], input_id: ''}}}
|
||||||
|
const input = pipeline.config.tables
|
||||||
|
? JSON.parse(pipeline.config.tables)
|
||||||
|
: null;
|
||||||
|
if (input)
|
||||||
|
await this.inputsService
|
||||||
|
.remove({
|
||||||
|
id: input.input_id,
|
||||||
|
info,
|
||||||
|
})
|
||||||
|
.catch((error) =>
|
||||||
|
this.logger.error('Could not delete input', {
|
||||||
|
data: { input, error },
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
const transformations: { id: string }[] = pipeline.transformations
|
||||||
|
? JSON.parse(pipeline.transformations)
|
||||||
|
: null;
|
||||||
|
if (transformations && transformations.length)
|
||||||
|
for (const transformation of transformations) {
|
||||||
|
await this.transformationsService
|
||||||
|
.remove({
|
||||||
|
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 +225,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`, {
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ import { Metadata } from '@grpc/grpc-js';
|
|||||||
import ErrorBuilder from 'src/utils/ErrorBuilder';
|
import ErrorBuilder from 'src/utils/ErrorBuilder';
|
||||||
import ErrorCodes from 'src/utils/errorCodes';
|
import ErrorCodes from 'src/utils/errorCodes';
|
||||||
|
|
||||||
// TODO GET de hierarquias e do PATCH em usuário
|
|
||||||
@ApiTags('Users')
|
@ApiTags('Users')
|
||||||
@Controller('users')
|
@Controller('users')
|
||||||
@ApiHeader({
|
@ApiHeader({
|
||||||
@@ -75,10 +74,6 @@ export class UsersController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@ApiOkResponse({
|
|
||||||
type: GetAllUsersByCustomerIdRes,
|
|
||||||
description: 'List of users of a customer',
|
|
||||||
})
|
|
||||||
async getAllUsersByCustomerId(
|
async getAllUsersByCustomerId(
|
||||||
@User() user: RequestUser,
|
@User() user: RequestUser,
|
||||||
@Headers('dadosfera-lang') language,
|
@Headers('dadosfera-lang') language,
|
||||||
|
|||||||
@@ -214,6 +214,16 @@ export function EnrichErrorCode(code: string) {
|
|||||||
message: 'Id encontra-se num formato inválido',
|
message: 'Id encontra-se num formato inválido',
|
||||||
code,
|
code,
|
||||||
};
|
};
|
||||||
|
case ErrorCodes.CONNECTION.NOT_FOUND:
|
||||||
|
case ErrorCodes.CONNECTION.PLATFORM_NOT_FOUND:
|
||||||
|
return {
|
||||||
|
statusCode: HttpStatus.NOT_FOUND,
|
||||||
|
error: 'Conexão não encontrada',
|
||||||
|
message:
|
||||||
|
'Não encontramos a conexão solicitada. Caso o erro persista, entre em contato com o suporte',
|
||||||
|
code,
|
||||||
|
};
|
||||||
|
|
||||||
case ErrorCodes.CONNECTION_TEST.ERROR:
|
case ErrorCodes.CONNECTION_TEST.ERROR:
|
||||||
return {
|
return {
|
||||||
statusCode: HttpStatus.BAD_REQUEST,
|
statusCode: HttpStatus.BAD_REQUEST,
|
||||||
@@ -248,14 +258,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;
|
||||||
|
}
|
||||||
+21
-1
@@ -51,17 +51,37 @@ 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 CONNECTION = {
|
||||||
|
NOT_FOUND: 'CONNECTION.NOT_FOUND',
|
||||||
|
PLATFORM_NOT_FOUND: 'CONNECTION.PLATFORM_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,
|
||||||
|
CONNECTION,
|
||||||
};
|
};
|
||||||
|
|
||||||
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